From a76baaabe56b98e23861e89722bd1425f92dbc2c Mon Sep 17 00:00:00 2001 From: Ken Sumrall Date: Tue, 9 Jul 2013 18:42:09 -0700 Subject: [PATCH] Add swapon_all to init's builtin commands For enabling swap devices found in the fstab file Change-Id: Iec4fd4d208df3d7a161a90d95f8606e8b516334a --- init/builtins.c | 12 ++++++++++++ init/init_parser.c | 1 + init/keywords.h | 2 ++ 3 files changed, 15 insertions(+) diff --git a/init/builtins.c b/init/builtins.c index 6e37d0867..bfc0ddb15 100644 --- a/init/builtins.c +++ b/init/builtins.c @@ -516,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; diff --git a/init/init_parser.c b/init/init_parser.c index 28bf30c14..776c699aa 100644 --- a/init/init_parser.c +++ b/init/init_parser.c @@ -151,6 +151,7 @@ int lookup_keyword(const char *s) if (!strcmp(s, "ocket")) return K_socket; if (!strcmp(s, "tart")) return K_start; if (!strcmp(s, "top")) return K_stop; + if (!strcmp(s, "wapon_all")) return K_swapon_all; if (!strcmp(s, "ymlink")) return K_symlink; if (!strcmp(s, "ysclktz")) return K_sysclktz; break; diff --git a/init/keywords.h b/init/keywords.h index f14750647..5a44df356 100644 --- a/init/keywords.h +++ b/init/keywords.h @@ -27,6 +27,7 @@ int do_setrlimit(int nargs, char **args); int do_setsebool(int nargs, char **args); int do_start(int nargs, char **args); int do_stop(int nargs, char **args); +int do_swapon_all(int nargs, char **args); int do_trigger(int nargs, char **args); int do_symlink(int nargs, char **args); int do_sysclktz(int nargs, char **args); @@ -84,6 +85,7 @@ enum { KEYWORD(socket, OPTION, 0, 0) KEYWORD(start, COMMAND, 1, do_start) KEYWORD(stop, COMMAND, 1, do_stop) + KEYWORD(swapon_all, COMMAND, 1, do_swapon_all) KEYWORD(trigger, COMMAND, 1, do_trigger) KEYWORD(symlink, COMMAND, 1, do_symlink) KEYWORD(sysclktz, COMMAND, 1, do_sysclktz)