516530c932bd17d87c9eb4347a490be051e495f4 uses $DEVNAME variable for device node name. This is fine, but only works for hotplugging, "mdev -s" will behave differently when DEVNAME and basename(path) differ.
This patch extracts the DEVNAME from the uevent sysfs file in make_device(), thus works for hot- and coldplugging; so using the environment DEVNAME on hotplug events is no longer necessary. Signed-off-by: Nikolaus Voss <[email protected]> --- util-linux/mdev.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/util-linux/mdev.c b/util-linux/mdev.c index 1ae9935..fa04021 100644 --- a/util-linux/mdev.c +++ b/util-linux/mdev.c @@ -497,8 +497,24 @@ static void make_device(char *device_name, char *path, int operation) /* else: for delete, -1 still deletes the node, but < -1 suppresses that */ /* Determine device name, type, major and minor */ - if (!device_name) - device_name = (char*) bb_basename(path); + if (!device_name) { + const char s[] = "DEVNAME="; + char *c = path + strlen(path); + + strcpy(c, "/uevent"); + len = open_read_close(path, c + 1, SCRATCH_SIZE); + *c = '\0'; + c = strstr(c + 1, s); + if (len > 1 && c) { + device_name = c + strlen(s); + c = strchr(device_name, '\n'); + } + + if (device_name && c) + *c = '\0'; + else + device_name = (char*) bb_basename(path); + } /* http://kernel.org/doc/pending/hotplug.txt says that only * "/sys/block/..." is for block devices. "/sys/bus" etc is not. * But since 2.6.25 block devices are also in /sys/class/block. -- 1.7.9.5 _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
