How can I make it so that any user can chmod in my fuse-mounted ext4-formatted /sdcard? I have an ASUS Transformer Pad TF101. I finally got round to rooting it just now.

Important: /sdcard is not FAT32. It's a fuse filesystem based in ext4. So it is capable of using chmod.

So that I can work on it optimally, I'd like to be able to place executables in /mnt/sdcard. (Note that while it is called sdcard it is not, in actual fact, an SD card; it is internal storage.) I'd also like chmod in general to succeed, as it causes problems with certain things in Mercurial when it fails (even when I've patched the things in the main codebase to make it work at all, a few things in Python standard library calls still break).

I presume that the problem is something to do with the mount flags, but I don't know what, so here they are:

$ mount
...
/dev/block/mmcblk0p7 on /data type ext4 (rw,nosuid,nodev,noatime,nodiratime,errors=panic,user_xattr,acl,barrier=1,nodelalloc,data=ordered)
...
/dev/fuse on /mnt/sdcard type fuse (rw,nosuid,nodev,relatime,user_id=1023,group_id=1023,default_permissions,allow_other)
...


I'm not sure what happens with the FUSE stuff, but I know that /sdcard's contents are stored in /data/media.

Here, then, is the baffling thing about it all:


As 10126 (terminal) in /sdcard, I can't chmod.
As 1023 in /sdcard, I can't chmod.
As 0 in /sdcard, I can chmod.
As 10126 in /data/media, I can't chmod.
As 1023 in /data/media, I can chmod.
As 0 in /data/media, I can chmod.


Having applied chmod a+w /data/media, 10126 can then chmod appropriate files in /data/media, but still neither 10126 nor 1023 can chmod in /mnt/sdcard, which is what I ideally want. (Because it sorts out all the rest of the permissions so that you don't end up with fragmented file ownership.)

Also, if I create files in /sdcard, they will be owned by UID/GID 0/1015 (1015 being sdcard_rw), while if I create them in /data/media, they will be owned by the UID/GID of the user (0/0) rather than 1023/1023 in /data/media (they will still be owned by 0/1015 in /sdcard&mdash;I don't understand that but am not drastically worried by it).

So then, my question: how can I make it so that any account can successfully chmod in /mnt/sdcard, rather than just root?

I have been using /mnt/sdcard and /sdcard interchangeably in this question; /sdcard is symlinked to /mnt/sdcard.
Chmod will never be supported. That's on purpose according to comments in the source code.

Here's a reference to the FUSE implementation on Github pointing to a comment that says this.

And the original head on Googlesource (a bit harder to navigate than Github).

Even root cannot bypass it:

shell@android: # id     
uid=0(root) gid=0(root)    
shell@android: # touch /mnt/sdcard/x; ls -l /data/media/0/x    
-rw-rw-r-- media_rw     media_rw        0 2013-01-05 17:35 x    
shell@android: # chmod 777 /mnt/sdcard/x; ls -l /data/media/0/x    
-rw-rw-r-- media_rw     media_rw        0 2013-01-05 17:35 x    
shell@android: # chmod 000 /mnt/sdcard/x; ls -l /data/media/0/x    
-rw-rw-r-- media_rw     media_rw        0 2013-01-05 17:35 x


Note that ownership is hardcoded to media_rw:media_rw (below /data/media). PS: /data/media is another story, all the regular permissions apply here, it's ext4 and root is allowed to do whatever it wants.