diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp index 4b94f9c97..a2b80ad9f 100644 --- a/fs_mgr/fs_mgr.cpp +++ b/fs_mgr/fs_mgr.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -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; diff --git a/libcutils/include/private/android_filesystem_config.h b/libcutils/include/private/android_filesystem_config.h index 2ecf5bce6..2f2e26238 100644 --- a/libcutils/include/private/android_filesystem_config.h +++ b/libcutils/include/private/android_filesystem_config.h @@ -122,6 +122,7 @@ #define AID_AUTOMOTIVE_EVS 1062 /* Automotive rear and surround view system */ #define AID_LOWPAN 1063 /* LoWPAN subsystem */ #define AID_HSM 1064 /* hardware security module subsystem */ +#define AID_RESERVED_DISK 1065 /* GID that has access to reserved disk space */ /* Changes to this file must be made in AOSP, *not* in internal branches. */ #define AID_SHELL 2000 /* adb and debug shell user */ diff --git a/rootdir/init.zygote32.rc b/rootdir/init.zygote32.rc index d836c4ef7..ac87979ec 100644 --- a/rootdir/init.zygote32.rc +++ b/rootdir/init.zygote32.rc @@ -2,7 +2,7 @@ service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-sys class main priority -20 user root - group root readproc + group root readproc reserved_disk socket zygote stream 660 root system onrestart write /sys/android_power/request_state wake onrestart write /sys/power/state on diff --git a/rootdir/init.zygote32_64.rc b/rootdir/init.zygote32_64.rc index 80bb6730d..a535846de 100644 --- a/rootdir/init.zygote32_64.rc +++ b/rootdir/init.zygote32_64.rc @@ -2,7 +2,7 @@ service zygote /system/bin/app_process32 -Xzygote /system/bin --zygote --start-s class main priority -20 user root - group root readproc + group root readproc reserved_disk socket zygote stream 660 root system onrestart write /sys/android_power/request_state wake onrestart write /sys/power/state on @@ -17,7 +17,7 @@ service zygote_secondary /system/bin/app_process64 -Xzygote /system/bin --zygote class main priority -20 user root - group root readproc + group root readproc reserved_disk socket zygote_secondary stream 660 root system onrestart restart zygote writepid /dev/cpuset/foreground/tasks diff --git a/rootdir/init.zygote64.rc b/rootdir/init.zygote64.rc index 05ec16fc9..6fc810bfa 100644 --- a/rootdir/init.zygote64.rc +++ b/rootdir/init.zygote64.rc @@ -2,7 +2,7 @@ service zygote /system/bin/app_process64 -Xzygote /system/bin --zygote --start-s class main priority -20 user root - group root readproc + group root readproc reserved_disk socket zygote stream 660 root system onrestart write /sys/android_power/request_state wake onrestart write /sys/power/state on diff --git a/rootdir/init.zygote64_32.rc b/rootdir/init.zygote64_32.rc index 09db7b03d..7ddd52ee5 100644 --- a/rootdir/init.zygote64_32.rc +++ b/rootdir/init.zygote64_32.rc @@ -2,7 +2,7 @@ service zygote /system/bin/app_process64 -Xzygote /system/bin --zygote --start-s class main priority -20 user root - group root readproc + group root readproc reserved_disk socket zygote stream 660 root system onrestart write /sys/android_power/request_state wake onrestart write /sys/power/state on @@ -17,7 +17,7 @@ service zygote_secondary /system/bin/app_process32 -Xzygote /system/bin --zygote class main priority -20 user root - group root readproc + group root readproc reserved_disk socket zygote_secondary stream 660 root system onrestart restart zygote writepid /dev/cpuset/foreground/tasks