[systemd-devel] udev: parent device DEVPATH in rule

Ian Pilcher arequipeno at gmail.com
Fri Aug 12 19:14:27 UTC 2022


What is the best way to use the parent device DEVPATH (or the DEVPATH
where a parent attribute matched) as a substitution in a udev rule?

I am doing this to create stable paths to the sysfs directories
containing the hardware monitoring attributes of my NAS, but the
location of the sysfs attributes provided by the it87 driver has changed
over the years ...

  ACTION!="add", GOTO="n5550_hwmon_end"
  SUBSYSTEM!="hwmon", GOTO="n5550_hwmon_end"

  # coretemp attributes are always in DEVPATH directory
  ATTR{name}=="coretemp", RUN{program}+="/bin/sh -c 'mkdir -p /run/n5550 
&& ln -s /sys$devpath /run/n5550/coretemp'", GOTO="n5550_hwmon_end"

  # it87 attributes are in DEVPATH directory on newer kernels
  ATTR{name}=="it8728", RUN{program}+="/bin/sh -c 'mkdir -p /run/n5550 
&& ln -s /sys$devpath /run/n5550/it87'", GOTO="n5550_hwmon_end"

  # On older kernels, it87 attributes are in parent's DEVPATH
  ATTRS{name}=="it8728", RUN{program}+="/bin/sh -c 'mkdir -p /run/n5550 
&& ln -s /sys$parent_devpath /run/n5550/it87'"
 
              ^^^^^^^^^^^^^^^
  LABEL="n5550_hwmon_end"

Of course "$parent_devpath" doesn't exist, so I'm trying to figure out
what I should be using instead.

(For added fun, the "older" kernel is this case is from CentOS 7, which
has systemd 219.)

Ideas appreciated.  Thanks!

-- 
========================================================================
Google                                      Where SkyNet meets Idiocracy
========================================================================



More information about the systemd-devel mailing list