Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4f7be172 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Andreas Gampe
Browse files

Fix casting bug, add control for hard quotas.

(cherry picked from commit bdd4de8a)

Bug: 64160395, 63255278
Test: /data/nativetest/installd_service_test/installd_cache_test
Merged-In: I8e2e24afd88da4dc13afdf05927e59c268e69825
Change-Id: I8e2e24afd88da4dc13afdf05927e59c268e69825
parent 3760ad3c
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -311,6 +311,7 @@ static int prepare_app_quota(const std::unique_ptr<std::string>& uuid, const std
        return -1;
        return -1;
    }
    }


#if APPLY_HARD_QUOTAS
    if ((dq.dqb_bhardlimit == 0) || (dq.dqb_ihardlimit == 0)) {
    if ((dq.dqb_bhardlimit == 0) || (dq.dqb_ihardlimit == 0)) {
        auto path = create_data_path(uuid ? uuid->c_str() : nullptr);
        auto path = create_data_path(uuid ? uuid->c_str() : nullptr);
        struct statvfs stat;
        struct statvfs stat;
@@ -335,6 +336,10 @@ static int prepare_app_quota(const std::unique_ptr<std::string>& uuid, const std
        // Hard quota already set; assume it's reasonable
        // Hard quota already set; assume it's reasonable
        return 0;
        return 0;
    }
    }
#else
    // Hard quotas disabled
    return 0;
#endif
}
}


binder::Status InstalldNativeService::createAppData(const std::unique_ptr<std::string>& uuid,
binder::Status InstalldNativeService::createAppData(const std::unique_ptr<std::string>& uuid,
+1 −1
Original line number Original line Diff line number Diff line
@@ -99,7 +99,7 @@ static int64_t size(const char* path) {
static int64_t free() {
static int64_t free() {
    struct statvfs buf;
    struct statvfs buf;
    if (!statvfs("/data/local/tmp", &buf)) {
    if (!statvfs("/data/local/tmp", &buf)) {
        return buf.f_bavail * buf.f_frsize;
        return static_cast<int64_t>(buf.f_bavail) * buf.f_frsize;
    } else {
    } else {
        PLOG(ERROR) << "Failed to statvfs";
        PLOG(ERROR) << "Failed to statvfs";
        return -1;
        return -1;
+1 −1
Original line number Original line Diff line number Diff line
@@ -656,7 +656,7 @@ int copy_dir_files(const char *srcname,
int64_t data_disk_free(const std::string& data_path) {
int64_t data_disk_free(const std::string& data_path) {
    struct statvfs sfs;
    struct statvfs sfs;
    if (statvfs(data_path.c_str(), &sfs) == 0) {
    if (statvfs(data_path.c_str(), &sfs) == 0) {
        return sfs.f_bavail * sfs.f_frsize;
        return static_cast<int64_t>(sfs.f_bavail) * sfs.f_frsize;
    } else {
    } else {
        PLOG(ERROR) << "Couldn't statvfs " << data_path;
        PLOG(ERROR) << "Couldn't statvfs " << data_path;
        return -1;
        return -1;
+2 −0
Original line number Original line Diff line number Diff line
@@ -36,6 +36,8 @@
#define BYPASS_QUOTA 0
#define BYPASS_QUOTA 0
#define BYPASS_SDCARDFS 0
#define BYPASS_SDCARDFS 0


#define APPLY_HARD_QUOTAS 1

namespace android {
namespace android {
namespace installd {
namespace installd {