]> err.no Git - systemd/commitdiff
"UDEV_MONITOR_KERNEL/UDEV" -> "kernel/udev"
authorKay Sievers <kay.sievers@vrfy.org>
Sun, 29 Mar 2009 18:08:52 +0000 (20:08 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Sun, 29 Mar 2009 18:08:52 +0000 (20:08 +0200)
udev/lib/libudev-monitor.c
udev/lib/libudev.h
udev/udevadm-monitor.c
udev/udevd.c

index b2f76c3129bf2216b333566fb53b9f12723b184a..d006596e07ffc612c17e6bff8f5a957c33a0bc42 100644 (file)
@@ -34,6 +34,11 @@ struct udev_monitor {
        socklen_t addrlen;
 };
 
+enum udev_monitor_netlink_group {
+       UDEV_MONITOR_KERNEL     = 1,
+       UDEV_MONITOR_UDEV       = 2,
+};
+
 /**
  * udev_monitor_new_from_socket:
  * @udev: udev library context
@@ -91,12 +96,23 @@ struct udev_monitor *udev_monitor_new_from_socket(struct udev *udev, const char
        return udev_monitor;
 }
 
-struct udev_monitor *udev_monitor_new_from_netlink(struct udev *udev, unsigned int group)
+struct udev_monitor *udev_monitor_new_from_netlink(struct udev *udev, const char *name)
 {
        struct udev_monitor *udev_monitor;
+       unsigned int group;
 
        if (udev == NULL)
                return NULL;
+
+       if (name == NULL)
+               return NULL;
+       if (strcmp(name, "kernel") == 0)
+               group = UDEV_MONITOR_KERNEL;
+       else if (strcmp(name, "udev") == 0)
+               group = UDEV_MONITOR_UDEV;
+       else
+               return NULL;
+
        udev_monitor = calloc(1, sizeof(struct udev_monitor));
        if (udev_monitor == NULL)
                return NULL;
index be09ddb75a331c2cad155eb3c7f7fb4ad1cd9fe9..e0aa571e26009c7cbf6dc41f6f4ec578bac42beb 100644 (file)
@@ -76,12 +76,8 @@ extern const char *udev_device_get_sysattr_value(struct udev_device *udev_device
 
 /* udev and kernel device events */
 struct udev_monitor;
-enum udev_monitor_netlink_group {
-       UDEV_MONITOR_KERNEL     = 1,
-       UDEV_MONITOR_UDEV       = 2,
-};
 extern struct udev_monitor *udev_monitor_new_from_socket(struct udev *udev, const char *socket_path);
-extern struct udev_monitor *udev_monitor_new_from_netlink(struct udev *udev, enum udev_monitor_netlink_group group);
+extern struct udev_monitor *udev_monitor_new_from_netlink(struct udev *udev, const char *name);
 extern int udev_monitor_enable_receiving(struct udev_monitor *udev_monitor);
 extern struct udev_monitor *udev_monitor_ref(struct udev_monitor *udev_monitor);
 extern void udev_monitor_unref(struct udev_monitor *udev_monitor);
index 43c1cc1163421a518a2279dd8987557aa1b88716..d8ec066467e9fbb001d3587b7580e80bc08b1e67 100644 (file)
@@ -125,7 +125,7 @@ int udevadm_monitor(struct udev *udev, int argc, char *argv[])
 
        printf("monitor will print the received events for:\n");
        if (print_udev) {
-               udev_monitor = udev_monitor_new_from_netlink(udev, UDEV_MONITOR_UDEV);
+               udev_monitor = udev_monitor_new_from_netlink(udev, "udev");
                if (udev_monitor == NULL) {
                        rc = 1;
                        goto out;
@@ -137,7 +137,7 @@ int udevadm_monitor(struct udev *udev, int argc, char *argv[])
                printf("UDEV - the event which udev sends out after rule processing\n");
        }
        if (print_kernel) {
-               kernel_monitor = udev_monitor_new_from_netlink(udev, UDEV_MONITOR_KERNEL);
+               kernel_monitor = udev_monitor_new_from_netlink(udev, "kernel");
                if (kernel_monitor == NULL) {
                        fprintf(stderr, "unable to subscribe to kernel events\n");
                        rc = 3;
@@ -147,7 +147,7 @@ int udevadm_monitor(struct udev *udev, int argc, char *argv[])
                        rc = 4;
                        goto out;
                }
-               printf("UEVENT - the kernel uevent\n");
+               printf("KERNEL - the kernel uevent\n");
        }
        printf("\n");
 
@@ -174,7 +174,7 @@ int udevadm_monitor(struct udev *udev, int argc, char *argv[])
                        device = udev_monitor_receive_device(kernel_monitor);
                        if (device == NULL)
                                continue;
-                       print_device(device, "UEVENT", env);
+                       print_device(device, "KERNEL", env);
                        udev_device_unref(device);
                }
 
index d9de26ea6cc705e8912bebc897ae3451f8d021fc..6de1196421eacd096da57fea3c78e95bb3cb1358 100644 (file)
@@ -813,7 +813,7 @@ int main(int argc, char *argv[])
                goto exit;
        }
 
-       kernel_monitor = udev_monitor_new_from_netlink(udev, UDEV_MONITOR_KERNEL);
+       kernel_monitor = udev_monitor_new_from_netlink(udev, "kernel");
        if (kernel_monitor == NULL || udev_monitor_enable_receiving(kernel_monitor) < 0) {
                fprintf(stderr, "error initializing netlink socket\n");
                err(udev, "error initializing netlink socket\n");