07.06.2014 Views

2 - Raspberry PI Community Projects

2 - Raspberry PI Community Projects

2 - Raspberry PI Community Projects

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

• ACTION: the action corresponding to the event (“add” when a device has been added,<br />

“remove” when it has been removed);<br />

• DEVPATH: the path of the device's /sys/ entry;<br />

• SUBSYSTEM: the kernel subsystem which generated the request (there are many, but a<br />

few examples are “usb”, “ide”, “net”, “firmware”, etc.);<br />

• ATTR{aribut}: file contents of the attribute file in the /sys/$devpath/ directory of the<br />

device. This is where you find the MAC address and other bus specific identifiers;<br />

• KERNELS, SUBSYSTEMS and ATTRS{aributes} are variations that will try to match the<br />

different options on one of the parent devices of the current device;<br />

• PROGRAM: delegates the test to the indicated program (true if it returns 0, false if not).<br />

The content of the program's standard output is stored so that it can be reused by the<br />

RESULT test;<br />

• RESULT: execute tests on the standard output stored during the last call to PROGRAM.<br />

The right operands can use pattern expressions to match several values at the same time. For<br />

instance, * matches any string (even an empty one); ? matches any character, and [] matches<br />

the set of characters listed between the square brackets (or the opposite thereof if the first<br />

character is an exclamation point, and contiguous ranges of characters are indicated like a-z).<br />

Regarding the assignment operators, = assigns a value (and replaces the current value); in the<br />

case of a list, it is emptied and contains only the value assigned. := does the same, but prevents<br />

later changes to the same variable. As for +=, it adds an item to a list. The following variables<br />

can be changed:<br />

• NAME: the device filename to be created in /dev/. Only the first assignment counts; the<br />

others are ignored;<br />

• SYMLINK: the list of symbolic links that will point to the same device;<br />

• OWNER, GROUP and MODE define the user and group that owns the device, as well as<br />

the associated permission;<br />

• RUN: the list of programs to execute in response to this event.<br />

The values assigned to these variables may use a number of substitutions:<br />

• $kernel or %k: equivalent to KERNEL;<br />

• $number or %n: the order number of the device, for example, for sda3, it would be “3”;<br />

• $devpath or %p: equivalent to DEVPATH;<br />

• $attr{aribute} or %s{aribute}: equivalent to ATTRS{aribute};<br />

Chapter 9 — Unix Services<br />

215

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!