Android关闭SdcardFS
16lz
2021-01-26
Author:Gary
Date:2019-8-26
参考博客:https://blog.csdn.net/pen_cil/article/details/79842706
由于项目先在Android6上进行实现的,现需要移植到Android8上。但是Android8上启用了SdcardFS,与原有设计中的Fuse不符,重新适配SdcardFS工作量比较大,找到如下方法可以关闭SdcardFS使用旧的Fuse文件系统:
打开安卓目录下的文件:system/core/sdcard/sdcard.cpp,第412行:
static bool supports_sdcardfs(void) { std::string filesystems; if (!android::base::ReadFileToString("/proc/filesystems", &filesystems)) { PLOG(ERROR) << "Could not read /proc/filesystems"; return false; } for (const auto& fs : android::base::Split(filesystems, "\n")) { if (fs.find("sdcardfs") != std::string::npos) return true; } return false;}
添加一行,直接返回false即可:
static bool supports_sdcardfs(void) {return false; std::string filesystems; if (!android::base::ReadFileToString("/proc/filesystems", &filesystems)) { PLOG(ERROR) << "Could not read /proc/filesystems"; return false; } for (const auto& fs : android::base::Split(filesystems, "\n")) { if (fs.find("sdcardfs") != std::string::npos) return true; } return false;}
修改完成后重新编译刷入,在adb shell中输入mount可以看到已经变成了fuse文件系统:
更多相关文章
- android flash分区(nand flash)
- Android(安卓)文件系统的权限设置
- Android文件系统的制作
- 在Android下查看蓝牙的Link Key
- UBI文件系统
- Android(安卓)NFS 文件系统
- Android培训班(10)
- Android(安卓)StatFs类
- 基于android系统的加密文件系统设计