]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev-util: drop udev_queue_init() from shared
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 18 Jul 2023 06:55:12 +0000 (15:55 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 31 Jul 2023 14:23:00 +0000 (23:23 +0900)
It is only used in libudev, let's move it.

src/libudev/libudev-queue.c
src/shared/udev-util.c
src/shared/udev-util.h

index 7c5bb5500c60000526f3fd9575834cd202445efa..0af99e5481b2dbbb09df56640f8b7a404ec8aa3d 100644 (file)
@@ -192,18 +192,21 @@ _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) {
-        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);
 }
 
 /**
index 3e81234dc1f3d7e8815141f6070b1b374cdeedaf..fddf096d76a7b63e9bb03a73d6b71d829268bfb7 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <ctype.h>
 #include <errno.h>
-#include <sys/inotify.h>
 #include <unistd.h>
 
 #include "alloc-util.h"
@@ -578,19 +577,6 @@ int udev_queue_is_empty(void) {
                 (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;
 
index 175fa0b6f086002381589077380beb82d011dea1..05a0849934b88ae3fc484770b016c6ea58015227 100644 (file)
@@ -53,7 +53,6 @@ int udev_resolve_subsys_kernel(const char *string, char *result, size_t maxsize,
 bool devpath_conflict(const char *a, const char *b);
 
 int udev_queue_is_empty(void);
-int udev_queue_init(void);
 
 bool udev_available(void);