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:
-
When AppSupport sets up a freshly formatted card,
Android/dataandAndroid/obbare created asappsupport-root:appsupport-root(500000:500000) with mode 700. Thesdcarddaemon 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”). -
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:
-
Format the card in Settings, start Android App Support.
-
Check the card:
ls -ln /run/media/defaultuser/<uuid>/Android/
→dataandobbare 500000:500000, mode 700 -
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 -
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 {} + -
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/showsnet.osmand.plusas10073 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/filesworks. -
chmod -R a+rwXon 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:
- Similar issue on 4.5, reported fixed in the Android 11 AppSupport: Android environment programs cannot create any files on external storage (SD Card)
- appsupport-root handling of Android data on SD card (OsmAnd, Magic Earth): OsmAnd + Magic Earth on 4.5.0.16 and then 4.5.0.18
- chmod not helping with Android write access on SD card: SD card write permission for Android