xfs
[Top] [All Lists]

[PATCH 2/3] xfs_quota: print and path output formatting: maintain revers

To: linux-xfs@xxxxxxxxxxxxxxx
Subject: [PATCH 2/3] xfs_quota: print and path output formatting: maintain reverse compatibility
From: "Bill O'Donnell" <billodo@xxxxxxxxxx>
Date: Wed, 14 Sep 2016 10:19:40 -0500
Cc: xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1473866381-28975-1-git-send-email-billodo@xxxxxxxxxx>
References: <1473866381-28975-1-git-send-email-billodo@xxxxxxxxxx>
This patch adjusts the formatting of the xfs_quota print and
path outputs, in order to maintain reverse compatability:
when -f flag isn't used, need to keep the output same as in
previous version.

Signed-off-by: Bill O'Donnell <billodo@xxxxxxxxxx>
---
 quota/path.c | 67 +++++++++++++++++++++++++++++++++++-------------------------
 1 file changed, 39 insertions(+), 28 deletions(-)

diff --git a/quota/path.c b/quota/path.c
index aa3d33e..ed9c044 100644
--- a/quota/path.c
+++ b/quota/path.c
@@ -36,39 +36,50 @@ printpath(
        int             c;
 
        if (index == 0) {
-               printf(_("%sFilesystem          Pathname\n"),
-                       number ? _("      ") : "");
+               if (foreign_allowed)
+                       printf(_("%s    Filesystem          Pathname\n"),
+                              number ? _("      ") : "");
+               else
+                       printf(_("%sFilesystem          Pathname\n"),
+                              number ? _("      ") : "");
        }
        if (number) {
                printf(_("%c%03d%c "), braces? '[':' ', index, braces? ']':' ');
        }
-       printf("%s ", (path->fs_flags & FS_FOREIGN) ? "(F)" : "   ");
-       printf(_("%-19s %s"), path->fs_dir, path->fs_name);
-       if (path->fs_flags & FS_PROJECT_PATH) {
-               prj = getprprid(path->fs_prid);
-               printf(_(" (project %u"), path->fs_prid);
-               if (prj)
-                       printf(_(", %s"), prj->pr_name);
-               printf(")");
-       } else if (xfsquotactl(XFS_GETQSTAT, path->fs_name, 0, 0,
-                               (void *)&qstat) == 0 && qstat.qs_flags) {
-               c = 0;
-               printf(" (");
-               if (qstat.qs_flags & XFS_QUOTA_UDQ_ENFD)
-                       c = printf("uquota");
-               else if (qstat.qs_flags & XFS_QUOTA_UDQ_ACCT)
-                       c = printf("uqnoenforce");
-               if (qstat.qs_flags & XFS_QUOTA_GDQ_ENFD)
-                       c = printf("%sgquota", c ? ", " : "");
-               else if (qstat.qs_flags & XFS_QUOTA_GDQ_ACCT)
-                       c = printf("%sgqnoenforce", c ? ", " : "");
-               if (qstat.qs_flags & XFS_QUOTA_PDQ_ENFD)
-                       printf("%spquota", c ? ", " : "");
-               else if (qstat.qs_flags & XFS_QUOTA_PDQ_ACCT)
-                       printf("%spqnoenforce", c ? ", " : "");
-               printf(")");
+       if (!((path->fs_flags & FS_FOREIGN) && !foreign_allowed)) {
+               printf("%s", (path->fs_flags & FS_FOREIGN) ? "(F) " : "");
+               if (path->fs_flags & FS_FOREIGN)
+                       printf(_("%-19s %s"), path->fs_dir, path->fs_name);
+               else if (foreign_allowed)
+                       printf(_("    %-19s %s"), path->fs_dir, path->fs_name);
+               else
+                       printf(_("%-19s %s"), path->fs_dir, path->fs_name);
+               if (path->fs_flags & FS_PROJECT_PATH) {
+                       prj = getprprid(path->fs_prid);
+                       printf(_(" (project %u"), path->fs_prid);
+                       if (prj)
+                               printf(_(", %s"), prj->pr_name);
+                       printf(")");
+               } else if (xfsquotactl(XFS_GETQSTAT, path->fs_name, 0, 0,
+                                      (void *)&qstat) == 0 && qstat.qs_flags) {
+                       c = 0;
+                       printf(" (");
+                       if (qstat.qs_flags & XFS_QUOTA_UDQ_ENFD)
+                               c = printf("uquota");
+                       else if (qstat.qs_flags & XFS_QUOTA_UDQ_ACCT)
+                               c = printf("uqnoenforce");
+                       if (qstat.qs_flags & XFS_QUOTA_GDQ_ENFD)
+                               c = printf("%sgquota", c ? ", " : "");
+                       else if (qstat.qs_flags & XFS_QUOTA_GDQ_ACCT)
+                               c = printf("%sgqnoenforce", c ? ", " : "");
+                       if (qstat.qs_flags & XFS_QUOTA_PDQ_ENFD)
+                               printf("%spquota", c ? ", " : "");
+                       else if (qstat.qs_flags & XFS_QUOTA_PDQ_ACCT)
+                               printf("%spqnoenforce", c ? ", " : "");
+                       printf(")");
+               }
+               printf("\n");
        }
-       printf("\n");
 }
 
 static int
-- 
2.7.4

<Prev in Thread] Current Thread [Next in Thread>