From e2e40e9a9e4074eaca7984b70a5d1cd7a7f0cbe0 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 9 Apr 2021 15:00:16 +0200 Subject: [PATCH] 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. --- src/libsystemd/sd-device/sd-device.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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) -- 2.47.3