keventd: resolve $attr{} and %s{} through the parent chain

Attribute substitution only looked at the device's own sysfs directory,
while the matching key ATTRS{} walks parents. Devices without an
attribute of their own, partitions in particular whose serial lives in
the parent disk, therefore substituted to an empty string.
This commit is contained in:
Paweł committed 2026-10-14 10:30:17 +02:00
1 parent 530d6703f1
commit a22a5fae7c
3 files changed
+52 -7

No files matched your search

+9
View File
@@ -40,6 +40,15 @@ int sysfs_read_file(const char *path, char *buf, size_t len);
int sysfs_read_attr(const char *devpath, const char *attr,
char *buf, size_t len);
/*
* Read a sysfs attribute for the device at /sys{devpath}, falling back
* to the parent chain, partitions have no "serial" of their own, it
* lives in the parent disk's sysfs directory.
* Returns 0 on success, -1 if no level of the chain has the attribute.
*/
int sysfs_read_attr_chain(const char *devpath, const char *attr,
char *buf, size_t len);
/*
* Walk the sysfs device tree upward from devpath toward /sys/devices,
* calling cb at each level. cb receives the absolute syspath and the