summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2019-05-24 12:53:32 +0200
committerJan Kara <jack@suse.cz>2019-05-24 12:53:32 +0200
commitdaba90fb6d9b8c8f1361457bf2bea7b18f4e35ec (patch)
treef9462e1cb40cd59ea5099058dcd753c06b5b86c1
parent7942290a0a6230fcc56eae42bf436e6eeca88777 (diff)
downloadlinuxquota-daba90fb6d9b8c8f1361457bf2bea7b18f4e35ec.tar.gz
setquota: Report failure to obtain quota information
setquota currently silently ignored when it could not obtain quota information to update and just skipped updating for the filesystem. Make it report error and exit properly. Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r--setquota.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/setquota.c b/setquota.c
index 08fdbfc..993d920 100644
--- a/setquota.c
+++ b/setquota.c
@@ -315,8 +315,17 @@ static int setlimits(struct quota_handle **handles)
int ret = 0;
curprivs = getprivs(id, handles, !!(flags & FL_ALL));
+ if (!curprivs) {
+ errstr(_("Error getting quota information to update.\n"));
+ return -1;
+ }
if (flags & FL_PROTO) {
protoprivs = getprivs(protoid, handles, 0);
+ if (!protoprivs) {
+ errstr(_("Error getting prototype quota information.\n"));
+ ret = -1;
+ goto out;
+ }
for (q = curprivs, protoq = protoprivs; q && protoq; q = q->dq_next, protoq = protoq->dq_next) {
q->dq_dqb.dqb_bsoftlimit = protoq->dq_dqb.dqb_bsoftlimit;
q->dq_dqb.dqb_bhardlimit = protoq->dq_dqb.dqb_bhardlimit;
@@ -337,6 +346,7 @@ static int setlimits(struct quota_handle **handles)
}
if (putprivs(curprivs, COMMIT_LIMITS) == -1)
ret = -1;
+out:
freeprivs(curprivs);
return ret;
}
@@ -436,6 +446,10 @@ static int batch_setlimits(struct quota_handle **handles)
while (!read_entry(&id, &isoftlimit, &ihardlimit, &bsoftlimit, &bhardlimit)) {
curprivs = getprivs(id, handles, !!(flags & FL_ALL));
+ if (!curprivs) {
+ errstr(_("Error getting quota information to update.\n"));
+ return -1;
+ }
for (q = curprivs; q; q = q->dq_next) {
q->dq_dqb.dqb_bsoftlimit = bsoftlimit;
q->dq_dqb.dqb_bhardlimit = bhardlimit;
@@ -475,6 +489,10 @@ static int setindivgraces(struct quota_handle **handles)
struct dquot *q, *curprivs;
curprivs = getprivs(id, handles, !!(flags & FL_ALL));
+ if (!curprivs) {
+ errstr(_("Error getting quota information to update.\n"));
+ return -1;
+ }
for (q = curprivs; q; q = q->dq_next) {
if (q->dq_dqb.dqb_bsoftlimit && toqb(q->dq_dqb.dqb_curspace) > q->dq_dqb.dqb_bsoftlimit)
q->dq_dqb.dqb_btime = toset.dqb_btime;