By Forivin

2018-07-24 15:49:27 8 Comments

I have a rooted OnePlus One running LineageOS 15.1 (Oreo 8.1). I am trying to adjust some file permissions/ownerships on the emulated sdcard partition.
The partition seems to be mounted as an sdcardfs:

A0001:/ # mount | grep /storage/emulated                                                                                                                                                           
/data/media on /storage/emulated type sdcardfs (rw,nosuid,nodev,noexec,noatime,fsuid=1023,fsgid=1023,gid=1015,multiuser,mask=6,derive_gid)

I'm not sure what that means. Some people suggest that Android used to use mount then switched to fuse and now with Oero uses sdcardfs. I'm not sure if that makes any sense, but I'm a bit scared that something like mount -o remount, rw /mnt/sdcard/ (which apparently is what you had to do in the past to be able to set file permissions on the emulated sdcard partition).

Short demonstration showing that file permissions won't be applied:

A0001:/ $ su
A0001:/ # ls -la /storage/emulated                                                                                                                                                                 
total 12
drwx--x--x  4 root sdcard_rw 4096 2018-07-24 17:44 .
drwxr-xr-x  4 root root        80 2018-07-24 17:21 ..
drwxrwx--x 14 root sdcard_rw 4096 2018-07-24 17:20 0
drwxrwx--x  2 root sdcard_rw 4096 1970-01-01 01:12 obb
A0001:/ # touch /storage/emulated/a
A0001:/ # ls -la /storage/emulated/a
-rw------- 1 root sdcard_rw 0 2018-07-24 17:44 /storage/emulated/a
A0001:/ # chmod 777 /storage/emulated/a
A0001:/ # ls -la /storage/emulated/a                                                                                                                                                               
-rw------- 1 root sdcard_rw 0 2018-07-24 17:44 /storage/emulated/a

(Note: the same happens if I use /storage/emulated/0 instead of /storage/emulated)

My question is: What do I have to run in order to be able to change the file permissions and file ownerships on this weird sdcardfs partition.


@Irfan Latif 2019-03-13 19:20:43

You cannot change permissions and ownerships of files on sdcardfs.

On all operating systems based on Linux kernel - like Android is - it's possible to set permissions on files (including directories) provided that filesystem supports UNIX permissions (uid, gid, mode). Common examples of such filesystems are ext4 and f2fs.

However Android's internal (confusingly called external) storage which is accessible by installed apps at /sdcard, is not an actual but virtual / emulated filesystem exposing /data/media (which is a real filesystem) through sdcardfs. sdcardfs and its predecessor FUSE expose the emulated filesystem with a fixed set of uid, gid and mask (mode). So the commands chmod and chown have no impact, whether executed through CLI (adb shell or terminal emulator) or GUI (file explorer).

It's possible to change permission bits of file on underlying actual filesystem, but accessing /data/media requires root access because only UID/GID 1023 (aid_media_rw) has read access to the directory. And still the permissions will remain same when viewed from emulated view /sdcard.

Further reading:


Related Questions

Sponsored Content

1 Answered Questions

[SOLVED] Cannot mount /system as rw

0 Answered Questions

Understanding android partitions and directories permissions

0 Answered Questions

1 Answered Questions

[SOLVED] Mount USB OTG to specific destination folder

1 Answered Questions

[SOLVED] Can't use chmod to alter permissions on emulated phone

0 Answered Questions

Downloads not possible after root

0 Answered Questions

Where's my mounted stuff?

  • 2015-02-08 19:14:54
  • Luis A. Florit
  • 46 View
  • 1 Score
  • 0 Answer
  • Tags:   encryption mount

1 Answered Questions

0 Answered Questions

Remount writable by all users?

Sponsored Content