linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* udev causing stale device nodes
@ 2004-02-23 13:20 Arnd Bergmann
  2004-02-23 21:05 ` Olaf Hering
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Arnd Bergmann @ 2004-02-23 13:20 UTC (permalink / raw)
  To: linux-hotplug

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_id\x1356&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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-02-23 23:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-23 13:20 udev causing stale device nodes Arnd Bergmann
2004-02-23 21:05 ` Olaf Hering
2004-02-23 22:35 ` Greg KH
2004-02-23 23:12 ` Kay Sievers
2004-02-23 23:16 ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).