summaryrefslogtreecommitdiff
path: root/VolumeManager.cpp
diff options
context:
space:
mode:
authorMartijn Coenen <maco@google.com>2020-02-18 15:06:37 +0100
committerMartijn Coenen <maco@google.com>2020-02-19 12:11:34 +0100
commit816f4d94f6223cbc00f9d03e95336740dc47a6a5 (patch)
tree83678278069c622e41b418ed1a3b5755812d1b13 /VolumeManager.cpp
parent442bb838286bd47edee68dcdae64edaa5ece55a3 (diff)
downloadvold-816f4d94f6223cbc00f9d03e95336740dc47a6a5.tar.gz
Add fixupAppDir() API.
This can be used to fixup application directories in case they have been created by some other entity besides vold; the main use case for this API right now is OBB directories, which can be created by installers outside of vold; on devices without sdcardfs, such directories and the files contained therein are not setup correctly. This API will make sure everything is setup the way it needs to be setup. Bug: 146419093 Test: inspect OBB dir after install Change-Id: I2e35b7ac2992dbb21cc950e53651ffc07cfca907
Diffstat (limited to 'VolumeManager.cpp')
-rw-r--r--VolumeManager.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index 6f158461..f7b36bff 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -814,7 +814,7 @@ int VolumeManager::unmountAll() {
return 0;
}
-int VolumeManager::setupAppDir(const std::string& path, int32_t appUid) {
+int VolumeManager::setupAppDir(const std::string& path, int32_t appUid, bool fixupExistingOnly) {
// Only offer to create directories for paths managed by vold
if (!StartsWith(path, "/storage/")) {
LOG(ERROR) << "Failed to find mounted volume for " << path;
@@ -859,8 +859,21 @@ int VolumeManager::setupAppDir(const std::string& path, int32_t appUid) {
const std::string volumeRoot = volume->getRootPath(); // eg /data/media/0
+ if (fixupExistingOnly && (access(lowerPath.c_str(), F_OK) != 0)) {
+ // Nothing to fixup
+ return OK;
+ }
+
// Create the app paths we need from the root
- return PrepareAppDirFromRoot(lowerPath, volumeRoot, appUid);
+ return PrepareAppDirFromRoot(lowerPath, volumeRoot, appUid, fixupExistingOnly);
+}
+
+int VolumeManager::fixupAppDir(const std::string& path, int32_t appUid) {
+ if (IsFilesystemSupported("sdcardfs")) {
+ //sdcardfs magically does this for us
+ return OK;
+ }
+ return setupAppDir(path, appUid, true /* fixupExistingOnly */);
}
int VolumeManager::createObb(const std::string& sourcePath, const std::string& sourceKey,