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

Commit 47dc236d authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Set reserved GID when setting reserved blocks.

If we're setting up the number of reserved blocks, we also want to
set our new AID_DISK_RESERVED as the GID that's allowed to use those
blocks.

Test: builds, boots
Bug: 62024591
Change-Id: Iaabfa7d63ad9ff0b9732e2b9996937607d622fe2
parent 354417a7
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@
#include <android-base/properties.h>
#include <android-base/stringprintf.h>
#include <android-base/unique_fd.h>
#include <cutils/android_filesystem_config.h>
#include <cutils/android_reboot.h>
#include <cutils/partition_utils.h>
#include <cutils/properties.h>
@@ -353,7 +354,7 @@ static void tune_reserved_size(const char* blk_device, const struct fstab_rec* r
        reserved_blocks = max_reserved_blocks;
    }

    if (ext4_r_blocks_count(sb) == reserved_blocks) {
    if ((ext4_r_blocks_count(sb) == reserved_blocks) && (sb->s_def_resgid == AID_RESERVED_DISK)) {
        return;
    }

@@ -363,11 +364,12 @@ static void tune_reserved_size(const char* blk_device, const struct fstab_rec* r
        return;
    }

    char buf[32];
    const char* argv[] = {TUNE2FS_BIN, "-r", buf, blk_device};

    snprintf(buf, sizeof(buf), "%" PRIu64, reserved_blocks);
    LINFO << "Setting reserved block count on " << blk_device << " to " << reserved_blocks;

    auto reserved_blocks_str = std::to_string(reserved_blocks);
    auto reserved_gid_str = std::to_string(AID_RESERVED_DISK);
    const char* argv[] = {
        TUNE2FS_BIN, "-r", reserved_blocks_str.c_str(), "-g", reserved_gid_str.c_str(), blk_device};
    if (!run_tune2fs(argv, ARRAY_SIZE(argv))) {
        LERROR << "Failed to run " TUNE2FS_BIN " to set the number of reserved blocks on "
               << blk_device;