UDEV Rules Didn't Behave Like I Thought

Dan McGhee beesnees at grm.net
Tue Mar 7 16:21:37 PST 2006


Dan Nicholson wrote:
> On 3/7/06, Dan McGhee <beesnees at grm.net> wrote:
>   
>> My original set up were lines in /etc/udev/rules.d.  Here are
>> the relevant parts:
>>
>> /etc/udev/rules.d/24-dvd.rules
>> KERNEL="hdc", SYMLINK="dvd"
>>     
>
> I'm not the expert here, but I think you need SYMLINK+=dvd.  Then,
> udev will retain this in it's memory until later when it finds the
> BUS=="ide" rule that tells it how to actually create the device nodes.
>  I'm pretty sure if you read the how-to-write-udev-rules.html doc that
> came with udev, it says that if you want multiple symlinks, you need
> to use +=.
>   
Dan, I'm not trying to refute what you've said here, I'm trying to 
understand this system.  Maybe this is just one of those things that 
must be left "not understood completely" unless one takes a course 
UDEV-631. :-)

If I may be so bold as to quote from "Writing UDEV rules:

> Take the rule:
>
>     KERNEL="hdc", SYMLINK="dvd"
>
> When udev finds this rule, it will take a mental note of it. Upon 
> finding another rule matching the same device which also includes a 
> /NAME/ parameter, udev will create the node as specified by the /NAME/ 
> parameter, plus symbolic links as specified by the /SYMLINK/ 
> parameters of both rules.
> To put it into practical terms, when udev is naming nodes for my /hdc/ 
> device, it will use the default rules for block devices as usual, with 
> the addition of my personal symlink "dvd".
>
> Similarly to normal rules, rules of this type will only take effect if 
> udev is able to find them /before/ it finds a rule specifying a /NAME/ 
> parameter.
And from the man page:

=       Assign a value to a key.  Keys that represent a list, are reset 
and only this single value is assigned.
+=     Add the value to a key that holds a list of entries

So it looks like the article may be in error here. 

> BUS=="ide", KERNEL=="hd[a-z]", PROGRAM="/bin/cat /proc/ide/%k/media",
> RESULT=="cdrom", NAME="%k", GROUP:="optical", SYMLINK+="cdrom%e"
> BUS=="ide", KERNEL=="hd[a-z]", PROGRAM="/bin/grep '^PLEXTOR' /proc/ide/%k/model"
> , SYMLINK+="cdrw"
> BUS=="ide", KERNEL=="hd[a-z]", PROGRAM="/bin/grep '^PIONEER' /proc/ide/%k/model"
> , SYMLINK+="dvd"
> BUS=="ide", KERNEL=="hd[a-z]", PROGRAM="/bin/grep '^PIONEER' /proc/ide/%k/model"
> , SYMLINK+="dvdrw"
> #KERNEL="hdd", SYMLINK+="dvd"
>
>   
 From your setup, it looks like += circumvents the NAME key thing 
mentioned in the article because three of the four SYMLINKS come 
afterwards.  In my case, I used SYMLINK="cdrom dvd"  But then I have 
only one drive too.

But the weird thing in my case, considering the article, is that 
/dev/dvd was created and /dev/cdrom was not.  25-lfs.rules and the 
directions (I think it's in MPlayer in BLFs) for setting up the dvd 
rules, should work according to the article.  But they didn't for me.

I'm not going to lose sleep over this.  However, I find it quite 
interesting.  It's got to have been something I did, since, as I said in 
my original post, the same combination of UDEV rules works in my other 
LFS system.  The bottom line is I got what I wanted.

Thanks for the response.

Dan



More information about the blfs-support mailing list