]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_db: refactor quota timer printing
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 20 Nov 2020 22:03:28 +0000 (17:03 -0500)
committerEric Sandeen <sandeen@sandeen.net>
Fri, 20 Nov 2020 22:03:28 +0000 (17:03 -0500)
Introduce type-specific printing functions to xfs_db to print a quota
timer instead of printing a raw int32 value.  This is needed to stay
ahead of changes that we're going to make to the quota timer format in
the following patches.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
db/dquot.c
db/field.c
db/field.h
db/fprint.c
db/fprint.h

index 1392aa1673ae07ada372d3577648cf2c9ac1cb0d..e52000f2e6eeefe629325f2cf029a3442eae3bfa 100644 (file)
@@ -60,8 +60,8 @@ const field_t disk_dquot_flds[] = {
          TYP_NONE },
        { "bcount", FLDT_QCNT, OI(DOFF(bcount)), C1, 0, TYP_NONE },
        { "icount", FLDT_QCNT, OI(DOFF(icount)), C1, 0, TYP_NONE },
-       { "itimer", FLDT_INT32D, OI(DOFF(itimer)), C1, 0, TYP_NONE },
-       { "btimer", FLDT_INT32D, OI(DOFF(btimer)), C1, 0, TYP_NONE },
+       { "itimer", FLDT_QTIMER, OI(DOFF(itimer)), C1, 0, TYP_NONE },
+       { "btimer", FLDT_QTIMER, OI(DOFF(btimer)), C1, 0, TYP_NONE },
        { "iwarns", FLDT_QWARNCNT, OI(DOFF(iwarns)), C1, 0, TYP_NONE },
        { "bwarns", FLDT_QWARNCNT, OI(DOFF(bwarns)), C1, 0, TYP_NONE },
        { "pad0", FLDT_UINT32X, OI(DOFF(pad0)), C1, FLD_SKIPALL, TYP_NONE },
@@ -70,7 +70,7 @@ const field_t disk_dquot_flds[] = {
        { "rtb_softlimit", FLDT_QCNT, OI(DOFF(rtb_softlimit)), C1, 0,
          TYP_NONE },
        { "rtbcount", FLDT_QCNT, OI(DOFF(rtbcount)), C1, 0, TYP_NONE },
-       { "rtbtimer", FLDT_INT32D, OI(DOFF(rtbtimer)), C1, 0, TYP_NONE },
+       { "rtbtimer", FLDT_QTIMER, OI(DOFF(rtbtimer)), C1, 0, TYP_NONE },
        { "rtbwarns", FLDT_QWARNCNT, OI(DOFF(rtbwarns)), C1, 0, TYP_NONE },
        { "pad", FLDT_UINT16X, OI(DOFF(pad)), C1, FLD_SKIPALL, TYP_NONE },
        { NULL }
index f0316aeb4a866cf691e1771d9ffcf0cbdc799869..51268938a9d31c733f9fbc3a045cee19576e2c2a 100644 (file)
@@ -351,6 +351,8 @@ const ftattr_t      ftattrtab[] = {
          FTARG_SIGNED, NULL, NULL },
        { FLDT_TIMESTAMP, "timestamp", NULL, (char *)timestamp_flds,
          SI(bitsz(xfs_timestamp_t)), 0, NULL, timestamp_flds },
+       { FLDT_QTIMER, "qtimer", fp_qtimer, NULL, SI(bitsz(uint32_t)), 0,
+         NULL, NULL },
        { FLDT_UINT1, "uint1", fp_num, "%u", SI(1), 0, NULL, NULL },
        { FLDT_UINT16D, "uint16d", fp_num, "%u", SI(bitsz(uint16_t)), 0, NULL,
          NULL },
index 15065373de39799b349c126414460fb1d577aa40..387c189ec87a792fb76f9b7b29993716018c38b6 100644 (file)
@@ -170,6 +170,7 @@ typedef enum fldt   {
 
        FLDT_TIME,
        FLDT_TIMESTAMP,
+       FLDT_QTIMER,
        FLDT_UINT1,
        FLDT_UINT16D,
        FLDT_UINT16O,
index 6e72bf076df203d69589d510ffea489593329e6d..72ed55fb5874dc29f4b474725790e0036ea5828d 100644 (file)
@@ -180,6 +180,40 @@ fp_nsec(
        return 1;
 }
 
+int
+fp_qtimer(
+       void                    *obj,
+       int                     bit,
+       int                     count,
+       char                    *fmtstr,
+       int                     size,
+       int                     arg,
+       int                     base,
+       int                     array)
+{
+       uint32_t                sec;
+       __be32                  *t;
+       int                     bitpos;
+       int                     i;
+
+       ASSERT(bitoffs(bit) == 0);
+       for (i = 0, bitpos = bit;
+            i < count && !seenint();
+            i++, bitpos += size) {
+               if (array)
+                       dbprintf("%d:", i + base);
+
+               t = obj + byteize(bitpos);
+               sec = be32_to_cpu(*t);
+
+               dbprintf("%u", sec);
+
+               if (i < count - 1)
+                       dbprintf(" ");
+       }
+       return 1;
+}
+
 /*ARGSUSED*/
 int
 fp_uuid(
index bfeed15ca7c46e59a1eba3d796d84d34c1e29dcf..a1ea935ca5313c0ec3855cafa1ec328555aa9944 100644 (file)
@@ -17,6 +17,8 @@ extern int    fp_time(void *obj, int bit, int count, char *fmtstr, int size,
                        int arg, int base, int array);
 extern int     fp_nsec(void *obj, int bit, int count, char *fmtstr, int size,
                        int arg, int base, int array);
+extern int     fp_qtimer(void *obj, int bit, int count, char *fmtstr, int size,
+                       int arg, int base, int array);
 extern int     fp_uuid(void *obj, int bit, int count, char *fmtstr, int size,
                        int arg, int base, int array);
 extern int     fp_crc(void *obj, int bit, int count, char *fmtstr, int size,