You are not logged in.

#1 2017-11-07 14:14:26

Inixi
Member
Registered: 2016-10-15
Posts: 54

udev rules - help with writting symlink rule

Hello,
A little story first. I have a funny problem with my thinkpad and thinkfan service, because I have set my thinkpad service to read values from /sys/devices/virtual/thermal/thermal_zone1/temp, but this endpoint can change name after next system restart to e.g.  /sys/devices/virtual/thermal/thermal_zone0/temp . So I wanted to write a udev rule to create a symlink. Before I have checked what rules should match this device and I performed udevadm info -a -p /sys/devices/virtual/thermal/thermal_zone1. The output is as follows:

  looking at device '/devices/virtual/thermal/thermal_zone1':
    KERNEL=="thermal_zone1"
    SUBSYSTEM=="thermal"
    DRIVER==""
    ATTR{available_policies}=="user_space bang_bang fair_share step_wise "
    ATTR{integral_cutoff}=="0"
    ATTR{k_d}=="0"
    ATTR{k_i}=="0"
    ATTR{k_po}=="0"
    ATTR{k_pu}=="0"
    ATTR{offset}=="0"
    ATTR{policy}=="step_wise"
    ATTR{slope}=="0"
    ATTR{sustainable_power}=="0"
    ATTR{temp}=="41000"
    ATTR{trip_point_0_temp}=="0"
    ATTR{trip_point_0_type}=="passive"
    ATTR{trip_point_1_temp}=="0"
    ATTR{trip_point_1_type}=="passive"
    ATTR{type}=="x86_pkg_temp"

and after that I have created file /etc/udev/rules.d/70-create-temperature-sensor-symlink.rules with contents:

KERNEL=="thermal_zone[0-3]", SUBSYSTEM=="thermal", ATTR{type}=="x86_pkg_temp", SYMLINK+="/dev/package_temp"

and afterwards I performed udevadm test /sys/devices/virtual/thermal/thermal_zone1 and the output was:

ACTION=add
DEVPATH=/devices/virtual/thermal/thermal_zone1
SUBSYSTEM=thermal
USEC_INITIALIZED=14576415239
Unload module index
Unloaded link configuration context.

So, nothing happens. And then for a little test I chaged the contents of the file to:

KERNEL=="thermal_zone[0-3]", SUBSYSTEM=="thermal", ATTR{type}=="x86_pkg_temp", RUN="some script"

...and the output:

RUN 'some script' /etc/udev/rules.d/70-create-temperature-sensor-symlink.rules:1
ACTION=add
DEVPATH=/devices/virtual/thermal/thermal_zone1
SUBSYSTEM=thermal
USEC_INITIALIZED=14754335606
run: 'some script'
Unload module index
Unloaded link configuration context.

So in my opinion the rule works just fine, but the SYMLINK action does not perform anything. Based on internet knowledge I have tried following configurations:

KERNEL=="thermal_zone[0-3]", SUBSYSTEM=="thermal", ATTR{type}=="x86_pkg_temp", SYMLINK+="package_temp"
ACTION=="add|change", KERNEL=="thermal_zone[0-3]", SUBSYSTEM=="thermal", ATTR{type}=="x86_pkg_temp", SYMLINK+="package_temp"
KERNEL=="thermal_zone1", SUBSYSTEM=="thermal", ATTR{type}=="x86_pkg_temp", SYMLINK+="package_temp"
ACTION=="add|change", KERNEL=="thermal_zone1", SUBSYSTEM=="thermal", ATTR{type}=="x86_pkg_temp", SYMLINK+="package_temp"

with no luck and I am asking for help here. Any suggestions how to make it work?


2020 ASUS Zephyrus G14

Offline

#2 2017-11-07 16:16:33

berbae
Member
From: France
Registered: 2007-02-12
Posts: 1,302

Re: udev rules - help with writting symlink rule

I am not sure that you need the '/dev' prefix in SYMLINK+="/dev/package_temp".
Is not it simply SYMLINK+="package_temp" ?

Edit: Sorry I just see that you already tried without the '/dev' part

Last edited by berbae (2017-11-07 16:19:20)

Offline

#3 2017-11-07 17:26:51

Inixi
Member
Registered: 2016-10-15
Posts: 54

Re: udev rules - help with writting symlink rule

@berbae, exactly, nothing happens with either values, like if SYMLINK did not work.


2020 ASUS Zephyrus G14

Offline

Board footer

Powered by FluxBB