CVS commit: src/usr.sbin/repquota

2017-10-22 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sun Oct 22 18:00:45 UTC 2017

Modified Files:
src/usr.sbin/repquota: repquota.8

Log Message:
Add quotadump to the NAME section


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/repquota/repquota.8

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/repquota/repquota.8
diff -u src/usr.sbin/repquota/repquota.8:1.17 src/usr.sbin/repquota/repquota.8:1.18
--- src/usr.sbin/repquota/repquota.8:1.17	Sat May 12 21:42:38 2012
+++ src/usr.sbin/repquota/repquota.8	Sun Oct 22 18:00:45 2017
@@ -29,13 +29,14 @@
 .\" SUCH DAMAGE.
 .\"
 .\" from: @(#)repquota.8	8.1 (Berkeley) 6/6/93
-.\"	$NetBSD: repquota.8,v 1.17 2012/05/12 21:42:38 wiz Exp $
+.\"	$NetBSD: repquota.8,v 1.18 2017/10/22 18:00:45 abhinav Exp $
 .\"
 .Dd May 12, 2012
 .Dt REPQUOTA 8
 .Os
 .Sh NAME
-.Nm repquota
+.Nm repquota ,
+.Nm quotadump
 .Nd summarize quotas for a file system
 .Sh SYNOPSIS
 .Nm



CVS commit: src/usr.sbin/repquota

2012-05-12 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat May 12 21:42:38 UTC 2012

Modified Files:
src/usr.sbin/repquota: repquota.8

Log Message:
Bump date for previous.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/repquota/repquota.8

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/repquota/repquota.8
diff -u src/usr.sbin/repquota/repquota.8:1.16 src/usr.sbin/repquota/repquota.8:1.17
--- src/usr.sbin/repquota/repquota.8:1.16	Sat May 12 19:47:26 2012
+++ src/usr.sbin/repquota/repquota.8	Sat May 12 21:42:38 2012
@@ -29,9 +29,9 @@
 .\ SUCH DAMAGE.
 .\
 .\ from: @(#)repquota.8	8.1 (Berkeley) 6/6/93
-.\	$NetBSD: repquota.8,v 1.16 2012/05/12 19:47:26 dholland Exp $
+.\	$NetBSD: repquota.8,v 1.17 2012/05/12 21:42:38 wiz Exp $
 .\
-.Dd February 13, 2012
+.Dd May 12, 2012
 .Dt REPQUOTA 8
 .Os
 .Sh NAME



CVS commit: src/usr.sbin/repquota

2012-02-13 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon Feb 13 13:37:45 UTC 2012

Modified Files:
src/usr.sbin/repquota: repquota.8

Log Message:
Bump date for previous.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/repquota/repquota.8

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/repquota/repquota.8
diff -u src/usr.sbin/repquota/repquota.8:1.14 src/usr.sbin/repquota/repquota.8:1.15
--- src/usr.sbin/repquota/repquota.8:1.14	Mon Feb 13 01:35:09 2012
+++ src/usr.sbin/repquota/repquota.8	Mon Feb 13 13:37:45 2012
@@ -29,9 +29,9 @@
 .\ SUCH DAMAGE.
 .\
 .\ from: @(#)repquota.8	8.1 (Berkeley) 6/6/93
-.\	$NetBSD: repquota.8,v 1.14 2012/02/13 01:35:09 dholland Exp $
+.\	$NetBSD: repquota.8,v 1.15 2012/02/13 13:37:45 wiz Exp $
 .\
-.Dd February 2, 2012
+.Dd February 13, 2012
 .Dt REPQUOTA 8
 .Os
 .Sh NAME



CVS commit: src/usr.sbin/repquota

2012-02-01 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Feb  1 09:30:01 UTC 2012

Modified Files:
src/usr.sbin/repquota: repquota.8

Log Message:
Bump date for previous.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/repquota/repquota.8

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/repquota/repquota.8
diff -u src/usr.sbin/repquota/repquota.8:1.12 src/usr.sbin/repquota/repquota.8:1.13
--- src/usr.sbin/repquota/repquota.8:1.12	Wed Feb  1 05:12:45 2012
+++ src/usr.sbin/repquota/repquota.8	Wed Feb  1 09:30:01 2012
@@ -29,9 +29,9 @@
 .\ SUCH DAMAGE.
 .\
 .\ from: @(#)repquota.8	8.1 (Berkeley) 6/6/93
-.\	$NetBSD: repquota.8,v 1.12 2012/02/01 05:12:45 dholland Exp $
+.\	$NetBSD: repquota.8,v 1.13 2012/02/01 09:30:01 wiz Exp $
 .\
-.Dd February 10, 2011
+.Dd February 2, 2012
 .Dt REPQUOTA 8
 .Os
 .Sh NAME



CVS commit: src/usr.sbin/repquota

2012-01-24 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Wed Jan 25 01:24:53 UTC 2012

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

Log Message:
More cleanup of repquota. For now we're going to compile in the number
of possible ID and object types, as making those numbers non-constant
requires a major rework.

This removes all dependence on quotaprop.h except for the code for
dumping the quota information as a blob of quota RPC XML packets. That
needs to go too and be replaced with a tabular dump format, but one
thing at a time.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/usr.sbin/repquota/repquota.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/repquota/repquota.c
diff -u src/usr.sbin/repquota/repquota.c:1.37 src/usr.sbin/repquota/repquota.c:1.38
--- src/usr.sbin/repquota/repquota.c:1.37	Mon Jan  9 15:42:37 2012
+++ src/usr.sbin/repquota/repquota.c	Wed Jan 25 01:24:53 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: repquota.c,v 1.37 2012/01/09 15:42:37 dholland Exp $	*/
+/*	$NetBSD: repquota.c,v 1.38 2012/01/25 01:24:53 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT(@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = @(#)repquota.c	8.2 (Berkeley) 11/22/94;
 #else
-__RCSID($NetBSD: repquota.c,v 1.37 2012/01/09 15:42:37 dholland Exp $);
+__RCSID($NetBSD: repquota.c,v 1.38 2012/01/25 01:24:53 dholland Exp $);
 #endif
 #endif /* not lint */
 
@@ -70,18 +70,30 @@ __RCSID($NetBSD: repquota.c,v 1.37 2012
 
 #include printquota.h
 
+/*
+ * XXX. Ideally we shouldn't compile either of these in, but it's a
+ * nontrivial rework to avoid it and it'll work ok for now.
+ */
+#define REPQUOTA_NUMIDTYPES	2
+#define REPQUOTA_NUMOBJTYPES	2
+
 struct fileusage {
 	struct	fileusage *fu_next;
-	struct	quotaval fu_qv[QUOTA_NLIMITS];
+	struct	quotaval fu_qv[REPQUOTA_NUMOBJTYPES];
 	uint32_t	fu_id;
 	char	fu_name[1];
 	/* actually bigger */
 };
+
 #define FUHASH 1024	/* must be power of two */
-static struct fileusage *fuhead[QUOTA_NCLASS][FUHASH];
-static uint32_t highid[QUOTA_NCLASS];	/* highest addid()'ed identifier per class */
-int valid[QUOTA_NCLASS];
-static struct quotaval defaultqv[QUOTA_NCLASS][QUOTA_NLIMITS];
+static struct fileusage *fuhead[REPQUOTA_NUMIDTYPES][FUHASH];
+
+/* highest addid()'ed identifier per idtype */
+static uint32_t highid[REPQUOTA_NUMIDTYPES];
+
+int valid[REPQUOTA_NUMIDTYPES];
+
+static struct quotaval defaultqv[REPQUOTA_NUMIDTYPES][REPQUOTA_NUMOBJTYPES];
 
 static int	vflag = 0;		/* verbose */
 static int	aflag = 0;		/* all file systems */
@@ -89,6 +101,15 @@ static int	Dflag = 0;		/* debug */
 static int	hflag = 0;		/* humanize */
 static int	xflag = 0;		/* export */
 
+/*
+ * XXX this should go away and be replaced with a call to
+ * quota_idtype_getname(), but that needs a quotahandle and requires
+ * the same nontrivial rework as getting rid of REPQUOTA_NUMIDTYPES.
+ */
+static const char *const repquota_idtype_names[REPQUOTA_NUMIDTYPES] = {
+	user,
+	group,
+};
 
 static struct fileusage *addid(uint32_t, int, const char *);
 static struct fileusage *lookup(uint32_t, int);
@@ -261,10 +282,12 @@ printquotas(int idtype, struct quotahand
 	int i;
 	struct fileusage *fup;
 	struct quotaval *q;
-	const char *timemsg[QUOTA_NLIMITS];
-	char overchar[QUOTA_NLIMITS];
+	const char *timemsg[REPQUOTA_NUMOBJTYPES];
+	char overchar[REPQUOTA_NUMOBJTYPES];
 	time_t now;
 	char b0[2][20], b1[20], b2[20], b3[20];
+	int ok, objtype;
+	int isbytes, width;
 
 	switch (idtype) {
 	case QUOTA_IDTYPE_GROUP:
@@ -295,7 +318,7 @@ printquotas(int idtype, struct quotahand
 		printf(\n);
 	if (vflag)
 		printf(*** Report for %s quotas on %s (%s: %s)\n,
-		ufs_quota_class_names[idtype], quota_getmountpoint(qh),
+		repquota_idtype_names[idtype], quota_getmountpoint(qh),
 		quota_getmountdevice(qh), quota_getimplname(qh));
 	printf(Block limits   
 	File limits\n);
@@ -307,7 +330,7 @@ printquotas(int idtype, struct quotahand
 		q = fup-fu_qv;
 		if (fup == 0)
 			continue;
-		for (i = 0; i  QUOTA_NLIMITS; i++) {
+		for (i = 0; i  REPQUOTA_NUMOBJTYPES; i++) {
 			switch (QL_STATUS(quota_check_limit(q[i].qv_usage, 1,
 			q[i].qv_softlimit, q[i].qv_hardlimit,
 			q[i].qv_expiretime, now))) {
@@ -330,31 +353,43 @@ printquotas(int idtype, struct quotahand
 			}
 		}
 
-		if (q[QUOTA_LIMIT_BLOCK].qv_usage == 0 
-		q[QUOTA_LIMIT_FILE].qv_usage == 0  vflag == 0 
-		overchar[QUOTA_LIMIT_BLOCK] == '-' 
-		overchar[QUOTA_LIMIT_FILE] == '-')
+		ok = 1;
+		for (objtype = 0; objtype  REPQUOTA_NUMOBJTYPES; objtype++) {
+			if (q[objtype].qv_usage != 0 ||
+			overchar[objtype] != '-') {
+ok = 0;
+			}
+		}
+		if (ok  vflag == 0)
 			continue;
 		if (strlen(fup-fu_name)  9)
 			printf(%s , fup-fu_name);
 		else
 			printf(%-10s, fup-fu_name);
-		printf(%c%c%9s%9s%9s%7s,
-			

CVS commit: src/usr.sbin/repquota

2012-01-09 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jan  9 15:38:20 UTC 2012

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

Log Message:
Begin cleaning up repquota.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/usr.sbin/repquota/repquota.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/repquota/repquota.c
diff -u src/usr.sbin/repquota/repquota.c:1.33 src/usr.sbin/repquota/repquota.c:1.34
--- src/usr.sbin/repquota/repquota.c:1.33	Fri Nov 25 16:55:06 2011
+++ src/usr.sbin/repquota/repquota.c	Mon Jan  9 15:38:20 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: repquota.c,v 1.33 2011/11/25 16:55:06 dholland Exp $	*/
+/*	$NetBSD: repquota.c,v 1.34 2012/01/09 15:38:20 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT(@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = @(#)repquota.c	8.2 (Berkeley) 11/22/94;
 #else
-__RCSID($NetBSD: repquota.c,v 1.33 2011/11/25 16:55:06 dholland Exp $);
+__RCSID($NetBSD: repquota.c,v 1.34 2012/01/09 15:38:20 dholland Exp $);
 #endif
 #endif /* not lint */
 
@@ -64,10 +64,9 @@ __RCSID($NetBSD: repquota.c,v 1.33 2011
 #include string.h
 #include unistd.h
 
-#include quota/quotaprop.h
 #include quota/quota.h
 #include ufs/ufs/quota1.h
-#include sys/quota.h
+#include quota.h
 
 #include printquota.h
 #include quotautil.h
@@ -158,18 +157,18 @@ main(int argc, char **argv)
 			continue;
 		if (aflag) {
 			if (gflag)
-errs += repquota(fst[i], QUOTA_CLASS_GROUP);
+errs += repquota(fst[i], QUOTA_IDTYPE_GROUP);
 			if (uflag)
-errs += repquota(fst[i], QUOTA_CLASS_USER);
+errs += repquota(fst[i], QUOTA_IDTYPE_USER);
 			continue;
 		}
 		if ((argnum = oneof(fst[i].f_mntonname, argv, argc)) = 0 ||
 		(argnum = oneof(fst[i].f_mntfromname, argv, argc)) = 0) {
 			done |= 1U  argnum;
 			if (gflag)
-errs += repquota(fst[i], QUOTA_CLASS_GROUP);
+errs += repquota(fst[i], QUOTA_IDTYPE_GROUP);
 			if (uflag)
-errs += repquota(fst[i], QUOTA_CLASS_USER);
+errs += repquota(fst[i], QUOTA_IDTYPE_USER);
 		}
 	}
 	if (xflag)
@@ -191,15 +190,15 @@ usage(void)
 }
 
 static int
-repquota(const struct statvfs *vfs, int class)
+repquota(const struct statvfs *vfs, int idtype)
 {
-	if (repquota2(vfs, class) != 0)
-		return repquota1(vfs, class);
+	if (repquota2(vfs, idtype) != 0)
+		return repquota1(vfs, idtype);
 	return 0;
 }
 
 static int
-repquota2(const struct statvfs *vfs, int class)
+repquota2(const struct statvfs *vfs, int idtype)
 {
 	prop_dictionary_t dict, data, cmd;
 	prop_array_t cmds, datas;
@@ -219,10 +218,10 @@ repquota2(const struct statvfs *vfs, int
 	if (dict == NULL || cmds == NULL || datas == NULL)
 		errx(1, can't allocate proplist);
 	if (!quota_prop_add_command(cmds, getall,
-	ufs_quota_class_names[class], datas))
+	ufs_quota_class_names[idtype], datas))
 		err(1, prop_add_command);
 	if (!quota_prop_add_command(cmds, get version,
-	ufs_quota_class_names[class], prop_array_create()))
+	ufs_quota_class_names[idtype], prop_array_create()))
 		err(1, prop_add_command);
 	if (!prop_dictionary_set(dict, commands, cmds))
 		err(1, prop_dictionary_set(command));
@@ -263,7 +262,7 @@ repquota2(const struct statvfs *vfs, int
 			if (error8 != EOPNOTSUPP) {
 errno = error8;
 warn(get %s quotas,
-ufs_quota_class_names[class]);
+ufs_quota_class_names[idtype]);
 			}
 			return error8;
 		}
@@ -284,9 +283,9 @@ repquota2(const struct statvfs *vfs, int
 		if (dataiter == NULL)
 			err(1, prop_array_iterator);
 
-		valid[class] = 0;
+		valid[idtype] = 0;
 		while ((data = prop_object_iterator_next(dataiter)) != NULL) {
-			valid[class] = 1;
+			valid[idtype] = 1;
 			strid = NULL;
 			if (!prop_dictionary_get_uint32(data, id, id)) {
 if (!prop_dictionary_get_cstring_nocopy(data,
@@ -297,10 +296,10 @@ repquota2(const struct statvfs *vfs, int
 	wrong id string %s in quota entry,
 	strid);
 }
-qvp = defaultqv[class];
+qvp = defaultqv[idtype];
 			} else {
-if ((fup = lookup(id, class)) == 0)
-	fup = addid(id, class, (char *)0);
+if ((fup = lookup(id, idtype)) == 0)
+	fup = addid(id, idtype, (char *)0);
 qvp = fup-fu_qv;
 			}
 			values[QUOTA_LIMIT_BLOCK] =
@@ -318,13 +317,13 @@ repquota2(const struct statvfs *vfs, int
 	}
 	prop_object_iterator_release(cmditer);
 	prop_object_release(dict);
-	if (xflag == 0  valid[class])
-		printquotas(class, vfs, version);
+	if (xflag == 0  valid[idtype])
+		printquotas(idtype, vfs, version);
 	return 0;
 }
 
 static int
-repquota1(const struct statvfs *vfs, int class)
+repquota1(const struct statvfs *vfs, int idtype)
 {
 	char qfpathname[MAXPATHLEN];
 	struct fstab *fs;
@@ -333,7 +332,7 @@ repquota1(const struct statvfs *vfs, int
 	uint32_t id;
 	struct dqblk dqbuf;
 	time_t bgrace = MAX_DQ_TIME, igrace = MAX_DQ_TIME;
-	int type = ufsclass2qtype(class);
+	int type 

CVS commit: src/usr.sbin/repquota

2012-01-09 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jan  9 15:38:59 UTC 2012

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

Log Message:
More work on repquota.
   - open quotahandles, pass them around, use them for metadata
   - split up some of the proplib code


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.sbin/repquota/repquota.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/repquota/repquota.c
diff -u src/usr.sbin/repquota/repquota.c:1.34 src/usr.sbin/repquota/repquota.c:1.35
--- src/usr.sbin/repquota/repquota.c:1.34	Mon Jan  9 15:38:20 2012
+++ src/usr.sbin/repquota/repquota.c	Mon Jan  9 15:38:59 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: repquota.c,v 1.34 2012/01/09 15:38:20 dholland Exp $	*/
+/*	$NetBSD: repquota.c,v 1.35 2012/01/09 15:38:59 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT(@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = @(#)repquota.c	8.2 (Berkeley) 11/22/94;
 #else
-__RCSID($NetBSD: repquota.c,v 1.34 2012/01/09 15:38:20 dholland Exp $);
+__RCSID($NetBSD: repquota.c,v 1.35 2012/01/09 15:38:59 dholland Exp $);
 #endif
 #endif /* not lint */
 
@@ -94,11 +94,11 @@ static int	xflag = 0;		/* export */
 static struct fileusage *addid(uint32_t, int, const char *);
 static struct fileusage *lookup(uint32_t, int);
 static struct fileusage *qremove(uint32_t, int);
-static int	repquota(const struct statvfs *, int);
-static int	repquota2(const struct statvfs *, int);
-static int	repquota1(const struct statvfs *, int);
+static int	repquota(struct quotahandle *, int);
+static int	repquota2(struct quotahandle *, int);
+static int	repquota1(struct quotahandle *, int);
 static void	usage(void) __attribute__((__noreturn__));
-static void	printquotas(int, const struct statvfs *, int);
+static void	printquotas(int, struct quotahandle *);
 static void	exportquotas(void);
 
 int
@@ -109,6 +109,7 @@ main(int argc, char **argv)
 	int ch;
 	struct statvfs *fst;
 	int nfst;
+	struct quotahandle *qh;
 
 	while ((ch = getopt(argc, argv, Daguhvx)) != -1) {
 		switch(ch) {
@@ -155,21 +156,35 @@ main(int argc, char **argv)
 	for (i = 0; i  nfst; i++) {
 		if ((fst[i].f_flag  ST_QUOTA) == 0)
 			continue;
-		if (aflag) {
-			if (gflag)
-errs += repquota(fst[i], QUOTA_IDTYPE_GROUP);
-			if (uflag)
-errs += repquota(fst[i], QUOTA_IDTYPE_USER);
-			continue;
-		}
-		if ((argnum = oneof(fst[i].f_mntonname, argv, argc)) = 0 ||
-		(argnum = oneof(fst[i].f_mntfromname, argv, argc)) = 0) {
+		/* check if we want this volume */
+		if (!aflag) {
+			argnum = oneof(fst[i].f_mntonname, argv, argc);
+			if (argnum  0) {
+argnum = oneof(fst[i].f_mntfromname,
+	   argv, argc);
+			}
+			if (argnum  0) {
+continue;
+			}
 			done |= 1U  argnum;
-			if (gflag)
-errs += repquota(fst[i], QUOTA_IDTYPE_GROUP);
-			if (uflag)
-errs += repquota(fst[i], QUOTA_IDTYPE_USER);
 		}
+
+		qh = quota_open(fst[i].f_mntonname);
+		if (qh == NULL) {
+			/* XXX: check this errno */
+			if (errno == EOPNOTSUPP || errno == ENXIO) {
+continue;
+			}
+			warn(%s: quota_open, fst[i].f_mntonname);
+			continue;
+		}
+
+		if (gflag)
+			errs += repquota(qh, QUOTA_IDTYPE_GROUP);
+		if (uflag)
+			errs += repquota(qh, QUOTA_IDTYPE_USER);
+
+		quota_close(qh);
 	}
 	if (xflag)
 		exportquotas();
@@ -190,26 +205,20 @@ usage(void)
 }
 
 static int
-repquota(const struct statvfs *vfs, int idtype)
+repquota(struct quotahandle *qh, int idtype)
 {
-	if (repquota2(vfs, idtype) != 0)
-		return repquota1(vfs, idtype);
+	if (repquota2(qh, idtype) != 0)
+		return repquota1(qh, idtype);
 	return 0;
 }
 
 static int
-repquota2(const struct statvfs *vfs, int idtype)
+repquota2_getstuff(struct quotahandle *qh, int idtype, prop_array_t *ret)
 {
-	prop_dictionary_t dict, data, cmd;
+	prop_dictionary_t dict, cmd;
 	prop_array_t cmds, datas;
 	struct plistref pref;
-	int8_t error8, version = 0;
-	prop_object_iterator_t cmditer, dataiter;
-	struct quotaval *qvp;
-	struct fileusage *fup;
-	const char *strid;
-	uint32_t id;
-	uint64_t *values[QUOTA_NLIMITS];
+	int8_t error8;
 
 	dict = quota_prop_create();
 	cmds = prop_array_create();
@@ -220,9 +229,6 @@ repquota2(const struct statvfs *vfs, int
 	if (!quota_prop_add_command(cmds, getall,
 	ufs_quota_class_names[idtype], datas))
 		err(1, prop_add_command);
-	if (!quota_prop_add_command(cmds, get version,
-	ufs_quota_class_names[idtype], prop_array_create()))
-		err(1, prop_add_command);
 	if (!prop_dictionary_set(dict, commands, cmds))
 		err(1, prop_dictionary_set(command));
 	if (Dflag)
@@ -232,7 +238,7 @@ repquota2(const struct statvfs *vfs, int
 		err(1, prop_dictionary_send_syscall);
 	prop_object_release(dict);
 
-	if (quotactl(vfs-f_mntonname, pref) != 0)
+	if (quotactl(quota_getmountpoint(qh), pref) != 0)
 		err(1, quotactl);
 
 	if (prop_dictionary_recv_syscall(pref, dict) != 0) 

CVS commit: src/usr.sbin/repquota

2012-01-09 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jan  9 15:40:47 UTC 2012

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

Log Message:
Make repquota use the libquota cursor interface.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.sbin/repquota/repquota.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/repquota/repquota.c
diff -u src/usr.sbin/repquota/repquota.c:1.35 src/usr.sbin/repquota/repquota.c:1.36
--- src/usr.sbin/repquota/repquota.c:1.35	Mon Jan  9 15:38:59 2012
+++ src/usr.sbin/repquota/repquota.c	Mon Jan  9 15:40:47 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: repquota.c,v 1.35 2012/01/09 15:38:59 dholland Exp $	*/
+/*	$NetBSD: repquota.c,v 1.36 2012/01/09 15:40:47 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT(@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = @(#)repquota.c	8.2 (Berkeley) 11/22/94;
 #else
-__RCSID($NetBSD: repquota.c,v 1.35 2012/01/09 15:38:59 dholland Exp $);
+__RCSID($NetBSD: repquota.c,v 1.36 2012/01/09 15:40:47 dholland Exp $);
 #endif
 #endif /* not lint */
 
@@ -213,134 +213,53 @@ repquota(struct quotahandle *qh, int idt
 }
 
 static int
-repquota2_getstuff(struct quotahandle *qh, int idtype, prop_array_t *ret)
-{
-	prop_dictionary_t dict, cmd;
-	prop_array_t cmds, datas;
-	struct plistref pref;
-	int8_t error8;
-
-	dict = quota_prop_create();
-	cmds = prop_array_create();
-	datas = prop_array_create();
-
-	if (dict == NULL || cmds == NULL || datas == NULL)
-		errx(1, can't allocate proplist);
-	if (!quota_prop_add_command(cmds, getall,
-	ufs_quota_class_names[idtype], datas))
-		err(1, prop_add_command);
-	if (!prop_dictionary_set(dict, commands, cmds))
-		err(1, prop_dictionary_set(command));
-	if (Dflag)
-		printf(message to kernel:\n%s\n,
-		prop_dictionary_externalize(dict));
-	if (prop_dictionary_send_syscall(dict, pref) != 0)
-		err(1, prop_dictionary_send_syscall);
-	prop_object_release(dict);
-
-	if (quotactl(quota_getmountpoint(qh), pref) != 0)
-		err(1, quotactl);
-
-	if (prop_dictionary_recv_syscall(pref, dict) != 0) {
-		err(1, prop_dictionary_recv_syscall);
-	}
-	if (Dflag)
-		printf(reply from kernel:\n%s\n,
-		prop_dictionary_externalize(dict));
-	if ((errno = quota_get_cmds(dict, cmds)) != 0) {
-		err(1, quota_get_cmds);
-	}
-
-	cmd = prop_array_get(cmds, 0);
-	if (cmd == NULL) {
-		err(1, prop_array_get(cmds));
-	}
-
-	const char *cmdstr;
-	if (!prop_dictionary_get_cstring_nocopy(cmd, command,
-	cmdstr))
-		err(1, prop_get(command));
-
-	if (!prop_dictionary_get_int8(cmd, return, error8))
-		err(1, prop_get(return));
-
-	if (error8) {
-		prop_object_release(dict);
-		if (error8 != EOPNOTSUPP) {
-			errno = error8;
-			warn(get %s quotas,
-			ufs_quota_class_names[idtype]);
-		}
-		return 1;
-	}
-	datas = prop_dictionary_get(cmd, data);
-	if (datas == NULL)
-		err(1, prop_dict_get(datas));
-
-	prop_object_retain(datas);
-	prop_object_release(dict);
-
-	*ret = datas;
-	return 0;
-}
-
-static int
 repquota2(struct quotahandle *qh, int idtype)
 {
-	prop_dictionary_t data;
-	prop_array_t datas;
-	prop_object_iterator_t dataiter;
+	struct quotacursor *qc;
+	struct quotakey qk;
+	struct quotaval qv;
 	struct quotaval *qvp;
 	struct fileusage *fup;
-	const char *strid;
-	uint32_t id;
-	uint64_t *values[QUOTA_NLIMITS];
 
-	if (repquota2_getstuff(qh, idtype, datas)) {
+	qc = quota_opencursor(qh);
+	if (qc == NULL) {
 		return 1;
 	}
 
-		dataiter = prop_array_iterator(datas);
-		if (dataiter == NULL)
-			err(1, prop_array_iterator);
-
-		valid[idtype] = 0;
-		while ((data = prop_object_iterator_next(dataiter)) != NULL) {
-			valid[idtype] = 1;
-			strid = NULL;
-			if (!prop_dictionary_get_uint32(data, id, id)) {
-if (!prop_dictionary_get_cstring_nocopy(data,
-id, strid))
-	errx(1, can't find id in quota entry);
-if (strcmp(strid, default) != 0) {
-	errx(1,
-	wrong id string %s in quota entry,
-	strid);
-}
-qvp = defaultqv[idtype];
-			} else {
-if ((fup = lookup(id, idtype)) == 0)
-	fup = addid(id, idtype, (char *)0);
-qvp = fup-fu_qv;
-			}
-			values[QUOTA_LIMIT_BLOCK] =
-			qvp[QUOTA_LIMIT_BLOCK].qv_hardlimit;
-			values[QUOTA_LIMIT_FILE] =
-			qvp[QUOTA_LIMIT_FILE].qv_hardlimit;
-
-			errno = proptoquota64(data, values,
-			ufs_quota_entry_names, UFS_QUOTA_NENTRIES,
-			ufs_quota_limit_names, QUOTA_NLIMITS);
-			if (errno)
-err(1, proptoquota64);
+	if (idtype == QUOTA_IDTYPE_USER) {
+		quotacursor_skipidtype(qc, QUOTA_IDTYPE_GROUP);
+	}
+	if (idtype == QUOTA_IDTYPE_GROUP) {
+		quotacursor_skipidtype(qc, QUOTA_IDTYPE_USER);
+	}
+
+	valid[idtype] = 0;
+	while (!quotacursor_atend(qc)) {
+		if (quotacursor_get(qc, qk, qv)) {
+			err(1, %s: quotacursor_get, quota_getmountpoint(qh));
+		}
+		if (qk.qk_idtype != idtype) {
+			continue;
 		}
-		

CVS commit: src/usr.sbin/repquota

2012-01-09 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jan  9 15:42:37 UTC 2012

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

Log Message:
Remove the explicit fallback direct file access code from repquota and
rely on libquota.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/usr.sbin/repquota/repquota.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/repquota/repquota.c
diff -u src/usr.sbin/repquota/repquota.c:1.36 src/usr.sbin/repquota/repquota.c:1.37
--- src/usr.sbin/repquota/repquota.c:1.36	Mon Jan  9 15:40:47 2012
+++ src/usr.sbin/repquota/repquota.c	Mon Jan  9 15:42:37 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: repquota.c,v 1.36 2012/01/09 15:40:47 dholland Exp $	*/
+/*	$NetBSD: repquota.c,v 1.37 2012/01/09 15:42:37 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT(@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = @(#)repquota.c	8.2 (Berkeley) 11/22/94;
 #else
-__RCSID($NetBSD: repquota.c,v 1.36 2012/01/09 15:40:47 dholland Exp $);
+__RCSID($NetBSD: repquota.c,v 1.37 2012/01/09 15:42:37 dholland Exp $);
 #endif
 #endif /* not lint */
 
@@ -65,11 +65,10 @@ __RCSID($NetBSD: repquota.c,v 1.36 2012
 #include unistd.h
 
 #include quota/quota.h
-#include ufs/ufs/quota1.h
+#include quota/quotaprop.h
 #include quota.h
 
 #include printquota.h
-#include quotautil.h
 
 struct fileusage {
 	struct	fileusage *fu_next;
@@ -95,11 +94,10 @@ static struct fileusage *addid(uint32_t,
 static struct fileusage *lookup(uint32_t, int);
 static struct fileusage *qremove(uint32_t, int);
 static int	repquota(struct quotahandle *, int);
-static int	repquota2(struct quotahandle *, int);
-static int	repquota1(struct quotahandle *, int);
 static void	usage(void) __attribute__((__noreturn__));
 static void	printquotas(int, struct quotahandle *);
 static void	exportquotas(void);
+static int	oneof(const char *, char *[], int cnt);
 
 int
 main(int argc, char **argv)
@@ -207,14 +205,6 @@ usage(void)
 static int
 repquota(struct quotahandle *qh, int idtype)
 {
-	if (repquota2(qh, idtype) != 0)
-		return repquota1(qh, idtype);
-	return 0;
-}
-
-static int
-repquota2(struct quotahandle *qh, int idtype)
-{
 	struct quotacursor *qc;
 	struct quotakey qk;
 	struct quotaval qv;
@@ -263,72 +253,6 @@ repquota2(struct quotahandle *qh, int id
 	return 0;
 }
 
-static int
-repquota1(struct quotahandle *qh, int idtype)
-{
-	char qfpathname[MAXPATHLEN];
-	struct fstab *fs;
-	struct fileusage *fup;
-	FILE *qf;
-	uint32_t id;
-	struct dqblk dqbuf;
-	time_t bgrace = MAX_DQ_TIME, igrace = MAX_DQ_TIME;
-	int type = ufsclass2qtype(idtype);
-	const char *mountpoint;
-
-	mountpoint = quota_getmountpoint(qh);
-
-	setfsent();
-	while ((fs = getfsent()) != NULL) {
-		if (strcmp(fs-fs_vfstype, ffs) == 0 
-		   strcmp(fs-fs_file, mountpoint) == 0)
-			break;
-	}
-	endfsent();
-	if (fs == NULL) {
-		warnx(%s not found in fstab, mountpoint);
-		return 1;
-	}
-	if (!hasquota(qfpathname, sizeof(qfpathname), fs, type))
-		return 0;
-		
-	if ((qf = fopen(qfpathname, r)) == NULL) {
-		warn(Cannot open `%s', qfpathname);
-		return 1;
-	}
-	for (id = 0; ; id++) {
-		fread(dqbuf, sizeof(struct dqblk), 1, qf);
-		if (feof(qf))
-			break;
-		if (id == 0) {
-			if (dqbuf.dqb_btime  0)
-bgrace = dqbuf.dqb_btime;
-			if (dqbuf.dqb_itime  0)
-igrace = dqbuf.dqb_itime;
-		}
-		if (dqbuf.dqb_curinodes == 0  dqbuf.dqb_curblocks == 0 
-		dqbuf.dqb_bsoftlimit == 0  dqbuf.dqb_bhardlimit == 0 
-		dqbuf.dqb_isoftlimit == 0  dqbuf.dqb_ihardlimit == 0)
-			continue;
-		if ((fup = lookup(id, idtype)) == 0)
-			fup = addid(id, idtype, (char *)0);
-		dqblk_to_quotaval(dqbuf, fup-fu_qv);
-		fup-fu_qv[QUOTA_LIMIT_BLOCK].qv_grace = bgrace;
-		fup-fu_qv[QUOTA_LIMIT_FILE].qv_grace = igrace;
-	}
-	defaultqv[idtype][QUOTA_LIMIT_BLOCK].qv_grace = bgrace;
-	defaultqv[idtype][QUOTA_LIMIT_FILE].qv_grace = igrace;
-	defaultqv[idtype][QUOTA_LIMIT_BLOCK].qv_softlimit = 
-	defaultqv[idtype][QUOTA_LIMIT_BLOCK].qv_hardlimit = 
-	defaultqv[idtype][QUOTA_LIMIT_FILE].qv_softlimit = 
-	defaultqv[idtype][QUOTA_LIMIT_FILE].qv_hardlimit = QUOTA_NOLIMIT;
-	fclose(qf);
-	valid[idtype] = 1;
-	if (xflag == 0)
-		printquotas(idtype, qh);
-	return 0;
-}
-
 static void
 printquotas(int idtype, struct quotahandle *qh)
 {
@@ -591,3 +515,17 @@ addid(uint32_t id, int idtype, const cha
 	fup-fu_qv[QUOTA_LIMIT_FILE] = defaultqv[idtype][QUOTA_LIMIT_FILE];
 	return fup;
 }
+
+/*
+ * Check to see if target appears in list of size cnt.
+ */
+static int
+oneof(const char *target, char *list[], int cnt)
+{
+	int i;
+
+	for (i = 0; i  cnt; i++)
+		if (strcmp(target, list[i]) == 0)
+			return i;
+	return -1;
+}



CVS commit: src/usr.sbin/repquota

2011-03-27 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar 27 17:15:17 UTC 2011

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

Log Message:
Make sure to not report quotas for a class if we didn't get valid datas
from kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/usr.sbin/repquota/repquota.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/repquota/repquota.c
diff -u src/usr.sbin/repquota/repquota.c:1.30 src/usr.sbin/repquota/repquota.c:1.31
--- src/usr.sbin/repquota/repquota.c:1.30	Thu Mar 24 17:05:47 2011
+++ src/usr.sbin/repquota/repquota.c	Sun Mar 27 17:15:17 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: repquota.c,v 1.30 2011/03/24 17:05:47 bouyer Exp $	*/
+/*	$NetBSD: repquota.c,v 1.31 2011/03/27 17:15:17 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = @(#)repquota.c	8.2 (Berkeley) 11/22/94;
 #else
-__RCSID($NetBSD: repquota.c,v 1.30 2011/03/24 17:05:47 bouyer Exp $);
+__RCSID($NetBSD: repquota.c,v 1.31 2011/03/27 17:15:17 bouyer Exp $);
 #endif
 #endif /* not lint */
 
@@ -284,8 +284,9 @@
 		if (dataiter == NULL)
 			err(1, prop_array_iterator);
 
-		valid[class] = 1;
+		valid[class] = 0;
 		while ((data = prop_object_iterator_next(dataiter)) != NULL) {
+			valid[class] = 1;
 			strid = NULL;
 			if (!prop_dictionary_get_uint32(data, id, id)) {
 if (!prop_dictionary_get_cstring_nocopy(data,
@@ -317,7 +318,7 @@
 	}
 	prop_object_iterator_release(cmditer);
 	prop_object_release(dict);
-	if (xflag == 0)
+	if (xflag == 0  valid[class])
 		printquotas(class, vfs, version);
 	return 0;
 }



CVS commit: src/usr.sbin/repquota

2011-03-07 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Mon Mar  7 11:56:31 UTC 2011

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

Log Message:
Don't use the same char b0[] for BLOCK and FILE timeprt(), they would
override each others.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/usr.sbin/repquota/repquota.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/repquota/repquota.c
diff -u src/usr.sbin/repquota/repquota.c:1.28 src/usr.sbin/repquota/repquota.c:1.29
--- src/usr.sbin/repquota/repquota.c:1.28	Sun Mar  6 23:25:42 2011
+++ src/usr.sbin/repquota/repquota.c	Mon Mar  7 11:56:31 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: repquota.c,v 1.28 2011/03/06 23:25:42 christos Exp $	*/
+/*	$NetBSD: repquota.c,v 1.29 2011/03/07 11:56:31 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = @(#)repquota.c	8.2 (Berkeley) 11/22/94;
 #else
-__RCSID($NetBSD: repquota.c,v 1.28 2011/03/06 23:25:42 christos Exp $);
+__RCSID($NetBSD: repquota.c,v 1.29 2011/03/07 11:56:31 bouyer Exp $);
 #endif
 #endif /* not lint */
 
@@ -387,7 +387,7 @@
 	const char *timemsg[N_QL];
 	char overchar[N_QL];
 	time_t now;
-	char b0[20], b1[20], b2[20], b3[20];
+	char b0[2][20], b1[20], b2[20], b3[20];
 
 	switch(type) {
 	case  GRPQUOTA:
@@ -435,12 +435,13 @@
 			case QL_S_DENY_HARD:
 			case QL_S_DENY_GRACE:
 			case QL_S_ALLOW_SOFT:
-timemsg[i] = timeprt(b0, 8, now, q[i].q2v_time);
+timemsg[i] = timeprt(b0[i], 8, now,
+q[i].q2v_time);
 overchar[i] = '+';
 break;
 			default:
 timemsg[i] =  (vflag  version == 2) ?
-timeprt(b0, 8, 0, q[i].q2v_grace) : ;
+timeprt(b0[i], 8, 0, q[i].q2v_grace) : ;
 overchar[i] = '-';
 break;
 			}



CVS commit: src/usr.sbin/repquota

2011-03-06 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Mar  6 17:36:32 UTC 2011

Modified Files:
src/usr.sbin/repquota: repquota.8

Log Message:
Sort options, split file system.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/repquota/repquota.8

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/repquota/repquota.8
diff -u src/usr.sbin/repquota/repquota.8:1.10 src/usr.sbin/repquota/repquota.8:1.11
--- src/usr.sbin/repquota/repquota.8:1.10	Sun Mar  6 17:08:43 2011
+++ src/usr.sbin/repquota/repquota.8	Sun Mar  6 17:36:32 2011
@@ -29,7 +29,7 @@
 .\ SUCH DAMAGE.
 .\
 .\ from: @(#)repquota.8	8.1 (Berkeley) 6/6/93
-.\	$NetBSD: repquota.8,v 1.10 2011/03/06 17:08:43 bouyer Exp $
+.\	$NetBSD: repquota.8,v 1.11 2011/03/06 17:36:32 wiz Exp $
 .\
 .Dd February 10, 2011
 .Dt REPQUOTA 8
@@ -39,25 +39,15 @@
 .Nd summarize quotas for a file system
 .Sh SYNOPSIS
 .Nm
-.Op Fl h
-.Op Fl D
-.Op Fl g
-.Op Fl u
-.Op Fl v
-.Ar filesystem Ar ...
+.Op Fl Dghuv
+.Ar file-system Ar ...
 .Nm
-.Op Fl h
-.Op Fl D
-.Op Fl g
-.Op Fl u
-.Op Fl v
+.Op Fl Dghuv
 .Fl a
 .Nm
 .Fl x
-.Op Fl D
-.Op Fl g
-.Op Fl u
-.Ar filesystem
+.Op Fl Dgu
+.Ar file-system
 .Sh DESCRIPTION
 .Nm
 prints a summary of the disk usage and quotas for the
@@ -66,24 +56,24 @@
 Available options:
 .Bl -tag -width Ds
 .It Fl a
-Print the quotas of all the mounted filesystems.
+Print the quotas of all the mounted file systems.
+.It Fl D
+Debug: print plist sent to and received from kernel.
 .It Fl g
 Print only group quotas (the default is to print both
 group and user quotas if they exist).
+.It Fl h
+Numbers are displayed in a human readable format.
 .It Fl u
 Print only user quotas (the default is to print both
 group and user quotas if they exist).
 .It Fl v
-Print a header line before printing each filesystem quotas.
+Print a header line before printing each file system quotas.
 Print all exiting quotas, including those whose current usage is 0.
-.It Fl D
-Debug: print plist sent to and received from kernel.
-.It Fl h
-Numbers are displayed in a human readable format.
 .It Fl x
-export filesystem quota in a plist format suitable for
+export file system quota in a plist format suitable for
 .Xr quotactl 8 .
-A single filesystem should be specified.
+A single file system should be specified.
 .El
 .Pp
 For each user or group, the current



CVS commit: src/usr.sbin/repquota

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

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

Log Message:
- KNF
- merge code
- fix error printing
- don't use static buffers


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/repquota/Makefile
cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/repquota/repquota.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/repquota/Makefile
diff -u src/usr.sbin/repquota/Makefile:1.6 src/usr.sbin/repquota/Makefile:1.7
--- src/usr.sbin/repquota/Makefile:1.6	Sun Mar  6 12:08:43 2011
+++ src/usr.sbin/repquota/Makefile	Sun Mar  6 17:33:55 2011
@@ -1,6 +1,7 @@
 #	from: @(#)Makefile	8.1 (Berkeley) 6/6/93
-#	$NetBSD: Makefile,v 1.6 2011/03/06 17:08:43 bouyer Exp $
+#	$NetBSD: Makefile,v 1.7 2011/03/06 22:33:55 christos Exp $
 
+WARNS ?= 4
 .include bsd.own.mk
 PROG=	repquota
 SRCS=	repquota.c 
@@ -11,7 +12,7 @@
 LDADD=	-lprop
 
 .PATH:	${NETBSDSRCDIR}/usr.bin/quota
-SRCS+=	printquota.c
+SRCS+=	printquota.c quotautil.c
 .PATH:	${NETBSDSRCDIR}/sys/ufs/ufs 
 SRCS+=	quota2_prop.c quota2_subr.c quota1_subr.c
 

Index: src/usr.sbin/repquota/repquota.c
diff -u src/usr.sbin/repquota/repquota.c:1.26 src/usr.sbin/repquota/repquota.c:1.27
--- src/usr.sbin/repquota/repquota.c:1.26	Sun Mar  6 12:08:43 2011
+++ src/usr.sbin/repquota/repquota.c	Sun Mar  6 17:33:55 2011
@@ -1,3 +1,5 @@
+/*	$NetBSD: repquota.c,v 1.27 2011/03/06 22:33:55 christos Exp $	*/
+
 /*
  * Copyright (c) 1980, 1990, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -40,7 +42,7 @@
 #if 0
 static char sccsid[] = @(#)repquota.c	8.2 (Berkeley) 11/22/94;
 #else
-__RCSID($NetBSD: repquota.c,v 1.26 2011/03/06 17:08:43 bouyer Exp $);
+__RCSID($NetBSD: repquota.c,v 1.27 2011/03/06 22:33:55 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -67,49 +69,42 @@
 #include ufs/ufs/quota2_prop.h
 #include ufs/ufs/quota1.h
 
-#include printquota.h
-
-const char *qfextension[] = INITQFNAMES;
-const char *qfname = QUOTAFILENAME;
+#include printquota.h
+#include quotautil.h
 
 struct fileusage {
 	struct	fileusage *fu_next;
 	struct	quota2_entry fu_q2e;
-	u_long	fu_id;
+	uint32_t	fu_id;
 	char	fu_name[1];
 	/* actually bigger */
 };
 #define FUHASH 1024	/* must be power of two */
-struct fileusage *fuhead[MAXQUOTAS][FUHASH];
-u_long highid[MAXQUOTAS];	/* highest addid()'ed identifier per type */
+static struct fileusage *fuhead[MAXQUOTAS][FUHASH];
+static uint32_t highid[MAXQUOTAS];	/* highest addid()'ed identifier per type */
 int valid[MAXQUOTAS];
-struct quota2_entry defaultq2e[MAXQUOTAS];
+static struct quota2_entry defaultq2e[MAXQUOTAS];
 
-int	vflag = 0;		/* verbose */
-int	aflag = 0;		/* all file systems */
-int	Dflag = 0;		/* debug */
-int	hflag = 0;		/* humanize */
-int	xflag = 0;		/* export */
-
-
-struct fileusage *addid(u_long, int, const char *);
-int	hasquota(struct fstab *, int, char **);
-struct fileusage *lookup(u_long, int);
-struct fileusage *qremove(u_long, int);
-int	main(int, char **);
-int	oneof(const char *, char **, int);
-int	repquota(const struct statvfs *, int);
-int	repquota2(const struct statvfs *, int);
-int	repquota1(const struct statvfs *, int);
-void	usage(void);
-void	printquotas(int, const struct statvfs *, int);
-void	exportquotas(void);
-void	dqblk2q2e(const struct dqblk *, struct quota2_entry *);
+static int	vflag = 0;		/* verbose */
+static int	aflag = 0;		/* all file systems */
+static int	Dflag = 0;		/* debug */
+static int	hflag = 0;		/* humanize */
+static int	xflag = 0;		/* export */
+
+
+static struct fileusage *addid(uint32_t, int, const char *);
+static struct fileusage *lookup(uint32_t, int);
+static struct fileusage *qremove(uint32_t, int);
+static int	oneof(const char *, char **, int);
+static int	repquota(const struct statvfs *, int);
+static int	repquota2(const struct statvfs *, int);
+static int	repquota1(const struct statvfs *, int);
+static void	usage(void) __attribute__((__noreturn__));
+static void	printquotas(int, const struct statvfs *, int);
+static void	exportquotas(void);
 
 int
-main(argc, argv)
-	int argc;
-	char **argv;
+main(int argc, char **argv)
 {
 	int gflag = 0, uflag = 0, errs = 0;
 	long i, argnum, done = 0;
@@ -158,7 +153,7 @@
 
 	nfst = getmntinfo(fst, MNT_WAIT);
 	if (nfst == 0)
-		errx(2, no filesystems mounted!);
+		errx(1, no filesystems mounted!);
 	for (i = 0; i  nfst; i++) {
 		if ((fst[i].f_flag  ST_QUOTA) == 0)
 			continue;
@@ -171,7 +166,7 @@
 		}
 		if ((argnum = oneof(fst[i].f_mntonname, argv, argc)) = 0 ||
 		(argnum = oneof(fst[i].f_mntfromname, argv, argc)) = 0) {
-			done |= 1  argnum;
+			done |= 1U  argnum;
 			if (gflag)
 errs += repquota(fst[i], GRPQUOTA);
 			if (uflag)
@@ -181,36 +176,35 @@
 	if (xflag)
 		exportquotas();
 	for (i = 0; i  argc; i++)
-		if ((done  (1  i)) == 0)
-			fprintf(stderr, %s not mounted\n, argv[i]);
-	

CVS commit: src/usr.sbin/repquota

2010-02-17 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Wed Feb 17 18:55:14 UTC 2010

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

Log Message:
Make block fields one char wider; allows to sanely display quotas up to
99.9GB while still fitting 80 columns.
Something else needs to be found for the long term ...


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.sbin/repquota/repquota.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/repquota/repquota.c
diff -u src/usr.sbin/repquota/repquota.c:1.24 src/usr.sbin/repquota/repquota.c:1.25
--- src/usr.sbin/repquota/repquota.c:1.24	Sat Apr 18 09:20:40 2009
+++ src/usr.sbin/repquota/repquota.c	Wed Feb 17 18:55:14 2010
@@ -40,7 +40,7 @@
 #if 0
 static char sccsid[] = @(#)repquota.c	8.2 (Berkeley) 11/22/94;
 #else
-__RCSID($NetBSD: repquota.c,v 1.24 2009/04/18 09:20:40 lukem Exp $);
+__RCSID($NetBSD: repquota.c,v 1.25 2010/02/17 18:55:14 bouyer Exp $);
 #endif
 #endif /* not lint */
 
@@ -216,7 +216,7 @@
 	fclose(qf);
 	printf(Block limits   File limits\n);
 	printf(type == USRQUOTA ? User  : Group);
-	printf(   usedsofthard  grace  usedsofthard  grace\n);
+	printf(used soft hard  grace  usedsofthard  grace\n);
 	for (id = 0; id = highid[type]; id++) {
 		fup = lookup(id, type);
 		if (fup == 0)
@@ -228,7 +228,7 @@
 			printf(%s , fup-fu_name);
 		else
 			printf(%-10s, fup-fu_name);
-		printf(%c%c%8d%8d%8d%7s,
+		printf(%c%c%9d%9d%9d%7s,
 			fup-fu_dqblk.dqb_bsoftlimit  
 			fup-fu_dqblk.dqb_curblocks = 
 			fup-fu_dqblk.dqb_bsoftlimit ? '+' : '-',