It is only used in libudev, let's move it.
* Returns: a file descriptor to watch for a queue to become empty.
*/
_public_ int udev_queue_get_fd(struct udev_queue *udev_queue) {
- int r;
+ _cleanup_close_ int fd = -EBADF;
assert_return(udev_queue, -EINVAL);
if (udev_queue->fd >= 0)
return udev_queue->fd;
- r = udev_queue_init();
- if (r < 0)
- return r;
+ fd = inotify_init1(IN_CLOEXEC);
+ if (fd < 0)
+ return -errno;
+
+ if (inotify_add_watch(fd, "/run/udev" , IN_DELETE) < 0)
+ return -errno;
- return udev_queue->fd = r;
+ return udev_queue->fd = TAKE_FD(fd);
}
/**
#include <ctype.h>
#include <errno.h>
-#include <sys/inotify.h>
#include <unistd.h>
#include "alloc-util.h"
(errno == ENOENT ? true : -errno) : false;
}
-int udev_queue_init(void) {
- _cleanup_close_ int fd = -EBADF;
-
- fd = inotify_init1(IN_CLOEXEC);
- if (fd < 0)
- return -errno;
-
- if (inotify_add_watch(fd, "/run/udev" , IN_DELETE) < 0)
- return -errno;
-
- return TAKE_FD(fd);
-}
-
bool udev_available(void) {
static int cache = -1;
bool devpath_conflict(const char *a, const char *b);
int udev_queue_is_empty(void);
-int udev_queue_init(void);
bool udev_available(void);