From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arnd Bergmann Date: Mon, 23 Feb 2004 13:20:17 +0000 Subject: udev causing stale device nodes Message-Id: <200402231420.17309.arnd@arndb.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org I got a report about symlinks in /udev pointing to the wrong disks. It turned out that the system had crashed and during the next reboot the disks were detected in a different order. The symlinks were created with the disk label but pointing to the device nodes from the previous boot: /udev/dasda /udev/dasda1 /udev/dasdb /udev/dasdb1 /udev/dasd/label/0X1000/disc -> ../../dasda /udev/dasd/label/0X1000/part1 -> ../../dasda1 /udev/dasd/label/0X1001/disc -> ../../dasdb /udev/dasd/label/0X1001/part1 -> ../../dasdb1 /udev/dasd/label/0X1002/disc -> ../../dasdb /udev/dasd/label/0X1002/part1 -> ../../dasdb1 When the 0X1002 device appeared, the 0X1001 symlink still pointed to the old device node. The worst thing that can happen is that two devices are added in reverse order so both symlinks point to a wrong device. The two solutions I could come up with are a) Always remove all udev-created nodes before udev starts b) When a device appears, remove everything previously associated with that kernel name. The patch below implements b) in a simple way, but I'm not sure if there are some races left where a device node might be on disc but not yet in udev's database. Arnd <>< diff -u udev-018/udev.c udev-018-patched/udev.c --- udev-018/udev.c 2004-02-13 02:01:37.000000000 +0100 +++ udev-018-patched/udev.c 2004-02-19 14:53:20.000000000 +0100 @@ -163,13 +163,14 @@ /* initialize the naming deamon */ namedev_init(); - if (strcmp(action, "add") = 0) + if (strcmp(action, "add") = 0) { + udev_remove_device(devpath, subsystem); retval = udev_add_device(devpath, subsystem, 0); - else if (strcmp(action, "remove") = 0) + } else if (strcmp(action, "remove") = 0) { retval = udev_remove_device(devpath, subsystem); - else { + } else { dbg("unknown action '%s'", action); retval = -EINVAL; } ------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id56&alloc_id438&op=click _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel