From eb5b86405b14ca2ac2508f9dec9862cc57110131 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Mon, 19 Mar 2007 09:56:53 +0100 Subject: [PATCH] update %n on netif name change --- udev_device.c | 11 +++++++---- udev_rules.c | 2 +- udev_sysfs.c | 1 - 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/udev_device.c b/udev_device.c index 24f65ca0..03514e1d 100644 --- a/udev_device.c +++ b/udev_device.c @@ -204,6 +204,7 @@ int udev_device_event(struct udev_rules *rules, struct udevice *udev) /* look if we want to change the name of the netif */ if (strcmp(udev->name, udev->dev->kernel) != 0) { + char devpath[PATH_MAX]; char *pos; retval = rename_netif(udev); @@ -214,14 +215,16 @@ int udev_device_event(struct udev_rules *rules, struct udevice *udev) /* export old name */ setenv("INTERFACE_OLD", udev->dev->kernel, 1); - /* now fake the devpath, because the kernel name changed silently */ - pos = strrchr(udev->dev->devpath, '/'); + /* now change the devpath, because the kernel device name has changed */ + strlcpy(devpath, udev->dev->devpath, sizeof(devpath)); + pos = strrchr(devpath, '/'); if (pos != NULL) { pos[1] = '\0'; - strlcat(udev->dev->devpath, udev->name, sizeof(udev->dev->devpath)); - strlcpy(udev->dev->kernel, udev->name, sizeof(udev->dev->kernel)); + strlcat(devpath, udev->name, sizeof(devpath)); + sysfs_device_set_values(udev->dev, devpath, NULL, NULL); setenv("DEVPATH", udev->dev->devpath, 1); setenv("INTERFACE", udev->name, 1); + info("changed devpath to '%s'", udev->dev->devpath); } } goto exit; diff --git a/udev_rules.c b/udev_rules.c index ea02b8e9..f8844a84 100644 --- a/udev_rules.c +++ b/udev_rules.c @@ -289,7 +289,7 @@ static int wait_for_sysfs(struct udevice *udev, const char *file, int timeout) info("file '%s' appeared after %i loops", filepath, (timeout * WAIT_LOOP_PER_SECOND) - loop-1); return 0; } - /* make sure the device does not have disappeared in the meantime */ + /* make sure, the device did not disappear in the meantime */ if (stat(devicepath, &stats) != 0) { info("device disappeared while waiting for '%s'", filepath); return -2; diff --git a/udev_sysfs.c b/udev_sysfs.c index 7431dd61..1846a42f 100644 --- a/udev_sysfs.c +++ b/udev_sysfs.c @@ -92,7 +92,6 @@ void sysfs_device_set_values(struct sysfs_device *dev, const char *devpath, pos = strrchr(dev->devpath, '/'); if (pos == NULL) return; - strlcpy(dev->kernel, &pos[1], sizeof(dev->kernel)); dbg("kernel='%s'", dev->kernel); -- 2.39.5