]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_quota: print quota id number if the name can't be found
authorZorro Lang <zlang@redhat.com>
Tue, 10 May 2016 07:16:06 +0000 (17:16 +1000)
committerDave Chinner <david@fromorbit.com>
Tue, 10 May 2016 07:16:06 +0000 (17:16 +1000)
When use GETNEXTQUOTA ioctl to report project quota, it always
report an unexpected quota:

  (null) 0 0 0 00 [--------]

The ID 0 store the default quota, even if no one set default quota,
it still have quota accounting, but not enforced. So GETNEXTQUOTA
can find and report this undefined quota.

From this problem, I thought if others' quota name miss, (null) will
be printed too. e.g.

  # xfs_quota -xc "limit -u bsoft=300m bhard=400m test" $mnt
  # xfs_quota -xc "report -u" $mnt
  User ID          Used       Soft       Hard    Warn/Grace
  ---------- --------------------------------------------------
  root                0          0          0     00 [--------]
  test                0     307200     409600     00 [--------]
  # userdel -r test
  # xfs_quota -xc "report -u" $mnt
  User ID          Used       Soft       Hard    Warn/Grace
  ---------- --------------------------------------------------
  root                0          0          0     00 [--------]
  (null)              0     307200     409600     00 [--------]

So this problem same with above id 0's problem. To deal with this,
this patch will print id number if the name can't be found.

However, if we use the old GETQUOTA ioctl, it won't print project id
0 quota information if it's not defined. That's different with
GETNEXTQUOTA. For keep consistent, this patch also print project id
0 when use old GETQUOTA.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
man/man8/xfs_quota.8
quota/report.c

index ab674235eab660fae4fd9b702859547446ec83fa..f66e4212395bd4e2f95e166c7746c05f4c9de9cf 100644 (file)
@@ -375,7 +375,9 @@ option outputs the report to
 .I file
 instead of stdout. The
 .B \-a
-option reports on all filesystems. The
+option reports on all filesystems. By default, outputs the name of
+the user/group/project. If no name is defined for a given ID, outputs
+the numeric ID instead. The
 .B \-n
 option outputs the numeric ID instead of the name. The
 .B \-L
index 48a3f2913476def70090a9842905cd75c26abf37..cc422d19107665f76ce0d827de3df9652e6ab743 100644 (file)
@@ -389,7 +389,11 @@ report_mount(
                                        name = p->pr_name;
                        }
                }
-               fprintf(fp, "%-10s", name);
+               /* If no name is found, print the id #num instead of (null) */
+               if (name != NULL)
+                       fprintf(fp, "%-10s", name);
+               else
+                       fprintf(fp, "#%-9u", d.d_id);
        }
 
        if (form & XFS_BLOCK_QUOTA) {
@@ -571,6 +575,16 @@ report_project_mount(
                        id = oid + 1;
                }
        } else {
+               if (!getprprid(0)) {
+                       /*
+                        * Print default project quota, even if projid 0
+                        * isn't defined
+                        */
+                       report_mount(fp, 0, NULL, NULL, form, XFS_PROJ_QUOTA,
+                                    mount, flags);
+                       flags |= NO_HEADER_FLAG;
+               }
+
                setprent();
                while ((p = getprent()) != NULL) {
                        if (report_mount(fp, p->pr_prid, p->pr_name, NULL,