Blob Blame History Raw
From d9e5d8ee642d97c6223d4b7536f33db0e9834a85 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Mon, 16 Jul 2018 11:22:53 +0200
Subject: [PATCH] quota(1): Distinguish between none quota limits and no
 allocated resources
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

If a user does not occupies any space or inodes on a file system but
quota limits are set, quota(1) tool still reports "none":

  # quota -u test
  Disk quotas for user test (uid 500): none

That's because the tool skips printing details for file systems
without any used resources but uses the shares the message with file
system without any quota limits.

This patch makes the distinction and changes "none" message into "no
quota limits set" and "no limited resources used" respectively.

Petr Písař: Ported to 4.01.

Signed-off-by: Petr Písař <ppisar@redhat.com>
---
 quota.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/quota.c b/quota.c
index 1befbde..7e1f25c 100644
--- a/quota.c
+++ b/quota.c
@@ -179,7 +179,7 @@ static int showquotas(int type, qid_t id, int mntcnt, char **mnt)
 	char timebuf[MAXTIMELEN];
 	char name[MAXNAMELEN];
 	struct quota_handle **handles;
-	int lines = 0, bover, iover, over;
+	int lines = 0, bover, iover, over, unlimited;
 	time_t now;
 
 	time(&now);
@@ -191,11 +191,16 @@ static int showquotas(int type, qid_t id, int mntcnt, char **mnt)
 		| ((flags & FL_NFSALL) ? MS_NFS_ALL : 0));
 	qlist = getprivs(id, handles, !!(flags & FL_QUIETREFUSE));
 	over = 0;
+	unlimited = 1;
 	for (q = qlist; q; q = q->dq_next) {
 		bover = iover = 0;
-		if (!(flags & FL_VERBOSE) && !q->dq_dqb.dqb_isoftlimit && !q->dq_dqb.dqb_ihardlimit
-		    && !q->dq_dqb.dqb_bsoftlimit && !q->dq_dqb.dqb_bhardlimit)
-			continue;
+		if (!q->dq_dqb.dqb_isoftlimit && !q->dq_dqb.dqb_ihardlimit
+		    && !q->dq_dqb.dqb_bsoftlimit && !q->dq_dqb.dqb_bhardlimit) {
+			if (!(flags & FL_VERBOSE))
+				continue;
+		} else {
+			unlimited = 0;
+		}
 		msgi = NULL;
 		if (q->dq_dqb.dqb_ihardlimit && q->dq_dqb.dqb_curinodes >= q->dq_dqb.dqb_ihardlimit) {
 			msgi = _("File limit reached on");
@@ -287,7 +292,7 @@ static int showquotas(int type, qid_t id, int mntcnt, char **mnt)
 		}
 	}
 	if (!(flags & FL_QUIET) && !lines && qlist)
-		heading(type, id, name, _("none"));
+		heading(type, id, name, unlimited ? _("none") : _("no limited resources used"));
 	freeprivs(qlist);
 	dispose_handle_list(handles);
 	return over > 0 ? 1 : 0;
-- 
2.14.4