最近在负责SD driver相关的问题。问题描述:在正常使用SD的后,从setting中选择Ejected ,在卸载SD卡后,重新插入SD卡, 显示
'SD card is corrupt. Touch to fix'刚开始怀疑是不是SD卡有问题,换了一张SD卡,还是出现同样的问题。从串口log中查看:[ 437.756727] mmc_sd_detect(mmc1): Unable to re-detect card (-123)
[ 437.955521] type=1400 audit(1483229505.993:201): avc: denied { ioctl } for pid=1969 comm="Binder_8" path="socket:[43706]" dev="sockfs" ino=43706 ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0
[ 437.979787] type=1400 audit(1483229505.993:202): avc: denied { ioctl } for pid=1969 comm="Binder_8" path="socket:[43706]" dev="sockfs" ino=43706 ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0
[ 438.120298] type=1400 audit(1483229506.153:203): avc: denied { ioctl } for pid=2074 comm="Binder_E" path="socket:[32824]" dev="sockfs" ino=32824 ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0
[ 438.142382] type=1400 audit(1483229506.163:204): avc: denied { ioctl } for pid=2074 comm="Binder_E" path="socket:[32824]" dev="sockfs" ino=32824 ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0
[ 438.470535] mmcblk1: error -123 sending status command, retrying
[ 438.475836] mmcblk1: error -123 sending status command, retrying
[ 438.482146] mmcblk1: error -123 sending status command, aborting
[ 438.658505] mmc_sd_detect(mmc1): Unable to re-detect card (-123)貌似没有检测到SD卡
后来去sys节点下去查看mount的信息。root@flo:/ # mount
mount
rootfs / rootfs ro,seclabel,size=794092k,nr_inodes=198523 0 0
tmpfs /dev tmpfs rw,seclabel,nosuid,relatime,size=912144k,nr_inodes=228036,mode=755 0 0
devpts /dev/pts devpts rw,seclabel,relatime,mode=600 0 0
proc /proc proc rw,relatime 0 0
sysfs /sys sysfs rw,seclabel,relatime 0 0
selinuxfs /sys/fs/selinux selinuxfs rw,relatime 0 0
debugfs /sys/kernel/debug debugfs rw,seclabel,relatime 0 0
none /acct cgroup rw,relatime,cpuacct 0 0
none /sys/fs/cgroup tmpfs rw,seclabel,relatime,size=912144k,nr_inodes=228036,mode=750,gid=1000 0 0
tmpfs /mnt tmpfs rw,seclabel,relatime,size=912144k,nr_inodes=228036,mode=755,gid=1000 0 0
none /dev/cpuctl cgroup rw,relatime,cpu 0 0
/dev/block/bootdevice/by-name/system /system ext4 ro,seclabel,relatime,discard,data=ordered 0 0
/dev/block/bootdevice/by-name/cache /cache ext4 rw,seclabel,nosuid,nodev,relatime,data=ordered 0 0
/dev/block/bootdevice/by-name/persist /persist ext4 rw,seclabel,nosuid,nodev,relatime,data=ordered 0 0
/dev/block/bootdevice/by-name/dsp /dsp ext4 ro,seclabel,nosuid,nodev,relatime,data=ordered 0 0
/dev/block/bootdevice/by-name/modem /firmware vfat ro,context=u:object_r:firmware_file:s0,relatime,uid=1000,gid=1000,fmask=0337,dmask=0227,codepage=437,iocharset=iso8859-1,shortname=lower,errors=remount-ro 0 0
tmpfs /storage tmpfs rw,seclabel,relatime,size=912144k,nr_inodes=228036,mode=755,gid=1000 0 0
none /config configfs rw,relatime 0 0
adb /dev/usb-ffs/adb functionfs rw,relatime 0 0
/dev/block/dm-0 /data ext4 rw,seclabel,nosuid,nodev,relatime,discard,noauto_da_alloc,data=ordered 0 0
/dev/fuse /mnt/runtime/default/emulated fuse rw,nosuid,nodev,noexec,noatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0
/dev/fuse /storage/emulated fuse rw,nosuid,nodev,noexec,noatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0
/dev/fuse /mnt/runtime/read/emulated fuse rw,nosuid,nodev,noexec,noatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0
/dev/fuse /mnt/runtime/write/emulated fuse rw,nosuid,nodev,noexec,noatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0
/dev/block/vold/public:179,65 /mnt/media_rw/FEA2-07D9 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 /mnt/runtime/default/FEA2-07D9 fuse rw,nosuid,nodev,noexec,noatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0
/dev/fuse /storage/FEA2-07D9 fuse rw,nosuid,nodev,noexec,noatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0
当我手动点击SD卡的卸载选项时,查看上述的挂载信息发现SD卡 FEA2-07D9 竟然还存在 发现SD卡其他挂载点没有卸载掉。这一块设计的SD卡的挂载流程,主要在system/core/vold目录下。vold 其功能主要包括:SD卡的插拔事件检测、SD卡挂载、卸载、格式化等。网络摘图:
Vold中的NetlinkManager模块接收来自Linux Kernel的uevent消息。
NetlinkManager将这些消息转发给VolumeManager模块。VolumeManager会对应做一些操作,然后把相关信息通过CommandListener发送给MountService。
MountService根据收到的消息后,根据情况会利用CommandListener发送相关的处理命令给VolumeManager做进一步处理。
CommandListener模块内部封装了一个Socket用于跨进程通信。它一方面接收来自MountService的控制命令,另一方面VolumeManager通过它将消息发送给MountService。修改文件:
PublicVolume.cppstatus_t PublicVolume::doUnmount()函数SD卡挂载正常。