diff options
author | kay.sievers@vrfy.org <kay.sievers@vrfy.org> | 2004-10-18 19:28:39 -0700 |
---|---|---|
committer | Greg KH <gregkh@suse.de> | 2005-04-26 22:02:46 -0700 |
commit | 5d24c6ca364c6232efa626049b03d02c15ab5e85 (patch) | |
tree | 972572aae40413a0fb29f2b272a52e1f257c239e /dev_d.c | |
parent | 7a947ce51586fd4212447643df90580542777ab9 (diff) |
[PATCH] cleanup netif handling and netif-dev.d/ events
Here we supress the dev.d/ execution if we didn't change a network
interface's name with a rule. This should solve the issue of two
running dhclients for the same interface, cause the
/etc/dev.d/net/hotplug.dev script that fakes the hotplug event runs
with every udevstart for every interface and fakes a second identical
hotplug event on bootup.
With this patch netif interfaces are no longer stored in the udevdb.
It is not needed, cause we don't have permissions or symlinks :) and
all information is available in sysfs.
This patch also moves the dev_d execution calls out of the
udev_add/udev_remove. As with the former api-cleanup-patch we have
all processed data in one udev struct and can place the execution
calls where needed.
Diffstat (limited to 'dev_d.c')
-rw-r--r-- | dev_d.c | 37 |
1 files changed, 15 insertions, 22 deletions
@@ -62,7 +62,7 @@ static int run_program(char *name) execv(name, argv); dbg("exec of child failed"); - exit(1); + _exit(1); case -1: dbg("fork of child failed"); break; @@ -80,42 +80,35 @@ static int run_program(char *name) * subsystem/ * default/ */ -void dev_d_send(struct udevice *udev) +void dev_d_execute(struct udevice *udev) { - char dirname[256]; - char env_devname[NAME_SIZE]; - char *devname; + char dirname[PATH_MAX]; + char devname[NAME_SIZE]; char *temp; + /* skip if UDEV_NO_DEVD is set */ if (udev_dev_d == 0) return; - memset(env_devname, 0x00, sizeof(env_devname)); - if (udev->type == 'b' || udev->type == 'c') { - strfieldcpy(env_devname, udev_root); - strfieldcat(env_devname, udev->name); - } else if (udev->type == 'n') { - strfieldcpy(env_devname, udev->name); - setenv("DEVPATH", udev->devpath, 1); - } - setenv("DEVNAME", env_devname, 1); - dbg("DEVNAME='%s'", env_devname); - - devname = strdup(udev->name); - if (!devname) { - dbg("out of memory"); + /* skip if udev did nothing, like unchanged netif or no "dev" file */ + if (udev->devname[0] == '\0') return; - } + + /* add the node name or the netif name to the environment */ + setenv("DEVNAME", udev->devname, 1); + dbg("DEVNAME='%s'", udev->devname); + + strfieldcpy(devname, udev->name); /* Chop the device name up into pieces based on '/' */ temp = strchr(devname, '/'); while (temp != NULL) { - *temp = 0x00; + temp[0] = '\0'; strcpy(dirname, DEVD_DIR); strfieldcat(dirname, devname); call_foreach_file(run_program, dirname, DEVD_SUFFIX); - *temp = '/'; + temp[0] = '/'; ++temp; temp = strchr(temp, '/'); } |