android - Android系统如何创建/storage/self/primary目录?
问题描述
我注意到 android 目录是由符号链接组织的,如下所示:
lrwxrwxrwx 1 root root 21 1970-01-01 08:00 /sdcard -> /storage/self/primary
lrwxrwxrwx 1 root root 19 1972-12-17 02:19 /storage/self/primary -> /mnt/user/0/primary
lrwxrwxrwx 1 root root 19 2020-02-21 10:31 /mnt/user/0/primary -> /storage/emulated/0
我搜索了一些android文档,发现:
/sdcard -> /storage/self/primary
由以下命令创建system/core/rootdir/init.rc
:
symlink /storage/self/primary /sdcard
/storage/self/
并/mnt/user/0/
安装在system/vold/VolumeManager.cpp
:
std::string storageSource;
if (mode == "default") {
storageSource = "/mnt/runtime/default";
} else if (mode == "read") {
storageSource = "/mnt/runtime/read";
} else if (mode == "write") {
storageSource = "/mnt/runtime/write";
} else if (mode == "full") {
storageSource = "/mnt/runtime/full";
} else {
// Sane default of no storage visible
_exit(0);
}
if (TEMP_FAILURE_RETRY(
mount(storageSource.c_str(), "/storage", NULL, MS_BIND | MS_REC, NULL)) == -1) {
PLOG(ERROR) << "Failed to mount " << storageSource << " for " << de->d_name;
_exit(1);
}
if (TEMP_FAILURE_RETRY(mount(NULL, "/storage", NULL, MS_REC | MS_SLAVE, NULL)) == -1) {
PLOG(ERROR) << "Failed to set MS_SLAVE to /storage for " << de->d_name;
_exit(1);
}
// Mount user-specific symlink helper into place
userid_t user_id = multiuser_get_user_id(uid);
std::string userSource(StringPrintf("/mnt/user/%d", user_id));
if (TEMP_FAILURE_RETRY(
mount(userSource.c_str(), "/storage/self", NULL, MS_BIND, NULL)) == -1) {
PLOG(ERROR) << "Failed to mount " << userSource << " for " << de->d_name;
_exit(1);
}
但是,我没有找到 Android 系统何时何地在or中创建primary
目录。你能帮我解决问题吗?非常感谢你!/storage/self
/mnt/user/0/self
解决方案
也许您可以参考 VolumeManager.cpp 中的“linkPrimary”函数。它将创建链接器 /mnt/user/0/primary -> /storage/emulated/0
推荐阅读
- go - 使用 OpenSSH 私钥连接到 SFTP 服务器
- jquery - 通过 Jquery 动态生成字段的 Quantity * Amount 计算
- php - 导入 wordpress 网站
- google-analytics - 如何正确匿名化跟踪代码管理器代码的 IP?
- java - 使用 maven 从具有无限循环的主动客户端生成 jar 可执行文件
- mysql - Mysql:使用计数加入查询
- javascript - 如何在日志文件中记录规范执行结果?- 茉莉花
- javascript - 无法在Angular 5中将一个数组的内容复制到另一个数组
- jquery - 用户已经授权登录,jquery 到 Api
- c# - C# saveFileDialog 打开两次