chiark / gitweb /
clean-up empty queue directories
authorScott James Remnant <scott@ubuntu.com>
Tue, 22 Nov 2005 14:49:49 +0000 (15:49 +0100)
committerKay Sievers <kay.sievers@suse.de>
Tue, 22 Nov 2005 14:49:49 +0000 (15:49 +0100)
This allows scripts to do:
  while test -d /dev/.udev/queue; do sleep 0.1; done

And don't create a failed symlink if there is another event
for the same devpath in the queue.

udevd.c

diff --git a/udevd.c b/udevd.c
index 446db8f..25ef857 100644 (file)
--- a/udevd.c
+++ b/udevd.c
@@ -176,6 +176,7 @@ static void export_event_state(struct uevent_msg *msg, enum event_state state)
        switch (state) {
        case EVENT_QUEUED:
                unlink(filename_failed);
+               delete_path(filename_failed);
 
                strlcpy(target, sysfs_path, sizeof(target));
                strlcat(target, msg->devpath, sizeof(target));
@@ -183,17 +184,26 @@ static void export_event_state(struct uevent_msg *msg, enum event_state state)
                symlink(target, filename);
                return;
        case EVENT_FINISHED:
+       case EVENT_FAILED:
                unlink(filename_failed);
+               delete_path(filename_failed);
 
-               /* don't remove if events for the same path are still pending */
+               /* don't remove, if events for the same path are still pending */
                list_for_each_entry(loop_msg, &running_list, node)
                        if (loop_msg->devpath && strcmp(loop_msg->devpath, msg->devpath) == 0)
                                return;
-               unlink(filename);
-               return;
-       case EVENT_FAILED:
-               create_path(filename_failed);
-               rename(filename, filename_failed);
+
+               /* move failed events to the failed directory */
+               if (state == EVENT_FAILED) {
+                       create_path(filename_failed);
+                       rename(filename, filename_failed);
+               } else {
+                       unlink(filename);
+               }
+
+               /* clean up the queue directory */
+               delete_path(filename);
+
                return;
        }
 }