+
+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 = strjoina(dirname, "/", name);
+
+ r = udev_device_set_syspath(udev_device, new_syspath);
+ if (r < 0)
+ return r;
+
+ 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;
+}
+
+struct udev_device *udev_device_new_from_nulstr(struct udev *udev, char *nulstr, ssize_t buflen) {
+ struct udev_device *device;
+ ssize_t bufpos = 0;
+
+ if (nulstr == NULL || buflen <= 0) {
+ errno = EINVAL;
+
+ return NULL;
+ }
+
+ device = udev_device_new(udev);
+ if (!device) {
+ errno = ENOMEM;
+
+ return NULL;
+ }
+
+ udev_device_set_info_loaded(device);
+
+ while (bufpos < buflen) {
+ char *key;
+ size_t keylen;
+
+ key = nulstr + bufpos;
+ keylen = strlen(key);
+ if (keylen == 0)
+ break;
+
+ bufpos += keylen + 1;
+ udev_device_add_property_from_string_parse(device, key);
+ }
+
+ if (udev_device_add_property_from_string_parse_finish(device) < 0) {
+ log_debug("missing values, invalid device");
+
+ udev_device_unref(device);
+
+ errno = EINVAL;
+
+ return NULL;
+ }
+
+ return device;
+}