diff options
author | kay.sievers@vrfy.org <kay.sievers@vrfy.org> | 2004-10-13 23:13:26 -0700 |
---|---|---|
committer | Greg KH <gregkh@suse.de> | 2005-04-26 21:47:44 -0700 |
commit | 7e89a569cc4db0c1482662dc4df5f60df7aef3ff (patch) | |
tree | 815fbb823b795e99cb04096a38f3b049c71a9ee2 /wait_for_sysfs.c | |
parent | c36f0ac34fa3bf8b952889b9197a5ee1ea5d2714 (diff) |
[PATCH] prevent deadlocks on an corrupt udev database
Here is the patch, that should prevent all of the known deadlocks with
corrupt tdb databases we discovered.
Thanks to Frank Steiner <fsteiner-mail@bio.ifi.lmu.de>, who tested all this
endlessly with a NFS mounted /dev. The conclusion is, that udev will not work
on filesystems without proper record locking, but we should prevent the
endless loops anyway. This patch implements:
o recovery from a corrupted udev database. udev will continue
without database support now, instead of doing nothing. So the node should
be generated in any case, remove will obviously not work for custom names.
o added iteration limits to the tdb-code at the places we discovered endless
loops. In the case tdb tries to find more than 100.000 entries with the
same hash, we better give up :)
o prevent a {all_partitions} loop caused by corrupt db data
o log all tdb errors to syslog
o switch sleep() to usleep() cause we want to use alarm()
Diffstat (limited to 'wait_for_sysfs.c')
-rw-r--r-- | wait_for_sysfs.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/wait_for_sysfs.c b/wait_for_sysfs.c index f87253d044..a5d8ab4111 100644 --- a/wait_for_sysfs.c +++ b/wait_for_sysfs.c @@ -101,11 +101,11 @@ static int wait_for_class_device_attributes(struct sysfs_class_device *class_dev return -1; } -/* skip waiting for physical device */ +/* check if we need to wait for a physical device */ static int class_device_expect_no_device_link(struct sysfs_class_device *class_dev) { - /* List of devices without a "device" symlink - * set .device to NULL to accept all devices in that subsystem */ + /* list of devices without a "device" symlink to the physical device + * if device is set to NULL, no devices in that subsystem has a link */ static struct class_device { char *subsystem; char *device; @@ -160,10 +160,9 @@ static int class_device_expect_no_device_link(struct sysfs_class_device *class_d struct class_device *classdevice; int len; - /* look if we want to look for another file instead of "dev" */ for (classdevice = class_device; classdevice->subsystem != NULL; classdevice++) { if (strcmp(class_dev->classname, classdevice->subsystem) == 0) { - /* if device is NULL, all devices in this class are ok */ + /* see if no device in this class is expected to have a device-link */ if (classdevice->device == NULL) return 1; @@ -173,11 +172,11 @@ static int class_device_expect_no_device_link(struct sysfs_class_device *class_d if (strncmp(class_dev->name, classdevice->device, len) != 0) continue; - /* exact match */ + /* exact name match */ if (strlen(class_dev->name) == len) return 1; - /* instance numbers are matching too */ + /* name match with instance number */ if (isdigit(class_dev->name[len])) return 1; } |