summaryrefslogtreecommitdiff
path: root/udev_add.c
diff options
context:
space:
mode:
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>2004-10-18 19:28:39 -0700
committerGreg KH <gregkh@suse.de>2005-04-26 22:02:46 -0700
commit5d24c6ca364c6232efa626049b03d02c15ab5e85 (patch)
tree972572aae40413a0fb29f2b272a52e1f257c239e /udev_add.c
parent7a947ce51586fd4212447643df90580542777ab9 (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 'udev_add.c')
-rw-r--r--udev_add.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/udev_add.c b/udev_add.c
index d07120de62..809a33cedb 100644
--- a/udev_add.c
+++ b/udev_add.c
@@ -355,7 +355,7 @@ int udev_add_device(struct udevice *udev, struct sysfs_class_device *class_dev)
retval = get_major_minor(class_dev, udev);
if (retval != 0) {
dbg("no dev-file found, do nothing");
- goto close;
+ return 0;
}
}
@@ -365,45 +365,44 @@ int udev_add_device(struct udevice *udev, struct sysfs_class_device *class_dev)
dbg("adding name='%s'", udev->name);
selinux_init();
- switch (udev->type) {
- case 'b':
- case 'c':
+
+ if (udev->type == 'b' || udev->type == 'c') {
retval = create_node(udev);
if (retval != 0)
goto exit;
- if ((!udev->test_run) && (udevdb_add_dev(udev) != 0))
- dbg("udevdb_add_dev failed, but we are going to try "
- "to create the node anyway. But remove might not "
- "work properly for this device.");
- dev_d_send(udev);
- break;
+ if (udevdb_add_dev(udev) != 0)
+ dbg("udevdb_add_dev failed, but we create the node anyway, "
+ "remove might not work for custom names");
- case 'n':
+ /* use full path to the environment */
+ snprintf(udev->devname, NAME_SIZE-1, "%s%s", udev_root, udev->name);
+
+ } else if (udev->type == 'n') {
+ /* look if we want to change the name of the netif */
if (strcmp(udev->name, udev->kernel_name) != 0) {
retval = rename_net_if(udev);
if (retval != 0)
goto exit;
- /* netif's are keyed with the configured name, cause
- * the original kernel name sleeps with the fishes
+
+ /* we've changed the name, now fake the devpath,
+ * cause original kernel name sleeps with the fishes
+ * and we don't get any event from the kernel now
*/
pos = strrchr(udev->devpath, '/');
if (pos != NULL) {
pos[1] = '\0';
strfieldcat(udev->devpath, udev->name);
+ setenv("DEVPATH", udev->devpath, 1);
}
- }
- if ((!udev->test_run) && (udevdb_add_dev(udev) != 0))
- dbg("udevdb_add_dev failed");
- dev_d_send(udev);
- break;
+ /* use netif name for the environment */
+ strfieldcpy(udev->devname, udev->name);
+ }
}
exit:
selinux_restore();
-close:
- sysfs_close_class_device(class_dev);
return retval;
}