Remove appDirRoot argument from setupAppDir.

This is no longer needed, because vold can deduce this itself now.

Bug: 146419093
Test: builds
Change-Id: Ib4f4a4109919af683722a63b305b343ef5fe972d
This commit is contained in:
Martijn Coenen 2020-02-12 15:29:02 +01:00
parent fd9cdbf124
commit 8a68a075a2
5 changed files with 20 additions and 17 deletions

View file

@ -458,14 +458,12 @@ binder::Status VoldNativeService::remountUid(int32_t uid, int32_t remountMode) {
return translate(VolumeManager::Instance()->remountUid(uid, remountMode)); return translate(VolumeManager::Instance()->remountUid(uid, remountMode));
} }
binder::Status VoldNativeService::setupAppDir(const std::string& path, binder::Status VoldNativeService::setupAppDir(const std::string& path, int32_t appUid) {
const std::string& appDirRoot, int32_t appUid) {
ENFORCE_SYSTEM_OR_ROOT; ENFORCE_SYSTEM_OR_ROOT;
CHECK_ARGUMENT_PATH(path); CHECK_ARGUMENT_PATH(path);
CHECK_ARGUMENT_PATH(appDirRoot);
ACQUIRE_LOCK; ACQUIRE_LOCK;
return translate(VolumeManager::Instance()->setupAppDir(path, appDirRoot, appUid)); return translate(VolumeManager::Instance()->setupAppDir(path, appUid));
} }
binder::Status VoldNativeService::createObb(const std::string& sourcePath, binder::Status VoldNativeService::createObb(const std::string& sourcePath,

View file

@ -65,8 +65,7 @@ class VoldNativeService : public BinderService<VoldNativeService>, public os::Bn
binder::Status remountUid(int32_t uid, int32_t remountMode); binder::Status remountUid(int32_t uid, int32_t remountMode);
binder::Status setupAppDir(const std::string& path, const std::string& appDirRoot, binder::Status setupAppDir(const std::string& path, int32_t appUid);
int32_t appUid);
binder::Status createObb(const std::string& sourcePath, const std::string& sourceKey, binder::Status createObb(const std::string& sourcePath, const std::string& sourceKey,
int32_t ownerGid, std::string* _aidl_return); int32_t ownerGid, std::string* _aidl_return);

View file

@ -823,8 +823,7 @@ int VolumeManager::unmountAll() {
return 0; return 0;
} }
int VolumeManager::setupAppDir(const std::string& path, const std::string& appDirRoot, int VolumeManager::setupAppDir(const std::string& path, int32_t appUid) {
int32_t appUid) {
// Only offer to create directories for paths managed by vold // Only offer to create directories for paths managed by vold
if (!StartsWith(path, "/storage/")) { if (!StartsWith(path, "/storage/")) {
LOG(ERROR) << "Failed to find mounted volume for " << path; LOG(ERROR) << "Failed to find mounted volume for " << path;

View file

@ -133,20 +133,27 @@ class VolumeManager {
/* /*
* Creates a directory 'path' for an application, automatically creating * Creates a directory 'path' for an application, automatically creating
* directories along the given path if they don't exist yet. 'appDirRoot' * directories along the given path if they don't exist yet.
* is the "root" directory for app-specific directories of this kind;
* 'path' must always start with 'appDirRoot'.
* *
* Example: * Example:
* path = /storage/emulated/0/Android/data/com.foo/files/ * path = /storage/emulated/0/Android/data/com.foo/files/
* appDirRoot = /storage/emulated/0/Android/data/
* *
* This function will set the UID of all app-specific directories below * This function will first match the first part of the path with the volume
* 'appDirRoot' to the 'appUid' argument. In the given example, the UID * root of any known volumes; in this case, "/storage/emulated/0" matches
* with the volume root of the emulated volume for user 0.
*
* The subseqent part of the path must start with one of the well-known
* Android/ data directories, /Android/data, /Android/obb or
* /Android/media.
*
* The final part of the path is application specific. This function will
* create all directories, including the application-specific ones, and
* set the UID of all app-specific directories below the well-known data
* directories to the 'appUid' argument. In the given example, the UID
* of /storage/emulated/0/Android/data/com.foo and * of /storage/emulated/0/Android/data/com.foo and
* /storage/emulated/0/Android/data/com.foo/files would be set to 'appUid'. * /storage/emulated/0/Android/data/com.foo/files would be set to 'appUid'.
* *
* The UID of the parent directories will be set according to the * The UID/GID of the parent directories will be set according to the
* requirements of the underlying filesystem and are of no concern to the * requirements of the underlying filesystem and are of no concern to the
* caller. * caller.
* *
@ -155,7 +162,7 @@ class VolumeManager {
* and ignored, unless the path ends with "/". Also ensures that path * and ignored, unless the path ends with "/". Also ensures that path
* belongs to a volume managed by vold. * belongs to a volume managed by vold.
*/ */
int setupAppDir(const std::string& path, const std::string& appDirRoot, int32_t appUid); int setupAppDir(const std::string& path, int32_t appUid);
int createObb(const std::string& path, const std::string& key, int32_t ownerGid, int createObb(const std::string& path, const std::string& key, int32_t ownerGid,
std::string* outVolId); std::string* outVolId);

View file

@ -54,7 +54,7 @@ interface IVold {
void remountUid(int uid, int remountMode); void remountUid(int uid, int remountMode);
void setupAppDir(@utf8InCpp String path, @utf8InCpp String appDirRoot, int appUid); void setupAppDir(@utf8InCpp String path, int appUid);
@utf8InCpp String createObb(@utf8InCpp String sourcePath, @utf8InCpp String sourceKey, @utf8InCpp String createObb(@utf8InCpp String sourcePath, @utf8InCpp String sourceKey,
int ownerGid); int ownerGid);