fbe业务流程分析2-data/media挂载

设置锁屏密码后开机的日志如下:

07-11 10:33:58.367   966  1338 I ActivityManager: Force stopping com.android.providers.media appid=10019 user=-1: vold reset  // vold reset
07-11 10:33:58.374   583   583 V vold    : Waiting for FUSE to spin up...	// emulatedVolume执行doMount()。fork子进程sdcardd挂载/data/media内部存储。ls命令查看文件名是已加密。但是只有用户输入凭证后如下目录才可用:
/sdcard -> /storage/self/primary
/storage/self/primary -> /mnt/user/0/primary
符号文件sdcard和/storage/self/primary已经创建,但是 /mnt/user/0/primary文件需要在onUserStarted()函数里才能创建。



当用户输入凭证后,上层调用e4crypt_unlock_user_key,设置user 0 CE key。
接着上层调用VoldNativeService::onUserStarted()启动用户。
onUserStarted()函数打印如下log:Linking /storage/emulated/0 to /mnt/user/0/primary

07-11 10:41:53.308   583   583 D vold    : e4crypt_unlock_user_key 0 serial=0 token_present=0
07-11 10:41:53.313   583   583 D vold    : Skipping non-key .
07-11 10:41:53.313   583   583 D vold    : Skipping non-key ..
07-11 10:41:53.313   583   583 D vold    : Trying user CE key /data/misc/vold/user_keys/ce/0/current
07-11 10:41:53.319   583   583 D vold    : Successfully retrieved key
07-11 10:41:53.323   583   583 D vold    : Added key 253940536 (ext4:ac0d2711774f4153) to keyring 339867308 in process 583
07-11 10:41:53.324   583   583 D vold    : Added key 572839207 (f2fs:ac0d2711774f4153) to keyring 339867308 in process 583
07-11 10:41:53.324   583   583 D vold    : Added key 171258648 (fscrypt:ac0d2711774f4153) to keyring 339867308 in process 583
07-11 10:41:53.324   583   583 D vold    : Installed ce key for user 0
07-11 10:41:53.326   583   583 D vold    : e4crypt_prepare_user_storage for volume null, user 0, serial 0, flags 2
07-11 10:41:53.326   583   583 D vold    : Preparing: /data/system_ce/0
07-11 10:41:53.326   583   583 D vold    : Preparing: /data/misc_ce/0
07-11 10:41:53.326   583   583 D vold    : Preparing: /data/vendor_ce/0
07-11 10:41:53.327   583   583 D vold    : Preparing: /data/media/0
07-11 10:41:53.328   583   583 D vold    : Preparing: /data/data
07-11 10:41:53.328   583   583 I vold    : Found policy ac0d2711774f4153 at /data/system_ce/0 which matches expected value
07-11 10:41:53.328   583   583 I vold    : Found policy ac0d2711774f4153 at /data/misc_ce/0 which matches expected value
07-11 10:41:53.328   583   583 I vold    : Policy for /data/vendor_ce/0 set to ac0d2711774f4153 modes 127/4
07-11 10:41:53.329   583   583 I vold    : Found policy ac0d2711774f4153 at /data/media/0 which matches expected value
07-11 10:41:53.329   583   583 I vold    : Found policy ac0d2711774f4153 at /data/data which matches expected value
07-11 10:41:53.329   583   583 V vold    : Starting restorecon of /data/system_ce/0
07-11 10:41:53.335   583   583 V vold    : Finished restorecon of /data/system_ce/0
07-11 10:41:53.335   583   583 V vold    : Starting restorecon of /data/misc_ce/0
07-11 10:41:53.340   583   583 V vold    : Finished restorecon of /data/misc_ce/0
07-11 10:41:53.340   583   583 V vold    : /system/bin/vold_prepare_subdirs
07-11 10:41:53.340   583   583 V vold    :     prepare
07-11 10:41:53.340   583   583 V vold    :
07-11 10:41:53.340   583   583 V vold    :     0
07-11 10:41:53.340   583   583 V vold    :     2
07-11 10:41:53.373  3240  3240 D vold_prepare_subdirs: Setting up mode 700 uid 0 gid 0 context u:object_r:vold_data_file:s0 on path: /data/misc_ce/0/vold
07-11 10:41:53.375  3240  3240 D vold_prepare_subdirs: Setting up mode 700 uid 0 gid 0 context u:object_r:storaged_data_file:s0 on path: /data/misc_ce/0/storaged
07-11 10:41:53.376   583   583 I vold_prepare_subdirs: SELinux: Loaded file_contexts
07-11 10:41:53.609   583   583 D vold    : Linking /storage/emulated/0 to /mnt/user/0/primary
原文地址:https://www.cnblogs.com/bobfly1984/p/14090086.html