chiark / gitweb /
libudev: introduce clone_with_db()
authorTom Gundersen <teg@jklm.no>
Fri, 6 Mar 2015 14:22:30 +0000 (15:22 +0100)
committerTom Gundersen <teg@jklm.no>
Thu, 12 Mar 2015 11:03:50 +0000 (12:03 +0100)
This allows us to move the db reading from udevd to libudev.

src/libudev/libudev-device.c
src/libudev/libudev-private.h
src/udev/udev-event.c

index 2604ad7..c0a061a 100644 (file)
@@ -1986,6 +1986,20 @@ struct udev_device *udev_device_shallow_clone(struct udev_device *old_device)
         return device;
 }
 
+struct udev_device *udev_device_clone_with_db(struct udev_device *old_device)
+{
+        struct udev_device *device;
+
+        device = udev_device_shallow_clone(old_device);
+        if (!device)
+                return NULL;
+
+        udev_device_read_db(device);
+        udev_device_set_info_loaded(device);
+
+        return device;
+}
+
 struct udev_device *udev_device_new_from_nulstr(struct udev *udev, char *nulstr, ssize_t buflen) {
         struct udev_device *device;
         ssize_t bufpos = 0;
index c0f9fbe..a34c0f7 100644 (file)
@@ -39,6 +39,7 @@ int udev_get_rules_path(struct udev *udev, char **path[], usec_t *ts_usec[]);
 /* libudev-device.c */
 struct udev_device *udev_device_new_from_nulstr(struct udev *udev, char *nulstr, ssize_t buflen);
 struct udev_device *udev_device_shallow_clone(struct udev_device *old_device);
+struct udev_device *udev_device_clone_with_db(struct udev_device *old_device);
 int udev_device_copy_properties(struct udev_device *dst, struct udev_device *src);
 mode_t udev_device_get_devnode_mode(struct udev_device *udev_device);
 uid_t udev_device_get_devnode_uid(struct udev_device *udev_device);
index 4ca73d3..f62c1ea 100644 (file)
@@ -807,11 +807,8 @@ void udev_event_execute_rules(struct udev_event *event,
                 udev_device_delete_db(dev);
                 udev_device_tag_index(dev, NULL, false);
         } else {
-                event->dev_db = udev_device_shallow_clone(dev);
+                event->dev_db = udev_device_clone_with_db(dev);
                 if (event->dev_db != NULL) {
-                        udev_device_read_db(event->dev_db);
-                        udev_device_set_info_loaded(event->dev_db);
-
                         /* disable watch during event processing */
                         if (major(udev_device_get_devnum(dev)) != 0)
                                 udev_watch_end(event->udev, event->dev_db);