From: Arnd Bergmann <arnd@arndb.de>
To: linux-hotplug@vger.kernel.org
Subject: udev causing stale device nodes
Date: Mon, 23 Feb 2004 13:20:17 +0000 [thread overview]
Message-ID: <200402231420.17309.arnd@arndb.de> (raw)
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
next reply other threads:[~2004-02-23 13:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-23 13:20 Arnd Bergmann [this message]
2004-02-23 21:05 ` udev causing stale device nodes Olaf Hering
2004-02-23 22:35 ` Greg KH
2004-02-23 23:12 ` Kay Sievers
2004-02-23 23:16 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200402231420.17309.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).