Bruce Dubbs wrote: > I'm trying to write a script to be run in Section 7.2 to initialize > 70-persistent-net.rules. I'm using, as a base, the udev-182 rule > 75-persistent-net-generator.rules. > > I have a problem in that this rule uses a variable SUBSYSTEMS.
Uh oh, that's one thing I was afraid of. :-( Might be fixable, but it might also be hard. SUBSYSTEMS is "the SUBSYSTEM of the matching parent device", but the concept of a "parent device" is not exposed any obvious way in the sysfs tree. The only way I know of to find it is to udevadm info --attribute-walk. The SUBSYSTEM value for a given device directory is definitely the basename of the target of the "subsystem" link; it's just that I don't know how to find the parent devices. Looking at the libudev source (from -180), it appears that the algorithm is simpler than I thought, though; it's as follows: 1. Start with the /sys path given, and resolve symlinks all the way down 2. Remove one directory from the end of the path 3. If the result of 2 is under /sys/devices, and the directory has a "uevent" file present, then finish. 4. If the result of 2 is under /sys/devices and the directory does not have a "uevent" file present, then goto 2. 5. If the result of 2 is not under /sys/devices, and the result is a directory, then finish. (Would be hard for this to fail.) 6. If the result of 2 is not under /sys/devices, and the result is not a directory, then goto 2. The result after "finish" is then the next level in the tree. The recursion stops when the code hits the /sys directory. So on my system, /sys/class/net/eth0 resolves to /sys/devices/pci0000:00/0000:00:06.0/0000:05:05.0/net/eth0. That has a uevent file. The first parent is the "net" directory, which does not have one, so the algorithm continues to the "0000:05:05.0" directory. That does have a uevent file, so that's next in line. The 0000:00:06.0 directory is next, then the pci0000:00 directory. The "devices" directory doesn't have a uevent file, so the next loop iteration is the last one (hits /sys), which doesn't find a parent for the pci0000:00 directory. > but we need to be able to skip setting the rules completely for xen. > Any way to do some kind of shell basename trickery, probably starting with "readlink -f" (to handle symlinks in the middle of the path), to find the parents in turn, looking for "[ $(basename $(readlink subsystem)) == "xen" ]"?
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