Linux XFS filesystem development
 help / color / mirror / Atom feed
* [PATCH] xfsprogs: mkfs.xfs replace assert on 0 size file with error and usage
@ 2026-05-25  9:05 Lukas Herbolt
  2026-05-27 12:44 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Lukas Herbolt @ 2026-05-25  9:05 UTC (permalink / raw)
  To: aalbersh; +Cc: linux-xfs, Lukas Herbolt

Running mkfs.xfs on zero size file ends up with assert() and coredump.
It would be better the print error message and usage.

Signed-off-by: Lukas Herbolt <lukas@herbolt.com>
---
 mkfs/xfs_mkfs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index dd8a48c3633e..3e83d336e8cf 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -3851,7 +3851,9 @@ validate_datadev(
 			fprintf(stderr, _("can't get size of data subvolume\n"));
 			usage();
 		}
-		ASSERT(cfg->dblocks);
+		fprintf(stderr,
+			_("data size must be specified for a zero-size file\n"));
+		usage();
 	} else if (cfg->dblocks) {
 		/* check the size fits into the underlying device */
 		if (cfg->dblocks > DTOBT(xi->data.size, cfg->blocklog)) {
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-27 18:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-25  9:05 [PATCH] xfsprogs: mkfs.xfs replace assert on 0 size file with error and usage Lukas Herbolt
2026-05-27 12:44 ` Christoph Hellwig
2026-05-27 18:20   ` Lukas Herbolt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox