aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBill Nottingham <notting@redhat.com>2006-11-28 23:11:04 +0000
committerBill Nottingham <notting@redhat.com>2006-11-28 23:11:04 +0000
commit6f233736fa8dfaabc83e4f77724453038e3dd7d0 (patch)
treef2861e48756404d1c543300f5bbf9caf02be17d2 /src
parente1f8f925745198e5a802d9577763586e70606820 (diff)
downloadinitscripts-6f233736fa8dfaabc83e4f77724453038e3dd7d0.tar
initscripts-6f233736fa8dfaabc83e4f77724453038e3dd7d0.tar.gz
initscripts-6f233736fa8dfaabc83e4f77724453038e3dd7d0.tar.bz2
initscripts-6f233736fa8dfaabc83e4f77724453038e3dd7d0.tar.xz
initscripts-6f233736fa8dfaabc83e4f77724453038e3dd7d0.zip
add a step to rename any temporarily renamed devices (#208740,
#204803, #214817)
Diffstat (limited to 'src')
-rw-r--r--src/rename_device.c31
1 files changed, 29 insertions, 2 deletions
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 <unistd.h>
#include <sys/ioctl.h>
+#include <sys/time.h>
#include <sys/types.h>
#include <linux/sockios.h>
@@ -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: