From: md@Linux.IT (Marco d'Itri) Date: Wed, 21 Dec 2005 18:04:08 +0000 Subject: Re: [PATCH] The Mandriva Collection Message-Id: <20051221180408.GB11094@wonderland.linux.it> MIME-Version: 1 Content-Type: multipart/mixed; boundary="ibTvN161/egqYuK8" List-Id: References: In-Reply-To: To: linux-hotplug@vger.kernel.org --ibTvN161/egqYuK8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Dec 21, Olivier Blin wrote: > It's often more convenient to write hotplug maps, because it allows to > gather all devices IDs in one file, without RUN settings duplication. If you want to go for convenience then you should just have a list of VID/PID pairs to be used to generate maps and rules, which is what most applications apparently do. > You have some perl program to write the rules, what does it take as > input? Maybe it can packaged with udev (IIRC, you're currently > shipping this script in all your packages using it). My program just parses the file provided by the package with the list of supported devices and is barely about the "quick hack" level, I do not think it's much interesting but here it is. -- ciao, Marco --ibTvN161/egqYuK8 Content-Type: text/x-perl; charset=us-ascii Content-Disposition: attachment; filename="build_rules.pl" #!/usr/bin/perl -w # build a udev rules file from the devices list in modules.db use strict; my %seen; print <) { chomp; next if /^#/ or /^$/; s/\t(\(#\d\))\t/ $1\t/; /^([^\t]+)\t+([\da-fA-F]{4})\t+([\da-fA-F]{4})\t+([\da-fA-F]{4})\t+([\da-fA-F]{4})\t+(GS\d{4})\t+(\d)\t+(\d)$/ or die "Cannot parse the following line:\n$_\n"; my ($device, $vid1, $pid1, $vid2, $pid2, $chip, $altsync, $altpppoeci) = ($1, $2, $3, $4, $5, $6, $7, $8); # suppress duplicated devices next if $seen{$vid1.$pid1.$vid2.$pid2.$chip.$altsync.$altpppoeci}; $seen{$vid1.$pid1.$vid2.$pid2.$chip.$altsync.$altpppoeci} = 1; # Some devices have the same VID and PID but require different alt # parameters. Their owners are out of luck, and will need to manually # fix their configuration. next if $device =~ /^Linkmax HSA 100$/; # sanity check die "DUPLICATE: $device!\n" if $seen{$vid1.$pid1} or $seen{$vid2.$pid2}; $seen{$vid1.$pid1} = 1; $seen{$vid2.$pid2} = 1; print "# $device\n"; print <<"END" if $vid1.$pid1 ne $vid2.$pid2; SYSFS{idVendor}=="$vid1", SYSFS{idProduct}=="$pid1", \\ RUN+="/lib/hotplug/eciadsl stage1" END print <<"END"; SYSFS{idVendor}=="$vid2", SYSFS{idProduct}=="$pid2", \\ RUN+="/lib/hotplug/eciadsl stage2 $altsync $chip" END } print <