>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*.
To what exactly do these symlinks point? I have no access to a kernel later than 2.6.24. > >Keep in mind that sysfs keeps changing. It has no stable API. >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). >...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... That is when you stay within /sys/class or /sys/block. Operating on the whole of /sys and following non-symlinks only will and does find all dev files reliably (don't know about the above mentioned loop devices). There is one assumption: a node name and respective dev file contents are distinct for all non-symlink paths within /sys. Being that sysfs continually evolves and imho busybox should work on many kernels, I have proposed and submitted a patch for mdev that evades the sysfs/kernel version specific problem. For convenience, I have attached the patch to this post. ___________________________________________ Cellent Finance Solutions AG Firmensitz: Calwer Straße 33, 70173 Stuttgart Registergericht: Amtsgericht Stuttgart, HRB 720743 Vorstand: Thomas Wild Vorsitzender des Aufsichtsrats: Rudolf Zipf
Index: util-linux/mdev.c =================================================================== --- util-linux/mdev.c (revision 22793) +++ util-linux/mdev.c (working copy) @@ -19,9 +19,6 @@ #define root_major (G.root_major) #define root_minor (G.root_minor) -/* Prevent infinite loops in /sys symlinks */ -#define MAX_SYSFS_DEPTH 3 - /* We use additional 64+ bytes in make_device() */ #define SCRATCH_SIZE 80 @@ -75,11 +72,10 @@ * "/sys/block/..." is for block devices. "/sys/bus" etc is not! * Since kernel 2.6.25 block devices are also in /sys/class/block. */ /* TODO: would it be acceptable to just use strstr(path, "/block/")? */ - if (strncmp(&path[5], "class/block/"+6, 6) != 0 - && strncmp(&path[5], "class/block/", 12) != 0) - type = S_IFCHR; - else - type = S_IFBLK; + if (NULL == strstr(&path[4], "/block/")) + type = S_IFCHR; + else + type = S_IFBLK; if (ENABLE_FEATURE_MDEV_CONF) { FILE *fp; @@ -319,15 +315,6 @@ return TRUE; } -/* Directory callback for /sys/ traversal */ -static int FAST_FUNC dirAction(const char *fileName UNUSED_PARAM, - struct stat *statbuf UNUSED_PARAM, - void *userData UNUSED_PARAM, - int depth) -{ - return (depth >= MAX_SYSFS_DEPTH ? SKIP : TRUE); -} - /* For the full gory details, see linux/Documentation/firmware_class/README * * Firmware loading works like this: @@ -420,17 +407,8 @@ root_major = major(st.st_dev); root_minor = minor(st.st_dev); - /* ACTION_FOLLOWLINKS is needed since in newer kernels - * /sys/block/loop* (for example) are symlinks to dirs, - * not real directories. - * (kernel's CONFIG_SYSFS_DEPRECATED makes them real dirs, - * but we can't enforce that on users) */ - recursive_action("/sys/block", - ACTION_RECURSE | ACTION_FOLLOWLINKS, - fileAction, dirAction, temp, 0); - recursive_action("/sys/class", - ACTION_RECURSE | ACTION_FOLLOWLINKS, - fileAction, dirAction, temp, 0); + recursive_action("/sys", ACTION_RECURSE + fileAction, NULL, temp, 0); } else { /* Hotplug: * env ACTION=... DEVPATH=... mdev
_______________________________________________ busybox mailing list busybox@busybox.net http://busybox.net/cgi-bin/mailman/listinfo/busybox