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.

ATTRS{rev}==" "<br />

ATTRS{state}=="running"<br />

[...]<br />

ATTRS{max_sectors}=="240"<br />

[...]<br />

looking at parent device '/devices/pci0000:00/0000:00:10.3/usb1/1-2/1-2.2':<br />

KERNELS=="9:0:0:0"<br />

SUBSYSTEMS=="usb"<br />

DRIVERS=="usb"<br />

ATTRS{configuration}=="iCfg"<br />

ATTRS{bNumInterfaces}==" 1"<br />

ATTRS{bConfigurationValue}=="1"<br />

ATTRS{bmAttributes}=="80"<br />

ATTRS{bMaxPower}=="100mA"<br />

ATTRS{urbnum}=="398"<br />

ATTRS{idVendor}=="4146"<br />

ATTRS{idProduct}=="4146"<br />

ATTRS{bcdDevice}=="0100"<br />

[...]<br />

ATTRS{manufacturer}=="USB Disk"<br />

ATTRS{product}=="USB Mass Storage Device"<br />

ATTRS{serial}=="M004021000001"<br />

[...]<br />

To create a new rule, you can use tests on the device's variables, as well as those of one of the<br />

parent devices. The above case allows us to create two rules like these:<br />

KERNEL=="sd?", SUBSYSTEM=="block", ATTRS{serial}=="M004021000001", SYMLINK+="<br />

➥ usb_key/disk"<br />

KERNEL=="sd?[0-9]", SUBSYSTEM=="block", ATTRS{serial}=="M004021000001",<br />

➥ SYMLINK+="usb_key/part%n"<br />

Once these rules are set in a file, named for example /etc/udev/rules.d/010_local.rules,<br />

you can simply remove and reconnect the USB key. You can then see that /dev/usb_key/disk<br />

represents the disk associated with the USB key, and /dev/usb_key/part1 is its first partition.<br />

GOING FURTHER<br />

Debugging udev's<br />

configuration<br />

Like many daemons, udevd stores logs in /var/log/daemon.log. But it is not<br />

very verbose by default, and it's usually not enough to understand what's happening.<br />

The udevadm control --log-priority=info command increases the<br />

verbosity level and solves this problem. udevadm control --log-priority=<br />

err returns to the default verbosity level.<br />

Chapter 9 — Unix Services<br />

217

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

Saved successfully!

Ooh no, something went wrong!