From 277552890a8833d999a8e80c0fd55dd99075a254 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sat, 22 Jul 2017 14:51:28 -0400 Subject: [PATCH] e2fsck: add support for printing the quota type in problem reports using %U Signed-off-by: Theodore Ts'o --- e2fsck/message.c | 26 +++++++++++++++++++++++++- e2fsck/problem.c | 2 +- e2fsck/quota.c | 2 ++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/e2fsck/message.c b/e2fsck/message.c index 1c3fcd8..a44205f 100644 --- a/e2fsck/message.c +++ b/e2fsck/message.c @@ -48,6 +48,9 @@ * the containing directory. * %r interpret blkcount as refcount * %s miscellaneous string + * %t time (in ) + * %T current time + * %U quota type (in ) * %S backup superblock * %X hexadecimal format * @@ -92,9 +95,9 @@ #include #include #include +#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; diff --git a/e2fsck/problem.c b/e2fsck/problem.c index c3e4f6a..5359d6b 100644 --- a/e2fsck/problem.c +++ b/e2fsck/problem.c @@ -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. */ diff --git a/e2fsck/quota.c b/e2fsck/quota.c index f98053b..173997e 100644 --- a/e2fsck/quota.c +++ b/e2fsck/quota.c @@ -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)) { -- 1.8.3.1