diff options
Diffstat (limited to 'cmds')
| -rw-r--r-- | cmds/installd/Android.mk | 17 | ||||
| -rw-r--r-- | cmds/installd/commands.c | 50 |
2 files changed, 11 insertions, 56 deletions
diff --git a/cmds/installd/Android.mk b/cmds/installd/Android.mk index 6673862..8641c30 100644 --- a/cmds/installd/Android.mk +++ b/cmds/installd/Android.mk @@ -1,21 +1,24 @@ ifneq ($(TARGET_SIMULATOR),true) -LOCAL_PATH:= $(call my-dir) +LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) -LOCAL_SRC_FILES:= \ +LOCAL_SRC_FILES := \ installd.c commands.c utils.c -LOCAL_C_INCLUDES := \ - $(call include-path-for, system-core)/cutils +#LOCAL_C_INCLUDES := \ +# $(call include-path-for, system-core)/cutils LOCAL_SHARED_LIBRARIES := \ libcutils -LOCAL_STATIC_LIBRARIES := +LOCAL_STATIC_LIBRARIES := \ + libdiskusage -LOCAL_MODULE:= installd +LOCAL_MODULE := installd + +LOCAL_MODULE_TAGS := optional include $(BUILD_EXECUTABLE) -endif # !simulator)) +endif # !simulator diff --git a/cmds/installd/commands.c b/cmds/installd/commands.c index 2f03c7a..cde1573 100644 --- a/cmds/installd/commands.c +++ b/cmds/installd/commands.c @@ -15,6 +15,7 @@ */ #include "installd.h" +#include <diskusage/dirsize.h> int install(const char *pkgname, int encrypted_fs_flag, uid_t uid, gid_t gid) { @@ -327,55 +328,6 @@ int protect(char *pkgname, gid_t gid) return 0; } -static int64_t stat_size(struct stat *s) -{ - int64_t blksize = s->st_blksize; - int64_t size = s->st_size; - - if (blksize) { - /* round up to filesystem block size */ - size = (size + blksize - 1) & (~(blksize - 1)); - } - - return size; -} - -static int64_t calculate_dir_size(int dfd) -{ - int64_t size = 0; - struct stat s; - DIR *d; - struct dirent *de; - - d = fdopendir(dfd); - if (d == NULL) { - close(dfd); - return 0; - } - - 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; - } - subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY); - if (subfd >= 0) { - size += calculate_dir_size(subfd); - } - } else { - if (fstatat(dfd, name, &s, AT_SYMLINK_NOFOLLOW) == 0) { - size += stat_size(&s); - } - } - } - closedir(d); - return size; -} - int get_size(const char *pkgname, const char *apkpath, const char *fwdlock_apkpath, int64_t *_codesize, int64_t *_datasize, int64_t *_cachesize, int encrypted_fs_flag) |
