Switch to new project ID constants.
Use new constants, instead of reusing previous sdcardfs values.
Bug: 146419093
Test: lsattr -pR
Change-Id: I7409d86cac5360e125e843cc79f3c5f41d74dd1e
diff --git a/FsCrypt.cpp b/FsCrypt.cpp
index 141f4c9..8682bdc 100644
--- a/FsCrypt.cpp
+++ b/FsCrypt.cpp
@@ -40,6 +40,7 @@
#include <unistd.h>
#include <private/android_filesystem_config.h>
+#include <private/android_projectid_config.h>
#include "android/os/IVold.h"
@@ -804,7 +805,8 @@
// Setup quota project ID and inheritance policy
if (!IsFilesystemSupported("sdcardfs")) {
if (SetQuotaInherit(media_ce_path) != 0) return false;
- if (SetQuotaProjectId(media_ce_path, multiuser_get_uid(user_id, AID_MEDIA_RW)) != 0) {
+ if (SetQuotaProjectId(media_ce_path,
+ multiuser_get_uid(user_id, PROJECT_ID_EXT_DEFAULT)) != 0) {
return false;
}
}
diff --git a/Utils.cpp b/Utils.cpp
index 9f9b357..0974a0b 100644
--- a/Utils.cpp
+++ b/Utils.cpp
@@ -29,6 +29,7 @@
#include <cutils/fs.h>
#include <logwrap/logwrap.h>
#include <private/android_filesystem_config.h>
+#include <private/android_projectid_config.h>
#include <dirent.h>
#include <fcntl.h>
@@ -318,7 +319,13 @@
}
std::string pathToCreate = root + appDir;
int depth = 0;
- bool withinCache = false;
+ // Derive initial project ID
+ if (appDir == kAppDataDir || appDir == kAppMediaDir) {
+ projectId = uid - AID_APP_START + PROJECT_ID_EXT_DATA_START;
+ } else if (appDir == kAppObbDir) {
+ projectId = uid - AID_APP_START + PROJECT_ID_EXT_OBB_START;
+ }
+
while ((pos = leftToCreate.find('/')) != std::string::npos) {
std::string component = leftToCreate.substr(0, pos + 1);
leftToCreate = leftToCreate.erase(0, pos + 1);
@@ -329,12 +336,7 @@
// Android/data, eg Android/data/com.foo/cache
// Note that this "sticks" - eg subdirs of this dir need the same
// project ID.
- withinCache = true;
- }
- if (withinCache) {
- projectId = uid - AID_APP_START + AID_CACHE_GID_START;
- } else {
- projectId = uid - AID_APP_START + AID_EXT_GID_START;
+ projectId = uid - AID_APP_START + PROJECT_ID_EXT_CACHE_START;
}
if (fixupExisting && access(pathToCreate.c_str(), F_OK) == 0) {