From: Sina Abroshan Date: Sun, 15 Feb 2026 08:34:17 +0000 (+0330) Subject: lsblk: improve error reporting for invalid device paths X-Git-Tag: v2.43-devel~73 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae8bbd3630ab9f111b9f0f09a6dd8407f8745e94;p=thirdparty%2Futil-linux.git lsblk: improve error reporting for invalid device paths Differentiate stat() failures from non-block-device cases, so users get accurate errno-based error messages. Signed-off-by: Sina Abroshan --- diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index 3d2bc21a6..6a8769bc7 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -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; }