summaryrefslogtreecommitdiffstats
path: root/init
diff options
context:
space:
mode:
Diffstat (limited to 'init')
-rw-r--r--init/Android.mk2
-rw-r--r--init/builtins.c17
-rw-r--r--init/devices.c2
-rw-r--r--init/init.c4
-rw-r--r--init/init.h1
-rw-r--r--init/init_parser.c1
-rw-r--r--init/keywords.h2
-rw-r--r--init/property_service.c4
-rw-r--r--init/readme.txt10
9 files changed, 39 insertions, 4 deletions
diff --git a/init/Android.mk b/init/Android.mk
index 740d10f..15a23be 100644
--- a/init/Android.mk
+++ b/init/Android.mk
@@ -17,6 +17,8 @@ LOCAL_SRC_FILES:= \
ueventd_parser.c \
watchdogd.c
+LOCAL_CFLAGS += -Wno-unused-parameter
+
ifeq ($(strip $(INIT_BOOTCHART)),true)
LOCAL_SRC_FILES += bootchart.c
LOCAL_CFLAGS += -DBOOTCHART=1
diff --git a/init/builtins.c b/init/builtins.c
index e2932d5..d973a6b 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/devices.c b/init/devices.c
index 80c6d75..5d7ad3b 100644
--- a/init/devices.c
+++ b/init/devices.c
@@ -699,7 +699,7 @@ static void handle_generic_device_event(struct uevent *uevent)
static void handle_device_event(struct uevent *uevent)
{
- if (!strcmp(uevent->action,"add") || !strcmp(uevent->action, "change"))
+ if (!strcmp(uevent->action,"add") || !strcmp(uevent->action, "change") || !strcmp(uevent->action, "online"))
fixup_sys_perms(uevent->path);
if (!strncmp(uevent->subsystem, "block", 5)) {
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/property_service.c b/init/property_service.c
index fe7cbb5..7e8d79a 100644
--- a/init/property_service.c
+++ b/init/property_service.c
@@ -269,6 +269,7 @@ static void write_persistent_property(const char *name, const char *value)
return;
}
write(fd, value, strlen(value));
+ fsync(fd);
close(fd);
snprintf(path, sizeof(path), "%s/%s", PERSISTENT_PROPERTY_DIR, name);
@@ -556,7 +557,8 @@ static void load_persistent_properties()
|| (sb.st_gid != 0)
|| (sb.st_nlink != 1)) {
ERROR("skipping insecure property file %s (uid=%u gid=%u nlink=%d mode=%o)\n",
- entry->d_name, sb.st_uid, sb.st_gid, sb.st_nlink, sb.st_mode);
+ entry->d_name, (unsigned int)sb.st_uid, (unsigned int)sb.st_gid,
+ sb.st_nlink, sb.st_mode);
close(fd);
continue;
}
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>