diff options
author | Bill Nottingham <notting@redhat.com> | 2007-10-05 17:57:44 +0000 |
---|---|---|
committer | Bill Nottingham <notting@redhat.com> | 2007-10-05 17:57:44 +0000 |
commit | 3e634c64683b759a68388b62337fb3c5547faa52 (patch) | |
tree | f521e347520845282abf3c531e0ffde390a17c63 /src | |
parent | 35b965fc7c9afd05515869345eb44f2b851fdd00 (diff) | |
download | initscripts-3e634c64683b759a68388b62337fb3c5547faa52.tar initscripts-3e634c64683b759a68388b62337fb3c5547faa52.tar.gz initscripts-3e634c64683b759a68388b62337fb3c5547faa52.tar.bz2 initscripts-3e634c64683b759a68388b62337fb3c5547faa52.tar.xz initscripts-3e634c64683b759a68388b62337fb3c5547faa52.zip |
just suggest an interface name, don't do actual renaming
Diffstat (limited to 'src')
-rw-r--r-- | src/rename_device.c | 89 |
1 files changed, 3 insertions, 86 deletions
diff --git a/src/rename_device.c b/src/rename_device.c index 8fb06997..7b3b3699 100644 --- a/src/rename_device.c +++ b/src/rename_device.c @@ -269,84 +269,6 @@ char *get_device_by_hwaddr(char *hwaddr) { return NULL; } -int do_rename(char *src, char *target) { - int sock; - struct ifreq ifr; - int ret; - - sock = socket(PF_INET, SOCK_DGRAM, 0); - if (sock == -1) - return 1; - - memset(&ifr,'\0', sizeof(struct ifreq)); - g_strlcpy(ifr.ifr_name, src, IFNAMSIZ); - g_strlcpy(ifr.ifr_newname, target, IFNAMSIZ); - ret = ioctl(sock, SIOCSIFNAME, &ifr); - close(sock); - return ret; -} - - -void rename_device(char *src, char *target, struct netdev *current) { - int rc; - - if (!current) { - current = calloc(1, sizeof(struct netdev)); - current->dev = src; - } - - rc = do_rename(src, target); - if (rc && errno != ENODEV) { - char *hw; - char *nconfig; - char *curdev; - char *dev = NULL; - struct netdev *i, *tmpdev; - char *fallback = NULL; - - hw = get_hwaddr(target); - if (!hw) { - devs = get_devs(); - hw = get_hwaddr(target); - if (!hw) - return; - } - - nconfig = get_config_by_hwaddr(hw, NULL); - curdev = get_device_by_hwaddr(hw); - - if (nconfig) { - dev = nconfig; - for (i = current; i; i = i->next) { - if (!strcmp(i->dev,dev)) { - fallback = dev; - dev = NULL; - } - } - } - if (!dev) - asprintf(&dev,"__tmp%d",rand()); - if (!dev) - return; - if (fallback) { - struct tmp *ntmp = calloc(1, sizeof(struct tmp)); - - ntmp->src = strdup(dev); - ntmp->target = strdup(fallback); - if (tmplist) - ntmp->next = tmplist; - tmplist = ntmp; - } - tmpdev = calloc(1,sizeof(struct netdev)); - tmpdev->dev = curdev; - if (current) - tmpdev->next = current; - current = tmpdev; - rename_device(curdev, dev, current); - do_rename(src,target); - } -} - void take_lock() { int count = 0; int lockfd; @@ -384,7 +306,6 @@ void take_lock() { int main(int argc, char **argv) { char *src, *target, *hw; - struct tmp *tmpdev; struct timeval tv; gettimeofday(&tv, NULL); @@ -408,15 +329,11 @@ int main(int argc, char **argv) { if (!hw) goto out_unlock; target = get_config_by_hwaddr(hw, src); - if (!target || !strcmp(src,target)) + if (!target) goto out_unlock; + + printf("%s", target); - rename_device(src, target, NULL); - for (tmpdev = tmplist; tmpdev ; tmpdev = tmpdev->next) { - rename_device(tmpdev->src, tmpdev->target, NULL); - } - printf("INTERFACE=%s\n",target); - printf("DEVPATH=/class/net/%s\n", target); out_unlock: unlink(LOCKFILE); exit(0); |