Whamcloud - gitweb
Merge branch 'maint' into next
[tools/e2fsprogs.git] / e2fsck / message.c
index 525f4a1..ba38038 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__
@@ -221,7 +224,7 @@ static void print_time(FILE *f, time_t t)
        static int              do_gmt = -1;
 
 #ifdef __dietlibc__
-               /* The diet libc doesn't respect the TZ environemnt variable */
+               /* The diet libc doesn't respect the TZ environment variable */
                if (do_gmt == -1) {
                        time_str = getenv("TZ");
                        if (!time_str)
@@ -278,19 +281,7 @@ static _INLINE_ void expand_inode_expression(FILE *f, ext2_filsys fs, char ch,
 
        switch (ch) {
        case 's':
-               if (LINUX_S_ISDIR(inode->i_mode))
-                       fprintf(f, "%u", inode->i_size);
-               else {
-#ifdef EXT2_NO_64_TYPE
-                       if (inode->i_size_high)
-                               fprintf(f, "0x%x%08x", inode->i_size_high,
-                                       inode->i_size);
-                       else
-                               fprintf(f, "%u", inode->i_size);
-#else
-                       fprintf(f, "%llu", EXT2_I_SIZE(inode));
-#endif
-               }
+               fprintf(f, "%llu", (unsigned long long) EXT2_I_SIZE(inode));
                break;
        case 'S':
                fprintf(f, "%u", large_inode->i_extra_isize);
@@ -316,7 +307,8 @@ static _INLINE_ void expand_inode_expression(FILE *f, ext2_filsys fs, char ch,
                fprintf(f, "%u", inode->i_faddr);
                break;
        case 'f':
-               fprintf(f, "%llu", ext2fs_file_acl_block(fs, inode));
+               fprintf(f, "%llu",
+                       (unsigned long long) ext2fs_file_acl_block(fs, inode));
                break;
        case 'd':
                fprintf(f, "%u", (LINUX_S_ISDIR(inode->i_mode) ?
@@ -411,11 +403,7 @@ static _INLINE_ void expand_percent_expression(FILE *f, ext2_filsys fs,
                fputc('%', f);
                break;
        case 'b':
-#ifdef EXT2_NO_64_TYPE
-               fprintf(f, "%*u", width, (unsigned long) ctx->blk);
-#else
                fprintf(f, "%*llu", width, (unsigned long long) ctx->blk);
-#endif
                break;
        case 'B':
                if (ctx->blkcount == BLOCK_COUNT_IND)
@@ -431,20 +419,11 @@ static _INLINE_ void expand_percent_expression(FILE *f, ext2_filsys fs,
                if (*first && islower(m[0]))
                        fputc(toupper(*m++), f);
                fputs(m, f);
-               if (ctx->blkcount >= 0) {
-#ifdef EXT2_NO_64_TYPE
-                       fprintf(f, "%d", ctx->blkcount);
-#else
+               if (ctx->blkcount >= 0)
                        fprintf(f, "%lld", (long long) ctx->blkcount);
-#endif
-               }
                break;
        case 'c':
-#ifdef EXT2_NO_64_TYPE
-               fprintf(f, "%*u", width, (unsigned long) ctx->blk2);
-#else
                fprintf(f, "%*llu", width, (unsigned long long) ctx->blk2);
-#endif
                break;
        case 'd':
                fprintf(f, "%*u", width, ctx->dir);
@@ -462,18 +441,10 @@ static _INLINE_ void expand_percent_expression(FILE *f, ext2_filsys fs,
                fprintf(f, "%*s", width, error_message(ctx->errcode));
                break;
        case 'N':
-#ifdef EXT2_NO_64_TYPE
-               fprintf(f, "%*u", width, ctx->num);
-#else
                fprintf(f, "%*llu", width, (long long)ctx->num);
-#endif
                break;
        case 'n':
-#ifdef EXT2_NO_64_TYPE
-               fprintf(f, "%*u", width, ctx->num2);
-#else
                fprintf(f, "%*llu", width, (long long)ctx->num2);
-#endif
                break;
        case 'p':
                print_pathname(f, fs, ctx->ino, 0);
@@ -489,14 +460,12 @@ static _INLINE_ void expand_percent_expression(FILE *f, ext2_filsys fs,
                print_pathname(f, fs, ctx->dir, ctx->ino);
                break;
        case 'r':
-#ifdef EXT2_NO_64_TYPE
-               fprintf(f, "%*d", width, ctx->blkcount);
-#else
                fprintf(f, "%*lld", width, (long long) ctx->blkcount);
-#endif
                break;
        case 'S':
-               fprintf(f, "%llu", get_backup_sb(NULL, fs, NULL, NULL));
+               fprintf(f, "%llu",
+                       (unsigned long long) get_backup_sb(NULL, fs,
+                                                          NULL, NULL));
                break;
        case 's':
                fprintf(f, "%*s", width, ctx->str ? ctx->str : "NULL");
@@ -507,15 +476,32 @@ 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 = _("project");
+                       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;
        case 'X':
-#ifdef EXT2_NO_64_TYPE
-               fprintf(f, "0x%0*x", width, ctx->num);
-#else
                fprintf(f, "0x%0*llx", width, (long long)ctx->num);
-#endif
                break;
        case 'y':
                fprintf(f, "0x%0*x", width, ctx->csum2);