]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/libudev/libudev-monitor.c
codespell: fix spelling errors
[thirdparty/systemd.git] / src / libudev / libudev-monitor.c
index 5be4d40752c33503aecdb892af7f7dde5569d0df..5f780e0be956e8ec7a7f2d70d0350b5081175a05 100644 (file)
@@ -10,7 +10,6 @@
 #include "device-private.h"
 #include "device-util.h"
 #include "libudev-device-internal.h"
-#include "libudev-private.h"
 #include "string-util.h"
 
 /**
@@ -41,39 +40,6 @@ static MonitorNetlinkGroup monitor_netlink_group_from_string(const char *name) {
         return _MONITOR_NETLINK_GROUP_INVALID;
 }
 
-struct udev_monitor *udev_monitor_new_from_netlink_fd(struct udev *udev, const char *name, int fd) {
-        _cleanup_(sd_device_monitor_unrefp) sd_device_monitor *m = NULL;
-        _cleanup_(udev_monitor_unrefp) struct udev_monitor *udev_monitor = NULL;
-        MonitorNetlinkGroup g;
-        int r;
-
-        g = monitor_netlink_group_from_string(name);
-        if (g < 0) {
-                errno = EINVAL;
-                return NULL;
-        }
-
-        r = device_monitor_new_full(&m, g, fd);
-        if (r < 0) {
-                errno = -r;
-                return NULL;
-        }
-
-        udev_monitor = new(struct udev_monitor, 1);
-        if (!udev_monitor) {
-                errno = ENOMEM;
-                return NULL;
-        }
-
-        *udev_monitor = (struct udev_monitor) {
-                .udev = udev,
-                .n_ref = 1,
-                .monitor = TAKE_PTR(m),
-        };
-
-        return TAKE_PTR(udev_monitor);
-}
-
 /**
  * udev_monitor_new_from_netlink:
  * @udev: udev library context
@@ -83,7 +49,7 @@ struct udev_monitor *udev_monitor_new_from_netlink_fd(struct udev *udev, const c
  * source. Valid sources identifiers are "udev" and "kernel".
  *
  * Applications should usually not connect directly to the
- * "kernel" events, because the devices might not be useable
+ * "kernel" events, because the devices might not be usable
  * at that time, before udev has configured them, and created
  * device nodes. Accessing devices at the same time as udev,
  * might result in unpredictable behavior. The "udev" events
@@ -97,7 +63,30 @@ struct udev_monitor *udev_monitor_new_from_netlink_fd(struct udev *udev, const c
  * Returns: a new udev monitor, or #NULL, in case of an error
  **/
 _public_ struct udev_monitor *udev_monitor_new_from_netlink(struct udev *udev, const char *name) {
-        return udev_monitor_new_from_netlink_fd(udev, name, -1);
+        _cleanup_(sd_device_monitor_unrefp) sd_device_monitor *m = NULL;
+        struct udev_monitor *udev_monitor;
+        MonitorNetlinkGroup g;
+        int r;
+
+        g = monitor_netlink_group_from_string(name);
+        if (g < 0)
+                return_with_errno(NULL, EINVAL);
+
+        r = device_monitor_new_full(&m, g, -1);
+        if (r < 0)
+                return_with_errno(NULL, r);
+
+        udev_monitor = new(struct udev_monitor, 1);
+        if (!udev_monitor)
+                return_with_errno(NULL, ENOMEM);
+
+        *udev_monitor = (struct udev_monitor) {
+                .udev = udev,
+                .n_ref = 1,
+                .monitor = TAKE_PTR(m),
+        };
+
+        return udev_monitor;
 }
 
 /**
@@ -115,13 +104,6 @@ _public_ int udev_monitor_filter_update(struct udev_monitor *udev_monitor) {
         return sd_device_monitor_filter_update(udev_monitor->monitor);
 }
 
-int udev_monitor_allow_unicast_sender(struct udev_monitor *udev_monitor, struct udev_monitor *sender) {
-        assert_return(udev_monitor, -EINVAL);
-        assert_return(sender, -EINVAL);
-
-        return device_monitor_allow_unicast_sender(udev_monitor->monitor, sender->monitor);
-}
-
 /**
  * udev_monitor_enable_receiving:
  * @udev_monitor: the monitor which should receive events
@@ -152,12 +134,6 @@ _public_ int udev_monitor_set_receive_buffer_size(struct udev_monitor *udev_moni
         return sd_device_monitor_set_receive_buffer_size(udev_monitor->monitor, (size_t) size);
 }
 
-int udev_monitor_disconnect(struct udev_monitor *udev_monitor) {
-        assert(udev_monitor);
-
-        return device_monitor_disconnect(udev_monitor->monitor);
-}
-
 static struct udev_monitor *udev_monitor_free(struct udev_monitor *udev_monitor) {
         assert(udev_monitor);
 
@@ -214,7 +190,7 @@ _public_ int udev_monitor_get_fd(struct udev_monitor *udev_monitor) {
         return device_monitor_get_fd(udev_monitor->monitor);
 }
 
-int udev_monitor_receive_sd_device(struct udev_monitor *udev_monitor, sd_device **ret) {
+static int udev_monitor_receive_sd_device(struct udev_monitor *udev_monitor, sd_device **ret) {
         struct pollfd pfd;
         int r;
 
@@ -275,26 +251,12 @@ _public_ struct udev_device *udev_monitor_receive_device(struct udev_monitor *ud
         assert_return(udev_monitor, NULL);
 
         r = udev_monitor_receive_sd_device(udev_monitor, &device);
-        if (r < 0) {
-                errno = -r;
-                return NULL;
-        }
+        if (r < 0)
+                return_with_errno(NULL, r);
 
         return udev_device_new(udev_monitor->udev, device);
 }
 
-int udev_monitor_send_device(
-                struct udev_monitor *udev_monitor,
-                struct udev_monitor *destination,
-                struct udev_device *udev_device) {
-        assert(udev_monitor);
-        assert(udev_device);
-
-        return device_monitor_send_device(udev_monitor->monitor,
-                                          destination ? destination->monitor : NULL,
-                                          udev_device->device);
-}
-
 /**
  * udev_monitor_filter_add_match_subsystem_devtype:
  * @udev_monitor: the monitor