From 4f7be17266046b255dd65ea1d9e244b34e37c3ec Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Fri, 11 Aug 2017 15:13:31 -0600 Subject: Fix casting bug, add control for hard quotas. (cherry picked from commit bdd4de8a98d57110befb0c29f662e8a3e4cfc275) Bug: 64160395, 63255278 Test: /data/nativetest/installd_service_test/installd_cache_test Merged-In: I8e2e24afd88da4dc13afdf05927e59c268e69825 Change-Id: I8e2e24afd88da4dc13afdf05927e59c268e69825 --- cmds/installd/InstalldNativeService.cpp | 5 +++++ cmds/installd/tests/installd_cache_test.cpp | 2 +- cmds/installd/utils.cpp | 2 +- cmds/installd/utils.h | 2 ++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp index c087713b15..4a93b1fd3d 100644 --- a/cmds/installd/InstalldNativeService.cpp +++ b/cmds/installd/InstalldNativeService.cpp @@ -311,6 +311,7 @@ static int prepare_app_quota(const std::unique_ptr& uuid, const std return -1; } +#if APPLY_HARD_QUOTAS if ((dq.dqb_bhardlimit == 0) || (dq.dqb_ihardlimit == 0)) { auto path = create_data_path(uuid ? uuid->c_str() : nullptr); struct statvfs stat; @@ -335,6 +336,10 @@ static int prepare_app_quota(const std::unique_ptr& uuid, const std // Hard quota already set; assume it's reasonable return 0; } +#else + // Hard quotas disabled + return 0; +#endif } binder::Status InstalldNativeService::createAppData(const std::unique_ptr& uuid, diff --git a/cmds/installd/tests/installd_cache_test.cpp b/cmds/installd/tests/installd_cache_test.cpp index aed068c390..2d58515b11 100644 --- a/cmds/installd/tests/installd_cache_test.cpp +++ b/cmds/installd/tests/installd_cache_test.cpp @@ -99,7 +99,7 @@ static int64_t size(const char* path) { static int64_t free() { struct statvfs buf; if (!statvfs("/data/local/tmp", &buf)) { - return buf.f_bavail * buf.f_frsize; + return static_cast(buf.f_bavail) * buf.f_frsize; } else { PLOG(ERROR) << "Failed to statvfs"; return -1; diff --git a/cmds/installd/utils.cpp b/cmds/installd/utils.cpp index 7fa356f762..462d004325 100644 --- a/cmds/installd/utils.cpp +++ b/cmds/installd/utils.cpp @@ -656,7 +656,7 @@ int copy_dir_files(const char *srcname, int64_t data_disk_free(const std::string& data_path) { struct statvfs sfs; if (statvfs(data_path.c_str(), &sfs) == 0) { - return sfs.f_bavail * sfs.f_frsize; + return static_cast(sfs.f_bavail) * sfs.f_frsize; } else { PLOG(ERROR) << "Couldn't statvfs " << data_path; return -1; diff --git a/cmds/installd/utils.h b/cmds/installd/utils.h index ac6a48808b..2a760d4623 100644 --- a/cmds/installd/utils.h +++ b/cmds/installd/utils.h @@ -36,6 +36,8 @@ #define BYPASS_QUOTA 0 #define BYPASS_SDCARDFS 0 +#define APPLY_HARD_QUOTAS 1 + namespace android { namespace installd { -- cgit v1.2.3-59-g8ed1b From e1d9b28ae57649a7568e35ea7832b94b2bb4827f Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Wed, 16 Aug 2017 17:12:33 -0700 Subject: Change log libraries in tests to be statically linked 32-bit versions of the log libraries aren't flashed on the phone, so we need to statically link them. (cherry picked from commit d438af0a09866cdeeb9f4c0f17543a23be513998) Test: build and run the 3 installd tests (32-bit and 64-bit) Test: on walleye/bullhead Merged-In: I06bea24c6c52ffdb34045449e0b40eb2ac146410 Change-Id: I06bea24c6c52ffdb34045449e0b40eb2ac146410 --- cmds/installd/tests/Android.bp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cmds/installd/tests/Android.bp b/cmds/installd/tests/Android.bp index c6ebb249d0..89c11aa160 100644 --- a/cmds/installd/tests/Android.bp +++ b/cmds/installd/tests/Android.bp @@ -6,13 +6,13 @@ cc_test { cflags: ["-Wall", "-Werror"], shared_libs: [ "libbase", - "liblog", "libutils", "libcutils", ], static_libs: [ - "libinstalld", "libdiskusage", + "libinstalld", + "liblog", ], } @@ -25,14 +25,14 @@ cc_test { "libbase", "libbinder", "libcutils", - "liblog", - "liblogwrap", "libselinux", "libutils", ], static_libs: [ - "libinstalld", "libdiskusage", + "libinstalld", + "liblog", + "liblogwrap", ], } @@ -45,13 +45,13 @@ cc_test { "libbase", "libbinder", "libcutils", - "liblog", - "liblogwrap", "libselinux", "libutils", ], static_libs: [ - "libinstalld", "libdiskusage", + "libinstalld", + "liblog", + "liblogwrap", ], } -- cgit v1.2.3-59-g8ed1b