From: sina-abroshan <sina.abroshan@gmail.com>
To: util-linux@vger.kernel.org
Cc: kzak@redhat.com, bensberg@coevern.nl,
Sina Abroshan <sina.abroshan@gmail.com>
Subject: [PATCH] lsblk: improve error reporting for invalid device paths
Date: Sun, 15 Feb 2026 12:04:17 +0330 [thread overview]
Message-ID: <20260215083417.185974-1-sina.abroshan@gmail.com> (raw)
In-Reply-To: <20260212112423.2400888-1-sina.abroshan@gmail.com>
From: Sina Abroshan <sina.abroshan@gmail.com>
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>
---
v2:
- Use tabs instead of spaces
- Drop unnecessary _() around "%s"
---
misc-utils/lsblk.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
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;
}
--
2.34.1
next prev parent reply other threads:[~2026-02-15 8:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-12 11:24 [PATCH] lsblk: improve error reporting for invalid device paths sina-abroshan
2026-02-14 15:24 ` Benno Schulenberg
2026-02-15 8:34 ` sina-abroshan [this message]
2026-02-18 10:01 ` Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260215083417.185974-1-sina.abroshan@gmail.com \
--to=sina.abroshan@gmail.com \
--cc=bensberg@coevern.nl \
--cc=kzak@redhat.com \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox