From 7a2a0145da40096ad5bf8df902bb5d4b332f29f7 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Wed, 1 Mar 2017 14:33:45 -0500 Subject: [PATCH] e2fsck: report the exit value in the logfile If e2fsck logging is enabled, report the exit value as the last line in the log file. Signed-off-by: Theodore Ts'o --- e2fsck/e2fsck.c | 3 +++ e2fsck/unix.c | 2 ++ e2fsck/util.c | 2 ++ 3 files changed, 7 insertions(+) diff --git a/e2fsck/e2fsck.c b/e2fsck/e2fsck.c index 5184a17ef..0f9da46a5 100644 --- a/e2fsck/e2fsck.c +++ b/e2fsck/e2fsck.c @@ -200,6 +200,9 @@ void e2fsck_free_context(e2fsck_t ctx) if (ctx->log_fn) free(ctx->log_fn); + if (ctx->logf) + fclose(ctx->logf); + ext2fs_free_mem(&ctx); } diff --git a/e2fsck/unix.c b/e2fsck/unix.c index 9e4d31a84..b7322bc6a 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -1951,6 +1951,8 @@ no_journal: ext2fs_close_free(&ctx->fs); free(ctx->journal_name); + if (ctx->logf) + fprintf(ctx->logf, "Exit status: %d\n", exit_value); e2fsck_free_context(ctx); remove_error_table(&et_ext2_error_table); remove_error_table(&et_prof_error_table); diff --git a/e2fsck/util.c b/e2fsck/util.c index 9e217e62b..87d320b99 100644 --- a/e2fsck/util.c +++ b/e2fsck/util.c @@ -83,6 +83,8 @@ out: ctx->flags |= E2F_FLAG_ABORT; if (ctx->flags & E2F_FLAG_SETJMP_OK) longjmp(ctx->abort_loc, 1); + if (ctx->logf) + fprintf(ctx->logf, "Exit status: %d\n", exit_value); exit(exit_value); } -- 2.47.2