summaryrefslogtreecommitdiffstats
path: root/cmds
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2010-11-30 13:49:32 -0800
committerKenny Root <kroot@google.com>2010-11-30 16:51:13 -0800
commit33b2264ea9ab0f1980c49698729a0ab3c51d07fe (patch)
tree0c30e474c5ddb66c8bc0bcdc44126447f26afd92 /cmds
parent0b44476a23660baabc1984c2fa8ee2c0c114460b (diff)
downloadframeworks_base-33b2264ea9ab0f1980c49698729a0ab3c51d07fe.zip
frameworks_base-33b2264ea9ab0f1980c49698729a0ab3c51d07fe.tar.gz
frameworks_base-33b2264ea9ab0f1980c49698729a0ab3c51d07fe.tar.bz2
Move disk usage utilities to its own library
Disk usage calculation will happen in more places now, so move the installd calculation utilities out to its own library that only gets built for the target. Change-Id: Idceb6bd663ca6ab3d38fa00e57ee74a25b784855
Diffstat (limited to 'cmds')
-rw-r--r--cmds/installd/Android.mk17
-rw-r--r--cmds/installd/commands.c50
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)