chiark / gitweb /
udev: event - move renaming of udev_device to libudev
[elogind.git] / src / libudev / libudev-device.c
index a7446bff77c100d86873641a22c98f089c3d920e..193c706d89d185e2d65152005ccd45a0ea51af7a 100644 (file)
@@ -1922,3 +1922,25 @@ void udev_device_set_db_persist(struct udev_device *udev_device)
 {
         udev_device->db_persist = true;
 }
+
+int udev_device_rename(struct udev_device *udev_device, const char *name)
+{
+        _cleanup_free_ char *dirname = NULL;
+        char *new_syspath;
+        int r;
+
+        if (udev_device == NULL || name == NULL)
+                return -EINVAL;
+
+        dirname = dirname_malloc(udev_device->syspath);
+        if (!dirname)
+                return -ENOMEM;
+
+        new_syspath = strappenda(dirname, "/", name);
+
+        r = udev_device_set_syspath(udev_device, new_syspath);
+        if (r < 0)
+                return r;
+
+        return 0;
+}