Module Name:    src
Committed By:   bouyer
Date:           Wed Feb  9 09:51:17 UTC 2011

Modified Files:
        src/usr.sbin/quotacheck [bouyer-quota2]: quotacheck.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.40.14.1 src/usr.sbin/quotacheck/quotacheck.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/quotacheck/quotacheck.c
diff -u src/usr.sbin/quotacheck/quotacheck.c:1.40 src/usr.sbin/quotacheck/quotacheck.c:1.40.14.1
--- src/usr.sbin/quotacheck/quotacheck.c:1.40	Thu Oct  9 14:56:35 2008
+++ src/usr.sbin/quotacheck/quotacheck.c	Wed Feb  9 09:51:17 2011
@@ -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"?) */

Reply via email to