UDEV Rules Didn't Behave Like I Thought

Dan Nicholson dbn.lists at gmail.com
Tue Mar 7 16:38:54 PST 2006


On 3/7/06, Dan McGhee <beesnees at grm.net> wrote:
> Dan, I'm not trying to refute what you've said here, I'm trying to
> understand this system.

I understand.  I think I groped through the exact same way you did.

> If I may be so bold as to quote from "Writing UDEV rules:
<snip>
> 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.

I think you're right.  I should have looked again.  I did get that
info about += from the man page after reading that the html file
applies to udev-058 or something (still haven't looked at it again).

> > 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.

I believe that since I set SYMLINK+= in the first rule, udev will
continue to try to apply SYMLINK keys for that named device.  Your
solution would work, too.  You could also try OPTIONS="last_rule" if
you want to put everything in one rule.

> 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.

This seems to follow what the man page says.  Since SYMLINK="dvd"
comes first, anything following that for the same identified device
won't have the SYMLINK key respected.

> 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.

I think from reading the man page you will get the most accurate
information.  The online version of the html file
(http://reactivated.net/writing_udev_rules.html) says that it was
written with udev-056.

This one rule would work for you (I think):

KERNEL==hdc, NAME=%k, GROUP=cdrom, SYMLINK="dvd cdrom", OPTIONS="last_rule"

Now I've confused myself.  I shouldn't be talking here because I
really don't know udev that well.  Certainly not for educating people.

--
Dan



More information about the blfs-support mailing list