From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kay Sievers Date: Thu, 01 Apr 2004 00:41:29 +0000 Subject: Re: [PATCH] netdev - udevdb+dev.d changes Message-Id: <20040401004129.GB13247@vrfy.org> MIME-Version: 1 Content-Type: multipart/mixed; boundary="ZGiS0Q5IWpPtfppv" List-Id: References: <20040328184840.GA5877@vrfy.org> In-Reply-To: <20040328184840.GA5877@vrfy.org> To: linux-hotplug@vger.kernel.org --ZGiS0Q5IWpPtfppv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Mar 31, 2004 at 04:22:30PM -0800, Greg KH wrote: > On Thu, Apr 01, 2004 at 01:40:26AM +0200, Kay Sievers wrote: > > > > o We now only add a device to the db, if we have successfully created > > > > the main node or successfully renamed a netdev. This is the main part > > > > of the patch, cause I needed to clean the retval passing trough all > > > > the functions used for node creation. > > > > > > > > o DEVNODE sounds a bit ugly for netdev's so I exported DEVNAME too. > > > > Can we change the name? > > > > > > Can you think of a better name? > > > > I think DEVNAME sounds better for a netdev and is fine for a node too? > > What do you think? > > That's what I originally had, yet changed it to DEVNODE. But now that > we have network device support, it makes more sense to call it that. > Care to make a patch that does that too? Here we change the DEVPATH for netdev's in the environment of the dev.d/ scripts to the name the device is renamed to. The original name doesn't exist in the kernel after rename. Do you have anything already done for the man page for the new dev.d/ logic? If not, I will care. thanks, Kay --ZGiS0Q5IWpPtfppv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="01-DEVPATH-for-netdev.patch" ===== dev_d.c 1.4 vs edited ===== --- 1.4/dev_d.c Sun Mar 28 16:39:40 2004 +++ edited/dev_d.c Thu Apr 1 02:33:57 2004 @@ -61,7 +61,7 @@ * subsystem/ * default/ */ -void dev_d_send(struct udevice *dev, char *subsystem) +void dev_d_send(struct udevice *dev, char *subsystem, char *devpath) { char dirname[256]; char devname[NAME_SIZE]; @@ -74,8 +74,8 @@ strfieldcat(devname, dev->name); } else if (dev->type == 'n') { strfieldcpy(devname, dev->name); + setenv("DEVPATH", devpath, 1); } - setenv("DEVNODE", devname, 1); /* FIXME: bad name for netif */ setenv("DEVNAME", devname, 1); dbg("DEVNAME='%s'", devname); ===== udev-add.c 1.68 vs edited ===== --- 1.68/udev-add.c Sun Mar 28 22:12:39 2004 +++ edited/udev-add.c Thu Apr 1 02:12:35 2004 @@ -403,7 +403,7 @@ { struct sysfs_class_device *class_dev; struct udevice dev; - char key[DEVPATH_SIZE]; + char devpath[DEVPATH_SIZE]; char *pos; int retval; @@ -452,10 +452,11 @@ 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(&dev, subsystem, path); break; case 'n': - strfieldcpy(key, path); if (strcmp(dev.name, dev.kernel_name) != 0) { retval = rename_net_if(&dev, fake); if (fake || retval != 0) @@ -463,19 +464,19 @@ /* netif's are keyed with the configured name, cause * the original kernel name sleeps with the fishes */ - pos = strrchr(key, '/'); + strfieldcpy(devpath, path); + pos = strrchr(devpath, '/'); if (pos != NULL) { pos[1] = '\0'; - strfieldcat(key, dev.name); + strfieldcat(devpath, dev.name); } } - if (udevdb_add_dev(key, &dev) != 0) + if (udevdb_add_dev(devpath, &dev) != 0) dbg("udevdb_add_dev failed"); + + dev_d_send(&dev, subsystem, devpath); break; } - - /* execute programs in dev.d/ with the name in the environment */ - dev_d_send(&dev, subsystem); exit: sysfs_close_class_device(class_dev); ===== udev-remove.c 1.30 vs edited ===== --- 1.30/udev-remove.c Sun Mar 28 07:20:27 2004 +++ edited/udev-remove.c Thu Apr 1 02:12:56 2004 @@ -148,7 +148,7 @@ dbg("name='%s'", dev.name); dev.type = get_device_type(path, subsystem); - dev_d_send(&dev, subsystem); + dev_d_send(&dev, subsystem, path); udevdb_delete_dev(path); if (dev.type == 'b' || dev.type == 'c') ===== udev.h 1.56 vs edited ===== --- 1.56/udev.h Sun Mar 28 18:34:01 2004 +++ edited/udev.h Thu Apr 1 02:12:12 2004 @@ -65,7 +65,7 @@ extern int udev_remove_device(char *path, char *subsystem); extern void udev_init_config(void); extern int parse_get_pair(char **orig_string, char **left, char **right); -extern void dev_d_send(struct udevice *dev, char *subsystem); +extern void dev_d_send(struct udevice *dev, char *subsystem, char *devpath); extern char **main_argv; extern char **main_envp; ===== udev_config.c 1.16 vs edited ===== --- 1.16/udev_config.c Sun Mar 28 07:20:28 2004 +++ edited/udev_config.c Thu Apr 1 02:19:09 2004 @@ -86,13 +86,13 @@ #define set_var(_name, _var) \ if (strcasecmp(variable, _name) == 0) { \ - dbg_parse("%s = '%s'", _name, value); \ - strfieldcpymax(_var, value, sizeof(_var));\ + dbg_parse("%s='%s'", _name, value); \ + strfieldcpy(_var, value);\ } #define set_bool(_name, _var) \ if (strcasecmp(variable, _name) == 0) { \ - dbg_parse("%s = '%s'", _name, value); \ + dbg_parse("%s='%s'", _name, value); \ _var = string_is_true(value); \ } ===== udevd.c 1.27 vs edited ===== --- 1.27/udevd.c Sun Mar 28 03:48:23 2004 +++ edited/udevd.c Thu Apr 1 02:23:57 2004 @@ -139,8 +139,10 @@ char devpath[DEVPATH_SIZE]; char *env[] = { action, devpath, NULL }; - snprintf(action, sizeof(action), "ACTION=%s", msg->action); - snprintf(devpath, sizeof(devpath), "DEVPATH=%s", msg->devpath); + strcpy(action, "ACTION="); + strfieldcat(action, msg->action); + strcpy(devpath, "DEVPATH="); + strfieldcat(devpath, msg->devpath); pid = fork(); switch (pid) { ===== udevstart.c 1.5 vs edited ===== --- 1.5/udevstart.c Sat Mar 27 00:33:41 2004 +++ edited/udevstart.c Thu Apr 1 02:14:35 2004 @@ -33,6 +33,7 @@ #include #include "logging.h" +#include "udev_lib.h" #ifdef LOG @@ -61,8 +62,8 @@ char nosleep[] = "UDEV_NO_SLEEP=1"; char *env[] = { action, devpath, nosleep, NULL }; - snprintf(devpath, MAX_PATHLEN, "DEVPATH=%s", path); - devpath[MAX_PATHLEN-1] = '\0'; + strcpy(action, "DEVPATH=%s"); + strfieldcat(action, path); pid = fork(); switch (pid) { --ZGiS0Q5IWpPtfppv-- ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel