Delay mount of /proc & /sys to *after* emergency_shell()

In case we run into problems mounting /sys or /proc we should have
signals and the optional emergency shell available for recovery.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2020-04-26 14:55:38 +02:00
parent dc99d8637b
commit e3884597a5
+16 -15
View File
@@ -318,27 +318,13 @@ int main(int argc, char *argv[])
ctx = &loop;
/*
* Set PATH and SHELL early to something sane
* Set PATH, SHELL, PWD and umask early to something sane
*/
setenv("PATH", _PATH_STDPATH, 1);
setenv("SHELL", _PATH_BSHELL, 1);
/*
* Mount base file system, kernel is assumed to run devtmpfs for /dev
*/
chdir("/");
umask(0);
if (mount("none", "/proc", "proc", 0, NULL))
_pe("Failed mounting /proc");
if (mount("none", "/sys", "sysfs", 0, NULL))
_pe("Failed mounting /sysfs");
if (fisdir("/proc/bus/usb"))
mount("none", "/proc/bus/usb", "usbfs", 0, NULL);
/*
* Initialize default control groups, if available
*/
cgroup_init();
/*
* Parse kernel command line (debug, rescue, splash, etc.)
@@ -360,6 +346,21 @@ int main(int argc, char *argv[])
*/
sig_init();
/*
* Mount base file system
*/
if (mount("none", "/proc", "proc", 0, NULL))
_pe("Failed mounting /proc");
if (mount("none", "/sys", "sysfs", 0, NULL))
_pe("Failed mounting /sys");
if (fisdir("/proc/bus/usb"))
mount("none", "/proc/bus/usb", "usbfs", 0, NULL);
/*
* Initialize default control groups, if available
*/
cgroup_init();
/*
* Load plugins early, finit.conf may contain references to
* features implemented by plugins.