diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2007-03-16 17:24:39 +0100 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2007-03-16 17:24:39 +0100 |
commit | 6eee03ef45fa3b04cf7ac94fd5bc5f982a33bfb7 (patch) | |
tree | 1e0cde393c6af6387a522a8734135e3492b28638 /udev_device.c | |
parent | 2afb8cb37af32495e4f4ff9188e21cbe3a44ce6c (diff) |
cleanup already existing db-entries and db-index on device update
Diffstat (limited to 'udev_device.c')
-rw-r--r-- | udev_device.c | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/udev_device.c b/udev_device.c index 91fa655480..daf94a5772 100644 --- a/udev_device.c +++ b/udev_device.c @@ -162,40 +162,39 @@ int udev_device_event(struct udev_rules *rules, struct udevice *udev) goto exit; } - /* read current database entry, we may want to cleanup symlinks */ + /* read current database entry, we may need to cleanup */ udev_old = udev_device_init(); if (udev_old != NULL) { - if (udev_db_get_device(udev_old, udev->dev->devpath) != 0) { + if (udev_db_get_device(udev_old, udev->dev->devpath) == 0) { + info("device '%s' already in database, cleanup", udev->dev->devpath); + udev_db_delete_device(udev_old); + } else { udev_device_cleanup(udev_old); udev_old = NULL; - } else - info("device '%s' already in database, validate currently present symlinks", - udev->dev->devpath); + } } /* create node and symlinks */ retval = udev_node_add(udev, udev_old); - if (retval == 0) { - /* store record in database */ + if (retval == 0) udev_db_add_device(udev); - /* remove possibly left-over symlinks */ - if (udev_old != NULL) { - struct name_entry *link_loop; - struct name_entry *link_old_loop; - struct name_entry *link_old_tmp_loop; - - /* remove still valid symlinks from old list */ - list_for_each_entry_safe(link_old_loop, link_old_tmp_loop, &udev_old->symlink_list, node) - list_for_each_entry(link_loop, &udev->symlink_list, node) - if (strcmp(link_old_loop->name, link_loop->name) == 0) { - dbg("symlink '%s' still valid, keep it", link_old_loop->name); - list_del(&link_old_loop->node); - free(link_old_loop); - } - udev_node_remove_symlinks(udev_old); - udev_device_cleanup(udev_old); - } + /* remove possibly left-over symlinks */ + if (udev_old != NULL) { + struct name_entry *link_loop; + struct name_entry *link_old_loop; + struct name_entry *link_old_tmp_loop; + + /* remove still valid symlinks from old list */ + list_for_each_entry_safe(link_old_loop, link_old_tmp_loop, &udev_old->symlink_list, node) + list_for_each_entry(link_loop, &udev->symlink_list, node) + if (strcmp(link_old_loop->name, link_loop->name) == 0) { + dbg("symlink '%s' still valid, keep it", link_old_loop->name); + list_del(&link_old_loop->node); + free(link_old_loop); + } + udev_node_remove_symlinks(udev_old); + udev_device_cleanup(udev_old); } goto exit; } |