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

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