Blame SOURCES/quota-4.04-quota-1-Distinguish-between-none-quota-limits-and-no.patch

30c500
From bd36c3cf438ac4fd44b6779714ad0a44453d41b5 Mon Sep 17 00:00:00 2001
30c500
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
30c500
Date: Mon, 16 Jul 2018 11:22:53 +0200
30c500
Subject: [PATCH] quota(1): Distinguish between none quota limits and no
30c500
 allocated resources
30c500
MIME-Version: 1.0
30c500
Content-Type: text/plain; charset=UTF-8
30c500
Content-Transfer-Encoding: 8bit
30c500
30c500
If a user does not occupies any space or inodes on a file system but
30c500
quota limits are set, quota(1) tool still reports "none":
30c500
30c500
  # quota -u test
30c500
  Disk quotas for user test (uid 500): none
30c500
30c500
That's because the tool skips printing details for file systems
30c500
without any used resources but uses the shares the message with file
30c500
system without any quota limits.
30c500
30c500
This patch makes the distinction and changes "none" message into "no
30c500
quota limits set" and "no limited resources used" respectively.
30c500
30c500
Signed-off-by: Petr Písař <ppisar@redhat.com>
30c500
---
30c500
 quota.c | 15 ++++++++++-----
30c500
 1 file changed, 10 insertions(+), 5 deletions(-)
30c500
30c500
diff --git a/quota.c b/quota.c
30c500
index 15c2a53..0303c7d 100644
30c500
--- a/quota.c
30c500
+++ b/quota.c
30c500
@@ -188,7 +188,7 @@ static int showquotas(int type, qid_t id, int mntcnt, char **mnt)
30c500
 	char timebuf[MAXTIMELEN];
30c500
 	char name[MAXNAMELEN];
30c500
 	struct quota_handle **handles;
30c500
-	int lines = 0, bover, iover, over;
30c500
+	int lines = 0, bover, iover, over, unlimited;
30c500
 	time_t now;
30c500
 
30c500
 	time(&now;;
30c500
@@ -204,11 +204,16 @@ static int showquotas(int type, qid_t id, int mntcnt, char **mnt)
30c500
 		goto out_handles;
30c500
 	}
30c500
 	over = 0;
30c500
+	unlimited = 1;
30c500
 	for (q = qlist; q; q = q->dq_next) {
30c500
 		bover = iover = 0;
30c500
-		if (!(flags & FL_VERBOSE) && !q->dq_dqb.dqb_isoftlimit && !q->dq_dqb.dqb_ihardlimit
30c500
-		    && !q->dq_dqb.dqb_bsoftlimit && !q->dq_dqb.dqb_bhardlimit)
30c500
-			continue;
30c500
+		if (!q->dq_dqb.dqb_isoftlimit && !q->dq_dqb.dqb_ihardlimit
30c500
+		    && !q->dq_dqb.dqb_bsoftlimit && !q->dq_dqb.dqb_bhardlimit) {
30c500
+			if (!(flags & FL_VERBOSE))
30c500
+				continue;
30c500
+		} else {
30c500
+			unlimited = 0;
30c500
+		}
30c500
 		msgi = NULL;
30c500
 		if (q->dq_dqb.dqb_ihardlimit && q->dq_dqb.dqb_curinodes >= q->dq_dqb.dqb_ihardlimit) {
30c500
 			msgi = _("File limit reached on");
30c500
@@ -300,7 +305,7 @@ static int showquotas(int type, qid_t id, int mntcnt, char **mnt)
30c500
 		}
30c500
 	}
30c500
 	if (!(flags & FL_QUIET) && !lines && qlist)
30c500
-		heading(type, id, name, _("none"));
30c500
+		heading(type, id, name, unlimited ? _("none") : _("no limited resources used"));
30c500
 	freeprivs(qlist);
30c500
 out_handles:
30c500
 	dispose_handle_list(handles);
30c500
-- 
30c500
2.14.4
30c500