diff options
Diffstat (limited to 'cmds/installd/utils.c')
-rw-r--r-- | cmds/installd/utils.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/cmds/installd/utils.c b/cmds/installd/utils.c index 3099b8341f6e..a53a93ce1073 100644 --- a/cmds/installd/utils.c +++ b/cmds/installd/utils.c @@ -109,7 +109,7 @@ int create_persona_path(char path[PKG_PATH_MAX], uid_len = 0; } else { persona_prefix = SECONDARY_USER_PREFIX; - uid_len = snprintf(NULL, 0, "%d", persona); + uid_len = snprintf(NULL, 0, "%d/", persona); } char *dst = path; @@ -126,7 +126,7 @@ int create_persona_path(char path[PKG_PATH_MAX], LOGE("Error building user path"); return -1; } - int ret = snprintf(dst, dst_size, "%d", persona); + int ret = snprintf(dst, dst_size, "%d/", persona); if (ret < 0 || (size_t) ret != uid_len) { LOGE("Error appending persona id to path"); return -1; @@ -135,6 +135,20 @@ int create_persona_path(char path[PKG_PATH_MAX], return 0; } +int create_move_path(char path[PKG_PATH_MAX], + const char* pkgname, + const char* leaf, + uid_t persona) +{ + if ((android_data_dir.len + strlen(PRIMARY_USER_PREFIX) + strlen(pkgname) + strlen(leaf) + 1) + >= PKG_PATH_MAX) { + return -1; + } + + sprintf(path, "%s%s%s/%s", android_data_dir.path, PRIMARY_USER_PREFIX, pkgname, leaf); + return 0; +} + /** * Checks whether the package name is valid. Returns -1 on error and * 0 on success. |