summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libudev/libudev-device.c21
-rw-r--r--src/libudev/libudev-private.h1
-rw-r--r--src/udev/udev-event.c5
3 files changed, 23 insertions, 4 deletions
diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c
index a7446bff77..24c8d3b02c 100644
--- a/src/libudev/libudev-device.c
+++ b/src/libudev/libudev-device.c
@@ -1922,3 +1922,24 @@ void udev_device_set_db_persist(struct udev_device *udev_device)
{
udev_device->db_persist = true;
}
+
+struct udev_device *udev_device_shallow_clone(struct udev_device *old_device)
+{
+ struct udev_device *device;
+
+ if (old_device == NULL)
+ return NULL;
+
+ device = udev_device_new(old_device->udev);
+ if (!device) {
+ errno = ENOMEM;
+
+ return NULL;
+ }
+
+ udev_device_set_syspath(device, udev_device_get_syspath(old_device));
+ udev_device_set_subsystem(device, udev_device_get_subsystem(old_device));
+ udev_device_set_devnum(device, udev_device_get_devnum(old_device));
+
+ return device;
+}
diff --git a/src/libudev/libudev-private.h b/src/libudev/libudev-private.h
index 64f132f91d..97f0cd68a4 100644
--- a/src/libudev/libudev-private.h
+++ b/src/libudev/libudev-private.h
@@ -38,6 +38,7 @@ int udev_get_rules_path(struct udev *udev, char **path[], usec_t *ts_usec[]);
/* libudev-device.c */
struct udev_device *udev_device_new(struct udev *udev);
+struct udev_device *udev_device_shallow_clone(struct udev_device *old_device);
mode_t udev_device_get_devnode_mode(struct udev_device *udev_device);
uid_t udev_device_get_devnode_uid(struct udev_device *udev_device);
gid_t udev_device_get_devnode_gid(struct udev_device *udev_device);
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index ae645457ac..df1bb81fe8 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -872,11 +872,8 @@ void udev_event_execute_rules(struct udev_event *event,
if (major(udev_device_get_devnum(dev)) != 0)
udev_node_remove(dev);
} else {
- event->dev_db = udev_device_new(event->udev);
+ event->dev_db = udev_device_shallow_clone(dev);
if (event->dev_db != NULL) {
- udev_device_set_syspath(event->dev_db, udev_device_get_syspath(dev));
- udev_device_set_subsystem(event->dev_db, udev_device_get_subsystem(dev));
- udev_device_set_devnum(event->dev_db, udev_device_get_devnum(dev));
udev_device_read_db(event->dev_db, NULL);
udev_device_set_info_loaded(event->dev_db);