Distinguish between none quota limits and no allocated resources in quota(1) tool output

This commit is contained in:
Petr Písař 2018-07-24 12:24:15 +02:00
parent 467928d37f
commit 47a961a4db
2 changed files with 82 additions and 1 deletions

View File

@ -0,0 +1,72 @@
From bd36c3cf438ac4fd44b6779714ad0a44453d41b5 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.
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 15c2a53..0303c7d 100644
--- a/quota.c
+++ b/quota.c
@@ -188,7 +188,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);
@@ -204,11 +204,16 @@ static int showquotas(int type, qid_t id, int mntcnt, char **mnt)
goto out_handles;
}
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");
@@ -300,7 +305,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);
out_handles:
dispose_handle_list(handles);
--
2.14.4

View File

@ -10,7 +10,7 @@
Name: quota
Epoch: 1
Version: 4.04
Release: 8%{?dist}
Release: 9%{?dist}
Summary: System administration tools for monitoring users' disk usage
# quota_nld.c, quotaio_xfs.h: GPLv2
# bylabel.c copied from util-linux: GPLv2+
@ -79,6 +79,10 @@ Patch10: quota-4.04-Listen-on-a-TCP-socket.patch
# Fix current block usage limit in RPC client, in upstream after 4.04,
# <https://sourceforge.net/p/linuxquota/bugs/127/>
Patch11: quota-4.04-rpc-Fix-wrong-limit-for-space-usage.patch
# Distinguish between none quota limits and no allocated resources in quota(1)
# tool output, proposed to upstream,
# <https://sourceforge.net/p/linuxquota/bugs/128/>
Patch12: quota-4.04-quota-1-Distinguish-between-none-quota-limits-and-no.patch
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: bash
@ -204,6 +208,7 @@ Linux/UNIX environment.
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
# Regenerate build scripts
autoreconf -f -i
@ -348,6 +353,10 @@ make check
%changelog
* Tue Jul 24 2018 Petr Pisar <ppisar@redhat.com> - 1:4.04-9
- Distinguish between none quota limits and no allocated resources in quota(1)
tool output
* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1:4.04-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild