#[SOLVED] Changing sysfs permissions using udev rules?
63 messages · Page 1 of 1 (latest)
No, /sys is not managed by udev
It is not?
It is not, udev is only in charge of /dev.
Files under /sys are direct kernel interfaces, created by the kernel and not affected by udev.
What the hell is this then?
/etc/udev/rules.d/99-swayosd.rules
ACTION=="add", SUBSYSTEM=="backlight", RUN+="/bin/chgrp video /sys/class/backlight/%k/brightness"
ACTION=="add", SUBSYSTEM=="backlight", RUN+="/bin/chmod g+w /sys/class/backlight/%k/brightness"
SwayOSD already added some rules and they apply to /sys
ACTION=="add", SUBSYSTEM=="backlight"
This is the cause, RUN+= is just the effect.
are backlight devices in /dev? Sounds like nonsense
Or... SUBSYSTEM is like a hook?
triggers after certain SUBSYSTEM has initialized?
Doesn't matter where it got mounted I assume?
Some of the keys also match against properties of the parent devices in sysfs
Still confused
IIRC udev is part of systemd, it is not very clearly documented except in the code, I think you can find some logic from SUBSYSTEM.
udev is also a part of initramfs which is way before pid 0 afaik?
What?
Put another way, udev is a component of systemd,
Its source code is available under systemd/src/udev.
This is an Arch Linux specific mkinitramfs HOOK, it does not represent a relationship between systemd and udev.
Ok but then what does hook do
Actually, forget it
Back to original question
How would I change perms for ideapad_acpi
which SUBSYSTEM is it?
if (type == TK_M_SUBSYSTEM && STR_IN_SET(value, "subsystem", "bus", "class"))
match_type = MATCH_TYPE_SUBSYSTEM;
Where is it
so... it's platform?
/sys/bus/platform/drivers/ideapad_acpi
Are you sure you are not looking for a subdirectory in there?
the one with some kind of id?
Are you trying to change conservation_mode without root?
Ah, perhaps the original question you asked isn't clear.
In original title I just asked for general udev help, I wasn't sure if I'm on the right track even
Because it's a device, it's possible that you can use udev to hook its event, but for most other files under /sys, udev won't work.
What is the device name?
It should look like this: VPC2004:00.
This shouldn't matter if devpath is used, although I'm not sure.
Can you try
SUBSYSTEM=="platform", DRIVER=="ideapad_acpi", \
RUN+="/usr/bin/chgrp power $devpath/conservation_mode"
Albeit, if you do not want to deal with obscure udev rules, you can always use
/etc/tmpfiles.d, which is a common practice used by systemd itself
e.g.
m /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00 0664 root power - -
(udev-worker)[277]: VPC2004:00: Process '/usr/bin/chgrp power /devices/pci0000:00/0000:00:1f.0/PNP0C09:00/VPC2004:00/conservation_mode' failed with exit code 1
works when I run manually
It's missing $sys before $devpath
Usually, if there is a device event, udev can be used, otherwise use tmpfiles.d or the systemd service.
Yes, devpath does not include /sys, my mistake.
Other attributes that can be used in a udev about a device can be found using
sudo udevadm info -q all /path/to/device