Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 28e0eae7 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by android-build-merger
Browse files

Merge "Allocate a GID range for external cache files."

am: edaed3ed

Change-Id: I15399bb3ce95bf52e6ab2d0585598bdf7774c480
parents 006ea1ae edaed3ed
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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() */
+3 −0
Original line number Diff line number Diff line
@@ -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 */

+8 −0
Original line number Diff line number Diff line
@@ -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);
+8 −0
Original line number Diff line number Diff line
@@ -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));