* Re: Silly udev script [was Re: udev and devfs - The final word]
2004-01-06 0:36 ` Silly udev script [was Re: udev and devfs - The final word] Greg KH
@ 2004-01-06 4:02 ` Kay Sievers
2004-01-10 1:04 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: Kay Sievers @ 2004-01-06 4:02 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1: Type: text/plain, Size: 1066 bytes --]
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
[-- Attachment #2: 01-cddb-name.diff --]
[-- Type: text/plain, Size: 1201 bytes --]
--- ../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";
}
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: Silly udev script [was Re: udev and devfs - The final word]
2004-01-06 0:36 ` Silly udev script [was Re: udev and devfs - The final word] Greg KH
2004-01-06 4:02 ` Kay Sievers
@ 2004-01-10 1:04 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2004-01-10 1:04 UTC (permalink / raw)
To: linux-hotplug
On Tue, Jan 06, 2004 at 05:02:34AM +0100, Kay Sievers wrote:
> 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
Doh, that's what I get for only trying it with a 1 word title cd, and
then adding error code after testing it...
Thanks, I've applied your fixes.
greg k-h
-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
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
^ permalink raw reply [flat|nested] 3+ messages in thread