[5.2.0.22] [Jolla Phone 2026] AppSupport: Android apps fail with EPERM on close() when writing to SD card; Android/data created as appsupport-root 700

REPRODUCIBILITY: 100%
OS VERSION: 5.2.0.22
HARDWARE: Jolla Phone (2026)
UI LANGUAGE: German
REGRESSION: Unknown (first device). A similar issue was reported for 4.5 and fixed there, see links below.

DESCRIPTION:
Android apps cannot write files to the microSD card. Two separate problems show up:

  1. When AppSupport sets up a freshly formatted card, Android/data and Android/obb are created as appsupport-root:appsupport-root (500000:500000) with mode 700. The sdcard daemon runs as defaultuser (/system/bin/sdcard -u 100000 -g 1077 ...) and cannot open these directories. Apps then fail to use the card at all (OsmAnd: “Maps could not be created in specified directory”).

  2. After fixing the ownership manually, apps can create directories and write data, but close() on a newly written file fails with EPERM. Root inside the container can write, close, rename and touch files on the same path without errors. The same operation works on internal storage.

PRECONDITIONS:

  • microSD card formatted via Settings > Storage (ext4, unencrypted), mounted by Sailfish at /run/media/defaultuser/<uuid>
  • Android App Support running
  • OsmAnd (net.osmand.plus) installed

STEPS TO REPRODUCE:

  1. Format the card in Settings, start Android App Support.

  2. Check the card: ls -ln /run/media/defaultuser/<uuid>/Android/
    → data and obb are 500000:500000, mode 700

  3. logcat shows:

    E sdcard  : opendir(/mnt/media_rw/alien_external_storage/<uuid>/Android/data) failed: Permission denied
    E StorageManagerService: Asked to fixup an app dir without a userId: /storage/<uuid>/Android/data/net.osmand.plus/files
    
  4. Work around step 2 so the sdcard daemon can access the directories:

    chown -R 100000:501077 /run/media/defaultuser/<uuid>/Android
    find .../Android -type d -exec chmod 775 {} +
    find .../Android -type f -exec chmod 664 {} +
    
  5. In OsmAnd, select the SD card as data storage folder (data migration succeeds) and download any map.

EXPECTED RESULT:
The map is downloaded and saved to the SD card, as it is on internal storage.

ACTUAL RESULT:
Download fails with “I/O error: close failed: EPERM (Operation not permitted)”:

E net.osmand: java.io.IOException: close failed: EPERM (Operation not permitted)
E net.osmand:    at libcore.io.IoBridge.closeAndSignalBlockedThreads(IoBridge.java:313)
E net.osmand:    at java.io.FileOutputStream.close(FileOutputStream.java:482)
E net.osmand:    at net.osmand.plus.download.DownloadFileHelper.copyFile(DownloadFileHelper.java:399)
E net.osmand:    at net.osmand.plus.download.DownloadFileHelper.unzipFile(DownloadFileHelper.java:377)
E net.osmand:    at net.osmand.plus.download.DownloadFileHelper.downloadFile(DownloadFileHelper.java:263)
E net.osmand: Caused by: android.system.ErrnoException: close failed: EPERM (Operation not permitted)
I MediaProvider: Deleted 0 0 0 0 0 0 0 items on <uuid> due to net.osmand.plus

MODIFICATIONS:

  • Developer mode enabled
  • Manual ownership/permission fix on the SD card as in step 4 (required to get past problem 1)

ADDITIONAL INFORMATION:
Checks done to narrow it down:

  • Ownership as seen from Android is correct: ls -ln /storage/<uuid>/Android/data/ shows net.osmand.plus as 10073 9997.

  • On the Sailfish side, files written by the app are 100000:501077, mode 664.

  • As root in the container (appsupport-attach), writing, closing, renaming and touching a file in /storage/<uuid>/Android/data/net.osmand.plus/files works.

  • chmod -R a+rwX on the app directory on the card does not change anything; still EPERM on close.

  • The same download works when OsmAnd uses internal storage.

  • The same EPERM occurred on a previous LUKS-encrypted ext4 card, so encryption is not the cause.

  • uid_map/gid_map of the sdcard process:

    0       500000  99999
    100000  100000  1
    100001  600001  99999
    

Related reports: