1
0
mirror of https://github.com/systemd/systemd synced 2026-04-10 17:15:03 +02:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
05c1b1c95e
Merge pull request #21763 from yuwata/udevadm-write-only-attributes
udevadm: also show write-only attributes
2021-12-15 13:22:45 +01:00
Yu Watanabe
3a90bef55a udevadm: also show write-only attributes 2021-12-14 21:50:02 +09:00
Yu Watanabe
ab218d0bdb sd-device: make FOREACH_DEVICE_SYSATTR() also list write-only attributes
Closes #10102.
2021-12-14 21:49:56 +09:00
2 changed files with 16 additions and 11 deletions

View File

@ -1812,7 +1812,7 @@ static int device_sysattrs_read_all_internal(sd_device *device, const char *subd
if (lstat(path, &statbuf) != 0)
continue;
if (!(statbuf.st_mode & S_IRUSR))
if ((statbuf.st_mode & (S_IRUSR | S_IWUSR)) == 0)
continue;
r = set_put_strdup(&device->sysattrs, p ?: dent->d_name);

View File

@ -73,6 +73,7 @@ static int print_all_attributes(sd_device *device, bool is_parent) {
_cleanup_free_ SysAttr *sysattrs = NULL;
const char *name, *value;
size_t n_items = 0;
int r;
value = NULL;
(void) sd_device_get_devpath(device, &value);
@ -96,9 +97,8 @@ static int print_all_attributes(sd_device *device, bool is_parent) {
if (skip_attribute(name))
continue;
if (sd_device_get_sysattr_value(device, name, &value) < 0)
continue;
r = sd_device_get_sysattr_value(device, name, &value);
if (r >= 0) {
/* skip any values that look like a path */
if (value[0] == '/')
continue;
@ -110,6 +110,11 @@ static int print_all_attributes(sd_device *device, bool is_parent) {
if (len > 0)
continue;
} else if (r == -EPERM)
value = "(write-only)";
else
continue;
if (!GREEDY_REALLOC(sysattrs, n_items + 1))
return log_oom();