Noob question about NAME rules

zll

Executive Member
Joined
Sep 1, 2005
Messages
7,319
Reaction score
4,312
Hi guys,

I am busy helping write a course on Linux, which I am slowly learning. I was wondering if someone could explain to me in the simplest terms possible what the use of uppercase NAME means:

If you want to create rules of your own, you should place them in a seperate file. The NAME rules that name devices are read lexically, where the first NAME rule will take precedence over any later ones. Only the first NAME rules for a device will be used. Later NAME rules for that same device will be ignored.

If I leave out the NAME part, I understand it as this:

The rules that name devices are read from lowest to highest, i.e the first set of rules will be used and later rules will be ignored. E.g. 10-rules.rules will be read before 20-rules.rules

I have tried to search net but can't find anything.
 
Thanks :confused:

Let me elaborate a bit more. It's about udev, specifically about creating udev rules. I am not sure if these guys using NAME is a linux thing or if it's something that they are just using in their book... I am leaning towards the latter.

Seriously, I hate people who over complicate things. I have this itching feeling that this is actually stupidly simple, but the way they have worded it makes it harder to understand than it should be!
 
udev deals with devices and the rules, obviously, with device rules, and it is correct, if there are multiple rules for say USB, then only the very first one will be honored. I think they meant to swap out "NAME" with "device name".

First you need to understand what udev does, and then you will know how to apply the rules.
From the man page:
udev provides a dynamic device directory containing only the files for
actually present devices. It creates or removes device node files in
the /dev directory, or it renames network interfaces.

Usually udev runs as udevd(8) and receives uevents directly from the
kernel if a device is added or removed from the system.

If udev receives a device event, it matches its configured rules
against the available device attributes provided in sysfs to identify
the device. Rules that match may provide additional device information
or specify a device node name and multiple symlink names and instruct
udev to run additional programs as part of the device event handling.
Rules:
The udev rules are read from the files located in the default rules
directory /lib/udev/rules.d/, the custom rules directory
/etc/udev/rules.d/ and the temporary rules directory
/dev/.udev/rules.d/. All rule files are sorted and processed in lexical
order, regardless in which of these directories they live.

Rule files are required to have a unique name, duplicate file names are
ignored. Files in /etc/udev/rules.d/ have precedence over files with
the same name in /lib/udev/rules.d/. This can be used to ignore a
default rules file if needed.

Every line in the rules file contains at least one key value pair.
There are two kind of keys, match and assignment keys. If all match
keys are matching against its value, the rule gets applied and the
assign keys get the specified value assigned.

A matching rule may specify the name of the device node, add a symlink
pointing to the node, or run a specified program as part of the event
handling. If no matching rule is found, the default device node name is
used.
There is much more, but I think this is the most relevant to what you want to know.
 
I sat with one of the guys over lunch and the best we can figure out is that it's a placeholder for a file. I.E. NAME = INSERT NAME OF FILE HERE. Thanks for the feedback tho.
 
I think NAME should actually be udev.

I could be wrong, but I'm sure I've seen this happen in documentation before. Maybe there is some broken indexing (or something) going on.
 
Top
Sign up to the MyBroadband newsletter
X