sd-device: fix error code returned by sd_device_get_sysattr_value() for non-existing attributes

lstat() returns the error in errno, not as return value. Let's propagate
this correctly.

This broke the bolt test suite, as @gicmo discovered.

Follow-up for acfc2a1d15.
This commit is contained in:
Lennart Poettering 2021-04-09 15:00:16 +02:00 committed by Luca Boccassi
parent 5b1375035b
commit e2e40e9a9e

View file

@ -1893,10 +1893,11 @@ _public_ int sd_device_get_sysattr_value(sd_device *device, const char *sysattr,
return r;
path = prefix_roota(syspath, sysattr);
r = lstat(path, &statbuf);
if (r < 0) {
if (lstat(path, &statbuf) < 0) {
int k;
r = -errno;
/* remember that we could not access the sysattr */
k = device_cache_sysattr_value(device, sysattr, NULL);
if (k < 0)