init: initialize property area early at boot
The property service is still started later, but the property area
and the initial boot properties are initialized before the init.rc
file is processed. This allows init.rc files to have access to boot
properties during parsing.
Change-Id: Iae9ed1093c821831a864b39ae6bc697e62b94757
Signed-off-by: Dima Zavin <dima@android.com>
diff --git a/init/init.c b/init/init.c
index d10ca47..6aa9179 100755
--- a/init/init.c
+++ b/init/init.c
@@ -518,17 +518,6 @@
return ret;
}
-static int property_init_action(int nargs, char **args)
-{
- bool load_defaults = true;
-
- INFO("property init\n");
- if (!strcmp(bootmode, "charger"))
- load_defaults = false;
- property_init(load_defaults);
- return 0;
-}
-
static int keychord_init_action(int nargs, char **args)
{
keychord_init();
@@ -576,7 +565,7 @@
return 0;
}
-static int set_init_properties_action(int nargs, char **args)
+static int set_init_properties(void)
{
char tmp[PROP_VALUE_MAX];
@@ -668,6 +657,7 @@
int property_set_fd_init = 0;
int signal_fd_init = 0;
int keychord_fd_init = 0;
+ bool is_charger = false;
if (!strcmp(basename(argv[0]), "ueventd"))
return ueventd_main(argc, argv);
@@ -702,30 +692,34 @@
open_devnull_stdio();
klog_init();
- INFO("reading config file\n");
- init_parse_config_file("/init.rc");
-
- /* pull the kernel commandline and ramdisk properties file in */
- import_kernel_cmdline(0, import_kernel_nv);
/* don't expose the raw commandline to nonpriv processes */
chmod("/proc/cmdline", 0440);
+ /* pull the kernel commandline and ramdisk properties file in */
+ import_kernel_cmdline(0, import_kernel_nv);
get_hardware_name(hardware, &revision);
+
+ is_charger = !strcmp(bootmode, "charger");
+
+ INFO("property init\n");
+ property_init(!is_charger);
+ set_init_properties();
+
+ INFO("reading config file\n");
+ init_parse_config_file("/init.rc");
snprintf(tmp, sizeof(tmp), "/init.%s.rc", hardware);
init_parse_config_file(tmp);
action_for_each_trigger("early-init", action_add_queue_tail);
queue_builtin_action(wait_for_coldboot_done_action, "wait_for_coldboot_done");
- queue_builtin_action(property_init_action, "property_init");
queue_builtin_action(keychord_init_action, "keychord_init");
queue_builtin_action(console_init_action, "console_init");
- queue_builtin_action(set_init_properties_action, "set_init_properties");
/* execute all the boot actions to get us started */
action_for_each_trigger("init", action_add_queue_tail);
/* skip mounting filesystems in charger mode */
- if (strcmp(bootmode, "charger") != 0) {
+ if (!is_charger) {
action_for_each_trigger("early-fs", action_add_queue_tail);
action_for_each_trigger("fs", action_add_queue_tail);
action_for_each_trigger("post-fs", action_add_queue_tail);
@@ -736,7 +730,7 @@
queue_builtin_action(signal_init_action, "signal_init");
queue_builtin_action(check_startup_action, "check_startup");
- if (!strcmp(bootmode, "charger")) {
+ if (is_charger) {
action_for_each_trigger("charger", action_add_queue_tail);
} else {
action_for_each_trigger("early-boot", action_add_queue_tail);