From: Lennart Poettering Date: Fri, 9 Apr 2021 13:00:16 +0000 (+0200) Subject: sd-device: fix error code returned by sd_device_get_sysattr_value() for non-existing... X-Git-Tag: v249-rc1~444 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e2e40e9a9e4074eaca7984b70a5d1cd7a7f0cbe0;p=thirdparty%2Fsystemd.git 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 acfc2a1d15560084e077ffb3be472cd117e9020a. --- diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index 4c05dd3f7b3..d9ea9852e36 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -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)