summaryrefslogtreecommitdiff
path: root/quotaops.c
diff options
context:
space:
mode:
authorjkar8572 <jkar8572>2001-07-16 03:24:49 +0000
committerjkar8572 <jkar8572>2001-07-16 03:24:49 +0000
commit88c7f535fbe80d96cf5ee15a3a2aa1bd1c535e1f (patch)
treef850410746d7ebb82f3b7b2a2d59a25ed4511069 /quotaops.c
parent865c3f4714cd2da77d590efc7dd3f7c2bcfb7cf9 (diff)
Fixed quotastats(8)
Grace times are now set when limits are set and usage is over limit. Added LARGEFILE flag to CFLAGS.
Diffstat (limited to 'quotaops.c')
-rw-r--r--quotaops.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/quotaops.c b/quotaops.c
index b9cd873..2168354 100644
--- a/quotaops.c
+++ b/quotaops.c
@@ -34,7 +34,7 @@
#ident "$Copyright: (c) 1980, 1990 Regents of the University of California. $"
#ident "$Copyright: All rights reserved. $"
-#ident "$Id: quotaops.c,v 1.4 2001/05/02 09:32:22 jkar8572 Exp $"
+#ident "$Id: quotaops.c,v 1.5 2001/07/16 03:24:49 jkar8572 Exp $"
#include <rpc/rpc.h>
#include <sys/types.h>
@@ -49,6 +49,7 @@
#include <signal.h>
#include <paths.h>
#include <unistd.h>
+#include <time.h>
#if defined(RPC)
#include "rquota.h"
@@ -84,6 +85,28 @@ static int cvtatos(time_t time, char *units, time_t * seconds)
}
/*
+ * Set grace time if needed
+ */
+void update_grace_times(struct dquot *q)
+{
+ time_t now;
+
+ time(&now);
+ if (q->dq_dqb.dqb_bsoftlimit && toqb(q->dq_dqb.dqb_curspace) >= q->dq_dqb.dqb_bsoftlimit) {
+ if (!q->dq_dqb.dqb_btime)
+ q->dq_dqb.dqb_btime = now + q->dq_h->qh_info.dqi_bgrace;
+ }
+ else
+ q->dq_dqb.dqb_btime = 0;
+ if (q->dq_dqb.dqb_isoftlimit && q->dq_dqb.dqb_curinodes >= q->dq_dqb.dqb_isoftlimit) {
+ if (!q->dq_dqb.dqb_itime)
+ q->dq_dqb.dqb_itime = now + q->dq_h->qh_info.dqi_igrace;
+ }
+ else
+ q->dq_dqb.dqb_itime = 0;
+}
+
+/*
* Collect the requested quota information.
*/
struct dquot *getprivs(qid_t id, struct quota_handle **handles)
@@ -177,7 +200,7 @@ int editprivs(char *tmpfile)
sigaddset(&nmask, SIGHUP);
sigprocmask(SIG_SETMASK, &nmask, &omask);
if ((pid = fork()) < 0) {
- perror("fork");
+ errstr("Can't fork(): %s\n", strerror(errno));
return -1;
}
if (pid == 0) {
@@ -254,26 +277,12 @@ static void merge_to_list(struct dquot *qlist, char *dev, u_int64_t blocks, u_in
if (!devcmp_handle(dev, q->dq_h))
continue;
- /*
- * Cause time limit to be reset when the quota is
- * next used if previously had no soft limit or were
- * under it, but now have a soft limit and are over
- * it.
- */
- if (bsoft && (toqb(q->dq_dqb.dqb_curspace) >= bsoft) &&
- (q->dq_dqb.dqb_bsoftlimit == 0 ||
- toqb(q->dq_dqb.dqb_curspace) < q->dq_dqb.dqb_bsoftlimit))
- q->dq_dqb.dqb_btime = 0;
-
- if (isoft && (q->dq_dqb.dqb_curinodes >= isoft) &&
- (q->dq_dqb.dqb_isoftlimit == 0 ||
- q->dq_dqb.dqb_curinodes < q->dq_dqb.dqb_isoftlimit)) q->dq_dqb.dqb_itime = 0;
-
q->dq_dqb.dqb_bsoftlimit = bsoft;
q->dq_dqb.dqb_bhardlimit = bhard;
q->dq_dqb.dqb_isoftlimit = isoft;
q->dq_dqb.dqb_ihardlimit = ihard;
q->dq_flags |= DQ_FOUND;
+ update_grace_times(q);
if (blocks != toqb(q->dq_dqb.dqb_curspace))
errstr(_("WARNING - %s: cannot change current block allocation\n"),