aboutsummaryrefslogtreecommitdiff
path: root/sbin/quotacheck/quotacheck.c
diff options
context:
space:
mode:
authorMike Pritchard <mpp@FreeBSD.org>1996-02-27 01:53:17 +0000
committerMike Pritchard <mpp@FreeBSD.org>1996-02-27 01:53:17 +0000
commit93b5f489621c75f16326536ed9a1089356a5e9df (patch)
tree007208e6376137f842e6659b1e7e405c4ca39dd5 /sbin/quotacheck/quotacheck.c
parent8349ecbf7a14fa18510cae1392a7110accc098d4 (diff)
downloadsrc-93b5f489621c75f16326536ed9a1089356a5e9df.tar.gz
src-93b5f489621c75f16326536ed9a1089356a5e9df.zip
Fix quotacheck to not do a bunch of unneeded fseeks if the
quota file information is accurate. This makes it about twice as fast when the uid name space is very large.
Notes
Notes: svn path=/head/; revision=14271
Diffstat (limited to 'sbin/quotacheck/quotacheck.c')
-rw-r--r--sbin/quotacheck/quotacheck.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/sbin/quotacheck/quotacheck.c b/sbin/quotacheck/quotacheck.c
index 913e381d9560..823ed46495fe 100644
--- a/sbin/quotacheck/quotacheck.c
+++ b/sbin/quotacheck/quotacheck.c
@@ -311,6 +311,7 @@ update(fsname, quotafile, type)
register struct fileusage *fup;
register FILE *qfi, *qfo;
register u_long id, lastid;
+ register off_t offset;
struct dqblk dqbuf;
static int warned = 0;
static struct dqblk zerodqbuf;
@@ -343,7 +344,8 @@ update(fsname, quotafile, type)
(void)printf("*** Warning: %s\n",
"Quotas are not compiled into this kernel");
}
- for (lastid = highid[type], id = 0; id <= lastid; id++) {
+ for (lastid = highid[type], id = 0, offset = 0; id <= lastid;
+ id++, offset += sizeof(struct dqblk)) {
if (fread((char *)&dqbuf, sizeof(struct dqblk), 1, qfi) == 0)
dqbuf = zerodqbuf;
if ((fup = lookup(id, type)) == 0)
@@ -352,7 +354,6 @@ update(fsname, quotafile, type)
dqbuf.dqb_curblocks == fup->fu_curblocks) {
fup->fu_curinodes = 0;
fup->fu_curblocks = 0;
- fseek(qfo, (long)sizeof(struct dqblk), 1);
continue;
}
if (vflag) {
@@ -381,6 +382,12 @@ update(fsname, quotafile, type)
dqbuf.dqb_itime = 0;
dqbuf.dqb_curinodes = fup->fu_curinodes;
dqbuf.dqb_curblocks = fup->fu_curblocks;
+ if (fseek(qfo, offset, SEEK_SET) < 0) {
+ (void) fprintf(stderr,
+ "quotacheck: %s: seek failed: %s\n",
+ quotafile, strerror(errno));
+ return(1);
+ }
fwrite((char *)&dqbuf, sizeof(struct dqblk), 1, qfo);
(void) quotactl(fsname, QCMD(Q_SETUSE, type), id,
(caddr_t)&dqbuf);