]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
e2fsck: add ability to limit the # of problems of a particular type
authorTheodore Ts'o <tytso@mit.edu>
Wed, 14 Mar 2012 21:44:54 +0000 (17:44 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 14 Mar 2012 21:44:54 +0000 (17:44 -0400)
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" <tytso@mit.edu>
e2fsck/problem.c
e2fsck/problemP.h

index b951eb752840eaa5d90f4df51470ebcc59402a0e..c66c6be85d2ff00c2f0c4c4b2dfea3998d781035 100644 (file)
@@ -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)
index a2ed35e5e6305c571b9222d9cd9000b0b765044b..7944cd6c72b83feb3e2e9c624c8454b427727005 100644 (file)
@@ -15,6 +15,8 @@ struct e2fsck_problem {
        char            prompt;
        int             flags;
        problem_t       second_code;
+       int             count;
+       int             max_count;
 };
 
 struct latch_descr {