chiark / gitweb /
cleanup old names before creating the new names
authorKay Sievers <kay.sievers@vrfy.org>
Fri, 16 Jan 2009 20:15:53 +0000 (21:15 +0100)
committerKay Sievers <kay.sievers@vrfy.org>
Fri, 16 Jan 2009 20:15:53 +0000 (21:15 +0100)
Scott found that the node /dev/pktcdvd can not be replaced by
/dev/pktcdvd/control by changing the rules, and re-trigger the
event. We used to create the new names before we cleaned up the
old ones, which can not work if we need to create subdir with
the same name.

udev/udev-event.c

index 6d055943371ac241ca2b59af2ddf8ad2e4801080..4b00cab30d1f989b3b542a8e7ae6159b8cf28c68 100644 (file)
@@ -582,22 +582,24 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules)
                util_strlcat(filename, event->name, sizeof(filename));
                udev_device_set_devnode(dev, filename);
 
-               /* read current database entry */
+               /* read old database entry */
                dev_old = udev_device_new_from_syspath(event->udev, udev_device_get_syspath(dev));
                if (dev_old != NULL) {
                        udev_device_read_db(dev_old);
                        udev_device_set_info_loaded(dev_old);
                }
 
-               /* update database, create node and symlinks */
+               /* write current database entry */
                udev_device_update_db(dev);
-               err = udev_node_add(dev, event->mode, event->uid, event->gid);
 
                /* remove/update possible left-over symlinks from old database entry */
                if (dev_old != NULL) {
                        udev_node_update_old_links(dev, dev_old);
                        udev_device_unref(dev_old);
                }
+
+               /* create new node and symlinks */
+               err = udev_node_add(dev, event->mode, event->uid, event->gid);
                goto exit;
        }