chiark / gitweb /
udevadm: settle - exit if udevd exits
authorKay Sievers <kay.sievers@vrfy.org>
Thu, 6 Nov 2008 18:41:58 +0000 (19:41 +0100)
committerKay Sievers <kay.sievers@vrfy.org>
Thu, 6 Nov 2008 18:41:58 +0000 (19:41 +0100)
udev/lib/exported_symbols
udev/lib/libudev-queue.c
udev/lib/libudev.h

index da84a89..abb6ae3 100644 (file)
@@ -59,6 +59,7 @@ udev_queue_unref
 udev_queue_get_udev
 udev_queue_get_kernel_seqnum
 udev_queue_get_udev_seqnum
 udev_queue_get_udev
 udev_queue_get_kernel_seqnum
 udev_queue_get_udev_seqnum
+udev_queue_get_udev_is_active
 udev_queue_get_queue_is_empty
 udev_queue_get_seqnum_is_finished
 udev_queue_get_queued_list_entry
 udev_queue_get_queue_is_empty
 udev_queue_get_seqnum_is_finished
 udev_queue_get_queued_list_entry
index 28d8777..51878da 100644 (file)
@@ -133,6 +133,20 @@ unsigned long long int udev_queue_get_udev_seqnum(struct udev_queue *udev_queue)
        return seqnum;
 }
 
        return seqnum;
 }
 
+int udev_queue_get_udev_is_active(struct udev_queue *udev_queue)
+{
+       char filename[UTIL_PATH_SIZE];
+       struct stat statbuf;
+
+       if (udev_queue == NULL)
+               return 0;
+       util_strlcpy(filename, udev_get_dev_path(udev_queue->udev), sizeof(filename));
+       util_strlcat(filename, "/.udev/uevent_seqnum", sizeof(filename));
+       if (stat(filename, &statbuf) == 0)
+               return 1;
+       return 0;
+}
+
 int udev_queue_get_queue_is_empty(struct udev_queue *udev_queue)
 {
        char queuename[UTIL_PATH_SIZE];
 int udev_queue_get_queue_is_empty(struct udev_queue *udev_queue)
 {
        char queuename[UTIL_PATH_SIZE];
@@ -152,7 +166,10 @@ int udev_queue_get_queue_is_empty(struct udev_queue *udev_queue)
                dbg(udev_queue->udev, "queue is empty\n");
                return 1;
        }
                dbg(udev_queue->udev, "queue is empty\n");
                return 1;
        }
-       udev_queue_get_udev_seqnum(udev_queue);
+       /* update udev seqnum, and check if udev is still running */
+       if (udev_queue_get_udev_seqnum(udev_queue) == 0)
+               if (!udev_queue_get_udev_is_active(udev_queue))
+                       return 1;
        if (seqnum_kernel <= udev_queue->last_seen_udev_seqnum) {
                dbg(udev_queue->udev, "queue is empty\n");
                return 1;
        if (seqnum_kernel <= udev_queue->last_seen_udev_seqnum) {
                dbg(udev_queue->udev, "queue is empty\n");
                return 1;
index 041ffd4..ea6c9dd 100644 (file)
@@ -113,6 +113,7 @@ extern void udev_queue_unref(struct udev_queue *udev_queue);
 extern struct udev *udev_queue_get_udev(struct udev_queue *udev_queue);
 extern unsigned long long int udev_queue_get_kernel_seqnum(struct udev_queue *udev_queue);
 extern unsigned long long int udev_queue_get_udev_seqnum(struct udev_queue *udev_queue);
 extern struct udev *udev_queue_get_udev(struct udev_queue *udev_queue);
 extern unsigned long long int udev_queue_get_kernel_seqnum(struct udev_queue *udev_queue);
 extern unsigned long long int udev_queue_get_udev_seqnum(struct udev_queue *udev_queue);
+extern int udev_queue_get_udev_is_active(struct udev_queue *udev_queue);
 extern int udev_queue_get_queue_is_empty(struct udev_queue *udev_queue);
 extern int udev_queue_get_seqnum_is_finished(struct udev_queue *udev_queue, unsigned long long int seqnum);
 extern struct udev_list_entry *udev_queue_get_queued_list_entry(struct udev_queue *udev_queue);
 extern int udev_queue_get_queue_is_empty(struct udev_queue *udev_queue);
 extern int udev_queue_get_seqnum_is_finished(struct udev_queue *udev_queue, unsigned long long int seqnum);
 extern struct udev_list_entry *udev_queue_get_queued_list_entry(struct udev_queue *udev_queue);