e.g.: don't mistake the /sys/block/mtdblock*/device symlinks
(which point to the /sys/class/mtd/mtd* character devices)
as being block devices in their own right.

This was `OK' until 2013-05-13 ("mdev: use $DEVNAME in uevent...",
c3cf1e30a3022453311a7e9fe11d94c7a381640e) because the prior behaviour
of always using basename() meant that all such symlinks lead to
"/dev/device"....

Signed-off-by: Joshua Judson Rosen <jro...@harvestai.com>
---
 util-linux/mdev.c |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index ca4b915..3c88213 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -559,6 +559,23 @@ static void make_device(char *device_name, char *path, int 
operation)
         * We also depend on path having writeable space after it.
         */
        major = -1;
+
+       if ((path_end - path) > 7 && strncmp((path_end - 7), "/device", 7) == 
0) {
+               /* Some wrapper-devices, e.g. /sys/block/mtdblock*, have
+                  a "device" symlink that points to the lower-level device--
+                  which either has already been handled separately,
+                  or will be handled separately.
+
+                  When symlink-traversal sends us down that rabbit-hole,
+                  avoid getting confused and thinking that it's actually
+                  a distinct device (e.g.: /sys/block/mtdblock1/device
+                  could trick us into thinking that /dev/mtd1 should be
+                  a block device when it shouldn't):
+                */
+
+               return;
+       }
+
        if (operation == OP_add) {
                strcpy(path_end, "/dev");
                len = open_read_close(path, path_end + 1, SCRATCH_SIZE - 1);
-- 
1.7.10.4

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to