diff options
| author | 2012-02-03 12:04:40 -0800 | |
|---|---|---|
| committer | 2012-02-03 12:04:40 -0800 | |
| commit | 1ef7d13172248848805b9ceb6161b0741d8580dd (patch) | |
| tree | 5166ec77df9727efecbb2672774c99a072def65f /cmds/installd/commands.c | |
| parent | 2d315df64118da9b03cfa4f65a43850299084730 (diff) | |
| parent | 742a67127366c376fdf188ff99ba30b27d3bf90c (diff) | |
Merge "Multi-user - 1st major checkin"
Diffstat (limited to 'cmds/installd/commands.c')
| -rw-r--r-- | cmds/installd/commands.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/cmds/installd/commands.c b/cmds/installd/commands.c index dd92bbe499bc..203d180a6439 100644 --- a/cmds/installd/commands.c +++ b/cmds/installd/commands.c @@ -148,6 +148,48 @@ int delete_persona(uid_t persona) return delete_dir_contents(pkgdir, 1, NULL); } +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]; + DIR *d; + struct dirent *de; + struct stat s; + uid_t uid; + + if (create_persona_path(src_data_dir, src_persona)) { + return -1; + } + + d = opendir(src_data_dir); + if (d != NULL) { + while ((de = readdir(d))) { + const char *name = de->d_name; + + if (de->d_type == DT_DIR) { + int subfd; + /* always skip "." and ".." */ + if (name[0] == '.') { + if (name[1] == 0) continue; + if ((name[1] == '.') && (name[2] == 0)) continue; + } + /* Create the full path to the package's data dir */ + create_pkg_path(pkg_path, name, PKG_DIR_POSTFIX, src_persona); + /* Get the file stat */ + if (stat(pkg_path, &s) < 0) continue; + /* Get the uid of the package */ + ALOGI("Adding datadir for uid = %d\n", s.st_uid); + uid = (uid_t) s.st_uid % PER_USER_RANGE; + /* Create the directory for the target */ + make_user_data(name, uid + target_persona * PER_USER_RANGE, + target_persona); + } + } + closedir(d); + } + return 0; +} + int delete_cache(const char *pkgname) { char cachedir[PKG_PATH_MAX]; |