* [PATCH] lsblk: improve error reporting for invalid device paths
@ 2026-02-12 11:24 sina-abroshan
2026-02-14 15:24 ` Benno Schulenberg
2026-02-15 8:34 ` sina-abroshan
0 siblings, 2 replies; 4+ messages in thread
From: sina-abroshan @ 2026-02-12 11:24 UTC (permalink / raw)
To: util-linux; +Cc: kzak, sina-abroshan
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 | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
index 3d2bc21a6..4a0d7c70e 100644
--- a/misc-utils/lsblk.c
+++ b/misc-utils/lsblk.c
@@ -1793,14 +1793,20 @@ static int __process_one_device(struct lsblk_devtree *tr, char *devname, dev_t d
int real_part = 0, rc = -EINVAL;
if (devno == 0 && devname) {
- struct stat st;
+ struct stat st;
- DBG(DEV, ul_debug("%s: reading alone device", devname));
+ 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;
}
+
devno = st.st_rdev;
} else if (devno) {
DBG(DEV, ul_debug("%d:%d: reading alone device", major(devno), minor(devno)));
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] lsblk: improve error reporting for invalid device paths
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
1 sibling, 0 replies; 4+ messages in thread
From: Benno Schulenberg @ 2026-02-14 15:24 UTC (permalink / raw)
To: sina-abroshan, util-linux; +Cc: kzak
[-- Attachment #1.1: Type: text/plain, Size: 553 bytes --]
Op 12-02-2026 om 12:24 schreef sina-abroshan:
> - struct stat st;
> + struct stat st;
>
> - DBG(DEV, ul_debug("%s: reading alone device", devname));
> + DBG(DEV, ul_debug("%s: reading alone device", devname));
Why these whitespace changes? There should be tabs there, not spaces.
> - if (stat(devname, &st) || !S_ISBLK(st.st_mode)) {
> + if (stat(devname, &st) != 0) {
> + warn(_("%s"), devname);
Gettextizing a message that contains nothing translatable is pointless.
In other words: drop the _() call.
Benno
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] lsblk: improve error reporting for invalid device paths
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
2026-02-18 10:01 ` Karel Zak
1 sibling, 1 reply; 4+ messages in thread
From: sina-abroshan @ 2026-02-15 8:34 UTC (permalink / raw)
To: util-linux; +Cc: kzak, bensberg, Sina Abroshan
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] lsblk: improve error reporting for invalid device paths
2026-02-15 8:34 ` sina-abroshan
@ 2026-02-18 10:01 ` Karel Zak
0 siblings, 0 replies; 4+ messages in thread
From: Karel Zak @ 2026-02-18 10:01 UTC (permalink / raw)
To: sina-abroshan; +Cc: util-linux, bensberg
On Sun, Feb 15, 2026 at 12:04:17PM +0330, sina-abroshan wrote:
> misc-utils/lsblk.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
Applied, thanks.
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-02-18 10:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2026-02-18 10:01 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox