[klibc] do_mounts new sysfs support?

Aaron Griffin aaronmgriffin at gmail.com
Mon Mar 20 11:04:49 PST 2006

Looking at do_mounts.c, it does not seem to support the "major:minor"
syntax exported in 'newer' sysfs (according to linux- 
The following is untested, but might work nicely... I will fully test
this when I get home later today.  PS, I also added some error output
when it fails to parse the device number, just for kicks.

As I said, I can't test this, so feel free to kick me if this doesn't
work as expected.

On a side note, would it be possible to pull the do_mounts device node
creation out into an external tool, ala fstype/ipconfig/nfsmount (I
named it 'mkrootdev' here), so that the device node can be created
before passing control to kinit?  The reason I ask is that I need to
call fstype and load the proper fs module before passing control.

Again, thanks for klibc!

--- usr/kinit/do_mounts.c   2006-03-13 01:14:12.000000000 -0600
+++ usr/kinit/do_mounts.c   2006-03-20 11:32:12.000000000 -0600
@@ -43,6 +43,13 @@
        goto fail;
    buf[len - 1] = '\0';
    res = (dev_t) strtoul(buf, &s, 16);
+    if (*s == ':')
+    {
+        dev_t maj, min;
+        maj = (int)res;
+        min = (dev_t) strtoul(s+1, &s, 16);
+        res = (dev_t) (maj<<8|min);
+    }
    if (*s)
        goto fail;

@@ -152,6 +161,7 @@
    return res;

+    fprintf(stderr,"Failed to parse device number for \"%s\"",name);
    return (dev_t)0;

More information about the klibc mailing list