Skip to content

Commit

Permalink
installd: Delete cache properly for devices using datadata partition
Browse files Browse the repository at this point in the history
The java side already checks /data/data for free space but installd
still checks /data causing it to never reap the cache (because it
thinks that enough free space is available.)

Change-Id: I191f3ceb84df1101ab2918ec0038213d72ec1ce2
  • Loading branch information
pawitp authored and Faryaab committed Apr 8, 2012
1 parent 40e3927 commit 333dc24
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cmds/installd/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

/* Directory records that are used in execution of commands. */
dir_rec_t android_data_dir;
dir_rec_t android_datadata_dir;
dir_rec_t android_asec_dir;
dir_rec_t android_app_dir;
dir_rec_t android_app_private_dir;
Expand Down Expand Up @@ -162,7 +163,11 @@ int delete_cache(const char *pkgname)
static int64_t disk_free()
{
struct statfs sfs;
if (statfs(android_data_dir.path, &sfs) == 0) {
/* Scanning /data/data because on some devices, it's on a different partition
* and scanning /data will yield the incorrect result. (This function is only
* used for freeing space on /data/data so it is okay to be more specific.)
*/
if (statfs(android_datadata_dir.path, &sfs) == 0) {
return sfs.f_bavail * sfs.f_bsize;
} else {
LOGE("Couldn't statfs %s: %s\n", android_data_dir.path, strerror(errno));
Expand Down
5 changes: 5 additions & 0 deletions cmds/installd/installd.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ int initialize_globals() {
return -1;
}

// Get the android datadata directory.
if (copy_and_append(&android_datadata_dir, &android_data_dir, DATA_SUBDIR) < 0) {
return -1;
}

// Get the android app directory.
if (copy_and_append(&android_app_dir, &android_data_dir, APP_SUBDIR) < 0) {
return -1;
Expand Down
2 changes: 2 additions & 0 deletions cmds/installd/installd.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@

#define CACHE_DIR_POSTFIX "/cache"

#define DATA_SUBDIR "data/" // sub-directory under ANDROID_DATA
#define APP_SUBDIR "app/" // sub-directory under ANDROID_DATA

/* other handy constants */
Expand Down Expand Up @@ -87,6 +88,7 @@ typedef struct {
extern dir_rec_t android_app_dir;
extern dir_rec_t android_app_private_dir;
extern dir_rec_t android_data_dir;
extern dir_rec_t android_datadata_dir;
extern dir_rec_t android_asec_dir;
extern dir_rec_array_t android_system_dirs;

Expand Down

0 comments on commit 333dc24

Please sign in to comment.