summaryrefslogtreecommitdiff
path: root/udev_add.c
diff options
context:
space:
mode:
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>2004-10-13 23:13:26 -0700
committerGreg KH <gregkh@suse.de>2005-04-26 21:47:44 -0700
commit7e89a569cc4db0c1482662dc4df5f60df7aef3ff (patch)
tree815fbb823b795e99cb04096a38f3b049c71a9ee2 /udev_add.c
parentc36f0ac34fa3bf8b952889b9197a5ee1ea5d2714 (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 'udev_add.c')
-rw-r--r--udev_add.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/udev_add.c b/udev_add.c
index e1e145de8a..78c78a1100 100644
--- a/udev_add.c
+++ b/udev_add.c
@@ -348,11 +348,10 @@ exit:
/* wait for the "dev" file to show up in the directory in sysfs.
* If it doesn't happen in about 10 seconds, give up.
*/
-#define SECONDS_TO_WAIT_FOR_FILE 10
static int sleep_for_file(const char *path, char* file)
{
char filename[SYSFS_PATH_MAX + 6];
- int loop = SECONDS_TO_WAIT_FOR_FILE;
+ int loop = WAIT_FOR_FILE_SECONDS * WAIT_FOR_FILE_RETRY_FREQ;
int retval;
strfieldcpy(filename, sysfs_path);
@@ -368,7 +367,7 @@ static int sleep_for_file(const char *path, char* file)
goto exit;
/* sleep to give the kernel a chance to create the dev file */
- sleep(1);
+ usleep(1000 * 1000 / WAIT_FOR_FILE_RETRY_FREQ);
}
retval = -ENODEV;
exit: