CVS commit: src/usr.sbin/quotacheck

2011-03-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar  6 23:07:23 UTC 2011

Modified Files:
src/usr.sbin/quotacheck: Makefile quotacheck.c

Log Message:
use merged out code.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/quotacheck/Makefile
cvs rdiff -u -r1.41 -r1.42 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/Makefile
diff -u src/usr.sbin/quotacheck/Makefile:1.18 src/usr.sbin/quotacheck/Makefile:1.19
--- src/usr.sbin/quotacheck/Makefile:1.18	Wed Apr 22 11:23:07 2009
+++ src/usr.sbin/quotacheck/Makefile	Sun Mar  6 18:07:23 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.18 2009/04/22 15:23:07 lukem Exp $
+#	$NetBSD: Makefile,v 1.19 2011/03/06 23:07:23 christos Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/5/93
 
 .include bsd.own.mk
@@ -8,7 +8,9 @@
 MAN=	quotacheck.8
 DPADD=	${LIBUTIL}
 LDADD+=	-lutil
-CPPFLAGS+=-I${NETBSDSRCDIR}/sbin/fsck
-.PATH:	${NETBSDSRCDIR}/sbin/fsck ${NETBSDSRCDIR}/sys/ufs/ffs
+CPPFLAGS+=-I${NETBSDSRCDIR}/sbin/fsck -I${NETBSDSRCDIR}/usr.bin/quota
+.PATH:	${NETBSDSRCDIR}/sbin/fsck ${NETBSDSRCDIR}/sys/ufs/ffs ${NETBSDSRCDIR}/usr.bin/quota
+SRCS+=  quotautil.c
+
 
 .include bsd.prog.mk

Index: src/usr.sbin/quotacheck/quotacheck.c
diff -u src/usr.sbin/quotacheck/quotacheck.c:1.41 src/usr.sbin/quotacheck/quotacheck.c:1.42
--- src/usr.sbin/quotacheck/quotacheck.c:1.41	Sun Mar  6 12:08:43 2011
+++ src/usr.sbin/quotacheck/quotacheck.c	Sun Mar  6 18:07:23 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: quotacheck.c,v 1.41 2011/03/06 17:08:43 bouyer Exp $	*/
+/*	$NetBSD: quotacheck.c,v 1.42 2011/03/06 23:07:23 christos 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.41 2011/03/06 17:08:43 bouyer Exp $);
+__RCSID($NetBSD: quotacheck.c,v 1.42 2011/03/06 23:07:23 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -72,6 +72,7 @@
 #include string.h
 
 #include fsutil.h
+#include quotautil.h
 
 #ifndef FS_UFS1_MAGIC
 # define FS_UFS1_MAGIC		FS_MAGIC /* 0x011954 */
@@ -89,8 +90,6 @@
 # define SBLOCKSEARCH	{ SBSIZE, -1 }
 #endif
 
-static const char *qfname = QUOTAFILENAME;
-static const char *qfextension[] = INITQFNAMES;
 static const char *quotagroup = QUOTAGROUP;
 
 static union {
@@ -113,7 +112,7 @@
 	struct	fileusage *fu_next;
 	u_long	fu_curinodes;
 	u_long	fu_curblocks;
-	u_int32_t fu_id;		/* uid_t, gid_t */
+	uint32_t fu_id;		/* uid_t, gid_t */
 	char	fu_name[1];
 	/* actually bigger */
 };
@@ -143,39 +142,34 @@
 static int	vflag;		/* verbose */
 static int	qflag;		/* quick but untidy mode */
 static int	fi;		/* open disk file descriptor */
-static u_int32_t highid[MAXQUOTAS];/* highest addid()'ed identifier per type */
+static uint32_t highid[MAXQUOTAS];/* highest addid()'ed identifier per type */
 static int needswap;	/* FS is in swapped order */
 static int got_siginfo = 0; /* got a siginfo signal */
 static int is_ufs2;
 
 
-int main __P((int, char *[]));
-static void usage __P((void));
-static void *needchk __P((struct fstab *));
-static int chkquota __P((const char *, const char *, const char *, void *,
-pid_t *));
-static int update __P((const char *, const char *, int));
-static u_int32_t skipforward __P((u_int32_t, u_int32_t, FILE *));
-static int oneof __P((const char *, char *[], int));
-static int getquotagid __P((void));
-static int hasquota __P((struct fstab *, int, char **));
-static struct fileusage *lookup __P((u_int32_t, int));
-static struct fileusage *addid __P((u_int32_t, int, const char *));
-static u_int32_t subsequent __P((u_int32_t, int)); 
-static union comb_dinode *getnextinode __P((ino_t));
-static void setinodebuf __P((ino_t));
-static void freeinodebuf __P((void));
-static void bread __P((daddr_t, char *, long));
-static void infohandler __P((int sig));
+static void usage(void) __attribute__((__noreturn__));
+static void *needchk(struct fstab *);
+static int chkquota(const char *, const char *, const char *, void *, pid_t *);
+static int update(const char *, const char *, int);
+static uint32_t skipforward(uint32_t, uint32_t, FILE *);
+static int oneof(const char *, char *[], int);
+static int getquotagid(void);
+static struct fileusage *lookup(uint32_t, int);
+static struct fileusage *addid(uint32_t, int, const char *);
+static uint32_t subsequent(uint32_t, int) ;
+static union comb_dinode *getnextinode(ino_t);
+static void setinodebuf(ino_t);
+static void freeinodebuf(void);
+static void bread(daddr_t, char *, long);
+static void infohandler(int sig);
 static void swap_dinode1(union comb_dinode *, int);
 #ifdef HAVE_UFSv2
 static void swap_dinode2(union comb_dinode *, int);
 #endif
 
 int
