summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2022-11-01 11:45:06 +0100
committerJan Kara <jack@suse.cz>2022-11-01 11:45:06 +0100
commitf7e24ee92d9bc16557132b33a34a6154aafd99d7 (patch)
tree0fe64b5db5c29afced421d8b2b57ccd9203d3c63
parent037eaa6037789a3fac082ca1d6e240073943ca1a (diff)
downloadlinuxquota-f7e24ee92d9bc16557132b33a34a6154aafd99d7.tar.gz
edquota: Fix editing of individual user grace times
When user is not over softlimit, there's no point to set the grace time. The kernel will just ignore it. Output error message instead so that user is not confused. Also editing of grace times when quotas are enabled did not really work because we didn't tell the kernel grace times have changed. Fix it. Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r--edquota.c3
-rw-r--r--quotaops.c12
2 files changed, 12 insertions, 3 deletions
diff --git a/edquota.c b/edquota.c
index a77106c..20ca306 100644
--- a/edquota.c
+++ b/edquota.c
@@ -352,7 +352,8 @@ int main(int argc, char **argv)
goto next_user;
}
}
- if (putprivs(curprivs, COMMIT_LIMITS) == -1)
+ if (putprivs(curprivs,
+ (flags & FL_EDIT_TIMES) ? COMMIT_TIMES : COMMIT_LIMITS) == -1)
ret = -1;
next_user:
freeprivs(curprivs);
diff --git a/quotaops.c b/quotaops.c
index 96086f4..2d25ae5 100644
--- a/quotaops.c
+++ b/quotaops.c
@@ -418,8 +418,16 @@ static void merge_times_to_list(struct dquot *qlist, char *dev, time_t btime, ti
if (!devcmp_handle(dev, q->dq_h))
continue;
- q->dq_dqb.dqb_btime = btime;
- q->dq_dqb.dqb_itime = itime;
+ if (!btime ||
+ (q->dq_dqb.dqb_bsoftlimit && toqb(q->dq_dqb.dqb_curspace) > q->dq_dqb.dqb_bsoftlimit))
+ q->dq_dqb.dqb_btime = btime;
+ else
+ errstr(_("Not setting block grace time on %s because softlimit is not exceeded.\n"), q->dq_h->qh_quotadev);
+ if (!itime ||
+ (q->dq_dqb.dqb_isoftlimit && q->dq_dqb.dqb_curinodes > q->dq_dqb.dqb_isoftlimit))
+ q->dq_dqb.dqb_itime = itime;
+ else
+ errstr(_("Not setting inode grace time on %s because softlimit is not exceeded.\n"), q->dq_h->qh_quotadev);
q->dq_flags |= DQ_FOUND;
}
}