X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;ds=sidebyside;f=helper%2Finit.c;h=0ca31354078087faecce7ac9beb883304430cb4b;hb=84ce1bc019392270456ce34372579bc777d21666;hp=8690f2258460d7c7475e65d810ff8f43aa3fc2bd;hpb=ef6f7db3e1ed2e0d09e02ac77be70848c221f3df;p=febootstrap.git diff --git a/helper/init.c b/helper/init.c index 8690f22..0ca3135 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) @@ -271,9 +291,9 @@ show_directory (const char *dirname) } while ((d = readdir (dir)) != NULL) { - fprintf (stderr, "%5d %c %-16s", d->d_ino, dirtype (d->d_type), d->d_name); + fprintf (stderr, "%5lu %c %-16s", d->d_ino, dirtype (d->d_type), d->d_name); if (lstat (d->d_name, &statbuf) >= 0) { - fprintf (stderr, " %06o %d %d:%d", + fprintf (stderr, " %06o %ld %d:%d", statbuf.st_mode, statbuf.st_size, statbuf.st_uid, statbuf.st_gid); if (S_ISLNK (statbuf.st_mode)) {