diff options
author | Tom Gundersen <teg@jklm.no> | 2015-02-11 16:21:18 -0500 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2015-02-11 16:21:58 -0500 |
commit | b39a4a3aba7e8593684b6e44b0780c2439e84d7d (patch) | |
tree | e4cdb633a310bae4689a4f44b306e778b974b628 /src/libudev | |
parent | 691df3c5c399899a9fd6624f6148883cc20fa18a (diff) |
udev: event - move renaming of udev_device to libudev
This is not exposed in the public API. We want to simplify the internal libudev-device API as much as possible
so that it will be simpler to rip the whole thing out in the future.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/libudev')
-rw-r--r-- | src/libudev/libudev-device.c | 22 | ||||
-rw-r--r-- | src/libudev/libudev-private.h | 1 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c index 32c80cc9ec..8df84d9888 100644 --- a/src/libudev/libudev-device.c +++ b/src/libudev/libudev-device.c @@ -1988,3 +1988,25 @@ struct udev_device *udev_device_new_from_nulstr(struct udev *udev, char *nulstr, return device; } + +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; +} diff --git a/src/libudev/libudev-private.h b/src/libudev/libudev-private.h index 29df8df6c4..e8629e2446 100644 --- a/src/libudev/libudev-private.h +++ b/src/libudev/libudev-private.h @@ -45,6 +45,7 @@ uid_t udev_device_get_devnode_uid(struct udev_device *udev_device); gid_t udev_device_get_devnode_gid(struct udev_device *udev_device); int udev_device_set_subsystem(struct udev_device *udev_device, const char *subsystem); int udev_device_set_syspath(struct udev_device *udev_device, const char *syspath); +int udev_device_rename(struct udev_device *udev_device, const char *new_name); int udev_device_set_devnum(struct udev_device *udev_device, dev_t devnum); int udev_device_add_devlink(struct udev_device *udev_device, const char *devlink); void udev_device_cleanup_devlinks_list(struct udev_device *udev_device); |