-main(argc, argv)
-	int argc;
-	char *argv[];
+main(int argc, char *argv[])
 {
 	struct fstab *fs;
 	struct passwd *pw;
@@ -241,13 +235,13 @@
 	if (gflag) {

CVS commit: src/usr.sbin/quotacheck

2011-03-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar  6 23:13:22 UTC 2011

Modified Files:
src/usr.sbin/quotacheck: quotacheck.c

Log Message:
more KNF


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 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.42 src/usr.sbin/quotacheck/quotacheck.c:1.43
--- src/usr.sbin/quotacheck/quotacheck.c:1.42	Sun Mar  6 18:07:23 2011
+++ src/usr.sbin/quotacheck/quotacheck.c	Sun Mar  6 18:13:22 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: quotacheck.c,v 1.42 2011/03/06 23:07:23 christos Exp $	*/
+/*	$NetBSD: quotacheck.c,v 1.43 2011/03/06 23:13:22 christos 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.42 2011/03/06 23:07:23 christos Exp $);
+__RCSID($NetBSD: quotacheck.c,v 1.43 2011/03/06 23:13:22 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -225,11 +225,11 @@
 		i = 0;
 		while ((fs = getfsent()) != NULL) {
 			if (needchk(fs))
-i=1;
+i = 1;
 		}
 		endfsent();
 		if (!i)	/* No filesystems with quotas */
-			exit(0);
+			return 0;
 	}
 
 	if (gflag) {
@@ -261,24 +261,21 @@
 	endfsent();
 	for (i = 0; i  argc; i++)
 		if ((done  (1  i)) == 0)
-			fprintf(stderr, %s not found in %s\n,
-argv[i], FSTAB);
-	exit(errs);
+			warnx(%s not found in %s\n, argv[i], FSTAB);
+	return errs;
 }
 
 static void
-usage()
+usage(void)
 {
-
-	(void)fprintf(stderr,
-	usage:\t%s -a [-gquv] [-l maxparallel]\n\t%s [-gquv] filesys ...\n, getprogname(),
-	getprogname());
+	const char *p = getprogname();
+	(void)fprintf(stderr, Usage: %s -a [-gquv] [-l maxparallel]\n
+	\t%s [-gquv] filesys ...\n, p, p);
 	exit(1);
 }
 
 static void *
-needchk(fs)
-	struct fstab *fs;
+needchk(struct fstab *fs)
 {
 	struct quotaname *qnp;
 	char qfnp[MAXPATHLEN];
@@ -303,16 +300,14 @@
 	return (NULL);
 }
 
-off_t sblock_try[] = SBLOCKSEARCH;
+static off_t sblock_try[] = SBLOCKSEARCH;
 
 /*
  * Scan the specified filesystem to check quota(s) present on it.
  */
 static int
-chkquota(type, fsname, mntpt, v, pid)
-	const char *type, *fsname, *mntpt;
-	void *v;
-	pid_t *pid;
+chkquota(const char *type, const char *fsname, const char *mntpt, void *v,
+pid_t *pid)
 {
 	struct quotaname *qnp = v;
 	struct fileusage *fup;
@@ -468,9 +463,7 @@
  * Update a specified quota file.
  */
 static int
-update(fsname, quotafile, type)
-	const char *fsname, *quotafile;
-	int type;
+update(const char *fsname, const char *quotafile, int type)
 {
 	struct fileusage *fup;
 	FILE *qfi, *qfo;
@@ -526,13 +519,17 @@
 			fup = zerofileusage;
 
 		nextid = subsequent(id, type);
-		if (nextid  0  nextid != id + 1) /* watch out for id == UINT32_MAX */
+		/* watch out for id == UINT32_MAX */
+		if (nextid  0  nextid != id + 1)
 			nextid = skipforward(id, nextid, qfi);
 
 		if (got_siginfo) {
-			/* XXX this could try to show percentage through the ID list */
-			fprintf(stderr,
-			%s: updating %s quotas for id=% PRIu32  (%s)\n, fsname,
+			/*
+			 * XXX this could try to show percentage through
+			 * the ID list
+			 */
+			fprintf(stderr, %s: updating %s quotas for id=%
+			PRIu32  (%s)\n, fsname,
 			qfextension[type  MAXQUOTAS ? type : MAXQUOTAS],
 			id, fup-fu_name);
 			got_siginfo = 0;
@@ -543,7 +540,8 @@
 			fup-fu_curblocks = 0;	/* for next filesystem */
 
 			need_seek = 1;
-			if (id == UINT32_MAX || nextid == 0) {	/* infinite loop avoidance (OR do as nextid  id?) */
+			/* infinite loop avoidance (OR do as nextid  id?) */
+			if (id == UINT32_MAX || nextid == 0) {
 break;
 			}
 			continue;
@@ -580,33 +578,32 @@
 			SEEK_SET);
 			need_seek = nextid != id + 1;
 		}
-		(void) fwrite((char *)dqbuf, sizeof(struct dqblk), 1, qfo);
+		(void) fwrite(dqbuf, sizeof(struct dqblk), 1, qfo);
 
 		fup-fu_curinodes = 0;
 		fup-fu_curblocks = 0;
-		if (id == UINT32_MAX || nextid == 0) {	/* infinite loop avoidance (OR do as nextid  id?) */
+		/* infinite loop avoidance (OR do as nextid  id?) */
+		if (id == UINT32_MAX || nextid == 0) {
 			break;
 		}
 	}
-	(void) fclose(qfi);
-	(void) fflush(qfo);
+	(void)fclose(qfi);
+	(void)fflush(qfo);
 	if (highid[type] != UINT32_MAX)
-		(void) ftruncate(fileno(qfo),
+		(void)ftruncate(fileno(qfo),
 		(off_t)((highid[type] + 1) * sizeof(struct dqblk)));
-	(void) fclose(qfo);
-	return (0);
+	(void)fclose(qfo);
+	return 0;
 }
 
-uint32_t
-skipforward(cur, to, qfi)
-	uint32_t cur, to;
-	FILE *qfi;
+static uint32_t
+skipforward(uint32_t cur, uint32_t to, FILE *qfi)
 {
 	struct dqblk dqbuf;
 
 	if (qflag) {
-		(void) fseeko(qfi, (off_t)to * sizeof(struct dqblk), SEEK_SET);
-		return (to);
+		(void)fseeko(qfi, (off_t)to * sizeof(struct dqblk), SEEK_SET);
+		return to;
 	}
 
 	while (++cur  

CVS commit: src/usr.sbin/quotacheck

2011-03-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar  6 23:07:23 UTC 2011

Modified Files:
src/usr.sbin/quotacheck: Makefile quotacheck.c

Log Message:
use merged out code.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/quotacheck/Makefile
cvs rdiff -u -r1.41 -r1.42 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.



CVS commit: src/usr.sbin/quotacheck

2011-03-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar  6 23:13:22 UTC 2011

Modified Files:
src/usr.sbin/quotacheck: quotacheck.c

Log Message:
more KNF


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 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.