chiark / gitweb /
Merge keymap building in the top-level Makefile.am.
[elogind.git] / libudev / libudev-monitor.c
index 7a0cb478526baaf625e4a89ad531c81bce725940..2c6c685c6b9aa8f25417849a1f2622c71d5d98e0 100644 (file)
 #include "libudev.h"
 #include "libudev-private.h"
 
 #include "libudev.h"
 #include "libudev-private.h"
 
+/**
+ * SECTION:libudev-monitor
+ * @short_description: device event source
+ *
+ * Connects to a device event source.
+ */
+
+/**
+ * udev_monitor:
+ *
+ * Opaque object handling one event source.
+ */
 struct udev_monitor {
        struct udev *udev;
        int refcount;
 struct udev_monitor {
        struct udev *udev;
        int refcount;
@@ -227,6 +239,14 @@ static inline void bpf_jmp(struct sock_filter *inss, unsigned int *i,
        (*i)++;
 }
 
        (*i)++;
 }
 
+/**
+ * udev_monitor_filter_update:
+ * @udev_monitor: monitor
+ *
+ * Update the installed filter. This might only be needed, if the filter was removed or changed.
+ *
+ * Returns: 0 on success, otherwise a negative error value.
+ */
 int udev_monitor_filter_update(struct udev_monitor *udev_monitor)
 {
        static struct sock_filter ins[256];
 int udev_monitor_filter_update(struct udev_monitor *udev_monitor)
 {
        static struct sock_filter ins[256];
@@ -290,7 +310,14 @@ int udev_monitor_allow_unicast_sender(struct udev_monitor *udev_monitor, struct
        udev_monitor->snl_trusted_sender.nl_pid = sender->snl.nl_pid;
        return 0;
 }
        udev_monitor->snl_trusted_sender.nl_pid = sender->snl.nl_pid;
        return 0;
 }
-
+/**
+ * udev_monitor_enable_receiving:
+ * @udev_monitor: the monitor which should receive events
+ *
+ * Binds the @udev_monitor socket to the event source.
+ *
+ * Returns: 0 on success, otherwise a negative error value.
+ */
 int udev_monitor_enable_receiving(struct udev_monitor *udev_monitor)
 {
        int err;
 int udev_monitor_enable_receiving(struct udev_monitor *udev_monitor)
 {
        int err;
@@ -477,7 +504,6 @@ struct udev_device *udev_monitor_receive_device(struct udev_monitor *udev_monito
        int action_set = 0;
        int maj = 0;
        int min = 0;
        int action_set = 0;
        int maj = 0;
        int min = 0;
-       int is_kernel = 0;
 
 retry:
        if (udev_monitor == NULL)
 
 retry:
        if (udev_monitor == NULL)
@@ -518,10 +544,10 @@ retry:
                        }
                } else if (snl.nl_groups == UDEV_MONITOR_KERNEL) {
                        if (snl.nl_pid > 0) {
                        }
                } else if (snl.nl_groups == UDEV_MONITOR_KERNEL) {
                        if (snl.nl_pid > 0) {
-                               info(udev_monitor->udev, "multicast kernel netlink message from pid %d ignored\n", snl.nl_pid);
+                               info(udev_monitor->udev, "multicast kernel netlink message from pid %d ignored\n",
+                                    snl.nl_pid);
                                return NULL;
                        }
                                return NULL;
                        }
-                       is_kernel = 1;
                }
        }
 
                }
        }
 
@@ -562,10 +588,9 @@ retry:
                }
        }
 
                }
        }
 
-       udev_device = device_new(udev_monitor->udev);
-       if (udev_device == NULL) {
+       udev_device = udev_device_new(udev_monitor->udev);
+       if (udev_device == NULL)
                return NULL;
                return NULL;
-       }
 
        while (bufpos < buflen) {
                char *key;
 
        while (bufpos < buflen) {
                char *key;
@@ -589,10 +614,10 @@ retry:
                } else if (strncmp(key, "DEVTYPE=", 8) == 0) {
                        udev_device_set_devtype(udev_device, &key[8]);
                } else if (strncmp(key, "DEVNAME=", 8) == 0) {
                } else if (strncmp(key, "DEVTYPE=", 8) == 0) {
                        udev_device_set_devtype(udev_device, &key[8]);
                } else if (strncmp(key, "DEVNAME=", 8) == 0) {
-                       if (is_kernel)
-                               udev_device_set_knodename(udev_device, &key[8]);
-                       else
+                       if (key[8] == '/')
                                udev_device_set_devnode(udev_device, &key[8]);
                                udev_device_set_devnode(udev_device, &key[8]);
+                       else
+                               udev_device_set_knodename(udev_device, &key[8]);
                } else if (strncmp(key, "DEVLINKS=", 9) == 0) {
                        char devlinks[UTIL_PATH_SIZE];
                        char *slink;
                } else if (strncmp(key, "DEVLINKS=", 9) == 0) {
                        char devlinks[UTIL_PATH_SIZE];
                        char *slink;
@@ -739,6 +764,16 @@ int udev_monitor_send_device(struct udev_monitor *udev_monitor,
        return count;
 }
 
        return count;
 }
 
+/**
+ * udev_monitor_filter_add_match_subsystem_devtype:
+ * @udev_monitor: the monitor
+ * @subsystem: the subsystem value to match the incoming devices against
+ * @devtype: the devtype value to matvh the incoming devices against
+ *
+ * The filter must be installed before the monitor is switched to listening mode.
+ *
+ * Returns: 0 on success, otherwise a negative error value.
+ */
 int udev_monitor_filter_add_match_subsystem_devtype(struct udev_monitor *udev_monitor, const char *subsystem, const char *devtype)
 {
        if (udev_monitor == NULL)
 int udev_monitor_filter_add_match_subsystem_devtype(struct udev_monitor *udev_monitor, const char *subsystem, const char *devtype)
 {
        if (udev_monitor == NULL)
@@ -751,6 +786,14 @@ int udev_monitor_filter_add_match_subsystem_devtype(struct udev_monitor *udev_mo
        return 0;
 }
 
        return 0;
 }
 
+/**
+ * udev_monitor_filter_remove:
+ * @udev_monitor: monitor
+ *
+ * Remove all filters from monitor.
+ *
+ * Returns: 0 on success, otherwise a negative error value.
+ */
 int udev_monitor_filter_remove(struct udev_monitor *udev_monitor)
 {
        static struct sock_fprog filter = { 0, NULL };
 int udev_monitor_filter_remove(struct udev_monitor *udev_monitor)
 {
        static struct sock_fprog filter = { 0, NULL };