summaryrefslogtreecommitdiffstats
path: root/cmds
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2012-09-23 17:46:53 -0700
committerDianne Hackborn <hackbod@google.com>2012-09-24 11:02:45 -0700
commit556b09e184b891d9542092962ed248616810e054 (patch)
tree8b924f113c33e48370dfd3d157edfd4a0b809533 /cmds
parent6b3292ce5b3908c7433503f64c852cf2b27718ed (diff)
downloadframeworks_base-556b09e184b891d9542092962ed248616810e054.zip
frameworks_base-556b09e184b891d9542092962ed248616810e054.tar.gz
frameworks_base-556b09e184b891d9542092962ed248616810e054.tar.bz2
Fix issue #6926562: Ensure all multi-user cache files are managed correctly
Now we correctly iterate through the different user cache dirs. Also update documentation to describe the new cache pruning behavior, and deprecate the file modes for making files world readable/writable which we really don't want people using any more. Change-Id: I3708df3ddc697b1f5c511143cce7cc40a5a3d0bd
Diffstat (limited to 'cmds')
-rw-r--r--cmds/installd/commands.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/cmds/installd/commands.c b/cmds/installd/commands.c
index 2934261..a9945b7 100644
--- a/cmds/installd/commands.c
+++ b/cmds/installd/commands.c
@@ -338,13 +338,32 @@ int free_cache(int64_t free_size)
closedir(d);
}
- // Collect cache files on external storage (if it is mounted as part
+ // Collect cache files on external storage for all users (if it is mounted as part
// of the internal storage).
strcpy(tmpdir, android_media_dir.path);
- if (lookup_media_dir(tmpdir, "Android") == 0
- && lookup_media_dir(tmpdir, "data") == 0) {
- //ALOGI("adding cache files from %s\n", tmpdir);
- add_cache_files(cache, tmpdir, "cache");
+ dirpos = tmpdir + strlen(tmpdir);
+ d = opendir(tmpdir);
+ if (d != NULL) {
+ while ((de = readdir(d))) {
+ if (de->d_type == DT_DIR) {
+ const char *name = de->d_name;
+ /* skip any dir that doesn't start with a number, so not a user */
+ if (name[0] < '0' || name[0] > '9') {
+ continue;
+ }
+ if ((strlen(name)+(dirpos-tmpdir)) < (sizeof(tmpdir)-1)) {
+ strcpy(dirpos, name);
+ if (lookup_media_dir(tmpdir, "Android") == 0
+ && lookup_media_dir(tmpdir, "data") == 0) {
+ //ALOGI("adding cache files from %s\n", tmpdir);
+ add_cache_files(cache, tmpdir, "cache");
+ }
+ } else {
+ ALOGW("Path exceeds limit: %s%s", tmpdir, name);
+ }
+ }
+ }
+ closedir(d);
}
clear_cache_files(cache, free_size);