Matthew Burgess wrote: > The only thing that confused me was if and when we need to use the > plural form of the key names.
We need to use the plural form whenever we want udev to search up the device tree to make a match. If (for instance) we're only interested in the subsystem value for the device udev is looking at, we can use SUBSYSTEM="xyz". But if we want to match all devices hooked up to a PCI bus, directly or indirectly, we have to have it walk the tree. (No, I'm not sure why we'd want to do this. But that's OK. ;-) ) For instance, a USB-storage device that I have here shows up as /sys/class/usb_device/usbdev4.3, and udevinfo tells me that the SUBSYSTEM for that level is "usb_device". But the SUBSYSTEMS values one and two levels up are both "usb", and the SUBSYSTEMS three levels up is "pci". To match on "pci", we would need to use SUBSYSTEMS. (If I would run udevinfo on the next level up, I'd get SUBSYSTEM=="usb" and would still have to use SUBSYSTEMS=="pci".) As for the mappings, the manpages imply this is what we need to do: SYSFS{...} --> ATTRS{...} BUS --> SUBSYSTEMS DRIVER --> DRIVERS ID --> KERNELS $sysfs{...} --> $attr{...} Explanations: SYSFS{...} matched any sysfs attribute all the way up the tree. This is now ATTRS{...}. I'd guess that in most cases we don't need to search the tree for this one, but I don't know for sure, so I'll say just dump ATTRS in for all the SYSFS values for now, to be safe. BUS searched the tree for a matching subsystem; from the manpage, that's SUBSYSTEMS now. (See the USB-storage device above.) DRIVER searched the tree before; that's DRIVERS now. ID searched the tree for a matching device node; that's KERNELS now. $sysfs{...} (as a replacement string) is now $attr{...}. I'm not sure why there's no $attrs{...}, though. I've attached a patch that does all of this; it looks like a few rules may have gotten missed before. I also found a couple screwy settings that have probably been there for a long time; I changed those as part of the patch as well. I'll enumerate them below: 1) The KERNEL=="mice" rule. All items need commas between them; this rule is missing a comma between GROUP and SYMLINK. It also should be SYMLINK+="mouse", not SYMLINK="mouse", in case the user added their own symlink before 25-lfs.rules. We don't want to destroy that. 2) lp[0-9] devices on a USB bus. This needs to be SUBSYSTEMS=="usb" (plural) to match the BUS=="usb" from before. Not sure if it really matters in this case, but better safe than sorry. 3) 26-modprobe.rules: Replace ATTR{...} with ATTRS{...} everywhere; SYSFS searched up before, so we should probably keep doing that, just in case it's required. 4) 60-persistent-storage.rules: Likewise. Also replace a (missed?) $sysfs{ieee1394_id} in the Firewire device rule that sets ID_BUS, with $attr{ieee1394_id}. *Also*, ATTRS{ieee1394_id} will always match "*"; it should test against "?*" to make sure the attribute is set to something other than the empty string. (This was a change made several udev versions ago.) > Oh, and I left contrib/ alone. Once the rule_generator rules go in, > I guess that directory can be removed, right? Yeah, looks that way. I would rather use the "standard" rule-generating rules than Debian's anyway (nothing against Debian, but the udev guys would like it if the sample rules got wider testing/usage, instead of everyone coming up with their own duplicate solution -- and I think Debian is moving to the udev-provided rules anyway).
Index: 25-lfs.rules =================================================================== --- 25-lfs.rules (revision 7791) +++ 25-lfs.rules (working copy) @@ -72,7 +72,7 @@ # Input devices go in their own subdirectory -KERNEL=="mice", MODE="0644", NAME="input/%k" SYMLINK="mouse" +KERNEL=="mice", MODE="0644", NAME="input/%k", SYMLINK+="mouse" KERNEL=="mouse*", MODE="0644", NAME="input/%k" KERNEL=="event*", MODE="0644", NAME="input/%k" KERNEL=="js*", MODE="0644", NAME="input/%k" @@ -89,7 +89,7 @@ KERNEL=="auer*", NAME="usb/%k" KERNEL=="legousbtower*", NAME="usb/%k" KERNEL=="dabusb*", NAME="usb/%k" -BUS=="usb", KERNEL=="lp[0-9]*", GROUP="lp", NAME="usb/%k" +SUBSYSTEMS=="usb", KERNEL=="lp[0-9]*", GROUP="lp", NAME="usb/%k" # DRI devices are managed by the X server, so prevent udev from creating them Index: 26-modprobe.rules =================================================================== --- 26-modprobe.rules (revision 7791) +++ 26-modprobe.rules (working copy) @@ -4,7 +4,7 @@ ACTION=="add", ENV{MODALIAS}=="?*", RUN+="/sbin/modprobe $env{MODALIAS}" -# SCSI devices require different modules, dependent on their SYSFS{type}. All +# SCSI devices require different modules, dependent on their ATTRS{type}. All # of them require 'sg' though. # # module name sysfs types @@ -12,7 +12,7 @@ # st/osst 1 (TYPE_TAPE) # sr 4 (TYPE_WORM), 5 (TYPE_ROM) -SUBSYSTEM=="scsi_device", ACTION=="add", SYSFS{type}=="0|7|14", RUN+="/sbin/modprobe sd_mod" -SUBSYSTEM=="scsi_device", ACTION=="add", SYSFS{type}=="1", RUN+="/sbin/modprobe st" -SUBSYSTEM=="scsi_device", ACTION=="add", SYSFS{type}=="[45]", RUN+="/sbin/modprobe sr_mod" +SUBSYSTEM=="scsi_device", ACTION=="add", ATTRS{type}=="0|7|14", RUN+="/sbin/modprobe sd_mod" +SUBSYSTEM=="scsi_device", ACTION=="add", ATTRS{type}=="1", RUN+="/sbin/modprobe st" +SUBSYSTEM=="scsi_device", ACTION=="add", ATTRS{type}=="[45]", RUN+="/sbin/modprobe sr_mod" SUBSYSTEM=="scsi_device", ACTION=="add", RUN+="/sbin/modprobe sg" Index: 60-persistent-storage.rules =================================================================== --- 60-persistent-storage.rules (revision 7791) +++ 60-persistent-storage.rules (working copy) @@ -8,8 +8,8 @@ KERNEL=="ram*|loop*|fd*|nbd*", GOTO="persistent_storage_end" # never access removable ide devices, the drivers are causing event loops on open() -KERNEL=="hd*[!0-9]", SYSFS{removable}=="1", DRIVER=="ide-cs|ide-floppy", GOTO="persistent_storage_end" -KERNEL=="hd*[0-9]", SYSFS{../removable}=="1", GOTO="persistent_storage_end" +KERNEL=="hd*[!0-9]", ATTRS{removable}=="1", DRIVERS=="ide-cs|ide-floppy", GOTO="persistent_storage_end" +KERNEL=="hd*[0-9]", ATTRS{../removable}=="1", GOTO="persistent_storage_end" # for partitions import parent information KERNEL=="*[0-9]", IMPORT{parent}=="ID_*" @@ -19,7 +19,7 @@ KERNEL=="hd*[!0-9]", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/ata-$env{ID_MODEL}_$env{ID_SERIAL}" KERNEL=="hd*[0-9]", IMPORT{parent}=="ID_*", SYMLINK+="disk/by-id/ata-$env{ID_MODEL}_$env{ID_SERIAL}-part%n" -KERNEL=="sd*[!0-9]|sr*|st*", SYSFS{ieee1394_id}=="*", ENV{ID_SERIAL}="$sysfs{ieee1394_id}", ENV{ID_BUS}="ieee1394" +KERNEL=="sd*[!0-9]|sr*|st*", ATTRS{ieee1394_id}=="?*", ENV{ID_SERIAL}="$attr{ieee1394_id}", ENV{ID_BUS}="ieee1394" KERNEL=="sd*[!0-9]|sr*|st*", ENV{ID_SERIAL}=="", IMPORT{program}="usb_id -x" KERNEL=="sd*[!0-9]|sr*|st*", ENV{ID_SERIAL}=="", IMPORT{program}="scsi_id -g -x -s %p -d $tempnode" KERNEL=="sd*[!0-9]|sr*|st*", ENV{ID_SERIAL}=="", IMPORT{program}="scsi_id -g -x -a -s %p -d $tempnode" @@ -35,7 +35,7 @@ KERNEL=="*[0-9]", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}-part%n" # by-label/by-uuid (filesystem properties) -KERNEL=="*[!0-9]", SYSFS{removable}=="1", GOTO="persistent_storage_end" +KERNEL=="*[!0-9]", ATTRS{removable}=="1", GOTO="persistent_storage_end" IMPORT{program}="vol_id --export $tempnode" ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_UUID}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID}" ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_SAFE}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_SAFE}"
signature.asc
Description: OpenPGP digital signature
-- http://linuxfromscratch.org/mailman/listinfo/lfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page