Whamcloud - gitweb
e2fsck: add support for printing the quota type in problem reports using %U
authorTheodore Ts'o <tytso@mit.edu>
Sat, 22 Jul 2017 18:51:28 +0000 (14:51 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 22 Jul 2017 18:51:28 +0000 (14:51 -0400)
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/message.c
e2fsck/problem.c
e2fsck/quota.c

index 1c3fcd8..a44205f 100644 (file)
@@ -48,6 +48,9 @@
  *                     the containing directory.
  *     %r      <blkcount>              interpret blkcount as refcount
  *     %s      <str>                   miscellaneous string
+ *     %t      time (in <num>)
+ *     %T      current time
+ *     %U      quota type (in <num>)
  *     %S      backup superblock
  *     %X      <num> hexadecimal format
  *
@@ -92,9 +95,9 @@
 #include <string.h>
 #include <ctype.h>
 #include <termios.h>
+#include "support/quotaio.h"
 
 #include "e2fsck.h"
-
 #include "problem.h"
 
 #ifdef __GNUC__
@@ -500,6 +503,27 @@ static _INLINE_ void expand_percent_expression(FILE *f, ext2_filsys fs,
        case 'T':
                print_time(f, e2fsck_ctx ? e2fsck_ctx->now : time(0));
                break;
+       case 'U':
+               switch (ctx->num) {
+               case USRQUOTA:
+                       m = _("user");
+                       break;
+               case GRPQUOTA:
+                       m = _("group");
+                       break;
+               case PRJQUOTA:
+                       m = _("group");
+                       break;
+               default:
+                       m = _("unknown quota type");
+                       break;
+               }
+               if (*first && islower(m[0]))
+                       fputc(toupper(*m++), f);
+               fputs(m, f);
+               if (ctx->num > PRJQUOTA)
+                       fprintf(f, " %d", (int) ctx->num);
+               break;
        case 'x':
                fprintf(f, "0x%0*x", width, ctx->csum1);
                break;
index c3e4f6a..5359d6b 100644 (file)
@@ -418,7 +418,7 @@ static struct e2fsck_problem problem_table[] = {
 
        /* Making quota inode hidden */
        { PR_0_HIDE_QUOTA,
-         N_("Making @q @i %i (%Q) hidden.\n"),
+         N_("Hiding %U @q @i %i (%Q).\n"),
          PROMPT_NONE, PR_PREEN_OK },
 
        /* Superblock has invalid MMP block. */
index f98053b..173997e 100644 (file)
@@ -71,7 +71,9 @@ void e2fsck_hide_quota(e2fsck_t ctx)
                return;
 
        for (qtype = 0; qtype < MAXQUOTAS; qtype++) {
+               pctx.dir = 2;   /* This is a guess, but it's a good one */
                pctx.ino = *quota_sb_inump(sb, qtype);
+               pctx.num = qtype;
                quota_ino = quota_type2inum(qtype, fs->super);
                if (pctx.ino && (pctx.ino != quota_ino) &&
                    fix_problem(ctx, PR_0_HIDE_QUOTA, &pctx)) {