From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kay Sievers Date: Tue, 06 Jan 2004 04:02:34 +0000 Subject: Re: Silly udev script [was Re: udev and devfs - The final word] Message-Id: <20040106040234.GA10384@vrfy.org> MIME-Version: 1 Content-Type: multipart/mixed; boundary="JP+T4n/bALQSJXh8" List-Id: References: <20040106003614.GA1043@kroah.com> In-Reply-To: <20040106003614.GA1043@kroah.com> To: linux-hotplug@vger.kernel.org --JP+T4n/bALQSJXh8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Jan 05, 2004 at 04:36:14PM -0800, Greg KH wrote: > On Mon, Jan 05, 2004 at 08:13:26AM -0800, Linus Torvalds wrote: > > [ Yeah, that sounds like a singularly silly thing to do, but it's a good > > example of something where there is no actual serial number, but you can > > "identify" it automatically through its contents, and name it stably > > according to that. ] > > That was such a silly thing to do, here's a script that does it, along > with the udev rule to add to udev.rules for it. It names your cdrom > Artist_Title, and creates a symlink called cdrom that points to it, just > to be a tiny bit sane :) Hey, this is funny. I couldn't resist to give it a try and we need a few changes: - it's %2c otherwise nearly all my CD's are "good", but sure I also have bad ones :) - remove the node first, cause get_cddb() dies and leaves the old one there - remove spaces in name, cause this is our separator /udev/ |-- The_Cure-The_Peel_Sessions |-- cdrom -> ./The_Cure-The_Peel_Sessions |-- hda |-- hda1 |-- hda2 |-- hda4 thanks, Kay --JP+T4n/bALQSJXh8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="01-cddb-name.diff" --- ../udev/extras/name_cdrom.pl 2004-01-06 04:15:31.000000000 +0100 +++ extras/name_cdrom.pl 2004-01-06 04:34:45.000000000 +0100 @@ -2,8 +2,8 @@ # a horribly funny script that shows how flexible udev can really be # This is to be executed by udev with the following rules: -# CALLOUT, BUS="ide", PROGRAM="name_cdrom.pl %M %m", ID="good*", NAME="%1c", SYMLINK="cdrom" -# CALLOUT, BUS="scsi", PROGRAM="name_cdrom.pl %M %m", ID="good*", NAME="%1c", SYMLINK="cdrom" +# CALLOUT, BUS="ide", PROGRAM="name_cdrom.pl %M %m", ID="good*", NAME="%2c", SYMLINK="cdrom" +# CALLOUT, BUS="scsi", PROGRAM="name_cdrom.pl %M %m", ID="good*", NAME="%2c", SYMLINK="cdrom" # # The scsi rule catches USB cdroms and ide-scsi devices. # @@ -27,9 +27,10 @@ $minor = $ARGV[1]; # create our temp device node to read the cd info from +unlink($dev_node); if (system("mknod $dev_node b $major $minor")) { die "bad mknod failed"; - } +} # get it on my %cd=get_cddb(\%config); @@ -41,5 +42,7 @@ unless(defined $cd{title}) { print"bad unknown cdrom\n"; } else { - print "good $cd{artist}_$cd{title}\n"; + $cd{artist} =~ s/ /_/g; + $cd{title} =~ s/ /_/g; + print "good $cd{artist}-$cd{title}\n"; } --JP+T4n/bALQSJXh8-- ------------------------------------------------------- This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&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