From 163e0a882c384e8a7d5acf24f51c3b445b6decf7 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 18 Feb 2021 23:38:04 +0900 Subject: [PATCH] sd-device: use appropriate error code --- src/libsystemd/sd-device/sd-device.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index 8aa47f2fdd..61cc79083a 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)