summaryrefslogtreecommitdiff
path: root/src/udev
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-02-11 16:21:18 -0500
committerAnthony G. Basile <blueness@gentoo.org>2015-02-11 16:21:58 -0500
commitb39a4a3aba7e8593684b6e44b0780c2439e84d7d (patch)
treee4cdb633a310bae4689a4f44b306e778b974b628 /src/udev
parent691df3c5c399899a9fd6624f6148883cc20fa18a (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/udev')
-rw-r--r--src/udev/udev-event.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index 7bd625495c..99b079f048 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -862,26 +862,27 @@ void udev_event_execute_rules(struct udev_event *event,
sigmask);
/* rename a new network interface, if needed */
- int r;
if (udev_device_get_ifindex(dev) > 0 && streq(udev_device_get_action(dev), "add") &&
event->name != NULL && !streq(event->name, udev_device_get_sysname(dev))) {
- char syspath[UTIL_PATH_SIZE];
- char *pos;
- char *finalifname = event->name;
+ int r;
r = rename_netif(event);
- if (r >= 0) {
- /* remember old name */
- udev_device_add_property(dev, "INTERFACE_OLD", udev_device_get_sysname(dev));
+ if (r < 0)
+ log_warning_errno(r, "could not rename interface '%d' from '%s' to '%s': %m", udev_device_get_ifindex(dev),
+ udev_device_get_sysname(dev), event->name);
+ else {
+ const char *interface_old;
- /* now change the devpath, because the kernel device name has changed */
- strscpy(syspath, sizeof(syspath), udev_device_get_syspath(dev));
- pos = strrchr(syspath, '/');
- if (pos != NULL) {
- pos++;
- strscpy(pos, sizeof(syspath) - (pos - syspath), finalifname);
- udev_device_set_syspath(event->dev, syspath);
- udev_device_add_property(dev, "INTERFACE", udev_device_get_sysname(dev));
+ /* remember old name */
+ interface_old = udev_device_get_sysname(dev);
+
+ r = udev_device_rename(dev, event->name);
+ if (r < 0)
+ log_warning_errno(r, "renamed interface '%d' from '%s' to '%s', but could not update udev_device: %m",
+ udev_device_get_ifindex(dev), udev_device_get_sysname(dev), event->name);
+ else {
+ udev_device_add_property(dev, "INTERFACE_OLD", interface_old);
+ udev_device_add_property(dev, "INTERFACE", event->name);
log_debug("changed devpath to '%s'", udev_device_get_devpath(dev));
}
}