From: "Darrick J. Wong" <djwong@kernel.org>
To: Andrey Albershteyn <aalbersh@redhat.com>
Cc: xfs <linux-xfs@vger.kernel.org>
Subject: [PATCH] mkfs: fix blkid probe API violations causing weird output
Date: Tue, 15 Apr 2025 18:28:37 -0700 [thread overview]
Message-ID: <20250416012837.GW25675@frogsfrogsfrogs> (raw)
From: Darrick J. Wong <djwong@kernel.org>
The blkid_do_fullprobe function in libblkid 2.38.1 will try to read the
last 512 bytes off the end of a block device. If the block device has a
2k LBA size, that read will fail. blkid_do_fullprobe passes the -EIO
back to the caller (mkfs) even though the API documentation says it
only returns 1, 0, or -1.
Change the "cannot detect existing fs" logic to look for any negative
number. Otherwise, you get unhelpful output like this:
$ mkfs.xfs -l size=32m -b size=4096 /dev/loop3
mkfs.xfs: Use the -f option to force overwrite.
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
libxfs/topology.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libxfs/topology.c b/libxfs/topology.c
index 8c6affb4c4e436..96ee74b61b30f5 100644
--- a/libxfs/topology.c
+++ b/libxfs/topology.c
@@ -205,7 +205,8 @@ check_overwrite(
out:
if (pr)
blkid_free_probe(pr);
- if (ret == -1)
+ /* libblkid 2.38.1 lies and can return -EIO */
+ if (ret < 0)
fprintf(stderr,
_("%s: probe of %s failed, cannot detect "
"existing filesystem.\n"), progname, device);
next reply other threads:[~2025-04-16 1:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-16 1:28 Darrick J. Wong [this message]
2025-04-16 4:35 ` [PATCH] mkfs: fix blkid probe API violations causing weird output Christoph Hellwig
2025-04-16 4:50 ` Darrick J. Wong
2025-04-16 5:12 ` Christoph Hellwig
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=20250416012837.GW25675@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=aalbersh@redhat.com \
--cc=linux-xfs@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.