From dbc60a0fcf2263388fadd88f584aa1fbaa9aa328 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Tue, 28 Nov 2006 23:19:58 +0000 Subject: - add a step to rename any temporarily renamed devices (#208740,#204803, #214817) --- initscripts.spec | 6 ++++-- src/rename_device.c | 31 +++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/initscripts.spec b/initscripts.spec index 8de59b71..c40ac202 100644 --- a/initscripts.spec +++ b/initscripts.spec @@ -1,6 +1,6 @@ Summary: The inittab file and the /etc/init.d scripts. Name: initscripts -Version: 8.45.9.EL +Version: 8.45.10.EL License: GPL Group: System Environment/Base Release: 1 @@ -193,8 +193,10 @@ rm -rf $RPM_BUILD_ROOT %ghost %attr(0664,root,utmp) /var/run/utmp %changelog +* Tue Nov 28 2006 Bill Nottingham 8.45.10.EL-1 +- add a step to rename any temporarily renamed devices (#208740, #204803, #214817) - rc.sysinit: fix reversed dmraid test (#216490) -- translation updates: pa +- translation updates (#216097) - don't automatically reload modules on module reomvals (#211474) * Fri Nov 3 2006 Bill Nottingham 8.45.9.EL-1 diff --git a/src/rename_device.c b/src/rename_device.c index cb960fc5..0ec08b46 100644 --- a/src/rename_device.c +++ b/src/rename_device.c @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -50,8 +51,15 @@ struct netdev { struct netdev *next; }; +struct tmp { + char *src; + char *target; + struct tmp *next; +}; + struct netdev *configs = NULL; struct netdev *devs = NULL; +struct tmp *tmplist = NULL; #if defined(__s390__) || defined(__s390x__) static int is_cdev(const struct dirent *dent) { @@ -294,6 +302,7 @@ void rename_device(char *src, char *target, struct netdev *current) { char *curdev; char *dev = NULL; struct netdev *i, *tmpdev; + char *fallback = NULL; hw = get_hwaddr(target); if (!hw) { @@ -309,14 +318,25 @@ void rename_device(char *src, char *target, struct netdev *current) { if (nconfig) { dev = nconfig; for (i = current; i; i = i->next) { - if (!strcmp(i->dev,dev)) + 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) @@ -364,7 +384,11 @@ void take_lock() { int main(int argc, char **argv) { char *src, *target, *hw; - + struct tmp *tmpdev; + struct timeval tv; + + gettimeofday(&tv, NULL); + srand(tv.tv_usec); take_lock(); signal(SIGSEGV,sighandler); @@ -388,6 +412,9 @@ int main(int argc, char **argv) { goto out_unlock; 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: -- cgit v1.2.1