summaryrefslogtreecommitdiff
path: root/init/builtins.cpp
diff options
context:
space:
mode:
authorYusuke Sato <yusukes@google.com>2015-07-21 15:50:59 -0700
committerYusuke Sato <yusukes@google.com>2015-07-21 17:45:01 -0700
commitf93d42933bfdd351bbb0eda79ccb7194a40461d8 (patch)
tree8e9df088e1b8811dcf3cb97e741fede791bfc08a /init/builtins.cpp
parent5208d5512920d77c89726cdad5df0ca27966d0c2 (diff)
Stop calling fsck on shutdown by default
Instead, run the command only when sys.powerctl is set to "shutdown,userrequested". This way, we can avoid running fsck when shutdown is triggered due to a low power state. This is a follow-up CL for http://r.android.com/158525. Bug: 21853106 Change-Id: Ie57c23cd25162cc2a8726f876a9ba212080105fb
Diffstat (limited to 'init/builtins.cpp')
-rw-r--r--init/builtins.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/init/builtins.cpp b/init/builtins.cpp
index d5d3faff6..b079dfbfa 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -623,8 +623,8 @@ int do_powerctl(int nargs, char **args)
char command[PROP_VALUE_MAX];
int res;
int len = 0;
- int cmd = 0;
- const char *reboot_target;
+ unsigned int cmd = 0;
+ const char *reboot_target = "";
void (*callback_on_ro_remount)(const struct mntent*) = NULL;
res = expand_props(command, args[1], sizeof(command));
@@ -636,7 +636,6 @@ int do_powerctl(int nargs, char **args)
if (strncmp(command, "shutdown", 8) == 0) {
cmd = ANDROID_RB_POWEROFF;
len = 8;
- callback_on_ro_remount = unmount_and_fsck;
} else if (strncmp(command, "reboot", 6) == 0) {
cmd = ANDROID_RB_RESTART2;
len = 6;
@@ -646,10 +645,15 @@ int do_powerctl(int nargs, char **args)
}
if (command[len] == ',') {
- reboot_target = &command[len + 1];
- } else if (command[len] == '\0') {
- reboot_target = "";
- } else {
+ if (cmd == ANDROID_RB_POWEROFF &&
+ !strcmp(&command[len + 1], "userrequested")) {
+ // The shutdown reason is PowerManager.SHUTDOWN_USER_REQUESTED.
+ // Run fsck once the file system is remounted in read-only mode.
+ callback_on_ro_remount = unmount_and_fsck;
+ } else if (cmd == ANDROID_RB_RESTART2) {
+ reboot_target = &command[len + 1];
+ }
+ } else if (command[len] != '\0') {
ERROR("powerctl: unrecognized reboot target '%s'\n", &command[len]);
return -EINVAL;
}