summaryrefslogtreecommitdiff
path: root/src/libudev
diff options
context:
space:
mode:
Diffstat (limited to 'src/libudev')
-rw-r--r--src/libudev/libudev-device.c21
-rw-r--r--src/libudev/libudev-private.h1
2 files changed, 22 insertions, 0 deletions
diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c
index 193c706d89..08331a2329 100644
--- a/src/libudev/libudev-device.c
+++ b/src/libudev/libudev-device.c
@@ -1944,3 +1944,24 @@ int udev_device_rename(struct udev_device *udev_device, const char *name)
return 0;
}
+
+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 017b6cc63b..31f150c764 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);