diff options
author | Kenny Root <kroot@google.com> | 2010-09-07 15:42:02 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-09-07 15:42:02 -0700 |
commit | 000ef46f5b0f84d08342711b00e8de560ea504af (patch) | |
tree | a7e5ee672671d91b5c339a99200f9749f8c8efd8 /cmds | |
parent | c50a4f374adbdfe75621928fb3eb3583e4ff4e77 (diff) | |
parent | 254293782a94652fd601d6b3f04ad447c072f714 (diff) | |
download | frameworks_base-000ef46f5b0f84d08342711b00e8de560ea504af.zip frameworks_base-000ef46f5b0f84d08342711b00e8de560ea504af.tar.gz frameworks_base-000ef46f5b0f84d08342711b00e8de560ea504af.tar.bz2 |
am 25429378: Merge "Allow installd to handle large partitions" into gingerbread
Merge commit '254293782a94652fd601d6b3f04ad447c072f714' into gingerbread-plus-aosp
* commit '254293782a94652fd601d6b3f04ad447c072f714':
Allow installd to handle large partitions
Diffstat (limited to 'cmds')
-rw-r--r-- | cmds/installd/commands.c | 28 | ||||
-rw-r--r-- | cmds/installd/installd.c | 14 | ||||
-rw-r--r-- | cmds/installd/installd.h | 6 |
3 files changed, 27 insertions, 21 deletions
diff --git a/cmds/installd/commands.c b/cmds/installd/commands.c index 2e87394..f6f80d1 100644 --- a/cmds/installd/commands.c +++ b/cmds/installd/commands.c @@ -136,7 +136,7 @@ int delete_cache(const char *pkgname, int encrypted_fs_flag) /* TODO(oam): depending on use case (ecryptfs or dmcrypt) * change implementation */ -static int disk_free() +static int64_t disk_free() { struct statfs sfs; if (statfs(PKG_DIR_PREFIX, &sfs) == 0) { @@ -154,18 +154,18 @@ static int disk_free() * also require that apps constantly modify file metadata even * when just reading from the cache, which is pretty awful. */ -int free_cache(int free_size) +int free_cache(int64_t free_size) { const char *name; int dfd, subfd; DIR *d; struct dirent *de; - int avail; + int64_t avail; avail = disk_free(); if (avail < 0) return -1; - LOGI("free_cache(%d) avail %d\n", free_size, avail); + LOGI("free_cache(%" PRId64 ") avail %" PRId64 "\n", free_size, avail); if (avail >= free_size) return 0; /* First try encrypted dir */ @@ -327,10 +327,10 @@ int protect(char *pkgname, gid_t gid) return 0; } -static int stat_size(struct stat *s) +static int64_t stat_size(struct stat *s) { - int blksize = s->st_blksize; - int size = s->st_size; + int64_t blksize = s->st_blksize; + int64_t size = s->st_size; if (blksize) { /* round up to filesystem block size */ @@ -340,9 +340,9 @@ static int stat_size(struct stat *s) return size; } -static int calculate_dir_size(int dfd) +static int64_t calculate_dir_size(int dfd) { - int size = 0; + int64_t size = 0; struct stat s; DIR *d; struct dirent *de; @@ -378,7 +378,7 @@ static int calculate_dir_size(int dfd) int get_size(const char *pkgname, const char *apkpath, const char *fwdlock_apkpath, - int *_codesize, int *_datasize, int *_cachesize, int encrypted_fs_flag) + int64_t *_codesize, int64_t *_datasize, int64_t *_cachesize, int encrypted_fs_flag) { DIR *d; int dfd; @@ -386,9 +386,9 @@ int get_size(const char *pkgname, const char *apkpath, struct stat s; char path[PKG_PATH_MAX]; - int codesize = 0; - int datasize = 0; - int cachesize = 0; + int64_t codesize = 0; + int64_t datasize = 0; + int64_t cachesize = 0; /* count the source apk as code -- but only if it's not * on the /system partition and its not on the sdcard. @@ -445,7 +445,7 @@ int get_size(const char *pkgname, const char *apkpath, } subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY); if (subfd >= 0) { - int size = calculate_dir_size(subfd); + int64_t size = calculate_dir_size(subfd); if (!strcmp(name,"lib")) { codesize += size; } else if(!strcmp(name,"cache")) { diff --git a/cmds/installd/installd.c b/cmds/installd/installd.c index 882c493..c991845 100644 --- a/cmds/installd/installd.c +++ b/cmds/installd/installd.c @@ -60,7 +60,7 @@ static int do_rename(char **arg, char reply[REPLY_MAX]) static int do_free_cache(char **arg, char reply[REPLY_MAX]) /* TODO int:free_size */ { - return free_cache(atoi(arg[0])); /* free_size */ + return free_cache((int64_t)atoll(arg[0])); /* free_size */ } static int do_rm_cache(char **arg, char reply[REPLY_MAX]) @@ -75,15 +75,19 @@ static int do_protect(char **arg, char reply[REPLY_MAX]) static int do_get_size(char **arg, char reply[REPLY_MAX]) { - int codesize = 0; - int datasize = 0; - int cachesize = 0; + int64_t codesize = 0; + int64_t datasize = 0; + int64_t cachesize = 0; int res = 0; /* pkgdir, apkpath */ res = get_size(arg[0], arg[1], arg[2], &codesize, &datasize, &cachesize, atoi(arg[3])); - sprintf(reply,"%d %d %d", codesize, datasize, cachesize); + /* + * Each int64_t can take up 22 characters printed out. Make sure it + * doesn't go over REPLY_MAX in the future. + */ + snprintf(reply, REPLY_MAX, "%" PRId64 " %" PRId64 " %" PRId64, codesize, datasize, cachesize); return res; } diff --git a/cmds/installd/installd.h b/cmds/installd/installd.h index 8e4adb1..479e4b2 100644 --- a/cmds/installd/installd.h +++ b/cmds/installd/installd.h @@ -19,6 +19,8 @@ #include <stdio.h> #include <stdlib.h> +#include <stdint.h> +#include <inttypes.h> #include <sys/stat.h> #include <dirent.h> #include <unistd.h> @@ -105,7 +107,7 @@ int move_dex(const char *src, const char *dst); int rm_dex(const char *path); int protect(char *pkgname, gid_t gid); int get_size(const char *pkgname, const char *apkpath, const char *fwdlock_apkpath, - int *codesize, int *datasize, int *cachesize, int encrypted_fs_flag); -int free_cache(int free_size); + int64_t *codesize, int64_t *datasize, int64_t *cachesize, int encrypted_fs_flag); +int free_cache(int64_t free_size); int dexopt(const char *apk_path, uid_t uid, int is_public); int movefiles(); |