From 61d16c39ff93f3da4ba9e2f6ee1359d48a2da969 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 14 May 2018 18:22:09 -0400 Subject: [PATCH] mke2fs: print error string if ext2fs_close_free() fails There are multiple reasons why ext2fs_close_free() might fail, not just an I/O error while writing out a backup superblock. Print the error code, and then allow mke2fs to exit with an exit status code of 1, instead of whatever random error code ext2fs_close_free() might have returned with. Signed-off-by: Theodore Ts'o --- misc/mke2fs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/misc/mke2fs.c b/misc/mke2fs.c index e18d9bc..57b5bbf 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -3295,8 +3295,9 @@ no_journal: max_mnt_count = fs->super->s_max_mnt_count; retval = ext2fs_close_free(&fs); if (retval) { - fprintf(stderr, "%s", - _("\nWarning, had trouble writing out superblocks.\n")); + com_err(program_name, retval, "%s", + _("while writing out and closing file system")); + retval = 1; } else if (!quiet) { printf("%s", _("done\n\n")); if (!getenv("MKE2FS_SKIP_CHECK_MSG")) -- 1.8.3.1