diff options
author | Yusuke Sato <yusukes@google.com> | 2015-07-31 23:13:15 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-07-31 23:13:15 +0000 |
commit | b5d6ad81cb963b6eceeb21c7f93bc433112c4b35 (patch) | |
tree | f99d32b83f9ebc8f311e18184bd44e8655c51b65 /init/builtins.cpp | |
parent | 0f91887868e51de67bdf9aedc97fbcb044dc1969 (diff) | |
parent | f93d42933bfdd351bbb0eda79ccb7194a40461d8 (diff) |
Merge "Stop calling fsck on shutdown by default"
Diffstat (limited to 'init/builtins.cpp')
-rw-r--r-- | init/builtins.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/init/builtins.cpp b/init/builtins.cpp index 4bc3b875e..df3cb0248 100644 --- a/init/builtins.cpp +++ b/init/builtins.cpp @@ -609,14 +609,13 @@ int do_powerctl(int nargs, char **args) { const char* command = args[1]; 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; 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; @@ -626,10 +625,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; } |