summaryrefslogtreecommitdiffstats
path: root/init
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2015-04-25 15:50:03 -0700
committerNick Kralevich <nnk@google.com>2015-04-25 15:50:03 -0700
commit9dec93bfeb7a4c1ef49745f60f551e0b11a35b2d (patch)
tree606cfb5cb6abe6c34faffdaa13510589a2253152 /init
parent8929c77ab9aa9be612291809669e9162837c54ae (diff)
downloadsystem_core-9dec93bfeb7a4c1ef49745f60f551e0b11a35b2d.zip
system_core-9dec93bfeb7a4c1ef49745f60f551e0b11a35b2d.tar.gz
system_core-9dec93bfeb7a4c1ef49745f60f551e0b11a35b2d.tar.bz2
init: don't double mount /proc and /sys
The first stage init mounts /proc and /sys, and then the second stage init also mounts /proc and /sys on top of the existing mount. Only mount these two directories once, in the first stage init. Not yet fixed: the double mounting of /dev. Removing the double mounting doesn't work right now because both init stages are trying to create a property space, and if the double mount of /dev goes away, the property service in the second stage init fails to work. Change-Id: I13719027a47526d074390c2b1a605ad99fb43a8f
Diffstat (limited to 'init')
-rw-r--r--init/init.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/init/init.cpp b/init/init.cpp
index 377b89c..4e22ec6 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -983,14 +983,20 @@ int main(int argc, char** argv) {
add_environment("PATH", _PATH_DEFPATH);
+ bool is_first_stage = (argc == 1) || (strcmp(argv[1], "--second-stage") != 0);
+
// Get the basic filesystem setup we need put together in the initramdisk
// on / and then we'll let the rc file figure out the rest.
+ // TODO: avoid mounting tmpfs twice, once in the first stage, and once in the
+ // second stage.
mount("tmpfs", "/dev", "tmpfs", MS_NOSUID, "mode=0755");
mkdir("/dev/pts", 0755);
mkdir("/dev/socket", 0755);
mount("devpts", "/dev/pts", "devpts", 0, NULL);
- mount("proc", "/proc", "proc", 0, NULL);
- mount("sysfs", "/sys", "sysfs", 0, NULL);
+ if (is_first_stage) {
+ mount("proc", "/proc", "proc", 0, NULL);
+ mount("sysfs", "/sys", "sysfs", 0, NULL);
+ }
// Indicate that booting is in progress to background fw loaders, etc.
close(open("/dev/.booting", O_WRONLY | O_CREAT | O_CLOEXEC, 0000));
@@ -1003,7 +1009,6 @@ int main(int argc, char** argv) {
klog_init();
klog_set_level(KLOG_NOTICE_LEVEL);
- bool is_first_stage = (argc == 1) || (strcmp(argv[1], "--second-stage") != 0);
NOTICE("init%s started!\n", is_first_stage ? "" : " second stage");
property_init();