]> err.no Git - systemd/commitdiff
Allow watch handle to be stored in the udevdb.
authorScott James Remnant <scott@ubuntu.com>
Mon, 23 Feb 2009 17:31:26 +0000 (17:31 +0000)
committerScott James Remnant <scott@ubuntu.com>
Mon, 23 Feb 2009 17:31:26 +0000 (17:31 +0000)
udev/lib/libudev-device-db-write.c
udev/lib/libudev-device.c
udev/lib/libudev-private.h

index 11e0ab5f60daaf6bc3892376405fe6a2629882a1..e96f3101c62a50df3892fd1810e8af82bc192440 100644 (file)
@@ -64,6 +64,8 @@ int udev_device_update_db(struct udev_device *udev_device)
                goto file;
        if (udev_device_get_event_timeout(udev_device) >= 0)
                goto file;
+       if (udev_device_get_watch_handle(udev_device) >= 0)
+               goto file;
        if (udev_device_get_devnode(udev_device) == NULL)
                goto out;
 
@@ -109,6 +111,8 @@ file:
                fprintf(f, "A:%u\n", udev_device_get_num_fake_partitions(udev_device));
        if (udev_device_get_ignore_remove(udev_device))
                fprintf(f, "R:%u\n", udev_device_get_ignore_remove(udev_device));
+       if (udev_device_get_watch_handle(udev_device) >= 0)
+               fprintf(f, "W:%u\n", udev_device_get_watch_handle(udev_device));
        udev_list_entry_foreach(list_entry, udev_device_get_properties_list_entry(udev_device)) {
                if (!udev_list_entry_get_flag(list_entry))
                        continue;
index fc881fb3fdacf27c5d194de6da0825254bc96df8..1a9d0a1e69aa9fd4a8454a9b31076366e31f47d5 100644 (file)
@@ -58,6 +58,7 @@ struct udev_device {
        int devlink_priority;
        int refcount;
        dev_t devnum;
+       int watch_handle;
        unsigned int parent_set:1;
        unsigned int subsystem_set:1;
        unsigned int devtype_set:1;
@@ -176,6 +177,9 @@ int udev_device_read_db(struct udev_device *udev_device)
                case 'E':
                        udev_device_add_property_from_string(udev_device, val);
                        break;
+               case 'W':
+                       udev_device_set_watch_handle(udev_device, atoi(val));
+                       break;
                }
        }
        fclose(f);
@@ -251,6 +255,7 @@ struct udev_device *device_new(struct udev *udev)
        udev_list_init(&udev_device->properties_list);
        udev_list_init(&udev_device->sysattr_list);
        udev_device->event_timeout = -1;
+       udev_device->watch_handle = -1;
        /* copy global properties */
        udev_list_entry_foreach(list_entry, udev_get_properties_list_entry(udev))
                udev_device_add_property(udev_device,
@@ -1291,3 +1296,16 @@ int udev_device_set_ignore_remove(struct udev_device *udev_device, int ignore)
        udev_device->ignore_remove = ignore;
        return 0;
 }
+
+int udev_device_get_watch_handle(struct udev_device *udev_device)
+{
+       if (!udev_device->info_loaded)
+               device_load_info(udev_device);
+       return udev_device->watch_handle;
+}
+
+int udev_device_set_watch_handle(struct udev_device *udev_device, int handle)
+{
+       udev_device->watch_handle = handle;
+       return 0;
+}
index 0d752bb1e5fb8847a21bc695e8b42112ad6a0707..0627aea071f9f79303b9dc6963eb5ea75ba187fe 100644 (file)
@@ -84,6 +84,8 @@ extern int udev_device_get_devlink_priority(struct udev_device *udev_device);
 extern int udev_device_set_devlink_priority(struct udev_device *udev_device, int prio);
 extern int udev_device_get_ignore_remove(struct udev_device *udev_device);
 extern int udev_device_set_ignore_remove(struct udev_device *udev_device, int ignore);
+extern int udev_device_get_watch_handle(struct udev_device *udev_device);
+extern int udev_device_set_watch_handle(struct udev_device *udev_device, int handle);
 extern void udev_device_set_info_loaded(struct udev_device *device);
 
 /* libudev-device-db-write.c */