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
diff --git a/VolumeManager.h b/VolumeManager.h
index 765349d..afea54e 100644
--- a/VolumeManager.h
+++ b/VolumeManager.h
@@ -157,12 +157,23 @@
* requirements of the underlying filesystem and are of no concern to the
* caller.
*
+ * If fixupExistingOnly is set, we make sure to fixup any existing dirs and
+ * files in the passed in path, but only if that path exists; if it doesn't
+ * exist, this function doesn't create them.
+ *
* Validates that given paths are absolute and that they contain no relative
* "." or ".." paths or symlinks. Last path segment is treated as filename
* and ignored, unless the path ends with "/". Also ensures that path
* belongs to a volume managed by vold.
*/
- int setupAppDir(const std::string& path, int32_t appUid);
+ int setupAppDir(const std::string& path, int32_t appUid, bool fixupExistingOnly = false);
+
+ /**
+ * Fixes up an existing application directory, as if it was created with
+ * setupAppDir() above. This includes fixing up the UID/GID, permissions and
+ * project IDs of the contained files and directories.
+ */
+ int fixupAppDir(const std::string& path, int32_t appUid);
int createObb(const std::string& path, const std::string& key, int32_t ownerGid,
std::string* outVolId);