summaryrefslogtreecommitdiff
path: root/src/libudev
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-03-06 18:30:09 +0100
committerAnthony G. Basile <blueness@gentoo.org>2015-03-18 20:37:21 -0400
commit87a58f20434358efb217ca0583f7ebce2e1cc3b3 (patch)
treeebbd06343d625695bc1f49f63a837ba126a3ff9a /src/libudev
parentb8adef56d8e5ebe1b7d004b660e6a72392a79e02 (diff)
libudev: introduce udev_device_properties_copy()
To copy properties from one device to another. Drop the equivalent functionality from udevd. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/libudev')
-rw-r--r--src/libudev/libudev-device.c15
-rw-r--r--src/libudev/libudev-private.h1
2 files changed, 16 insertions, 0 deletions
diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c
index 242a0d89b6..2604ad7051 100644
--- a/src/libudev/libudev-device.c
+++ b/src/libudev/libudev-device.c
@@ -2030,3 +2030,18 @@ struct udev_device *udev_device_new_from_nulstr(struct udev *udev, char *nulstr,
return device;
}
+
+int udev_device_copy_properties(struct udev_device *dst, struct udev_device *src) {
+ struct udev_list_entry *entry;
+
+ for ((entry = udev_device_get_properties_list_entry(src)); entry; entry = udev_list_entry_get_next(entry)) {
+ const char *key, *value;
+
+ key = udev_list_entry_get_name(entry);
+ value = udev_list_entry_get_value(entry);
+
+ udev_device_add_property(dst, key, value);
+ }
+
+ return 0;
+}
diff --git a/src/libudev/libudev-private.h b/src/libudev/libudev-private.h
index 597ef54bd6..f464062539 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);
+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);
gid_t udev_device_get_devnode_gid(struct udev_device *udev_device);