2

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—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.

3
  • 1
    I suggest that you edit your question so that it states in the title that it's in fact a ext4 formated SD card (e.g. "How can I make it so that any user can chmod in a ext4 formated /sdcard?").
    – Flow
    Commented Jan 5, 2013 at 15:47
  • 1
    @Flow: thanks, that's a wise suggestion. Done. Commented Jan 5, 2013 at 16:02
  • It's not implemented, you have to live without it (or patch the fuse implementation yourself)
    – ce4
    Commented Jan 5, 2013 at 16:25

1 Answer 1

3

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.

6
  • The implementation has a few further shortcomings, e.g. setting time stamps doesn't work either (yet, see bug here: code.google.com/p/android/issues/detail?id=25460).
    – ce4
    Commented Jan 5, 2013 at 16:20
  • How come it works for root, then? Commented Jan 5, 2013 at 16:30
  • It doesn't work at all in the /mnt/sdcard folder (only in the /data/media folder and that's clear why root may chmod here, it's just the regular stuff). /mnt/sdcard however just lacks the implementation, the calls silently fail.
    – ce4
    Commented Jan 5, 2013 at 16:35
  • :-/ Silly me. That's what comes of not actually changing the bits in the chmod call... well then, I guess I'm stuck with working in /data/media if I ever want things +x. Thanks for explaining. Commented Jan 5, 2013 at 16:40
  • It's dreadful, I know. But it's part of the SD card legacy hell that Google tries to abandon. Let's hope they improve it eventually...
    – ce4
    Commented Jan 5, 2013 at 16:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .