aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2018-02-13 13:46:42 -0600
committerEric Sandeen <sandeen@redhat.com>2018-02-13 13:46:42 -0600
commit5454c2bfb6f0228b836ed386507485624756bf8b (patch)
treec054daddc7f2b92baeb7c5ab6adf8f92c905c2e1
parent2e4959c1c632c5faf5efff445429d3a4a5089f27 (diff)
downloadxfsprogs-dev-5454c2bfb6f0228b836ed386507485624756bf8b.tar.gz
xfs_scrub: refactor outcome display into a separate helper
Move all the printing of the scrub outcome into a separate helper to declutter the main function. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> [sandeen: put "Unmount ..." on its own line] Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-rw-r--r--scrub/xfs_scrub.c46
1 files changed, 28 insertions, 18 deletions
diff --git a/scrub/xfs_scrub.c b/scrub/xfs_scrub.c
index 89b7fa0eca..ab26e63359 100644
--- a/scrub/xfs_scrub.c
+++ b/scrub/xfs_scrub.c
@@ -493,6 +493,32 @@ _("Scrub aborted after phase %d."),
return moveon;
}
+static void
+report_outcome(
+ struct scrub_ctx *ctx)
+{
+ unsigned long long total_errors;
+
+ total_errors = ctx->errors_found + ctx->runtime_errors;
+
+ if (total_errors == 0 && ctx->warnings_found == 0)
+ return;
+
+ if (total_errors == 0)
+ fprintf(stderr, _("%s: warnings found: %llu\n"), ctx->mntpoint,
+ ctx->warnings_found);
+ else if (ctx->warnings_found == 0)
+ fprintf(stderr, _("%s: errors found: %llu\n"), ctx->mntpoint,
+ total_errors);
+ else
+ fprintf(stderr, _("%s: errors found: %llu; warnings found: %llu\n"),
+ ctx->mntpoint, total_errors,
+ ctx->warnings_found);
+ if (ctx->need_repair)
+ fprintf(stderr, _("%s: Unmount and run xfs_repair.\n"),
+ ctx->mntpoint);
+}
+
int
main(
int argc,
@@ -501,9 +527,7 @@ main(
struct scrub_ctx ctx = {0};
struct phase_rusage all_pi;
char *mtab = NULL;
- char *repairstr = "";
FILE *progress_fp = NULL;
- unsigned long long total_errors;
bool moveon = true;
bool ismnt;
int c;
@@ -692,22 +716,8 @@ _("%s: Not a XFS mount point or block device.\n"),
ctx.runtime_errors++;
out:
- total_errors = ctx.errors_found + ctx.runtime_errors;
- if (ctx.need_repair)
- repairstr = _(" Unmount and run xfs_repair.");
- if (total_errors && ctx.warnings_found)
- fprintf(stderr,
-_("%s: %llu errors and %llu warnings found.%s\n"),
- ctx.mntpoint, total_errors, ctx.warnings_found,
- repairstr);
- else if (total_errors && ctx.warnings_found == 0)
- fprintf(stderr,
-_("%s: %llu errors found.%s\n"),
- ctx.mntpoint, total_errors, repairstr);
- else if (total_errors == 0 && ctx.warnings_found)
- fprintf(stderr,
-_("%s: %llu warnings found.\n"),
- ctx.mntpoint, ctx.warnings_found);
+ report_outcome(&ctx);
+
if (ctx.errors_found) {
if (ctx.error_action == ERRORS_SHUTDOWN)
xfs_shutdown_fs(&ctx);