From: Theodore Ts'o Date: Wed, 14 Mar 2012 21:44:54 +0000 (-0400) Subject: e2fsck: add ability to limit the # of problems of a particular type X-Git-Tag: v1.42.2~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=def8da382927803a88d6003d5baa159f668a153b;p=thirdparty%2Fe2fsprogs.git e2fsck: add ability to limit the # of problems of a particular type This throttles the output of a particular problem type, to avoid a bottleneck caused by (for example) printing a large number of characters over a rate-limited a serial console. Signed-off-by: "Theodore Ts'o" --- diff --git a/e2fsck/problem.c b/e2fsck/problem.c index b951eb752..c66c6be85 100644 --- a/e2fsck/problem.c +++ b/e2fsck/problem.c @@ -1824,10 +1824,13 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx) reconfigure_bool(ctx, ptr, key, PR_NO_NOMSG, "no_nomsg"); reconfigure_bool(ctx, ptr, key, PR_PREEN_NOHDR, "preen_noheader"); reconfigure_bool(ctx, ptr, key, PR_FORCE_NO, "force_no"); + profile_get_integer(ctx->profile, "problems", key, "max_count", + ptr->max_count, &ptr->max_count); ptr->flags |= PR_CONFIG; } def_yn = 1; + ptr->count++; if ((ptr->flags & PR_NO_DEFAULT) || ((ptr->flags & PR_PREEN_NO) && (ctx->options & E2F_OPT_PREEN)) || (ctx->options & E2F_OPT_NO)) @@ -1856,6 +1859,16 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx) if ((ptr->flags & PR_NO_NOMSG) && ((ctx->options & E2F_OPT_NO) || (ptr->flags & PR_FORCE_NO))) suppress++; + if (ptr->max_count && (ptr->count > ptr->max_count)) { + if (ctx->options & (E2F_OPT_NO | E2F_OPT_YES)) + suppress++; + if ((ctx->options & E2F_OPT_PREEN) && + (ptr->flags & PR_PREEN_OK)) + suppress++; + if ((ptr->flags & PR_LATCH_MASK) && + (ldesc->flags & (PRL_YES | PRL_NO))) + suppress++; + } if (!suppress) { message = ptr->e2p_description; if ((ctx->options & E2F_OPT_PREEN) && @@ -1927,6 +1940,13 @@ profile_get_boolean(profile_t profile, const char *name, const char *subname, return 0; } +errcode_t +profile_get_integer(profile_t profile, const char *name, const char *subname, + const char *subsubname, int def_val, int *ret_int) +{ + return 0; +} + void print_e2fsck_message(e2fsck_t ctx, const char *msg, struct problem_context *pctx, int first, int recurse) diff --git a/e2fsck/problemP.h b/e2fsck/problemP.h index a2ed35e5e..7944cd6c7 100644 --- a/e2fsck/problemP.h +++ b/e2fsck/problemP.h @@ -15,6 +15,8 @@ struct e2fsck_problem { char prompt; int flags; problem_t second_code; + int count; + int max_count; }; struct latch_descr {