summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-03-06 15:22:30 +0100
committerAnthony G. Basile <blueness@gentoo.org>2015-03-18 20:41:10 -0400
commit5ddef03da1cddeb95d149b604fadf7862b0aa388 (patch)
treea18cad51651a81339e8d9adfdf35280e49711c31 /src
parente5df4c6a5255272ee5d9edb24e2da49bfae17c09 (diff)
libudev: introduce clone_with_db()
This allows us to move the db reading from udevd to libudev. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src')
-rw-r--r--src/libudev/libudev-device.c14
-rw-r--r--src/libudev/libudev-private.h1
-rw-r--r--src/udev/udev-event.c5
3 files changed, 16 insertions, 4 deletions
diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c
index 2604ad7051..c0a061af6c 100644
--- a/src/libudev/libudev-device.c
+++ b/src/libudev/libudev-device.c
@@ -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;
diff --git a/src/libudev/libudev-private.h b/src/libudev/libudev-private.h
index f464062539..43ccc3be64 100644
--- a/src/libudev/libudev-private.h
+++ b/src/libudev/libudev-private.h
@@ -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);
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index 7d6ba55243..7a6b55cf07 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -825,11 +825,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);