chiark / gitweb /
libudev: monitor - add event properties to udev_device
[elogind.git] / udev / lib / libudev-monitor.c
index 2cba7ca..454a646 100644 (file)
@@ -88,6 +88,7 @@ struct udev_monitor *udev_monitor_new_from_socket(struct udev *udev, const char
                free(udev_monitor);
                return NULL;
        }
+       info(udev, "monitor %p created with '%s'\n", udev_monitor, socket_path);
        return udev_monitor;
 }
 
@@ -96,7 +97,7 @@ int udev_monitor_enable_receiving(struct udev_monitor *udev_monitor)
        int err;
        const int on = 1;
 
-       err = bind(udev_monitor->sock, (struct sockaddr *) &udev_monitor->saddr, udev_monitor->addrlen);
+       err = bind(udev_monitor->sock, (struct sockaddr *)&udev_monitor->saddr, udev_monitor->addrlen);
        if (err < 0) {
                err(udev_monitor->udev, "bind failed: %s\n", strerror(errno));
                return err;
@@ -104,7 +105,7 @@ int udev_monitor_enable_receiving(struct udev_monitor *udev_monitor)
 
        /* enable receiving of the sender credentials */
        setsockopt(udev_monitor->sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
-       info(udev_monitor->udev, "udev_monitor: %p created\n", udev_monitor);
+       info(udev_monitor->udev, "monitor %p listening\n", udev_monitor);
        return 0;
 }
 
@@ -142,7 +143,7 @@ void udev_monitor_unref(struct udev_monitor *udev_monitor)
                return;
        if (udev_monitor->sock >= 0)
                close(udev_monitor->sock);
-       info(udev_monitor->udev, "udev_monitor: %p released\n", udev_monitor);
+       info(udev_monitor->udev, "monitor %p released\n", udev_monitor);
        free(udev_monitor);
 }
 
@@ -202,6 +203,8 @@ struct udev_device *udev_monitor_receive_device(struct udev_monitor *udev_monito
        char cred_msg[CMSG_SPACE(sizeof(struct ucred))];
        char buf[4096];
        size_t bufpos;
+       int maj = 0;
+       int min = 0;
 
        if (udev_monitor == NULL)
                return NULL;
@@ -278,9 +281,26 @@ struct udev_device *udev_monitor_receive_device(struct udev_monitor *udev_monito
                        }
                        if (slink[0] != '\0')
                                device_add_devlink(udev_device, slink);
+               } else if (strncmp(key, "DRIVER=", 7) == 0) {
+                       device_set_driver(udev_device, &key[7]);
+               } else if (strncmp(key, "ACTION=", 7) == 0) {
+                       device_set_action(udev_device, &key[7]);
+               } else if (strncmp(key, "MAJOR=", 6) == 0) {
+                       maj = strtoull(&key[6], NULL, 10);
+               } else if (strncmp(key, "MINOR=", 6) == 0) {
+                       min = strtoull(&key[6], NULL, 10);
+               } else if (strncmp(key, "DEVPATH_OLD=", 12) == 0) {
+                       device_set_devpath_old(udev_device, &key[12]);
+               } else if (strncmp(key, "PHYSDEVPATH=", 12) == 0) {
+                       device_set_physdevpath(udev_device, &key[12]);
+               } else if (strncmp(key, "SEQNUM=", 7) == 0) {
+                       device_set_seqnum(udev_device, strtoull(&key[7], NULL, 10));
+               } else if (strncmp(key, "TIMEOUT=", 8) == 0) {
+                       device_set_timeout(udev_device, strtoull(&key[8], NULL, 10));
                }
                device_add_property(udev_device, key);
        }
+       device_set_devnum(udev_device, makedev(maj, min));
 
        return udev_device;
 }