On Fri, 2013-11-15 at 11:17 +0000, Jon Medhurst (Tixy) wrote:
Can anyone provide clues to help me get 'sdcard' partition working on Linaro Android KitKat images? Here's where I've got to so far...
After updating the vexpress storage config for KitKat [1] the sdcard partition on Linaro Android images is getting mounted by vold, but apps can't access this because android.process.media keeps crashing in attachVolume because FileUtils.getFatVolumeId is returning -1.
With MediaProvider hacked to provide verbose logging I get:
V/MediaProvider( 2825): /storage/sdcard0 volume ID: -1 E/MediaProvider( 2825): Can't obtain external volume ID even though it's mounted.
and I've verified the -1 comes from the call ioctl(fd, VFAT_IOCTL_GET_VOLUME_ID) in android_os_FileUtils_getFatVolumeId in frameworks/base/core/jni/android_os_FileUtils.cpp.
Running 'mount' gives...
rootfs / rootfs rw,relatime 0 0 tmpfs /dev tmpfs rw,nosuid,relatime,mode=755 0 0 devpts /dev/pts devpts rw,relatime,mode=600 0 0 proc /proc proc rw,relatime 0 0 sysfs /sys sysfs rw,relatime 0 0 tmpfs /mnt/secure tmpfs rw,relatime,mode=700 0 0 tmpfs /mnt/asec tmpfs rw,relatime,mode=755,gid=1000 0 0 tmpfs /mnt/obb tmpfs rw,relatime,mode=755,gid=1000 0 0 /sys/kernel/debug /sys/kernel/debug debugfs rw,relatime 0 0 /dev/block/sda2 /system ext4 ro,relatime,data=ordered 0 0 /dev/block/sda3 /cache ext4 rw,nosuid,nodev,noatime,errors=panic,data=ordered 0 0 /dev/block/sda5 /data ext4 rw,nosuid,nodev,noatime,errors=panic,data=ordered 0 0 nodev /dev/gator gatorfs rw,relatime 0 0 /dev/block/vold/8:6 /mnt/media_rw/sdcard0 vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1023,gid=1023,fmask=0007,dmask=0007,allow_utime=0020,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0 /dev/block/vold/8:6 /mnt/secure/asec vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1023,gid=1023,fmask=0007,dmask=0007,allow_utime=0020,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0 /dev/fuse /storage/sdcard0 fuse rw,nosuid,nodev,relatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0
So first guess would be that fuse doesn't support this function, however as this seems to be the standard Android way of doing things, you would assume that it should work...?
So the error comes from fuse_dir_ioctl failing this check:
/* FUSE_IOCTL_DIR only supported for API version >= 7.18 */ if (fc->minor < 18) return -ENOTTY;
because fc->minor == 13. This version matches the fuse implementation in system/core/sdcard/fuse.h, and there doesn't appear to be any code in the sdcard daemon to handle things like faking up a FAT Volume Id.
I therefore think that KitKat is just plain broke, as the MediaProvider assumes removable media is a raw FAT volume, and the new way of doing things makes all access go through a fuse daemon.
So, this begs the question, why don't we just have the 'sdcard' partition of Linaro's images set as internal, i.e. android:removable="false" in storage_list.xml? After all, we can't actually physically remove the SD card as it also contains the system partition. Is there a use case where removable=true is required? (We had this in previous Android versions, I can't remember why)
This obviously isn't a solution for platforms which really do support a separate removable SD card, for that MediaProvider needs to be fixed.