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

+8 -7
View File
@@ -602,12 +602,12 @@ static void subst_value(const char *src, char *buf, size_t bufsz,
if (al >= sizeof(attr))
al = sizeof(attr) - 1;
memcpy(attr, as, al);
attr[al] = 0;
if (!sysfs_read_attr(ev->devpath, attr,
tmp, sizeof(tmp)))
append_str(buf, &pos, bufsz, tmp);
p = ae + 1;
memcpy(attr, as, al);
attr[al] = 0;
if (!sysfs_read_attr_chain(ev->devpath, attr,
tmp, sizeof(tmp)))
append_str(buf, &pos, bufsz, tmp);
p = ae + 1;
} else {
buf[pos++] = '%'; buf[pos] = 0;
}
@@ -681,7 +681,8 @@ static void subst_value(const char *src, char *buf, size_t bufsz,
al = sizeof(attr) - 1;
memcpy(attr, as, al);
attr[al] = 0;
if (!sysfs_read_attr(ev->devpath, attr, tmp, sizeof(tmp)))
if (!sysfs_read_attr_chain(ev->devpath, attr,
tmp, sizeof(tmp)))
append_str(buf, &pos, bufsz, tmp);
p = ae + 1;
} else {