- /* wait for events in queue to finish */
- while (loop--) {
- struct stat statbuf;
-
- if (stat(queuename, &statbuf) < 0) {
- info("queue is empty\n");
- break;
- }
- usleep(1000 * 1000 / LOOP_PER_SECOND);
- }
- if (loop <= 0) {
- info("timeout waiting for queue\n");
- print_queue(queuename);
- goto exit;
- }
-
- /* read current udev seqnum */
- strlcpy(filename, udev_root, sizeof(filename));
- 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 seqnum = %llu\n", seq_udev);
-
- /* read current kernel seqnum */
- strlcpy(filename, sysfs_path, sizeof(filename));
- 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("kernel seqnum = %llu\n", seq_kernel);
-
- /* make sure all kernel events have arrived in the queue */
- if (seq_udev >= seq_kernel) {
- info("queue is empty and no pending events left\n");
- rc = 0;
- goto exit;
- }