From: Kay Sievers <kay.sievers@vrfy.org>
To: linux-hotplug@vger.kernel.org
Subject: Re: [PATCH] netdev - udevdb+dev.d changes
Date: Thu, 01 Apr 2004 00:41:29 +0000 [thread overview]
Message-ID: <20040401004129.GB13247@vrfy.org> (raw)
In-Reply-To: <20040328184840.GA5877@vrfy.org>
[-- Attachment #1: Type: text/plain, Size: 1160 bytes --]
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
[-- Attachment #2: 01-DEVPATH-for-netdev.patch --]
[-- Type: text/plain, Size: 4550 bytes --]
===== 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 <unistd.h>
#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) {
next prev parent reply other threads:[~2004-04-01 0:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-28 18:48 [PATCH] netdev - udevdb+dev.d changes Kay Sievers
2004-03-31 23:14 ` Greg KH
2004-03-31 23:40 ` Kay Sievers
2004-04-01 0:22 ` Greg KH
2004-04-01 0:41 ` Kay Sievers [this message]
2004-04-01 1:02 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040401004129.GB13247@vrfy.org \
--to=kay.sievers@vrfy.org \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).