summaryrefslogtreecommitdiffstats
path: root/init/builtins.c
diff options
context:
space:
mode:
Diffstat (limited to 'init/builtins.c')
-rw-r--r--init/builtins.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/init/builtins.c b/init/builtins.c
index 576f0d9..bfc0ddb 100644
--- a/init/builtins.c
+++ b/init/builtins.c
@@ -32,6 +32,7 @@
#include <sys/wait.h>
#include <linux/loop.h>
#include <cutils/partition_utils.h>
+#include <cutils/android_reboot.h>
#include <sys/system_properties.h>
#include <fs_mgr.h>
@@ -515,6 +516,18 @@ int do_mount_all(int nargs, char **args)
return ret;
}
+int do_swapon_all(int nargs, char **args)
+{
+ struct fstab *fstab;
+ int ret;
+
+ fstab = fs_mgr_read_fstab(args[1]);
+ ret = fs_mgr_swapon_all(fstab);
+ fs_mgr_free_fstab(fstab);
+
+ return ret;
+}
+
int do_setcon(int nargs, char **args) {
if (is_selinux_enabled() <= 0)
return 0;
@@ -598,6 +611,43 @@ int do_restart(int nargs, char **args)
return 0;
}
+int do_powerctl(int nargs, char **args)
+{
+ char command[PROP_VALUE_MAX];
+ int res;
+ int len = 0;
+ int cmd = 0;
+ char *reboot_target;
+
+ res = expand_props(command, args[1], sizeof(command));
+ if (res) {
+ ERROR("powerctl: cannot expand '%s'\n", args[1]);
+ return -EINVAL;
+ }
+
+ if (strncmp(command, "shutdown", 8) == 0) {
+ cmd = ANDROID_RB_POWEROFF;
+ len = 8;
+ } else if (strncmp(command, "reboot", 6) == 0) {
+ cmd = ANDROID_RB_RESTART2;
+ len = 6;
+ } else {
+ ERROR("powerctl: unrecognized command '%s'\n", command);
+ return -EINVAL;
+ }
+
+ if (command[len] == ',') {
+ reboot_target = &command[len + 1];
+ } else if (command[len] == '\0') {
+ reboot_target = "";
+ } else {
+ ERROR("powerctl: unrecognized reboot target '%s'\n", &command[len]);
+ return -EINVAL;
+ }
+
+ return android_reboot(cmd, 0, reboot_target);
+}
+
int do_trigger(int nargs, char **args)
{
action_for_each_trigger(args[1], action_add_queue_tail);