Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.
shell@android:/sdcard/SW # ls -l
-rw-rw-r-- root     sdcard_rw      128 2012-09-22 11:42 usb0config.sh
shell@android:/sdcard/SW # chmod 777 usb0config.sh                             
shell@android:/sdcard/SW # ls -l
-rw-rw-r-- root     sdcard_rw      128 2012-09-22 11:42 usb0config.sh
shell@android:/sdcard/SW # 

Why can I not assign exec permissions to a file on the SD card?

$ adb shell su -c mount |grep -si sdcard
/dev/block/vold/179:97 /mnt/ext_sdcard vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0002,dmask=0002,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
tmpfs /mnt/ext_sdcard/.android_secure tmpfs ro,relatime,size=0k,mode=000 0 0
/dev/fuse /mnt/sdcard fuse rw,nosuid,nodev,relatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0


$ adb shell su -c "mount -t vfat -o umask=0000 /dev/fuse /mnt/sdcard"
mount: Block device required

Now it seems remount successfully.

$ adb shell su -c "mount -t vfat -o remount,umask=0000 /dev/fuse /mnt/sdcard"

but the file yet cannot be assigned 777 mode.

shell@android:/sdcard/Sw # ls -l
-rw-rw-r-- root     sdcard_rw      128 2012-09-22 11:42 usb0config.sh
shell@android:/sdcard/Sw # chmod 777 usb0config.sh                             
shell@android:/sdcard/Sw # ls -l
-rw-rw-r-- root     sdcard_rw      128 2012-09-22 11:42 usb0config.sh

The mount info doesn't change comparing to before remount's.

$ adb shell su -c mount |grep -si sdcard
/dev/block/vold/179:97 /mnt/ext_sdcard vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0002,dmask=0002,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
tmpfs /mnt/ext_sdcard/.android_secure tmpfs ro,relatime,size=0k,mode=000 0 0
/dev/fuse /mnt/sdcard fuse rw,relatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0
share|improve this question
add comment

1 Answer 1

Unless you've done something unusual with your device, the SD card will be formatted as a FAT file system, which does not support *nix file permissions. This Linux FAQ entry from one of MIT's professors explains it a bit, and also explains how you can potentially use mount options to change the permission mode of the device (this would require root, though, and affect all files/folders on the device). Also, the SD card in Android is mounted by default with the -noexec flag.

For the exec bit you'd probably want to remount with a umask of 0000, since the umask is essentially a binary NOT of the permissions you want (so umask 0000 says don't mask out any permissions, allow them all). Untested, but doing it temporarily would be something along the lines of:

mount -t vfat -o umask=0000 /dev/your/sdcard/device /mnt/sdcard

The mount point may need to be changed from /mnt/sdcard to something slightly different depending on your device. Again, though, I believe mount requires that you have root permissions for this.

share|improve this answer
    
I try remount using your gave command, but failed, please see supplement of my question. –  Victor S Sep 22 '12 at 5:06
    
please see my question's update. –  Victor S Sep 22 '12 at 5:22
1  
@VictorS: It looks like you have both an internal and an external SD card. The internal one is not treated the same way, and I don't know if there's a way to get it re-mounted with the permissions you want. Alternatively, though, you could execute your script by invoking sh: sh usb0config.sh. –  eldarerathis Sep 22 '12 at 5:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.