summaryrefslogtreecommitdiffstats
path: root/helper
diff options
context:
space:
mode:
authorHilko Bengen <bengen@hilluzination.de>2011-06-01 00:43:12 +0200
committerRichard W.M. Jones <rjones@redhat.com>2011-06-01 10:35:07 +0100
commit1c014ec078bf7b435957774bbb0e1812880d731f (patch)
tree75ee6c4035b49b4a925bb6097f0d4f3a8746bcce /helper
parentef6f7db3e1ed2e0d09e02ac77be70848c221f3df (diff)
downloadfebootstrap-1c014ec078bf7b435957774bbb0e1812880d731f.tar.gz
febootstrap-1c014ec078bf7b435957774bbb0e1812880d731f.tar.xz
febootstrap-1c014ec078bf7b435957774bbb0e1812880d731f.zip
febootstrap/helper/init: Mount /proc if not already present.
Diffstat (limited to 'helper')
-rw-r--r--helper/init.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/helper/init.c b/helper/init.c
index 8690f22..514146f 100644
--- a/helper/init.c
+++ b/helper/init.c
@@ -45,6 +45,7 @@ extern long init_module (void *, unsigned long, const char *);
*/
#define verbose 1
+static void mount_proc (void);
static void print_uptime (void);
static void insmod (const char *filename);
static void show_directory (const char *dir);
@@ -54,6 +55,8 @@ static char line[1024];
int
main ()
{
+ mount_proc ();
+
print_uptime ();
fprintf (stderr, "febootstrap: ext2 mini initrd starting up\n");
@@ -214,6 +217,23 @@ insmod (const char *filename)
}
}
+/* Mount /proc unless it's mounted already. */
+static void
+mount_proc (void)
+{
+ if (access ("/proc/uptime", R_OK) == -1) {
+ mkdir ("/proc", 0755);
+
+ if (verbose)
+ fprintf (stderr, "febootstrap: mounting /proc\n");
+
+ if (mount ("proc", "/proc", "proc", 0, "") == -1) {
+ perror ("mount: /proc");
+ /* Non-fatal. */
+ }
+ }
+}
+
/* Print contents of /proc/uptime. */
static void
print_uptime (void)