Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/bouyer-quota2]: src/usr.sbin/quotacheck Make it build in new world.



details:   https://anonhg.NetBSD.org/src/rev/0267ad43e7b1
branches:  bouyer-quota2
changeset: 761134:0267ad43e7b1
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Wed Feb 09 09:51:17 2011 +0000

description:
Make it build in new world.
Don't attempt to update in-kernel quota, but instead warn if quotas
are already on. The rc.d script runs quotacheck before quotaon
so this shouldn't be a problem.

diffstat:

 usr.sbin/quotacheck/quotacheck.c |  35 +++++++++++++++++++++--------------
 1 files changed, 21 insertions(+), 14 deletions(-)

diffs (81 lines):

diff -r d6d6b9ee6547 -r 0267ad43e7b1 usr.sbin/quotacheck/quotacheck.c
--- a/usr.sbin/quotacheck/quotacheck.c  Tue Feb 08 22:39:23 2011 +0000
+++ b/usr.sbin/quotacheck/quotacheck.c  Wed Feb 09 09:51:17 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: quotacheck.c,v 1.40 2008/10/09 14:56:35 christos Exp $ */
+/*     $NetBSD: quotacheck.c,v 1.40.14.1 2011/02/09 09:51:17 bouyer Exp $      */
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)quotacheck.c       8.6 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: quotacheck.c,v 1.40 2008/10/09 14:56:35 christos Exp $");
+__RCSID("$NetBSD: quotacheck.c,v 1.40.14.1 2011/02/09 09:51:17 bouyer Exp $");
 #endif
 #endif /* not lint */
 
@@ -52,9 +52,10 @@
 #include <sys/param.h>
 #include <sys/stat.h>
 #include <sys/queue.h>
+#include <sys/statvfs.h>
 
 #include <ufs/ufs/dinode.h>
-#include <ufs/ufs/quota.h>
+#include <ufs/ufs/quota1.h>
 #include <ufs/ufs/ufs_bswap.h>
 #include <ufs/ffs/fs.h>
 #include <ufs/ffs/ffs_extern.h>
@@ -482,9 +483,25 @@
        u_int32_t id, lastid, nextid;
        int need_seek;
        struct dqblk dqbuf;
-       static int warned = 0;
        static struct dqblk zerodqbuf;
        static struct fileusage zerofileusage;
+       struct statvfs *fst;
+       int nfst, i;
+
+       nfst = getmntinfo(&fst, MNT_WAIT);
+       if (nfst == 0)
+               errx(1, "no filesystems mounted!");
+
+       for (i = 0; i < nfst; i++) {
+               if (strncmp(fst[i].f_fstypename, "ffs",
+                   sizeof(fst[i].f_fstypename)) == 0 &&
+                   strncmp(fst[i].f_mntonname, fsname,
+                   sizeof(fst[i].f_mntonname)) == 0 &&
+                   (fst[i].f_flag & ST_QUOTA) != 0) {
+                       warnx("filesystem %s has quotas already turned on",
+                           fsname);
+               }
+       }
 
        if ((qfo = fopen(quotafile, "r+")) == NULL) {
                if (errno == ENOENT)
@@ -507,12 +524,6 @@
                (void) fclose(qfo);
                return (1);
        }
-       if (quotactl(fsname, QCMD(Q_SYNC, type), 0, (void *) NULL) < 0 &&
-           errno == EOPNOTSUPP && !warned && vflag) {
-               warned++;
-               (void)printf("*** Warning: %s\n",
-                   "Quotas are not compiled into this kernel");
-       }
        need_seek = 1;
        for (lastid = highid[type], id = 0; id <= lastid; id = nextid) {
                if (fread((char *)&dqbuf, sizeof(struct dqblk), 1, qfi) == 0)
@@ -577,10 +588,6 @@
                }
                (void) fwrite((char *)&dqbuf, sizeof(struct dqblk), 1, qfo);
 
-               if (!warned)
-                       (void) quotactl(fsname, QCMD(Q_SETUSE, type), id,
-                           (caddr_t)&dqbuf);
-
                fup->fu_curinodes = 0;
                fup->fu_curblocks = 0;
                if (id == UINT32_MAX || nextid == 0) {  /* infinite loop avoidance (OR do as "nextid < id"?) */



Home | Main Index | Thread Index | Old Index