From: Jean Tourrilhes Date: Thu, 15 Mar 2007 23:27:05 +0000 Subject: Re: [PATCH] udev+ifrename integration Message-Id: <20070315232705.GA12564@bougret.hpl.hp.com> List-Id: References: <20070307194435.GA22264@bougret.hpl.hp.com> In-Reply-To: <20070307194435.GA22264@bougret.hpl.hp.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: linux-hotplug@vger.kernel.org On Mon, Mar 12, 2007 at 05:51:04PM +0100, Kay Sievers wrote: > On Mon, 2007-03-12 at 09:07 -0700, Jean Tourrilhes wrote: >=20 > > Maybe a sample of rules would help me. >=20 > SUBSYSTEM=3D"net", ACTION=3D"add", IMPORT=3D"/sbin/ifrename --export -i %= k" >=20 > > Second, I don't see how this would prevent subsequent naming > > rules to apply. >=20 > We can make NAME=3D"" work, to prevent other NAME rules from matching. For > now NAME=3D"%k" may already work. Thanks for the help, I'm still learning about udev. It all make sense now. I've tested udev with your patch (see below) and the following udev rule and confirm that it works properly. --------------------------------- SUBSYSTEM=3D"net", ACTION=3D"add", IMPORT=3D"/sbin/ifrename -u -i %k", NAME= :=3D"%k" --------------------------------- If the interface is specified in /etc/iftab, the renaming is done and further rules ignored. If the interface is not in /etc/iftab, or if /etc/iftab does not exist, no renaming is done and further rule do apply. And it works properly at boot time. This allow smooth integration. I've released a new version of ifrename that fixes some devpath bugs. Also, with the additional fix in the attached patch, you can use udevtest like this : --------------------------------- ENV{UDEV_LOG}=3D"6", SUBSYSTEM=3D"net", ACTION=3D"add", IMPORT=3D"/sbin/ifr= ename -D -V -u -i %k", NAME:=3D"%k" --------------------------------- > Kay Thanks a lot ! Jean ------------------------------------------------------------------ diff -u -p udev-106/udev_rules.j1.c udev-106/udev_rules.c --- udev-106/udev_rules.j1.c 2007-03-15 10:07:51.000000000 -0700 +++ udev-106/udev_rules.c 2007-03-15 10:09:50.000000000 -0700 @@ -186,7 +186,16 @@ static int import_keys_into_env(struct u linepos =3D line; if (get_key(&linepos, &variable, &value) =3D 0) { dbg("import '%s=3D%s'", variable, value); - name_list_key_add(&udev->env_list, variable, value); + /* handle device, renamed by external tool, + * returning new path */ + if (strcmp(variable, "DEVPATH") =3D 0) { + info("updating devpath from '%s' to '%s'", + udev->dev->devpath, value); + sysfs_device_set_values(udev->dev, value, + NULL, NULL); + } else + name_list_key_add(&udev->env_list, + variable, value); setenv(variable, value, 1); } } diff -u -p udev-106/udevtest.j1.c udev-106/udevtest.c --- udev-106/udevtest.j1.c 2007-03-15 10:39:16.000000000 -0700 +++ udev-106/udevtest.c 2007-03-15 10:42:09.000000000 -0700 @@ -59,8 +59,13 @@ int main(int argc, char *argv[], char *e =20 info("version %s", UDEV_VERSION); udev_config_init(); - if (udev_log_priority < LOG_INFO) + if (udev_log_priority < LOG_INFO) { + char priority[32]; + udev_log_priority =3D LOG_INFO; + sprintf(priority, "%i", udev_log_priority); + setenv("UDEV_LOG", priority, 1); + } =20 for (i =3D 1 ; i < argc; i++) { char *arg =3D argv[i]; ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=DEVD= EV _______________________________________________ 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