linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kay Sievers <kay.sievers@vrfy.org>
To: linux-hotplug@vger.kernel.org
Subject: Re: Silly udev script [was Re: udev and devfs - The final word]
Date: Tue, 06 Jan 2004 04:02:34 +0000	[thread overview]
Message-ID: <20040106040234.GA10384@vrfy.org> (raw)
In-Reply-To: <20040106003614.GA1043@kroah.com>

[-- 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";
 }

  reply	other threads:[~2004-01-06  4:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20040104034934.A3669@pclin040.win.tue.nl>
     [not found] ` <Pine.LNX.4.58.0401031856130.2162@home.osdl.org>
     [not found]   ` <20040104142111.A11279@pclin040.win.tue.nl>
     [not found]     ` <Pine.LNX.4.58.0401041302080.2162@home.osdl.org>
     [not found]       ` <20040104230104.A11439@pclin040.win.tue.nl>
     [not found]         ` <Pine.LNX.4.58.0401041847370.2162@home.osdl.org>
     [not found]           ` <20040105030737.GA29964@nevyn.them.org>
     [not found]             ` <Pine.LNX.4.58.0401041918260.2162@home.osdl.org>
     [not found]               ` <20040105132756.A975@pclin040.win.tue.nl>
     [not found]                 ` <Pine.LNX.4.58.0401050749490.21265@home.osdl.org>
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 [this message]
2004-01-10  1:04                     ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040106040234.GA10384@vrfy.org \
    --to=kay.sievers@vrfy.org \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).