* [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* Re: [PATCH] xfsprogs: mkfs.xfs replace assert on 0 size file with error and usage
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
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2026-05-27 12:44 UTC (permalink / raw)
To: Lukas Herbolt; +Cc: aalbersh, linux-xfs
On Mon, May 25, 2026 at 11:05:44AM +0200, Lukas Herbolt wrote:
> Running mkfs.xfs on zero size file ends up with assert() and coredump.
> It would be better the print error message and usage.
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
It would be nice to add a generic xfstests case to try mkfs on
zero size files, and maybe also weird things like character devices
and sockets to test the error handling in case you're looking for
another little project in this area.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xfsprogs: mkfs.xfs replace assert on 0 size file with error and usage
2026-05-27 12:44 ` Christoph Hellwig
@ 2026-05-27 18:20 ` Lukas Herbolt
0 siblings, 0 replies; 3+ messages in thread
From: Lukas Herbolt @ 2026-05-27 18:20 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: aalbersh, linux-xfs
On 2026-05-27 14:44, Christoph Hellwig wrote:
> On Mon, May 25, 2026 at 11:05:44AM +0200, Lukas Herbolt wrote:
>> Running mkfs.xfs on zero size file ends up with assert() and coredump.
>> It would be better the print error message and usage.
>
> Looks good:
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
>
> It would be nice to add a generic xfstests case to try mkfs on
> zero size files, and maybe also weird things like character devices
> and sockets to test the error handling in case you're looking for
> another little project in this area.
Hmm, I thought about the test. Thanks for the suggestion for the "weird"
files. I will look into it.
--
-lhe
^ permalink raw reply [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