diff options
author | Kay Sievers <kay.sievers@suse.de> | 2006-04-12 22:08:05 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@suse.de> | 2006-04-12 22:08:05 +0200 |
commit | ff9a488d8c559a2ee40e522cdc68b750670711e4 (patch) | |
tree | be773a20aff7ccbae7ef8cc9b6e2cab33d3e27ad /udev_device.c | |
parent | 00a074480e4ab15e61f13f8791015fa0befcadce (diff) |
remove old symlinks before creating current ones
This will prevent incorrect symlinks when a filesystem
label is changed and the event is triggered again from
sysfs.
Diffstat (limited to 'udev_device.c')
-rw-r--r-- | udev_device.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/udev_device.c b/udev_device.c index 84d0ab2204..b356f163a5 100644 --- a/udev_device.c +++ b/udev_device.c @@ -114,7 +114,10 @@ int udev_device_event(struct udev_rules *rules, struct udevice *udev) /* add device node */ if (major(udev->devt) != 0 && strcmp(udev->action, "add") == 0) { + struct udevice *udev_old; + dbg("device node add '%s'", udev->dev->devpath); + udev_rules_get_name(rules, udev); if (udev->ignore_device) { info("device event will be ignored"); @@ -124,8 +127,19 @@ int udev_device_event(struct udev_rules *rules, struct udevice *udev) info("device node creation supressed"); goto exit; } - /* create node, store in db */ - retval = udev_node_add(udev); + + /* read current database entry, we may want to cleanup symlinks */ + udev_old = udev_device_init(); + if (udev_old != NULL) { + if (udev_db_get_device(udev_old, udev->dev->devpath) == 0) { + info("device '%s' already known, remove possible symlinks", udev->dev->devpath); + udev_node_remove_symlinks(udev_old); + } + udev_device_cleanup(udev_old); + } + + /* create node and symlinks, store record in database */ + retval = udev_node_add(udev, udev_old); if (retval == 0) udev_db_add_device(udev); goto exit; |