return _MONITOR_NETLINK_GROUP_INVALID;
}
-struct udev_monitor *udev_monitor_new_from_netlink_fd(struct udev *udev, const char *name, int fd) {
+/**
+ * udev_monitor_new_from_netlink:
+ * @udev: udev library context
+ * @name: name of event source
+ *
+ * Create new udev monitor and connect to a specified event
+ * 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
+ * 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
+ * are sent out after udev has finished its event processing,
+ * all rules have been processed, and needed device nodes are
+ * created.
+ *
+ * The initial refcount is 1, and needs to be decremented to
+ * release the resources of the udev monitor.
+ *
+ * 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) {
_cleanup_(sd_device_monitor_unrefp) sd_device_monitor *m = NULL;
_cleanup_(udev_monitor_unrefp) struct udev_monitor *udev_monitor = NULL;
MonitorNetlinkGroup g;
return NULL;
}
- r = device_monitor_new_full(&m, g, fd);
+ r = device_monitor_new_full(&m, g, -1);
if (r < 0) {
errno = -r;
return NULL;
return TAKE_PTR(udev_monitor);
}
-/**
- * udev_monitor_new_from_netlink:
- * @udev: udev library context
- * @name: name of event source
- *
- * Create new udev monitor and connect to a specified event
- * 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
- * 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
- * are sent out after udev has finished its event processing,
- * all rules have been processed, and needed device nodes are
- * created.
- *
- * The initial refcount is 1, and needs to be decremented to
- * release the resources of the udev monitor.
- *
- * 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);
-}
-
/**
* udev_monitor_filter_update:
* @udev_monitor: 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
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);
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;
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