diff options
author | 2012-08-14 18:47:09 -0700 | |
---|---|---|
committer | 2012-08-15 19:45:53 -0700 | |
commit | 5b1ada2562c17921adf6a62ea62bcb445160983c (patch) | |
tree | de45aa88e185f4ce052df43acf486e77778adcfb /cmds/installd/commands.c | |
parent | 4d1988699b11a9409015ef38a825d0de841a1d0f (diff) |
Multi-user external storage support.
Emulated external storage always has multi-user support using paths
like "/data/media/<user_id>". Creates and destroys these paths along
with user data. Uses new ensure_dir() to create directories while
always ensuring permissions.
Add external storage mount mode to zygote, supporting both single-
and multi-user devices. For example, devices with physical SD cards
are treated as single-user. Begin migrating to mount mode instead
of relying on sdcard_r GID to enforce READ_EXTERNAL_STORAGE.
Bug: 6925012
Change-Id: I9b872ded992cd078e2c013567d59f9f0032ec02b
Diffstat (limited to 'cmds/installd/commands.c')
-rw-r--r-- | cmds/installd/commands.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/cmds/installd/commands.c b/cmds/installd/commands.c index d94daf70ea3b..0a7cb2d82fbf 100644 --- a/cmds/installd/commands.c +++ b/cmds/installd/commands.c @@ -213,18 +213,30 @@ int make_user_data(const char *pkgname, uid_t uid, uid_t persona) int delete_persona(uid_t persona) { - char pkgdir[PKG_PATH_MAX]; + char data_path[PKG_PATH_MAX]; + if (create_persona_path(data_path, persona)) { + return -1; + } + if (delete_dir_contents(data_path, 1, NULL)) { + return -1; + } - if (create_persona_path(pkgdir, persona)) + char media_path[PATH_MAX]; + if (create_persona_media_path(media_path, (userid_t) persona) == -1) { + return -1; + } + if (delete_dir_contents(media_path, 1, NULL) == -1) { return -1; + } - return delete_dir_contents(pkgdir, 1, NULL); + return 0; } int clone_persona_data(uid_t src_persona, uid_t target_persona, int copy) { char src_data_dir[PKG_PATH_MAX]; char pkg_path[PKG_PATH_MAX]; + char media_path[PATH_MAX]; DIR *d; struct dirent *de; struct stat s; @@ -233,6 +245,9 @@ int clone_persona_data(uid_t src_persona, uid_t target_persona, int copy) if (create_persona_path(src_data_dir, src_persona)) { return -1; } + if (create_persona_media_path(media_path, (userid_t) target_persona) == -1) { + return -1; + } d = opendir(src_data_dir); if (d != NULL) { @@ -260,6 +275,11 @@ int clone_persona_data(uid_t src_persona, uid_t target_persona, int copy) } closedir(d); } + + // ensure /data/media/<user_id> exists + if (ensure_dir(media_path, 0770, AID_MEDIA_RW, AID_MEDIA_RW) == -1) { + return -1; + } return 0; } |