summaryrefslogtreecommitdiff
path: root/VolumeManager.cpp
diff options
context:
space:
mode:
authorRicky Wai <rickywai@google.com>2020-12-03 15:32:52 +0000
committerRicky Wai <rickywai@google.com>2020-12-03 15:38:03 +0000
commitbbfb6ea1ac459116512b34db94c647092dc99140 (patch)
treec81d880a15fb31512210db8ed42beb75aabf27fe /VolumeManager.cpp
parente8838a862d83c9302100d7dc41e44f3003426f15 (diff)
downloadvold-bbfb6ea1ac459116512b34db94c647092dc99140.tar.gz
Check if storage app data and obb directories exist in vold
As storage is not mounted in system server, we use vold to check if storage app data and obb directories exist instead. We add a method in vold so it only creates app data and obb dirs if dirs do not exist to speed up app starting time. Bug: 160336374 Test: Data and obb directories are created when a new app is started Change-Id: I1bd784d9c9e05463f71433fc782ac4e0c831cbf1
Diffstat (limited to 'VolumeManager.cpp')
-rw-r--r--VolumeManager.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index f0fc3887..714122d2 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -984,7 +984,25 @@ int VolumeManager::unmountAll() {
return 0;
}
-int VolumeManager::setupAppDir(const std::string& path, int32_t appUid, bool fixupExistingOnly) {
+int VolumeManager::ensureAppDirsCreated(const std::vector<std::string>& paths, int32_t appUid) {
+ if (IsSdcardfsUsed()) {
+ // sdcardfs magically does this for us
+ return OK;
+ }
+
+ int size = paths.size();
+ for (int i = 0; i < size; i++) {
+ int result = setupAppDir(paths[i], appUid, false /* fixupExistingOnly */,
+ true /* skipIfDirExists */);
+ if (result != OK) {
+ return result;
+ }
+ }
+ return OK;
+}
+
+int VolumeManager::setupAppDir(const std::string& path, int32_t appUid, bool fixupExistingOnly,
+ bool skipIfDirExists) {
// Only offer to create directories for paths managed by vold
if (!StartsWith(path, "/storage/")) {
LOG(ERROR) << "Failed to find mounted volume for " << path;
@@ -1029,11 +1047,18 @@ int VolumeManager::setupAppDir(const std::string& path, int32_t appUid, bool fix
const std::string volumeRoot = volume->getRootPath(); // eg /data/media/0
- if (fixupExistingOnly && (access(lowerPath.c_str(), F_OK) != 0)) {
+ const int access_result = access(lowerPath.c_str(), F_OK);
+ if (fixupExistingOnly && access_result != 0) {
// Nothing to fixup
return OK;
}
+ if (skipIfDirExists && access_result == 0) {
+ // It's safe to assume it's ok as it will be used for zygote to bind mount dir only,
+ // which the dir doesn't need to have correct permission for now yet.
+ return OK;
+ }
+
if (volume->getType() == VolumeBase::Type::kPublic) {
// On public volumes, we don't need to setup permissions, as everything goes through
// FUSE; just create the dirs and be done with it.