Merge "Allocate a GID range for external cache files."
This commit is contained in:
commit
edaed3ed7a
4 changed files with 20 additions and 0 deletions
|
@ -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 a new issue