"mdev -s" fails to create /dev entries

Rob Landley rob at landley.net
Mon Jul 7 00:35:45 UTC 2008


On Sunday 06 July 2008 09:06:53 Vladimir Dronnikov wrote:
> In particular /sys/block/loop* are the symlinks and mdev -s ceased to
> mknod /dev/loop*.

Keep in mind that sysfs keeps changing.  It has no stable API.

In toybox, my callback from dirtree_read() is doing:

http://landley.net/hg/toybox/file/292/toys/mdev.c

static int callback(char *path, struct dirtree *node)
{
        // Entries in /sys/class/block aren't char devices, so skip 'em.  (We'll
        // get block devices out of /sys/block.)
        if(!strcmp(node->name, "block")) return 1;

        // Does this directory have a "dev" entry in it?
        if (S_ISDIR(node->st.st_mode) || S_ISLNK(node->st.st_mode)) {
                char *dest = path+strlen(path);
                strcpy(dest, "/dev");
                if (!access(path, R_OK)) make_device(path);
                *dest = 0;
        }

        // Circa 2.6.25 the entries more than 2 deep are all either redundant
        // (mouse#, event#) or unnamed (every usb_* entry is called "device").
        return node->depth>1;
}

So essentially it recurses into /sys/class/*/* (but no deeper), skips any
nodes named "block" (because /sys/class/block didn't used to exist,
so we can't rely on it being there and have to check /sys/block to find
block devices, but now it's a symlink to the same place as /sys/block
so if we _do_ find it it does not contain char devices).

I don't _think_ Greg KH and Kay Sievers are intentionally trying to
break every other user of sysfs.  It's probably just callous disregard
rather than intentional malice...  The "symlink vs non-symlink" thing
used to be a reliable and simple indicator of what was interesting.
And then they changed the kernel again.  They've broken mdev
something like 5 times since the first shell script version, by changing
sysfs to have a different (still undocumented) API...

Rob
-- 
"One of my most productive days was throwing away 1000 lines of code."
  - Ken Thompson.



More information about the busybox mailing list