5eda098
From daba90fb6d9b8c8f1361457bf2bea7b18f4e35ec Mon Sep 17 00:00:00 2001
5eda098
From: Jan Kara <jack@suse.cz>
5eda098
Date: Fri, 24 May 2019 12:53:32 +0200
5eda098
Subject: [PATCH 4/4] setquota: Report failure to obtain quota information
5eda098
MIME-Version: 1.0
5eda098
Content-Type: text/plain; charset=UTF-8
5eda098
Content-Transfer-Encoding: 8bit
5eda098
5eda098
setquota currently silently ignored when it could not obtain quota
5eda098
information to update and just skipped updating for the filesystem. Make
5eda098
it report error and exit properly.
5eda098
5eda098
Signed-off-by: Jan Kara <jack@suse.cz>
5eda098
Signed-off-by: Petr Písař <ppisar@redhat.com>
5eda098
---
5eda098
 setquota.c | 18 ++++++++++++++++++
5eda098
 1 file changed, 18 insertions(+)
5eda098
5eda098
diff --git a/setquota.c b/setquota.c
5eda098
index 08fdbfc..993d920 100644
5eda098
--- a/setquota.c
5eda098
+++ b/setquota.c
5eda098
@@ -315,8 +315,17 @@ static int setlimits(struct quota_handle **handles)
5eda098
 	int ret = 0;
5eda098
 
5eda098
 	curprivs = getprivs(id, handles, !!(flags & FL_ALL));
5eda098
+	if (!curprivs) {
5eda098
+		errstr(_("Error getting quota information to update.\n"));
5eda098
+		return -1;
5eda098
+	}
5eda098
 	if (flags & FL_PROTO) {
5eda098
 		protoprivs = getprivs(protoid, handles, 0);
5eda098
+		if (!protoprivs) {
5eda098
+			errstr(_("Error getting prototype quota information.\n"));
5eda098
+			ret = -1;
5eda098
+			goto out;
5eda098
+		}
5eda098
 		for (q = curprivs, protoq = protoprivs; q && protoq; q = q->dq_next, protoq = protoq->dq_next) {
5eda098
 			q->dq_dqb.dqb_bsoftlimit = protoq->dq_dqb.dqb_bsoftlimit;
5eda098
 			q->dq_dqb.dqb_bhardlimit = protoq->dq_dqb.dqb_bhardlimit;
5eda098
@@ -337,6 +346,7 @@ static int setlimits(struct quota_handle **handles)
5eda098
 	}
5eda098
 	if (putprivs(curprivs, COMMIT_LIMITS) == -1)
5eda098
 		ret = -1;
5eda098
+out:
5eda098
 	freeprivs(curprivs);
5eda098
 	return ret;
5eda098
 }
5eda098
@@ -436,6 +446,10 @@ static int batch_setlimits(struct quota_handle **handles)
5eda098
 
5eda098
 	while (!read_entry(&id, &isoftlimit, &ihardlimit, &bsoftlimit, &bhardlimit)) {
5eda098
 		curprivs = getprivs(id, handles, !!(flags & FL_ALL));
5eda098
+		if (!curprivs) {
5eda098
+			errstr(_("Error getting quota information to update.\n"));
5eda098
+			return -1;
5eda098
+		}
5eda098
 		for (q = curprivs; q; q = q->dq_next) {
5eda098
 			q->dq_dqb.dqb_bsoftlimit = bsoftlimit;
5eda098
 			q->dq_dqb.dqb_bhardlimit = bhardlimit;
5eda098
@@ -475,6 +489,10 @@ static int setindivgraces(struct quota_handle **handles)
5eda098
 	struct dquot *q, *curprivs;
5eda098
 
5eda098
 	curprivs = getprivs(id, handles, !!(flags & FL_ALL));
5eda098
+	if (!curprivs) {
5eda098
+		errstr(_("Error getting quota information to update.\n"));
5eda098
+		return -1;
5eda098
+	}
5eda098
 	for (q = curprivs; q; q = q->dq_next) {
5eda098
 		if (q->dq_dqb.dqb_bsoftlimit && toqb(q->dq_dqb.dqb_curspace) > q->dq_dqb.dqb_bsoftlimit)
5eda098
 			q->dq_dqb.dqb_btime = toset.dqb_btime;
5eda098
-- 
5eda098
2.20.1
5eda098