]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsblk: improve error reporting for invalid device paths
authorSina Abroshan <sina.abroshan@gmail.com>
Sun, 15 Feb 2026 08:34:17 +0000 (12:04 +0330)
committerKarel Zak <kzak@redhat.com>
Tue, 17 Feb 2026 11:39:40 +0000 (12:39 +0100)
Differentiate stat() failures from non-block-device cases,
so users get accurate errno-based error messages.

Signed-off-by: Sina Abroshan <sina.abroshan@gmail.com>
misc-utils/lsblk.c

index 3d2bc21a6a3b390f7d566a75fbc2f432e97caec6..6a8769bc7838124ee50ac20a2ff91f00018c46b5 100644 (file)
@@ -1797,7 +1797,12 @@ static int __process_one_device(struct lsblk_devtree *tr, char *devname, dev_t d
 
                DBG(DEV, ul_debug("%s: reading alone device", devname));
 
-               if (stat(devname, &st) || !S_ISBLK(st.st_mode)) {
+               if (stat(devname, &st) != 0) {
+                       warn("%s", devname);
+                       goto leave;
+               }
+
+               if (!S_ISBLK(st.st_mode)) {
                        warnx(_("%s: not a block device"), devname);
                        goto leave;
                }