【转】Android Fuse and Runtime Permissions
/storage/self 是访问 sdcard 的关键路径。 各个路径间的关系:
/sdcard (intrc) -> symbol link -> /storage/self/primary
/storage/self (zygote) -> bind mount -> /mnt/user/user_id
/mnt/user/0/primary (vold) -> symbol link -> /storage/emulated/0
/storage (zygote) -> bind mount -> /mnt/runtime/default
/mnt/runtime/default/emulated -> fuse mount -> /data/media
为什么要做这些symbol link和bind mount呢? 是为了支持多用户和运行时权限。
路径链接关系:
/sdcard ---> /storage/self/primary
/mnt/sdcard ---> /storage/self/primary
/storage/self/primary ---> /mnt/user/0/primary
/mnt/runtime/default/self/primary ---> /mnt/user/0/primary
/mnt/user/0/primary ---> /storage/emulated/0
因此最终是链接到/storage/emulated/0目录,/storage/emulated是通过fuse系统挂载的/data/media
/dev/fuse on /storage/emulated type fuse (rw,nosuid,nodev,noexec,noatime,user_id=1023,group_id=1023,default_permissions,allow_other)
storage默认开机在init.rc中挂载的是/mnt/runtime/default
Mount default storage into root namespace
mount none /mnt/runtime/default /storage slave bind rec
重新挂载动作在EmulatedVolume::doMount()@EmulatedVolume.cpp中完成。
网友评论