diff options
author | JP Abgrall <jpa@google.com> | 2014-05-03 09:06:53 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-05-03 09:06:53 +0000 |
commit | d2e4281204da89a77c9c9743e5cf54a1c3e42a4a (patch) | |
tree | 6d48857746b18aac1661555d5f27ec29108f0950 /init | |
parent | 6988e0e87f58b635e5ab9a5539a538ce84bfa566 (diff) | |
parent | d96f05d2a7881dbb18fc86b765a67066560b7a1a (diff) | |
download | system_core-d2e4281204da89a77c9c9743e5cf54a1c3e42a4a.zip system_core-d2e4281204da89a77c9c9743e5cf54a1c3e42a4a.tar.gz system_core-d2e4281204da89a77c9c9743e5cf54a1c3e42a4a.tar.bz2 |
am d96f05d2: am a7bf5bd1: am 3c049bbe: Merge "init: add \'enable <service>\' to negate "service <service>... disabled""
* commit 'd96f05d2a7881dbb18fc86b765a67066560b7a1a':
init: add 'enable <service>' to negate "service <service>... disabled"
Diffstat (limited to 'init')
-rw-r--r-- | init/builtins.c | 17 | ||||
-rw-r--r-- | init/init.c | 4 | ||||
-rw-r--r-- | init/init.h | 1 | ||||
-rw-r--r-- | init/init_parser.c | 1 | ||||
-rw-r--r-- | init/keywords.h | 2 | ||||
-rw-r--r-- | init/readme.txt | 10 |
6 files changed, 33 insertions, 2 deletions
diff --git a/init/builtins.c b/init/builtins.c index a857c98..a9cd1bd 100644 --- a/init/builtins.c +++ b/init/builtins.c @@ -196,6 +196,8 @@ static void service_start_if_not_disabled(struct service *svc) { if (!(svc->flags & SVC_DISABLED)) { service_start(svc, NULL); + } else { + svc->flags |= SVC_DISABLED_START; } } @@ -238,6 +240,21 @@ int do_domainname(int nargs, char **args) return write_file("/proc/sys/kernel/domainname", args[1]); } +int do_enable(int nargs, char **args) +{ + struct service *svc; + svc = service_find_by_name(args[1]); + if (svc) { + svc->flags &= ~(SVC_DISABLED | SVC_RC_DISABLED); + if (svc->flags & SVC_DISABLED_START) { + service_start(svc, NULL); + } + } else { + return -1; + } + return 0; +} + int do_exec(int nargs, char **args) { return -1; diff --git a/init/init.c b/init/init.c index 0884236..fc20198 100644 --- a/init/init.c +++ b/init/init.c @@ -164,7 +164,7 @@ void service_start(struct service *svc, const char *dynamic_args) * state and immediately takes it out of the restarting * state if it was in there */ - svc->flags &= (~(SVC_DISABLED|SVC_RESTARTING|SVC_RESET|SVC_RESTART)); + svc->flags &= (~(SVC_DISABLED|SVC_RESTARTING|SVC_RESET|SVC_RESTART|SVC_DISABLED_START)); svc->time_started = 0; /* running processes require no additional work -- if @@ -364,7 +364,7 @@ static void service_stop_or_reset(struct service *svc, int how) { /* The service is still SVC_RUNNING until its process exits, but if it has * already exited it shoudn't attempt a restart yet. */ - svc->flags &= (~SVC_RESTARTING); + svc->flags &= ~(SVC_RESTARTING | SVC_DISABLED_START); if ((how != SVC_DISABLED) && (how != SVC_RESET) && (how != SVC_RESTART)) { /* Hrm, an illegal flag. Default to SVC_DISABLED */ diff --git a/init/init.h b/init/init.h index 736b75b..c241912 100644 --- a/init/init.h +++ b/init/init.h @@ -74,6 +74,7 @@ struct svcenvinfo { so it can be restarted with its class */ #define SVC_RC_DISABLED 0x80 /* Remember if the disabled flag was set in the rc script */ #define SVC_RESTART 0x100 /* Use to safely restart (stop, wait, start) a service */ +#define SVC_DISABLED_START 0x200 /* a start was requested but it was disabled at the time */ #define NR_SVC_SUPP_GIDS 12 /* twelve supplementary groups */ diff --git a/init/init_parser.c b/init/init_parser.c index f49e698..02e5bdc 100644 --- a/init/init_parser.c +++ b/init/init_parser.c @@ -98,6 +98,7 @@ static int lookup_keyword(const char *s) if (!strcmp(s, "omainname")) return K_domainname; break; case 'e': + if (!strcmp(s, "nable")) return K_enable; if (!strcmp(s, "xec")) return K_exec; if (!strcmp(s, "xport")) return K_export; break; diff --git a/init/keywords.h b/init/keywords.h index 97fe50c..6625330 100644 --- a/init/keywords.h +++ b/init/keywords.h @@ -6,6 +6,7 @@ int do_class_start(int nargs, char **args); int do_class_stop(int nargs, char **args); int do_class_reset(int nargs, char **args); int do_domainname(int nargs, char **args); +int do_enable(int nargs, char **args); int do_exec(int nargs, char **args); int do_export(int nargs, char **args); int do_hostname(int nargs, char **args); @@ -55,6 +56,7 @@ enum { KEYWORD(critical, OPTION, 0, 0) KEYWORD(disabled, OPTION, 0, 0) KEYWORD(domainname, COMMAND, 1, do_domainname) + KEYWORD(enable, COMMAND, 1, do_enable) KEYWORD(exec, COMMAND, 1, do_exec) KEYWORD(export, COMMAND, 2, do_export) KEYWORD(group, OPTION, 0, 0) diff --git a/init/readme.txt b/init/readme.txt index 42a09cb..613a9e9 100644 --- a/init/readme.txt +++ b/init/readme.txt @@ -178,6 +178,16 @@ class_stop <serviceclass> domainname <name> Set the domain name. +enable <servicename> + Turns a disabled service into an enabled one as if the service did not + specify disabled. + If the service is supposed to be running, it will be started now. + Typically used when the bootloader sets a variable that indicates a specific + service should be started when needed. E.g. + on property:ro.boot.myfancyhardware=1 + enable my_fancy_service_for_my_fancy_hardware + + insmod <path> Install the module at <path> |