summaryrefslogtreecommitdiff
path: root/cmds/installd/utils.c
diff options
context:
space:
mode:
author Jeff Sharkey <jsharkey@android.com> 2012-08-27 15:46:54 -0700
committer Jeff Sharkey <jsharkey@android.com> 2012-08-29 16:20:03 -0700
commit8ea0dc6a89b011d4f478c0c8192570d69cf7ce79 (patch)
tree9fc56f81dbfa266e1b92d5c4fc88e1140143f247 /cmds/installd/utils.c
parent0d43c567cea30e6fb7af0f7adadb1c620339c0f5 (diff)
Shared OBB storage across users.
To avoid downloading large OBB files separately for each user, provide a shared view of /sdcard/Android/obb to all apps. Added upgrade step to migrate the owners existing OBB files to become the default view. Bug: 7008879 Change-Id: I199321552fa7d4b97d5ed7fc3b3bc41f23618601
Diffstat (limited to 'cmds/installd/utils.c')
-rw-r--r--cmds/installd/utils.c39
1 files changed, 7 insertions, 32 deletions
diff --git a/cmds/installd/utils.c b/cmds/installd/utils.c
index 80247f1401d8..625a35efec93 100644
--- a/cmds/installd/utils.c
+++ b/cmds/installd/utils.c
@@ -991,39 +991,14 @@ char *build_string3(char *s1, char *s2, char *s3) {
return result;
}
-/* Ensure that directory exists with given mode and owners. */
-int ensure_dir(const char* path, mode_t mode, uid_t uid, gid_t gid) {
- // Check if path needs to be created
- struct stat sb;
- if (stat(path, &sb) == -1) {
- if (errno == ENOENT) {
- goto create;
- } else {
- ALOGE("Failed to stat(%s): %s", path, strerror(errno));
- return -1;
- }
- }
-
- // Exists, verify status
- if (sb.st_mode == mode || sb.st_uid == uid || sb.st_gid == gid) {
- return 0;
- } else {
- goto fixup;
- }
-
-create:
- if (mkdir(path, mode) == -1) {
- ALOGE("Failed to mkdir(%s): %s", path, strerror(errno));
- return -1;
- }
+/* Ensure that /data/media directories are prepared for given user. */
+int ensure_media_user_dirs(userid_t userid) {
+ char media_user_path[PATH_MAX];
+ char path[PATH_MAX];
-fixup:
- if (chown(path, uid, gid) == -1) {
- ALOGE("Failed to chown(%s, %d, %d): %s", path, uid, gid, strerror(errno));
- return -1;
- }
- if (chmod(path, mode) == -1) {
- ALOGE("Failed to chown(%s, %d): %s", path, mode, strerror(errno));
+ // Ensure /data/media/<userid> exists
+ create_persona_media_path(media_user_path, userid);
+ if (fs_prepare_dir(media_user_path, 0770, AID_MEDIA_RW, AID_MEDIA_RW) == -1) {
return -1;
}