From: Kay Sievers Date: Sat, 10 Mar 2007 13:28:13 +0000 Subject: Re: [PATCH] udev+ifrename integration Message-Id: <1173533294.5745.6.camel@pim.off.vrfy.org> MIME-Version: 1 Content-Type: multipart/mixed; boundary="=-VUK/eL834QlRCLxcPIVt" List-Id: References: <20070307194435.GA22264@bougret.hpl.hp.com> In-Reply-To: <20070307194435.GA22264@bougret.hpl.hp.com> To: linux-hotplug@vger.kernel.org --=-VUK/eL834QlRCLxcPIVt Content-Type: text/plain Content-Transfer-Encoding: 7bit On Fri, 2007-03-09 at 17:50 -0800, Jean Tourrilhes wrote: > On Fri, Mar 09, 2007 at 02:59:25PM +0100, Kay Sievers wrote: > > On Wed, 2007-03-07 at 13:11 -0800, Jean Tourrilhes wrote: > > > > Anyway, how about you add a "hotplug" option to ifrename to output all > > useful information in env-key format after its work, like: > > $ifrename --hotplug-use -i %k > > DEVPATH=/sys/class/net/renamed3 > > INTERFACE=renamed3 > > INTERFACE_OLD=eth1 > > > > and whatever information may be useful for the stuff that runs after the > > renaming, I'm sure you will find something more to export. :) > > > > Integration into udev would happen with the IMPORT= key. I would change > > udev to update all internal variables that carry the name, if DEVPATH is > > overwritten from an IMPORT action. How does that sound to you? > > Ok, I've just looked into doing that. I've implemented the > ifrename part in version 29.pre16. > The "proof of concept" patch for udev is attached. I've not > yet tested that patch, because I'm not sure this is the right > implementation and it makes me wonder if this is the right > solution. It's definitely more messy than the previous patch I sent. Oh, I think we should just match on a DEVPATH variable to import. Any external tool, not limited to the INTERFACE variable, that causes the kernel to change the devpath, would just need to pass the new value for udev to update all internal values like %k %n %p. Thanks, Kay --=-VUK/eL834QlRCLxcPIVt Content-Disposition: inline; filename=import-devpath.patch Content-Type: text/x-patch; name=import-devpath.patch; charset=utf-8 Content-Transfer-Encoding: 7bit diff --git a/udev_rules.c b/udev_rules.c index 200b4e7..7ab3bba 100644 --- a/udev_rules.c +++ b/udev_rules.c @@ -186,7 +186,13 @@ static int import_keys_into_env(struct u linepos = line; if (get_key(&linepos, &variable, &value) == 0) { dbg("import '%s=%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") == 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); } } --=-VUK/eL834QlRCLxcPIVt Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- 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=join.php&p=sourceforge&CID=DEVDEV --=-VUK/eL834QlRCLxcPIVt Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --=-VUK/eL834QlRCLxcPIVt--