From: Yu Watanabe Date: Thu, 18 Feb 2021 14:38:04 +0000 (+0900) Subject: sd-device: use appropriate error code X-Git-Tag: v248-rc1~19^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=163e0a882c384e8a7d5acf24f51c3b445b6decf7;p=thirdparty%2Fsystemd.git sd-device: use appropriate error code --- diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index 8aa47f2fdd3..61cc79083a5 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -1914,13 +1914,13 @@ _public_ int sd_device_get_sysattr_value(sd_device *device, const char *sysattr, return r; } else return -EINVAL; - } else if (S_ISDIR(statbuf.st_mode)) { + } else if (S_ISDIR(statbuf.st_mode)) /* skip directories */ - return -EINVAL; - } else if (!(statbuf.st_mode & S_IRUSR)) { + return -EISDIR; + else if (!(statbuf.st_mode & S_IRUSR)) /* skip non-readable files */ return -EPERM; - } else { + else { /* read attribute value */ r = read_full_virtual_file(path, &value, NULL); if (r < 0)