Merge changes from topic "resgidz"

* changes:
  Add reserved disk GID to critical component.
  Set reserved GID when setting reserved blocks.
  Allocate GID to use reserved disk space.
This commit is contained in:
Jeff Sharkey 2018-01-08 18:17:50 +00:00 committed by Gerrit Code Review
commit a7004e5fed
6 changed files with 14 additions and 11 deletions

View file

@ -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;

View file

@ -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 */

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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