]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-device: fix error code returned by sd_device_get_sysattr_value() for non-existing...
authorLennart Poettering <lennart@poettering.net>
Fri, 9 Apr 2021 13:00:16 +0000 (15:00 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 9 Apr 2021 18:41:43 +0000 (19:41 +0100)
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

index 4c05dd3f7b39f5b0186f839dcbbc8656ba4ee769..d9ea9852e364eb19b91d53de950016ca1f6052d2 100644 (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)