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

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