Allocate a GID range for external cache files.
We can't reuse the GID range for internal cache files, otherwise we don't have a way to tease apart the difference when deciding if it's safe to move apps. Test: builds, boots Bug: 37193650 Change-Id: I22c4e575cd557636e74c5c73035adb1d4dcbb7f7
This commit is contained in:
parent
29ab67b0c1
commit
bd2ecd8e6d
|
@ -33,6 +33,7 @@ extern uid_t multiuser_get_uid(userid_t user_id, appid_t app_id);
|
|||
|
||||
extern gid_t multiuser_get_cache_gid(userid_t user_id, appid_t app_id);
|
||||
extern gid_t multiuser_get_ext_gid(userid_t user_id, appid_t app_id);
|
||||
extern gid_t multiuser_get_ext_cache_gid(userid_t user_id, appid_t app_id);
|
||||
extern gid_t multiuser_get_shared_gid(userid_t user_id, appid_t app_id);
|
||||
|
||||
/* TODO: switch callers over to multiuser_get_shared_gid() */
|
||||
|
|
|
@ -171,6 +171,9 @@
|
|||
#define AID_EXT_GID_START 30000 /* start of gids for apps to mark external data */
|
||||
#define AID_EXT_GID_END 39999 /* end of gids for apps to mark external data */
|
||||
|
||||
#define AID_EXT_CACHE_GID_START 40000 /* start of gids for apps to mark external cached data */
|
||||
#define AID_EXT_CACHE_GID_END 49999 /* end of gids for apps to mark external cached data */
|
||||
|
||||
#define AID_SHARED_GID_START 50000 /* start of gids for apps in each user to share */
|
||||
#define AID_SHARED_GID_END 59999 /* end of gids for apps in each user to share */
|
||||
|
||||
|
|
|
@ -45,6 +45,14 @@ gid_t multiuser_get_ext_gid(userid_t user_id, appid_t app_id) {
|
|||
}
|
||||
}
|
||||
|
||||
gid_t multiuser_get_ext_cache_gid(userid_t user_id, appid_t app_id) {
|
||||
if (app_id >= AID_APP_START && app_id <= AID_APP_END) {
|
||||
return multiuser_get_uid(user_id, (app_id - AID_APP_START) + AID_EXT_CACHE_GID_START);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
gid_t multiuser_get_shared_gid(userid_t user_id, appid_t app_id) {
|
||||
if (app_id >= AID_APP_START && app_id <= AID_APP_END) {
|
||||
return multiuser_get_uid(user_id, (app_id - AID_APP_START) + AID_SHARED_GID_START);
|
||||
|
|
|
@ -68,6 +68,14 @@ TEST(MultiuserTest, TestExt) {
|
|||
EXPECT_EQ(1030000U, multiuser_get_ext_gid(10, 10000));
|
||||
}
|
||||
|
||||
TEST(MultiuserTest, TestExtCache) {
|
||||
EXPECT_EQ(ERR_GID, multiuser_get_ext_cache_gid(0, 0));
|
||||
EXPECT_EQ(ERR_GID, multiuser_get_ext_cache_gid(0, 1000));
|
||||
EXPECT_EQ(40000U, multiuser_get_ext_cache_gid(0, 10000));
|
||||
EXPECT_EQ(ERR_GID, multiuser_get_ext_cache_gid(0, 50000));
|
||||
EXPECT_EQ(1040000U, multiuser_get_ext_cache_gid(10, 10000));
|
||||
}
|
||||
|
||||
TEST(MultiuserTest, TestShared) {
|
||||
EXPECT_EQ(ERR_GID, multiuser_get_shared_gid(0, 0));
|
||||
EXPECT_EQ(ERR_GID, multiuser_get_shared_gid(0, 1000));
|
||||
|
|
Loading…
Reference in New Issue