Skip to contentSkip to conversation

Clarification on /etc/udev/rules.d processing

DISCUSSION Kevin P. Fleming 3 participants 4 messages Apr 21, 2004

lore
Share & tools
lore
#0 lore raw

I've just started using udev, and I've decided I'd much rather have individual config files for various purposes in /etc/udev/rules.d rather than one combined file.

From my reading of the code, it appears that udev always reads all the
files in that directory (which is good), and they are read in readdir() order which should mean I can control the order by using alphanumeric sorting of the names (also good).

What I'm not clear on is how udev will handle multiple rules that match for a given device: if more than one rule wants to provide a device name, I presume udev will stop looking for device name rules as soon as any rules matches, right? In spite of that, rules that add symlinks to a device seem to always be processed even if they appear in the file after the rule that supplied the device name. I think this is the correct behavior, but I want to make sure it's the _expected_ behavior, not just "unspecified behavior" that could change at any time.

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#1 lore raw
Quoted 9 lines · Kevin P. Fleming

I've just started using udev, and I've decided I'd much rather have individual config files for various purposes in /etc/udev/rules.d rather than one combined file.

From my reading of the code, it appears that udev always reads all the files in that directory (which is good), and they are read in readdir() order which should mean I can control the order by using alphanumeric sorting of the names (also good).

Quoted 4 lines

What I'm not clear on is how udev will handle multiple rules that match for a given device: if more than one rule wants to provide a device name, I presume udev will stop looking for device name rules as soon as any rules matches, right?

Yes.

Quoted 3 lines

In spite of that, rules that add symlinks to a
device seem to always be processed even if they appear in the file after the rule that supplied the device name.

No, if NAME is set by a rule, the processing is stopped. No later "symlink only" rule will be applied.

thanks,
Kay

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#2 lore raw
In reply to Kevin P. Fleming
Quoted 2 lines · Kay Sievers

No, if NAME is set by a rule, the processing is stopped. No later "symlink only" rule will be applied.

Any chance that behavior could be changed? For example, the current udev default rules file creates

/dev/device-mapper

for the device mapper control device. However, the recent standard location for that is

/dev/mapper/control

It is simple enough to create a SYMLINK rule to create this node, and it works fine. However, when using multiple rules files (in /etc/udev/rules.d), I'll have to ensure that the file containing my SYMLINK rule always gets processed before the one containing the NAME rule. I can do that, but it seems an unnecessary restriction.

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#3 lore raw
In reply to Kevin P. Fleming
Quoted 3 lines · Kevin P. Fleming

/etc/udev/rules.d), I'll have to ensure that the file containing my SYMLINK rule always gets processed before the one containing the NAME rule. I can do that, but it seems an unnecessary restriction.

Agreed, this is very annoying.

Signature · 13 lines
ciao, |
Marco | [5877 sev.CLHBjFpPY]


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel