LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices

Reply
 
Search this Thread
Old 09-24-2008, 09:30 PM   #1
arctgx
LQ Newbie
 
Registered: Dec 2007
Location: Brodnica, Poland
Distribution: Debian testing
Posts: 10

Rep: Reputation: 0
Why UDEV ignores multiple rules for the same device?


I have created two experimental rules for one device sda1.
Code:
KERNEL=="sda1", \
	NAME="%k", \
	ATTRS{serial}=="0000000272",\
	SYMLINK+="pendr-eqe"

KERNEL=="sda1", \
	NAME="%k", \
	ATTRS{serial}=="0000000272",\
	SYMLINK+="pendr-eqs"
In my opinion, udev should create two symlink pointing to sda1 after sending uevent to it or executing udevadm test --force /block/sda/sda1.

Only one, first symlink is created. Why the second is ignored?

OK, I know that it is possible to put two link names in one SYMLINK key (SYMLINK+="pendr-eqe pendr-eqs"), but I would like to know why the first method doesn't work.

My udev version is 0.125-6 from Debian.

Last edited by arctgx; 09-24-2008 at 09:38 PM. Reason: small typo
 
Old 09-25-2008, 08:25 AM   #2
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,791
Blog Entries: 1

Rep: Reputation: 414Reputation: 414Reputation: 414Reputation: 414Reputation: 414
A complete guess on my part, but I suspect that udev simply executes the first rule it find that matches the device and doesn't look for other rules that may match.
 
Old 09-25-2008, 12:04 PM   #3
arctgx
LQ Newbie
 
Registered: Dec 2007
Location: Brodnica, Poland
Distribution: Debian testing
Posts: 10

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Hangdog42 View Post
A complete guess on my part, but I suspect that udev simply executes the first rule it find that matches the device and doesn't look for other rules that may match.
Then what is the sense of existing the "last_rule" option?
 
Old 09-25-2008, 04:50 PM   #4
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,791
Blog Entries: 1

Rep: Reputation: 414Reputation: 414Reputation: 414Reputation: 414Reputation: 414
Hey, I said it was a guess. It turns out it was a wrong one however:


Quote:
One device can be matched by more than one rule. This has it's practical advantages, for example, we can write two rules which match the same device, where each one provides its own alternate name for the device. Both alternate names will be created, even if the rules are in separate files. It is important to understand that udev will not stop processing when it finds a matching rule, it will continue searching and attempt to apply every rule that it knows about.
The above quote is from this site, so apparently you are allowed to do what you're trying to do. As to why yours doesn't work, try reversing the order and see if the first one is still the only one executed. According to the site I linked to, the += operator should be appending to a list of names pointing to the original device, however I suppose it is possible that by having two rules, the second time the list gets "appended" it gets wiped out and recreated instead.
 
Old 09-25-2008, 07:58 PM   #5
arctgx
LQ Newbie
 
Registered: Dec 2007
Location: Brodnica, Poland
Distribution: Debian testing
Posts: 10

Original Poster
Rep: Reputation: 0
Independently of the order of rules, after reloading database and running udevadm test, only the first rule is executed.

Maybe this behaviour of udevd is a small bug. I should test a present or the recent version on another distro.

Sorry if my post sounded like I think that your comment would be statement, not supposition. I am still a beginner in writing English This may be cause of many misunderstandings in the future.
 
Old 01-16-2013, 06:47 AM   #6
slack32
LQ Newbie
 
Registered: Apr 2012
Distribution: Slackware
Posts: 19

Rep: Reputation: Disabled
i have similar problem. use udev 182.
But my problem is, i have multiple GROUP= directive on separate .rules files for the same device. one on /etc/udev/rules.d/, the other on /lib/udev/rules.d. i want the rules on /etc/udev/rules.d/ takes higher priority and then no other rules follow. This could be achieved with OPTIONS="last_rule". But newer udev seems dropped the "last_rule" directive.

Is there any other way ?

Last edited by slack32; 01-16-2013 at 06:55 AM.
 
  


Reply

Tags
udev rules


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cat: /etc/udev/rules.d/70-persistent-net.rules: No such file or directory rcg1984 Linux From Scratch 2 09-17-2008 08:02 AM
udev.rules & ttyS0 device lordwolf Slackware 8 05-26-2008 10:01 PM
Udev rules not holding for device binarybob0001 Linux - Software 6 04-14-2007 05:04 PM
Multiple External camera flash memory card readers, udev rules best way? Old_Fogie Slackware 1 11-02-2006 07:18 AM
udev rules, finding the kernel name of a device? rignes Linux - Software 2 11-07-2005 12:42 AM


All times are GMT -5. The time now is 12:47 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration