- /* read current udev seqnum */
- util_strlcpy(filename, udev_get_dev_path(udev), sizeof(filename));
- util_strlcat(filename, "/.udev/uevent_seqnum", sizeof(filename));
- fd = open(filename, O_RDONLY);
- if (fd < 0)
- goto exit;
- len = read(fd, seqnum, sizeof(seqnum)-1);
- close(fd);
- if (len <= 0)
- goto exit;
- seqnum[len] = '\0';
- seq_udev = strtoull(seqnum, NULL, 10);
- info(udev, "udev seqnum = %llu\n", seq_udev);
-
- /* read current kernel seqnum */
- util_strlcpy(filename, udev_get_sys_path(udev), sizeof(filename));
- util_strlcat(filename, "/kernel/uevent_seqnum", sizeof(filename));
- fd = open(filename, O_RDONLY);
- if (fd < 0)
- goto exit;
- len = read(fd, seqnum, sizeof(seqnum)-1);
- close(fd);
- if (len <= 0)
- goto exit;
- seqnum[len] = '\0';
- seq_kernel = strtoull(seqnum, NULL, 10);
- info(udev, "kernel seqnum = %llu\n", seq_kernel);
-
- /* make sure all kernel events have arrived in the queue */
- if (seq_udev >= seq_kernel) {
- info(udev, "queue is empty and no pending events left\n");
- rc = 0;
- goto exit;
+ if (timeout > 0) {
+ unsigned long long age_usec;
+
+ age_usec = now_usec() - start_usec;
+ if (age_usec / (1000 * 1000) >= timeout) {
+ struct udev_list_entry *list_entry;
+
+ if (!quiet && udev_queue_get_queued_list_entry(udev_queue) != NULL) {
+ info(udev, "timeout waiting for udev queue\n");
+ printf("\nudevadm settle - timeout of %i seconds reached, the event queue contains:\n", timeout);
+ udev_list_entry_foreach(list_entry, udev_queue_get_queued_list_entry(udev_queue))
+ printf(" %s (%s)\n",
+ udev_list_entry_get_name(list_entry),
+ udev_list_entry_get_value(list_entry));
+ }
+
+ break;
+ }