summaryrefslogtreecommitdiffstats
path: root/src/libudev/libudev-queue.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2020-12-14 10:20:18 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2020-12-15 18:28:08 +0100
commitbee33d05276326f32a9e677eee6526d3935d0106 (patch)
tree424eb5226d6db1f147efe3b99d2eaf6f90caeed5 /src/libudev/libudev-queue.c
parentlibudev: fix indentation (diff)
downloadsystemd-bee33d05276326f32a9e677eee6526d3935d0106.tar.xz
systemd-bee33d05276326f32a9e677eee6526d3935d0106.zip
udev: introduce udev_queue_is_empty() and udev_queue_init()
Diffstat (limited to 'src/libudev/libudev-queue.c')
-rw-r--r--src/libudev/libudev-queue.c30
1 files changed, 11 insertions, 19 deletions
diff --git a/src/libudev/libudev-queue.c b/src/libudev/libudev-queue.c
index 01b237fde4..7ca17fa6c3 100644
--- a/src/libudev/libudev-queue.c
+++ b/src/libudev/libudev-queue.c
@@ -4,9 +4,6 @@
***/
#include <errno.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <sys/inotify.h>
#include <unistd.h>
#include "libudev.h"
@@ -14,6 +11,7 @@
#include "alloc-util.h"
#include "fd-util.h"
#include "io-util.h"
+#include "udev-util.h"
/**
* SECTION:libudev-queue
@@ -144,7 +142,7 @@ _public_ int udev_queue_get_udev_is_active(struct udev_queue *udev_queue) {
* Returns: a flag indicating if udev is currently handling events.
**/
_public_ int udev_queue_get_queue_is_empty(struct udev_queue *udev_queue) {
- return access("/run/udev/queue", F_OK) < 0;
+ return udev_queue_is_empty() > 0;
}
/**
@@ -153,14 +151,13 @@ _public_ int udev_queue_get_queue_is_empty(struct udev_queue *udev_queue) {
* @start: first event sequence number
* @end: last event sequence number
*
- * This function is deprecated, it just returns the result of
- * udev_queue_get_queue_is_empty().
+ * This function is deprecated, and equivalent to udev_queue_get_queue_is_empty().
*
* Returns: a flag indicating if udev is currently handling events.
**/
_public_ int udev_queue_get_seqnum_sequence_is_finished(struct udev_queue *udev_queue,
unsigned long long int start, unsigned long long int end) {
- return udev_queue_get_queue_is_empty(udev_queue);
+ return udev_queue_is_empty() > 0;
}
/**
@@ -168,13 +165,12 @@ _public_ int udev_queue_get_seqnum_sequence_is_finished(struct udev_queue *udev_
* @udev_queue: udev queue context
* @seqnum: sequence number
*
- * This function is deprecated, it just returns the result of
- * udev_queue_get_queue_is_empty().
+ * This function is deprecated, and equivalent to udev_queue_get_queue_is_empty().
*
* Returns: a flag indicating if udev is currently handling events.
**/
_public_ int udev_queue_get_seqnum_is_finished(struct udev_queue *udev_queue, unsigned long long int seqnum) {
- return udev_queue_get_queue_is_empty(udev_queue);
+ return udev_queue_is_empty() > 0;
}
/**
@@ -196,22 +192,18 @@ _public_ struct udev_list_entry *udev_queue_get_queued_list_entry(struct udev_qu
* Returns: a file descriptor to watch for a queue to become empty.
*/
_public_ int udev_queue_get_fd(struct udev_queue *udev_queue) {
- _cleanup_close_ int fd = -1;
+ int r;
assert_return(udev_queue, -EINVAL);
if (udev_queue->fd >= 0)
return udev_queue->fd;
- fd = inotify_init1(IN_CLOEXEC);
- if (fd < 0)
- return -errno;
-
- if (inotify_add_watch(fd, "/run/udev" , IN_DELETE) < 0)
- return -errno;
+ r = udev_queue_init();
+ if (r < 0)
+ return r;
- udev_queue->fd = TAKE_FD(fd);
- return udev_queue->fd;
+ return udev_queue->fd = r;
}
/**