Skip to contentSkip to conversation

xfsprogs: mkfs.xfs replace assert on 0 size file with error and usage

PATCH In review Lukas Herbolt 2 participants 3 messages May 25 – May 27

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfsprogs: mkfs.xfs replace assert on 0 size file with error and usage

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

---
 mkfs/xfs_mkfs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
mkfs/xfs_mkfs.c +3 -1
index dd8a48c3633e..3e83d336e8cf 100644
@@ -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)) {
Signature · 1 line
2.54.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 2 lines · 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.

Looks good:

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.

#2 lore raw
Quoted 4 lines · Christoph Hellwig
Quoted 2 lines · 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.

Quoted 8 lines

Looks good:

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.

Signature · 1 line
-lhe