CVS commit: src/usr.bin/quota

2020-01-20 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Jan 21 07:57:49 UTC 2020

Modified Files:
src/usr.bin/quota: quota.1

Log Message:
Use standard Dd format. Remove superfluous Pp


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/quota/quota.1

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

Modified files:

Index: src/usr.bin/quota/quota.1
diff -u src/usr.bin/quota/quota.1:1.22 src/usr.bin/quota/quota.1:1.23
--- src/usr.bin/quota/quota.1:1.22	Mon Jan 20 21:38:29 2020
+++ src/usr.bin/quota/quota.1	Tue Jan 21 07:57:49 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: quota.1,v 1.22 2020/01/20 21:38:29 dholland Exp $
+.\"	$NetBSD: quota.1,v 1.23 2020/01/21 07:57:49 wiz Exp $
 .\"
 .\" Copyright (c) 1983, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -32,7 +32,7 @@
 .\"
 .\"	from: @(#)quota.1	8.1 (Berkeley) 6/6/93
 .\"
-.Dd Jan 20, 2020
+.Dd January 20, 2020
 .Dt QUOTA 1
 .Os
 .Sh NAME
@@ -60,7 +60,6 @@ displays users' disk usage and limits.
 By default only the user quotas are printed.
 .Pp
 Options:
-.Pp
 .Bl -tag -width Ds
 .It Fl d
 Query the kernel for default user or group quota instead of a specific



CVS commit: src/usr.bin/quota

2020-01-20 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jan 20 21:38:30 UTC 2020

Modified Files:
src/usr.bin/quota: quota.1

Log Message:
...and it seems that -d is no longer restricted to root.

(No particular reason it should be; I suspect this changed when we got
real quota plumbing as historically -d would have been a special case
of asking about another user.)


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/quota/quota.1

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

Modified files:

Index: src/usr.bin/quota/quota.1
diff -u src/usr.bin/quota/quota.1:1.21 src/usr.bin/quota/quota.1:1.22
--- src/usr.bin/quota/quota.1:1.21	Mon Jan 20 21:35:41 2020
+++ src/usr.bin/quota/quota.1	Mon Jan 20 21:38:29 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: quota.1,v 1.21 2020/01/20 21:35:41 dholland Exp $
+.\"	$NetBSD: quota.1,v 1.22 2020/01/20 21:38:29 dholland Exp $
 .\"
 .\" Copyright (c) 1983, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -99,10 +99,6 @@ argument with the
 .Fl g
 flag to view only the limits of groups they belong to.
 .Pp
-Only the super-user may use the
-.Fl d
-flag.
-.Pp
 The
 .Fl q
 flag takes precedence over the



CVS commit: src/usr.bin/quota

2020-01-20 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jan 20 21:35:41 UTC 2020

Modified Files:
src/usr.bin/quota: quota.1

Log Message:
Document the actual behavior of -g; clarify the optional user/group args.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/quota/quota.1

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

Modified files:

Index: src/usr.bin/quota/quota.1
diff -u src/usr.bin/quota/quota.1:1.20 src/usr.bin/quota/quota.1:1.21
--- src/usr.bin/quota/quota.1:1.20	Mon Jan 20 21:30:41 2020
+++ src/usr.bin/quota/quota.1	Mon Jan 20 21:35:41 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: quota.1,v 1.20 2020/01/20 21:30:41 dholland Exp $
+.\"	$NetBSD: quota.1,v 1.21 2020/01/20 21:35:41 dholland Exp $
 .\"
 .\" Copyright (c) 1983, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -66,7 +66,8 @@ Options:
 Query the kernel for default user or group quota instead of a specific
 user or group.
 .It Fl g
-Print group quotas for the group of which the user is a member.
+Print group quotas.
+By default, print group quotas for all groups the user belongs to.
 .It Fl h
 Numbers are displayed in a human readable format.
 .It Fl q
@@ -87,16 +88,16 @@ and
 displays both the user quotas and the group quotas (for
 the user).
 .Pp
-Only the super-user may use the
-.Fl u
-flag and the optional
+Only the super-user may use the optional
 .Ar user
-argument to view the limits of other users.
-Non-super-users can use the
-.Fl g
-flag and optional
+argument with the
+.Fl u
+flag to view quotas for other users.
+Non-super-users can use the optional
 .Ar group
-argument to view only the limits of groups of which they are members.
+argument with the
+.Fl g
+flag to view only the limits of groups they belong to.
 .Pp
 Only the super-user may use the
 .Fl d



CVS commit: src/usr.bin/quota

2020-01-20 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jan 20 21:30:41 UTC 2020

Modified Files:
src/usr.bin/quota: quota.1

Log Message:
Clarify -u.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/quota/quota.1

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

Modified files:

Index: src/usr.bin/quota/quota.1
diff -u src/usr.bin/quota/quota.1:1.19 src/usr.bin/quota/quota.1:1.20
--- src/usr.bin/quota/quota.1:1.19	Sat May 12 21:43:09 2012
+++ src/usr.bin/quota/quota.1	Mon Jan 20 21:30:41 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: quota.1,v 1.19 2012/05/12 21:43:09 wiz Exp $
+.\"	$NetBSD: quota.1,v 1.20 2020/01/20 21:30:41 dholland Exp $
 .\"
 .\" Copyright (c) 1983, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -32,7 +32,7 @@
 .\"
 .\"	from: @(#)quota.1	8.1 (Berkeley) 6/6/93
 .\"
-.Dd May 12, 2012
+.Dd Jan 20, 2020
 .Dt QUOTA 1
 .Os
 .Sh NAME
@@ -67,14 +67,14 @@ Query the kernel for default user or gro
 user or group.
 .It Fl g
 Print group quotas for the group of which the user is a member.
-The optional
-.Fl u
-flag is equivalent to the default.
 .It Fl h
 Numbers are displayed in a human readable format.
 .It Fl q
 Print a more terse message, containing only information
 on file systems where usage is over quota.
+.It Fl u
+Print user quotas.
+This is the default.
 .It Fl v
 .Nm
 will display quotas on file systems where no storage is allocated.



CVS commit: src/usr.bin/quota

2014-07-12 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Jul 13 01:46:04 UTC 2014

Modified Files:
src/usr.bin/quota: quota.c

Log Message:
Remove leftover #if 0 code from before the libquota rework.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/usr.bin/quota/quota.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.bin/quota/quota.c
diff -u src/usr.bin/quota/quota.c:1.49 src/usr.bin/quota/quota.c:1.50
--- src/usr.bin/quota/quota.c:1.49	Sat May 12 19:53:22 2012
+++ src/usr.bin/quota/quota.c	Sun Jul 13 01:46:04 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota.c,v 1.49 2012/05/12 19:53:22 dholland Exp $	*/
+/*	$NetBSD: quota.c,v 1.50 2014/07/13 01:46:04 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)quota.c	8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: quota.c,v 1.49 2012/05/12 19:53:22 dholland Exp $");
+__RCSID("$NetBSD: quota.c,v 1.50 2014/07/13 01:46:04 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -502,30 +502,6 @@ getprivs(id_t id, int idtype)
 			}
 			err(1, "%s: quota_open", fst[i].f_mntonname);
 		}
-#if 0
-		if (strncmp(fst[i].f_fstypename, "nfs", 
-		sizeof(fst[i].f_fstypename)) == 0) {
-			version = 0;
-			qup->numqvs = QUOTA_NLIMITS;
-			qup->qvs = malloc(qup->numqvs * sizeof(qup->qvs[0]));
-			if (qup->qvs == NULL) {
-err(1, "Out of memory");
-			}
-			if (getnfsquota(fst[i].f_mntfromname,
-			qup->qvs, id, ufs_quota_class_names[idtype]) != 1)
-continue;
-		} else if ((fst[i].f_flag & ST_QUOTA) != 0) {
-			qup->numqvs = QUOTA_NLIMITS;
-			qup->qvs = malloc(qup->numqvs * sizeof(qup->qvs[0]));
-			if (qup->qvs == NULL) {
-err(1, "Out of memory");
-			}
-			if (getvfsquota(fst[i].f_mntonname, qup->qvs, &version,
-			id, idtype, dflag, 0) != 1)
-continue;
-		} else
-			continue;
-#else
 		qup->numqvs = quota_getnumidtypes(qup->qh);
 		qup->qvs = malloc(qup->numqvs * sizeof(qup->qvs[0]));
 		if (qup->qvs == NULL) {
@@ -547,7 +523,6 @@ getprivs(id_t id, int idtype)
 quotaval_clear(&qup->qvs[j]);
 			}
 		}
-#endif
 		(void)strlcpy(qup->fsname, fst[i].f_mntonname,
 		sizeof(qup->fsname));
 		if (quphead == NULL)



CVS commit: src/usr.bin/quota

2013-08-10 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Aug 11 06:09:29 UTC 2013

Modified Files:
src/usr.bin/quota: Makefile

Log Message:
Passes WARNS=5; don't set WARNS=4.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/quota/Makefile

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

Modified files:

Index: src/usr.bin/quota/Makefile
diff -u src/usr.bin/quota/Makefile:1.12 src/usr.bin/quota/Makefile:1.13
--- src/usr.bin/quota/Makefile:1.12	Wed Feb  1 17:53:01 2012
+++ src/usr.bin/quota/Makefile	Sun Aug 11 06:09:29 2013
@@ -1,7 +1,6 @@
-#	$NetBSD: Makefile,v 1.12 2012/02/01 17:53:01 dholland Exp $	
+#	$NetBSD: Makefile,v 1.13 2013/08/11 06:09:29 dholland Exp $	
 #	from: @(#)Makefile	8.1 (Berkeley) 6/6/93
 
-WARNS ?= 4
 .include 
 PROG=	quota
 SRCS=	quota.c printquota.c



CVS commit: src/usr.bin/quota

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

Modified Files:
src/usr.bin/quota: quota.1

Log Message:
Bump date for previous.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/quota/quota.1

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

Modified files:

Index: src/usr.bin/quota/quota.1
diff -u src/usr.bin/quota/quota.1:1.18 src/usr.bin/quota/quota.1:1.19
--- src/usr.bin/quota/quota.1:1.18	Sat May 12 19:53:21 2012
+++ src/usr.bin/quota/quota.1	Sat May 12 21:43:09 2012
@@ -1,4 +1,4 @@
-.\"	$NetBSD: quota.1,v 1.18 2012/05/12 19:53:21 dholland Exp $
+.\"	$NetBSD: quota.1,v 1.19 2012/05/12 21:43:09 wiz Exp $
 .\"
 .\" Copyright (c) 1983, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -32,7 +32,7 @@
 .\"
 .\"	from: @(#)quota.1	8.1 (Berkeley) 6/6/93
 .\"
-.Dd March 6, 2011
+.Dd May 12, 2012
 .Dt QUOTA 1
 .Os
 .Sh NAME



CVS commit: src/usr.bin/quota

2012-05-12 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sat May 12 19:53:22 UTC 2012

Modified Files:
src/usr.bin/quota: quota.1 quota.c

Log Message:
Remove traces of -D option, which no longer does anything.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/quota/quota.1
cvs rdiff -u -r1.48 -r1.49 src/usr.bin/quota/quota.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.bin/quota/quota.1
diff -u src/usr.bin/quota/quota.1:1.17 src/usr.bin/quota/quota.1:1.18
--- src/usr.bin/quota/quota.1:1.17	Mon Feb 13 19:53:25 2012
+++ src/usr.bin/quota/quota.1	Sat May 12 19:53:21 2012
@@ -1,4 +1,4 @@
-.\"	$NetBSD: quota.1,v 1.17 2012/02/13 19:53:25 dholland Exp $
+.\"	$NetBSD: quota.1,v 1.18 2012/05/12 19:53:21 dholland Exp $
 .\"
 .\" Copyright (c) 1983, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -40,19 +40,19 @@
 .Nd display disk usage and limits
 .Sh SYNOPSIS
 .Nm
-.Op Fl Dghu
+.Op Fl ghu
 .Op Fl v | Fl q
 .Nm
-.Op Fl Dhu
+.Op Fl hu
 .Op Fl v | Fl q
 .Ar user
 .Nm
-.Op Fl Dgh
+.Op Fl gh
 .Op Fl v | Fl q
 .Ar group
 .Nm
 .Fl d
-.Op Fl Dgh
+.Op Fl gh
 .Op Fl v | Fl q
 .Sh DESCRIPTION
 .Nm
@@ -62,8 +62,6 @@ By default only the user quotas are prin
 Options:
 .Pp
 .Bl -tag -width Ds
-.It Fl D
-Debug: print plist sent to and received from kernel.
 .It Fl d
 Query the kernel for default user or group quota instead of a specific
 user or group.

Index: src/usr.bin/quota/quota.c
diff -u src/usr.bin/quota/quota.c:1.48 src/usr.bin/quota/quota.c:1.49
--- src/usr.bin/quota/quota.c:1.48	Sun Feb  5 14:14:44 2012
+++ src/usr.bin/quota/quota.c	Sat May 12 19:53:22 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota.c,v 1.48 2012/02/05 14:14:44 dholland Exp $	*/
+/*	$NetBSD: quota.c,v 1.49 2012/05/12 19:53:22 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)quota.c	8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: quota.c,v 1.48 2012/02/05 14:14:44 dholland Exp $");
+__RCSID("$NetBSD: quota.c,v 1.49 2012/05/12 19:53:22 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -104,7 +104,6 @@ static int	qflag = 0;
 static int	vflag = 0;
 static int	hflag = 0;
 static int	dflag = 0;
-static int	Dflag = 0;
 static uid_t	myuid;
 static int needheading;
 
@@ -117,7 +116,7 @@ main(int argc, char *argv[])
 	int ch;
 
 	myuid = getuid();
-	while ((ch = getopt(argc, argv, "Ddhugvq")) != -1) {
+	while ((ch = getopt(argc, argv, "dhugvq")) != -1) {
 		switch(ch) {
 		case 'g':
 			gflag++;
@@ -137,9 +136,6 @@ main(int argc, char *argv[])
 		case 'd':
 			dflag++;
 			break;
-		case 'D':
-			Dflag++;
-			break;
 		default:
 			usage();
 		}
@@ -525,7 +521,7 @@ getprivs(id_t id, int idtype)
 err(1, "Out of memory");
 			}
 			if (getvfsquota(fst[i].f_mntonname, qup->qvs, &version,
-			id, idtype, dflag, Dflag) != 1)
+			id, idtype, dflag, 0) != 1)
 continue;
 		} else
 			continue;



CVS commit: src/usr.bin/quota

2012-01-30 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jan 30 19:21:37 UTC 2012

Removed Files:
src/usr.bin/quota: getvfsquota.c getvfsquota.h

Log Message:
Remove this material, which is no longer used.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r0 src/usr.bin/quota/getvfsquota.c
cvs rdiff -u -r1.5 -r0 src/usr.bin/quota/getvfsquota.h

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



CVS commit: src/usr.bin/quota

2012-01-30 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jan 30 16:46:30 UTC 2012

Modified Files:
src/usr.bin/quota: quota.c

Log Message:
Remove unused include.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/usr.bin/quota/quota.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.bin/quota/quota.c
diff -u src/usr.bin/quota/quota.c:1.45 src/usr.bin/quota/quota.c:1.46
--- src/usr.bin/quota/quota.c:1.45	Mon Jan 30 06:00:49 2012
+++ src/usr.bin/quota/quota.c	Mon Jan 30 16:46:30 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota.c,v 1.45 2012/01/30 06:00:49 dholland Exp $	*/
+/*	$NetBSD: quota.c,v 1.46 2012/01/30 16:46:30 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)quota.c	8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: quota.c,v 1.45 2012/01/30 06:00:49 dholland Exp $");
+__RCSID("$NetBSD: quota.c,v 1.46 2012/01/30 16:46:30 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -74,7 +74,6 @@ __RCSID("$NetBSD: quota.c,v 1.45 2012/01
 #include 
 
 #include "printquota.h"
-#include "getvfsquota.h"
 
 struct quotause {
 	struct	quotause *next;



CVS commit: src/usr.bin/quota

2012-01-29 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jan 30 06:14:43 UTC 2012

Modified Files:
src/usr.bin/quota: quotautil.c quotautil.h

Log Message:
Remove stray p in identifier name. This has (as far as I can tell)
prevented quotacheck and other old-style quota bits from working since
last March. Use a correct declaration in the header file, so that if
something similar happens again affected programs will fail to link
instead of failing to work.

This kind of nonsense is why I like -Wl,-warn-common.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/quota/quotautil.c
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/quota/quotautil.h

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

Modified files:

Index: src/usr.bin/quota/quotautil.c
diff -u src/usr.bin/quota/quotautil.c:1.5 src/usr.bin/quota/quotautil.c:1.6
--- src/usr.bin/quota/quotautil.c:1.5	Mon Jan 30 06:02:12 2012
+++ src/usr.bin/quota/quotautil.c	Mon Jan 30 06:14:43 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quotautil.c,v 1.5 2012/01/30 06:02:12 dholland Exp $ */
+/*	$NetBSD: quotautil.c,v 1.6 2012/01/30 06:14:43 dholland Exp $ */
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)quota.c	8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: quotautil.c,v 1.5 2012/01/30 06:02:12 dholland Exp $");
+__RCSID("$NetBSD: quotautil.c,v 1.6 2012/01/30 06:14:43 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -65,7 +65,7 @@ __RCSID("$NetBSD: quotautil.c,v 1.5 2012
 #include "quotautil.h"
 
 const char *qfextension[] = INITQFNAMES;
-const char *qfnamep = QUOTAFILENAME;
+const char *qfname = QUOTAFILENAME;
  
 /*
  * Check to see if a particular quota is to be enabled.

Index: src/usr.bin/quota/quotautil.h
diff -u src/usr.bin/quota/quotautil.h:1.3 src/usr.bin/quota/quotautil.h:1.4
--- src/usr.bin/quota/quotautil.h:1.3	Thu Mar 24 17:05:46 2011
+++ src/usr.bin/quota/quotautil.h	Mon Jan 30 06:14:43 2012
@@ -1,7 +1,7 @@
-/*	$NetBSD: quotautil.h,v 1.3 2011/03/24 17:05:46 bouyer Exp $ */
+/*	$NetBSD: quotautil.h,v 1.4 2012/01/30 06:14:43 dholland Exp $ */
 
-const char *qfextension[MAXQUOTAS];
-const char *qfname;
+extern const char *qfextension[MAXQUOTAS];
+extern const char *qfname;
 struct fstab;
 int hasquota(char *, size_t, struct fstab *, int);
 int oneof(const char *, char *[], int);



CVS commit: src/usr.bin/quota

2012-01-29 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jan 30 06:02:12 UTC 2012

Modified Files:
src/usr.bin/quota: quotautil.c

Log Message:
Don't strlcpy from a string buffer to itself; the behavior is not
defined.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/quota/quotautil.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.bin/quota/quotautil.c
diff -u src/usr.bin/quota/quotautil.c:1.4 src/usr.bin/quota/quotautil.c:1.5
--- src/usr.bin/quota/quotautil.c:1.4	Wed Jan 25 01:24:07 2012
+++ src/usr.bin/quota/quotautil.c	Mon Jan 30 06:02:12 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quotautil.c,v 1.4 2012/01/25 01:24:07 dholland Exp $ */
+/*	$NetBSD: quotautil.c,v 1.5 2012/01/30 06:02:12 dholland Exp $ */
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)quota.c	8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: quotautil.c,v 1.4 2012/01/25 01:24:07 dholland Exp $");
+__RCSID("$NetBSD: quotautil.c,v 1.5 2012/01/30 06:02:12 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -76,6 +76,7 @@ hasquota(char *buf, size_t len, struct f
 	char *opt;
 	char *cp = NULL;
 	static char initname, usrname[100], grpname[100];
+	char optbuf[256];
 
 	if (!initname) {
 		(void)snprintf(usrname, sizeof(usrname), "%s%s",
@@ -84,8 +85,8 @@ hasquota(char *buf, size_t len, struct f
 		qfextension[GRPQUOTA], qfname);
 		initname = 1;
 	}
-	strlcpy(buf, fs->fs_mntops, len);
-	for (opt = strtok(buf, ","); opt; opt = strtok(NULL, ",")) {
+	strlcpy(optbuf, fs->fs_mntops, sizeof(optbuf));
+	for (opt = strtok(optbuf, ","); opt; opt = strtok(NULL, ",")) {
 		if ((cp = strchr(opt, '=')) != NULL)
 			*cp++ = '\0';
 		if (type == USRQUOTA && strcmp(opt, usrname) == 0)



CVS commit: src/usr.bin/quota

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

Modified Files:
src/usr.bin/quota: quotautil.c

Log Message:
Remove unnecessary include.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/quota/quotautil.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.bin/quota/quotautil.c
diff -u src/usr.bin/quota/quotautil.c:1.3 src/usr.bin/quota/quotautil.c:1.4
--- src/usr.bin/quota/quotautil.c:1.3	Thu Mar 24 17:05:46 2011
+++ src/usr.bin/quota/quotautil.c	Wed Jan 25 01:24:07 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quotautil.c,v 1.3 2011/03/24 17:05:46 bouyer Exp $ */
+/*	$NetBSD: quotautil.c,v 1.4 2012/01/25 01:24:07 dholland Exp $ */
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)quota.c	8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: quotautil.c,v 1.3 2011/03/24 17:05:46 bouyer Exp $");
+__RCSID("$NetBSD: quotautil.c,v 1.4 2012/01/25 01:24:07 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -60,7 +60,6 @@ __RCSID("$NetBSD: quotautil.c,v 1.3 2011
 #include 
 #include 
 
-#include 
 #include 
 
 #include "quotautil.h"



CVS commit: src/usr.bin/quota

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

Modified Files:
src/usr.bin/quota: Makefile quota.c

Log Message:
Clean up usr.bin/quota to use the new libquota API.
(with one relatively minor exception remaining)


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/quota/Makefile
cvs rdiff -u -r1.43 -r1.44 src/usr.bin/quota/quota.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.bin/quota/Makefile
diff -u src/usr.bin/quota/Makefile:1.10 src/usr.bin/quota/Makefile:1.11
--- src/usr.bin/quota/Makefile:1.10	Thu Mar 24 17:05:46 2011
+++ src/usr.bin/quota/Makefile	Mon Jan  9 15:35:44 2012
@@ -1,10 +1,10 @@
-#	$NetBSD: Makefile,v 1.10 2011/03/24 17:05:46 bouyer Exp $	
+#	$NetBSD: Makefile,v 1.11 2012/01/09 15:35:44 dholland Exp $	
 #	from: @(#)Makefile	8.1 (Berkeley) 6/6/93
 
 WARNS ?= 4
 .include 
 PROG=	quota
-SRCS=	quota.c printquota.c getvfsquota.c
+SRCS=	quota.c printquota.c
 
 CPPFLAGS+= -I${NETBSDSRCDIR}/usr.bin/quota
 DPADD=	${LIBQUOTA} ${LIBRPCSVC} ${LIBPROP}

Index: src/usr.bin/quota/quota.c
diff -u src/usr.bin/quota/quota.c:1.43 src/usr.bin/quota/quota.c:1.44
--- src/usr.bin/quota/quota.c:1.43	Wed Nov 30 16:12:32 2011
+++ src/usr.bin/quota/quota.c	Mon Jan  9 15:35:44 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota.c,v 1.43 2011/11/30 16:12:32 dholland Exp $	*/
+/*	$NetBSD: quota.c,v 1.44 2012/01/09 15:35:44 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)quota.c	8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: quota.c,v 1.43 2011/11/30 16:12:32 dholland Exp $");
+__RCSID("$NetBSD: quota.c,v 1.44 2012/01/09 15:35:44 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -70,7 +70,7 @@ __RCSID("$NetBSD: quota.c,v 1.43 2011/11
 #include 
 #include 
 
-#include 
+#include 
 #include 
 
 #include "printquota.h"
@@ -78,26 +78,25 @@ __RCSID("$NetBSD: quota.c,v 1.43 2011/11
 
 struct quotause {
 	struct	quotause *next;
-	long	flags;
 	uid_t	id;
 	struct	quotaval *qvs;
 	unsigned numqvs;
 	char	fsname[MAXPATHLEN + 1];
+	struct	quotahandle *qh;
 };
-#define	FOUND	0x01
-#define	QUOTA2	0x02
 
 static int	anyusage(struct quotaval *, unsigned);
 static int	anyover(struct quotaval *, unsigned, time_t);
 static const char *getovermsg(struct quotaval *, const char *, time_t);
 static struct quotause	*getprivs(id_t, int);
-static void	heading(int, id_t, const char *, const char *);
+static void	heading(int, const char *, id_t, const char *, const char *);
 static int	isover(struct quotaval *qv, time_t now);
-static void	printqv(struct quotaval *, int, int, time_t);
+static void	printqv(struct quotaval *, int, time_t);
 static void	showgid(gid_t);
 static void	showgrpname(const char *);
-static void	showonequota(int, id_t, const char *, struct quotause *);
-static void	showquotas(int, id_t, const char *);
+static void	showonequota(int, const char *, id_t, const char *,
+			 struct quotause *);
+static void	showquotas(int, const char *, id_t, const char *);
 static void	showuid(uid_t);
 static void	showusrname(const char *);
 static int	unlimited(struct quotaval *qvs, unsigned numqvs);
@@ -157,9 +156,9 @@ main(int argc, char *argv[])
 			errx(1, "-d: permission denied");
 #endif
 		if (uflag)
-			showquotas(QUOTA_CLASS_USER, 0, "");
+			showquotas(QUOTA_IDTYPE_USER, "user", 0, "");
 		if (gflag)
-			showquotas(QUOTA_CLASS_GROUP, 0, "");
+			showquotas(QUOTA_IDTYPE_GROUP, "group", 0, "");
 		return 0;
 	}
 	if (argc == 0) {
@@ -233,7 +232,7 @@ showuid(uid_t uid)
 		warnx("%s (uid %d): permission denied", name, uid);
 		return;
 	}
-	showquotas(QUOTA_CLASS_USER, uid, name);
+	showquotas(QUOTA_IDTYPE_USER, "user", uid, name);
 }
 
 /*
@@ -252,7 +251,7 @@ showusrname(const char *name)
 		warnx("%s (uid %d): permission denied", name, pwd->pw_uid);
 		return;
 	}
-	showquotas(QUOTA_CLASS_USER, pwd->pw_uid, name);
+	showquotas(QUOTA_IDTYPE_USER, "user", pwd->pw_uid, name);
 }
 
 /*
@@ -286,7 +285,7 @@ showgid(gid_t gid)
 			return;
 		}
 	}
-	showquotas(QUOTA_CLASS_GROUP, gid, name);
+	showquotas(QUOTA_IDTYPE_GROUP, "group", gid, name);
 }
 
 /*
@@ -320,39 +319,35 @@ showgrpname(const char *name)
 			return;
 		}
 	}
-	showquotas(QUOTA_CLASS_GROUP, grp->gr_gid, name);
+	showquotas(QUOTA_IDTYPE_GROUP, "group", grp->gr_gid, name);
 }
 
 static void
-showquotas(int type, id_t id, const char *idname)
+showquotas(int idtype, const char *idtypename, id_t id, const char *idname)
 {
 	struct quotause *qup;
 	struct quotause *quplist;
 
 	needheading = 1;
 
-	quplist = getprivs(id, type);
+	quplist = getprivs(id, idtype);
 	for (qup = quplist; qup; qup = qup->next) {
-		showonequota(type, id, idname, qup);
+		showonequota(idtype, idtypename, id, idname, qup);
 	}
 	if (!qflag) {
 		/* In case nothing printed, issue a header saying "none" */
-		heading(type, id, idname

CVS commit: src/usr.bin/quota

2011-11-30 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Wed Nov 30 16:12:32 UTC 2011

Modified Files:
src/usr.bin/quota: quota.c

Log Message:
Adjust the quota-fetching code to allow more than two object types.
(as far as we can so far, at least)

Note that quota won't actually work fully with multiple object types
as it is, but this and the last change are a good start and do fold
together a lot of duplicated code.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/usr.bin/quota/quota.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.bin/quota/quota.c
diff -u src/usr.bin/quota/quota.c:1.42 src/usr.bin/quota/quota.c:1.43
--- src/usr.bin/quota/quota.c:1.42	Wed Nov 30 16:09:29 2011
+++ src/usr.bin/quota/quota.c	Wed Nov 30 16:12:32 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota.c,v 1.42 2011/11/30 16:09:29 dholland Exp $	*/
+/*	$NetBSD: quota.c,v 1.43 2011/11/30 16:12:32 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)quota.c	8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: quota.c,v 1.42 2011/11/30 16:09:29 dholland Exp $");
+__RCSID("$NetBSD: quota.c,v 1.43 2011/11/30 16:12:32 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -80,7 +80,8 @@ struct quotause {
 	struct	quotause *next;
 	long	flags;
 	uid_t	id;
-	struct	quotaval qv[QUOTA_NLIMITS];
+	struct	quotaval *qvs;
+	unsigned numqvs;
 	char	fsname[MAXPATHLEN + 1];
 };
 #define	FOUND	0x01
@@ -353,8 +354,8 @@ showonequota(int type, id_t id, const ch
 	const char *msg;
 	int isquota2;
 
-	qvs = qup->qv;
-	numqvs = QUOTA_NLIMITS;
+	qvs = qup->qvs;
+	numqvs = qup->numqvs;
 
 	if (now == 0) {
 		time(&now);
@@ -399,7 +400,8 @@ showonequota(int type, id_t id, const ch
 		isquota2 = (qup->flags & QUOTA2) != 0;
 
 		for (i=0; i= QUOTA_NLIMITS ? 0 : isbytes[i], now);
 		}
 		printf("\n");
 	}
@@ -494,16 +496,26 @@ getprivs(id_t id, int quotatype)
 	for (i = 0; i < nfst; i++) {
 		if (qup == NULL) {
 			if ((qup = malloc(sizeof *qup)) == NULL)
-err(1, "out of memory");
+err(1, "Out of memory");
 		}
 		if (strncmp(fst[i].f_fstypename, "nfs", 
 		sizeof(fst[i].f_fstypename)) == 0) {
 			version = 0;
+			qup->numqvs = QUOTA_NLIMITS;
+			qup->qvs = malloc(qup->numqvs * sizeof(qup->qvs[0]));
+			if (qup->qvs == NULL) {
+err(1, "Out of memory");
+			}
 			if (getnfsquota(fst[i].f_mntfromname,
-			qup->qv, id, ufs_quota_class_names[quotatype]) != 1)
+			qup->qvs, id, ufs_quota_class_names[quotatype]) != 1)
 continue;
 		} else if ((fst[i].f_flag & ST_QUOTA) != 0) {
-			if (getvfsquota(fst[i].f_mntonname, qup->qv, &version,
+			qup->numqvs = QUOTA_NLIMITS;
+			qup->qvs = malloc(qup->numqvs * sizeof(qup->qvs[0]));
+			if (qup->qvs == NULL) {
+err(1, "Out of memory");
+			}
+			if (getvfsquota(fst[i].f_mntonname, qup->qvs, &version,
 			id, quotatype, dflag, Dflag) != 1)
 continue;
 		} else



CVS commit: src/usr.bin/quota

2011-11-30 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Wed Nov 30 16:09:29 UTC 2011

Modified Files:
src/usr.bin/quota: quota.c

Log Message:
Clean up the printout code to support more than the old fixed two
object types.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/usr.bin/quota/quota.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.bin/quota/quota.c
diff -u src/usr.bin/quota/quota.c:1.41 src/usr.bin/quota/quota.c:1.42
--- src/usr.bin/quota/quota.c:1.41	Wed Nov 30 16:07:28 2011
+++ src/usr.bin/quota/quota.c	Wed Nov 30 16:09:29 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota.c,v 1.41 2011/11/30 16:07:28 dholland Exp $	*/
+/*	$NetBSD: quota.c,v 1.42 2011/11/30 16:09:29 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)quota.c	8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: quota.c,v 1.41 2011/11/30 16:07:28 dholland Exp $");
+__RCSID("$NetBSD: quota.c,v 1.42 2011/11/30 16:09:29 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -56,6 +56,7 @@ __RCSID("$NetBSD: quota.c,v 1.41 2011/11
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -85,14 +86,20 @@ struct quotause {
 #define	FOUND	0x01
 #define	QUOTA2	0x02
 
+static int	anyusage(struct quotaval *, unsigned);
+static int	anyover(struct quotaval *, unsigned, time_t);
+static const char *getovermsg(struct quotaval *, const char *, time_t);
 static struct quotause	*getprivs(id_t, int);
 static void	heading(int, id_t, const char *, const char *);
+static int	isover(struct quotaval *qv, time_t now);
+static void	printqv(struct quotaval *, int, int, time_t);
 static void	showgid(gid_t);
 static void	showgrpname(const char *);
 static void	showonequota(int, id_t, const char *, struct quotause *);
 static void	showquotas(int, id_t, const char *);
 static void	showuid(uid_t);
 static void	showusrname(const char *);
+static int	unlimited(struct quotaval *qvs, unsigned numqvs);
 static void	usage(void) __dead;
 
 static int	qflag = 0;
@@ -316,7 +323,7 @@ showgrpname(const char *name)
 }
 
 static void
-showquotas(int type, id_t id, const char *name)
+showquotas(int type, id_t id, const char *idname)
 {
 	struct quotause *qup;
 	struct quotause *quplist;
@@ -325,131 +332,81 @@ showquotas(int type, id_t id, const char
 
 	quplist = getprivs(id, type);
 	for (qup = quplist; qup; qup = qup->next) {
-		showonequota(type, id, name, qup);
+		showonequota(type, id, idname, qup);
 	}
 	if (!qflag) {
 		/* In case nothing printed, issue a header saying "none" */
-		heading(type, id, name, "none");
+		heading(type, id, idname, "none");
 	}
 }
 
 static void
-showonequota(int type, id_t id, const char *name, struct quotause *qup)
+showonequota(int type, id_t id, const char *idname, struct quotause *qup)
 {
-	char b0[20], b1[20], b2[20], b3[20];
-	const char *msgi, *msgb, *nam, *timemsg;
-	int ql_stat;
-	struct quotaval *q = qup->qv;
+	static const int isbytes[QUOTA_NLIMITS] = {
+		[QUOTA_LIMIT_BLOCK] = 1, 
+		[QUOTA_LIMIT_FILE] = 0,
+	};
 	static time_t now;
+	struct quotaval *qvs;
+	unsigned numqvs, i;
+	const char *msg;
+	int isquota2;
+
+	qvs = qup->qv;
+	numqvs = QUOTA_NLIMITS;
 
 	if (now == 0) {
 		time(&now);
 	}
 
-	if (!vflag &&
-	q[QUOTA_LIMIT_BLOCK].qv_softlimit == UQUAD_MAX &&
-	q[QUOTA_LIMIT_BLOCK].qv_hardlimit == UQUAD_MAX &&
-	q[QUOTA_LIMIT_FILE].qv_softlimit == UQUAD_MAX &&
-	q[QUOTA_LIMIT_FILE].qv_hardlimit == UQUAD_MAX)
+	if (!vflag && unlimited(qvs, numqvs)) {
 		return;
-	ql_stat = quota_check_limit(q[QUOTA_LIMIT_FILE].qv_usage, 1,
-q[QUOTA_LIMIT_FILE].qv_softlimit,
-q[QUOTA_LIMIT_FILE].qv_hardlimit,
-q[QUOTA_LIMIT_FILE].qv_expiretime, now);
-	switch(QL_STATUS(ql_stat)) {
-	case QL_S_DENY_HARD:
-		msgi = "File limit reached on";
-		break;
-	case QL_S_DENY_GRACE:
-		msgi = "Over file quota on";
-		break;
-	case QL_S_ALLOW_SOFT:
-		msgi = "In file grace period on";
-		break;
-	default:
-		msgi = NULL;
-	}
-	ql_stat = quota_check_limit(q[QUOTA_LIMIT_BLOCK].qv_usage, 1,
-q[QUOTA_LIMIT_BLOCK].qv_softlimit,
-q[QUOTA_LIMIT_BLOCK].qv_hardlimit,
-q[QUOTA_LIMIT_BLOCK].qv_expiretime, now);
-	switch(QL_STATUS(ql_stat)) {
-	case QL_S_DENY_HARD:
-		msgb = "Block limit reached on";
-		break;
-	case QL_S_DENY_GRACE:
-		msgb = "Over block quota on";
-		break;
-	case QL_S_ALLOW_SOFT:
-		msgb = "In block grace period on";
-		break;
-	default:
-		msgb = NULL;
 	}
+
 	if (qflag) {
-		if (msgi != NULL) {
-			heading(type, id, name, "");
-			printf("\t%s %s\n", msgi, qup->fsname);
-		}
-		if (msgb != NULL) {
-			heading(type, id, name, "");
-			printf("\t%s %s\n", msgb, qup->fsname);
+		for (i=0; ifsname);
+			}
 		}
 		return;
 	}
-	if (vflag || dflag || msgi || msgb ||
-	q[QUOTA_LIMIT_BLOCK].qv_usage ||
-	q[QUOTA_LIMIT_FILE].q

CVS commit: src/usr.bin/quota

2011-11-30 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Wed Nov 30 16:07:28 UTC 2011

Modified Files:
src/usr.bin/quota: quota.c

Log Message:
Move a big chunk of code out of a loop into its own function.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/usr.bin/quota/quota.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.bin/quota/quota.c
diff -u src/usr.bin/quota/quota.c:1.40 src/usr.bin/quota/quota.c:1.41
--- src/usr.bin/quota/quota.c:1.40	Sun Nov 27 13:24:32 2011
+++ src/usr.bin/quota/quota.c	Wed Nov 30 16:07:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota.c,v 1.40 2011/11/27 13:24:32 dholland Exp $	*/
+/*	$NetBSD: quota.c,v 1.41 2011/11/30 16:07:28 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)quota.c	8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: quota.c,v 1.40 2011/11/27 13:24:32 dholland Exp $");
+__RCSID("$NetBSD: quota.c,v 1.41 2011/11/30 16:07:28 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -89,6 +89,7 @@ static struct quotause	*getprivs(id_t, i
 static void	heading(int, id_t, const char *, const char *);
 static void	showgid(gid_t);
 static void	showgrpname(const char *);
+static void	showonequota(int, id_t, const char *, struct quotause *);
 static void	showquotas(int, id_t, const char *);
 static void	showuid(uid_t);
 static void	showusrname(const char *);
@@ -100,6 +101,7 @@ static int	hflag = 0;
 static int	dflag = 0;
 static int	Dflag = 0;
 static uid_t	myuid;
+static int needheading;
 
 int
 main(int argc, char *argv[])
@@ -318,125 +320,141 @@ showquotas(int type, id_t id, const char
 {
 	struct quotause *qup;
 	struct quotause *quplist;
+
+	needheading = 1;
+
+	quplist = getprivs(id, type);
+	for (qup = quplist; qup; qup = qup->next) {
+		showonequota(type, id, name, qup);
+	}
+	if (!qflag) {
+		/* In case nothing printed, issue a header saying "none" */
+		heading(type, id, name, "none");
+	}
+}
+
+static void
+showonequota(int type, id_t id, const char *name, struct quotause *qup)
+{
+	char b0[20], b1[20], b2[20], b3[20];
 	const char *msgi, *msgb, *nam, *timemsg;
-	int lines = 0;
+	int ql_stat;
+	struct quotaval *q = qup->qv;
 	static time_t now;
-	char b0[20], b1[20], b2[20], b3[20];
 
-	if (now == 0)
+	if (now == 0) {
 		time(&now);
-	quplist = getprivs(id, type);
-	for (qup = quplist; qup; qup = qup->next) {
-		int ql_stat;
-		struct quotaval *q = qup->qv;
-		if (!vflag &&
-		q[QUOTA_LIMIT_BLOCK].qv_softlimit == UQUAD_MAX &&
-		q[QUOTA_LIMIT_BLOCK].qv_hardlimit == UQUAD_MAX &&
-		q[QUOTA_LIMIT_FILE].qv_softlimit == UQUAD_MAX &&
-		q[QUOTA_LIMIT_FILE].qv_hardlimit == UQUAD_MAX)
-			continue;
-		ql_stat = quota_check_limit(q[QUOTA_LIMIT_FILE].qv_usage, 1,
-		q[QUOTA_LIMIT_FILE].qv_softlimit,
-		q[QUOTA_LIMIT_FILE].qv_hardlimit,
-		q[QUOTA_LIMIT_FILE].qv_expiretime, now);
-		switch(QL_STATUS(ql_stat)) {
-		case QL_S_DENY_HARD:
-			msgi = "File limit reached on";
-			break;
-		case QL_S_DENY_GRACE:
-			msgi = "Over file quota on";
-			break;
-		case QL_S_ALLOW_SOFT:
-			msgi = "In file grace period on";
-			break;
-		default:
-			msgi = NULL;
-		}
-		ql_stat = quota_check_limit(q[QUOTA_LIMIT_BLOCK].qv_usage, 1,
-		q[QUOTA_LIMIT_BLOCK].qv_softlimit,
-		q[QUOTA_LIMIT_BLOCK].qv_hardlimit,
-		q[QUOTA_LIMIT_BLOCK].qv_expiretime, now);
-		switch(QL_STATUS(ql_stat)) {
-		case QL_S_DENY_HARD:
-			msgb = "Block limit reached on";
-			break;
-		case QL_S_DENY_GRACE:
-			msgb = "Over block quota on";
-			break;
-		case QL_S_ALLOW_SOFT:
-			msgb = "In block grace period on";
-			break;
-		default:
-			msgb = NULL;
-		}
-		if (qflag) {
-			if ((msgi != NULL || msgb != NULL) &&
-			lines++ == 0)
-heading(type, id, name, "");
-			if (msgi != NULL)
-printf("\t%s %s\n", msgi, qup->fsname);
-			if (msgb != NULL)
-printf("\t%s %s\n", msgb, qup->fsname);
-			continue;
+	}
+
+	if (!vflag &&
+	q[QUOTA_LIMIT_BLOCK].qv_softlimit == UQUAD_MAX &&
+	q[QUOTA_LIMIT_BLOCK].qv_hardlimit == UQUAD_MAX &&
+	q[QUOTA_LIMIT_FILE].qv_softlimit == UQUAD_MAX &&
+	q[QUOTA_LIMIT_FILE].qv_hardlimit == UQUAD_MAX)
+		return;
+	ql_stat = quota_check_limit(q[QUOTA_LIMIT_FILE].qv_usage, 1,
+q[QUOTA_LIMIT_FILE].qv_softlimit,
+q[QUOTA_LIMIT_FILE].qv_hardlimit,
+q[QUOTA_LIMIT_FILE].qv_expiretime, now);
+	switch(QL_STATUS(ql_stat)) {
+	case QL_S_DENY_HARD:
+		msgi = "File limit reached on";
+		break;
+	case QL_S_DENY_GRACE:
+		msgi = "Over file quota on";
+		break;
+	case QL_S_ALLOW_SOFT:
+		msgi = "In file grace period on";
+		break;
+	default:
+		msgi = NULL;
+	}
+	ql_stat = quota_check_limit(q[QUOTA_LIMIT_BLOCK].qv_usage, 1,
+q[QUOTA_LIMIT_BLOCK].qv_softlimit,
+q[QUOTA_LIMIT_BLOCK].qv_hardlimit,
+q[QUOTA_LIMIT_BLOCK].qv_expiretime, now);
+	switch(QL_STATUS(ql_

CVS commit: src/usr.bin/quota

2011-11-27 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Nov 27 13:24:32 UTC 2011

Modified Files:
src/usr.bin/quota: quota.c

Log Message:
Use __dead, not attribute noreturn.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/usr.bin/quota/quota.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.bin/quota/quota.c
diff -u src/usr.bin/quota/quota.c:1.39 src/usr.bin/quota/quota.c:1.40
--- src/usr.bin/quota/quota.c:1.39	Sun Nov 27 13:23:50 2011
+++ src/usr.bin/quota/quota.c	Sun Nov 27 13:24:32 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota.c,v 1.39 2011/11/27 13:23:50 dholland Exp $	*/
+/*	$NetBSD: quota.c,v 1.40 2011/11/27 13:24:32 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)quota.c	8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: quota.c,v 1.39 2011/11/27 13:23:50 dholland Exp $");
+__RCSID("$NetBSD: quota.c,v 1.40 2011/11/27 13:24:32 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -92,7 +92,7 @@ static void	showgrpname(const char *);
 static void	showquotas(int, id_t, const char *);
 static void	showuid(uid_t);
 static void	showusrname(const char *);
-static void	usage(void) __attribute__((__noreturn__));
+static void	usage(void) __dead;
 
 static int	qflag = 0;
 static int	vflag = 0;



CVS commit: src/usr.bin/quota

2011-11-27 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Nov 27 13:23:50 UTC 2011

Modified Files:
src/usr.bin/quota: quota.c

Log Message:
The proper type for a variable that can be either a uid or gid is id_t,
not uint32_t.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/usr.bin/quota/quota.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.bin/quota/quota.c
diff -u src/usr.bin/quota/quota.c:1.38 src/usr.bin/quota/quota.c:1.39
--- src/usr.bin/quota/quota.c:1.38	Fri Nov 25 16:55:05 2011
+++ src/usr.bin/quota/quota.c	Sun Nov 27 13:23:50 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota.c,v 1.38 2011/11/25 16:55:05 dholland Exp $	*/
+/*	$NetBSD: quota.c,v 1.39 2011/11/27 13:23:50 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)quota.c	8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: quota.c,v 1.38 2011/11/25 16:55:05 dholland Exp $");
+__RCSID("$NetBSD: quota.c,v 1.39 2011/11/27 13:23:50 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -85,11 +85,11 @@ struct quotause {
 #define	FOUND	0x01
 #define	QUOTA2	0x02
 
-static struct quotause	*getprivs(uint32_t, int);
-static void	heading(int, uint32_t, const char *, const char *);
+static struct quotause	*getprivs(id_t, int);
+static void	heading(int, id_t, const char *, const char *);
 static void	showgid(gid_t);
 static void	showgrpname(const char *);
-static void	showquotas(int, uint32_t, const char *);
+static void	showquotas(int, id_t, const char *);
 static void	showuid(uid_t);
 static void	showusrname(const char *);
 static void	usage(void) __attribute__((__noreturn__));
@@ -314,7 +314,7 @@ showgrpname(const char *name)
 }
 
 static void
-showquotas(int type, uint32_t id, const char *name)
+showquotas(int type, id_t id, const char *name)
 {
 	struct quotause *qup;
 	struct quotause *quplist;
@@ -435,7 +435,7 @@ showquotas(int type, uint32_t id, const 
 }
 
 static void
-heading(int type, uint32_t id, const char *name, const char *tag)
+heading(int type, id_t id, const char *name, const char *tag)
 {
 	if (dflag)
 		printf("Default %s disk quotas: %s\n",
@@ -464,7 +464,7 @@ heading(int type, uint32_t id, const cha
  * Collect the requested quota information.
  */
 static struct quotause *
-getprivs(uint32_t id, int quotatype)
+getprivs(id_t id, int quotatype)
 {
 	struct quotause *qup, *quptail;
 	struct quotause *quphead;



CVS commit: src/usr.bin/quota

2011-03-12 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Mar 12 12:28:47 UTC 2011

Modified Files:
src/usr.bin/quota: getvfsquota.c

Log Message:
Don't include quotautil.h here, it's not used.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/quota/getvfsquota.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.bin/quota/getvfsquota.c
diff -u src/usr.bin/quota/getvfsquota.c:1.4 src/usr.bin/quota/getvfsquota.c:1.5
--- src/usr.bin/quota/getvfsquota.c:1.4	Sun Mar  6 22:36:07 2011
+++ src/usr.bin/quota/getvfsquota.c	Sat Mar 12 12:28:47 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: getvfsquota.c,v 1.4 2011/03/06 22:36:07 christos Exp $ */
+/*	$NetBSD: getvfsquota.c,v 1.5 2011/03/12 12:28:47 bouyer Exp $ */
 
 /*-
   * Copyright (c) 2011 Manuel Bouyer
@@ -29,7 +29,7 @@
   */
 
 #include 
-__RCSID("$NetBSD: getvfsquota.c,v 1.4 2011/03/06 22:36:07 christos Exp $");
+__RCSID("$NetBSD: getvfsquota.c,v 1.5 2011/03/12 12:28:47 bouyer Exp $");
 
 #include 
 #include 
@@ -43,7 +43,6 @@
 #include 
 
 #include "getvfsquota.h"
-#include "quotautil.h"
 
 /* retrieve quotas from vfs, for the given user id */
 int



CVS commit: src/usr.bin/quota

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

Modified Files:
src/usr.bin/quota: printquota.c

Log Message:
Properly evaluate the space needed to print "unlimited" in an human-readable
way.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/quota/printquota.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.bin/quota/printquota.c
diff -u src/usr.bin/quota/printquota.c:1.4 src/usr.bin/quota/printquota.c:1.5
--- src/usr.bin/quota/printquota.c:1.4	Sun Mar  6 22:36:07 2011
+++ src/usr.bin/quota/printquota.c	Mon Mar  7 11:46:55 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: printquota.c,v 1.4 2011/03/06 22:36:07 christos Exp $ */
+/*	$NetBSD: printquota.c,v 1.5 2011/03/07 11:46:55 bouyer Exp $ */
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)quota.c	8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: printquota.c,v 1.4 2011/03/06 22:36:07 christos Exp $");
+__RCSID("$NetBSD: printquota.c,v 1.5 2011/03/07 11:46:55 bouyer Exp $");
 #endif
 #endif /* not lint */
 
@@ -68,7 +68,7 @@
 intprt(char *buf, size_t len, uint64_t val, int flags, int hflag)
 {
 	if (val == UQUAD_MAX)
-		return (len >= sizeof("unlimited")) ? "unlimited" : "-";
+		return (len > sizeof("unlimited")) ? "unlimited" : "-";
 
 	if (flags & HN_B)
 		val = dbtob(val);



CVS commit: src/usr.bin/quota

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

Modified Files:
src/usr.bin/quota: quotautil.c quotautil.h

Log Message:
merge one more triplicated function


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/quota/quotautil.c \
src/usr.bin/quota/quotautil.h

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

Modified files:

Index: src/usr.bin/quota/quotautil.c
diff -u src/usr.bin/quota/quotautil.c:1.1 src/usr.bin/quota/quotautil.c:1.2
--- src/usr.bin/quota/quotautil.c:1.1	Sun Mar  6 17:36:07 2011
+++ src/usr.bin/quota/quotautil.c	Sun Mar  6 18:26:05 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: quotautil.c,v 1.1 2011/03/06 22:36:07 christos Exp $ */
+/*	$NetBSD: quotautil.c,v 1.2 2011/03/06 23:26:05 christos Exp $ */
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)quota.c	8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: quotautil.c,v 1.1 2011/03/06 22:36:07 christos Exp $");
+__RCSID("$NetBSD: quotautil.c,v 1.2 2011/03/06 23:26:05 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -117,3 +117,17 @@
 	} while ((c = *s++) != 0);
 	return 1;
 }
+
+/*
+ * Check to see if target appears in list of size cnt.
+ */
+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;
+}
Index: src/usr.bin/quota/quotautil.h
diff -u src/usr.bin/quota/quotautil.h:1.1 src/usr.bin/quota/quotautil.h:1.2
--- src/usr.bin/quota/quotautil.h:1.1	Sun Mar  6 17:36:07 2011
+++ src/usr.bin/quota/quotautil.h	Sun Mar  6 18:26:16 2011
@@ -1,7 +1,8 @@
-/*	$NetBSD: quotautil.h,v 1.1 2011/03/06 22:36:07 christos Exp $ */
+/*	$NetBSD: quotautil.h,v 1.2 2011/03/06 23:26:16 christos Exp $ */
 
 const char *qfextension[MAXQUOTAS];
 const char *qfname;
 struct fstab;
 int hasquota(char *, size_t, struct fstab *, int);
 int alldigits(const char *);
+int oneof(const char *, char *[], int);



CVS commit: src/usr.bin/quota

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

Modified Files:
src/usr.bin/quota: Makefile getvfsquota.c printquota.c printquota.h
quota.c
Added Files:
src/usr.bin/quota: quotautil.c quotautil.h

Log Message:
- merge more code.
- simplify struct access.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/quota/Makefile
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/quota/getvfsquota.c \
src/usr.bin/quota/printquota.c src/usr.bin/quota/printquota.h
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/quota/quota.c
cvs rdiff -u -r0 -r1.1 src/usr.bin/quota/quotautil.c \
src/usr.bin/quota/quotautil.h

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

Modified files:

Index: src/usr.bin/quota/Makefile
diff -u src/usr.bin/quota/Makefile:1.8 src/usr.bin/quota/Makefile:1.9
--- src/usr.bin/quota/Makefile:1.8	Sun Mar  6 15:47:59 2011
+++ src/usr.bin/quota/Makefile	Sun Mar  6 17:36:07 2011
@@ -1,10 +1,10 @@
-#	$NetBSD: Makefile,v 1.8 2011/03/06 20:47:59 christos Exp $	
+#	$NetBSD: Makefile,v 1.9 2011/03/06 22:36:07 christos Exp $	
 #	from: @(#)Makefile	8.1 (Berkeley) 6/6/93
 
 WARNS ?= 4
 .include 
 PROG=	quota
-SRCS=	quota.c printquota.c getvfsquota.c
+SRCS=	quota.c printquota.c getvfsquota.c quotautil.c
 
 CPPFLAGS+=-I${NETBSDSRCDIR}/sys -I${NETBSDSRCDIR}/usr.bin/quota
 DPADD=	${LIBRPCSVC} ${LIBPROP}

Index: src/usr.bin/quota/getvfsquota.c
diff -u src/usr.bin/quota/getvfsquota.c:1.3 src/usr.bin/quota/getvfsquota.c:1.4
--- src/usr.bin/quota/getvfsquota.c:1.3	Sun Mar  6 15:47:59 2011
+++ src/usr.bin/quota/getvfsquota.c	Sun Mar  6 17:36:07 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: getvfsquota.c,v 1.3 2011/03/06 20:47:59 christos Exp $ */
+/*	$NetBSD: getvfsquota.c,v 1.4 2011/03/06 22:36:07 christos Exp $ */
 
 /*-
   * Copyright (c) 2011 Manuel Bouyer
@@ -29,7 +29,7 @@
   */
 
 #include 
-__RCSID("$NetBSD: getvfsquota.c,v 1.3 2011/03/06 20:47:59 christos Exp $");
+__RCSID("$NetBSD: getvfsquota.c,v 1.4 2011/03/06 22:36:07 christos Exp $");
 
 #include 
 #include 
@@ -42,9 +42,8 @@
 #include 
 #include 
 
-#include 
-
-const char *qfextension[] = INITQFNAMES;
+#include "getvfsquota.h"
+#include "quotautil.h"
 
 /* retrieve quotas from vfs, for the given user id */
 int
Index: src/usr.bin/quota/printquota.c
diff -u src/usr.bin/quota/printquota.c:1.3 src/usr.bin/quota/printquota.c:1.4
--- src/usr.bin/quota/printquota.c:1.3	Sun Mar  6 15:47:59 2011
+++ src/usr.bin/quota/printquota.c	Sun Mar  6 17:36:07 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: printquota.c,v 1.3 2011/03/06 20:47:59 christos Exp $ */
+/*	$NetBSD: printquota.c,v 1.4 2011/03/06 22:36:07 christos Exp $ */
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)quota.c	8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: printquota.c,v 1.3 2011/03/06 20:47:59 christos Exp $");
+__RCSID("$NetBSD: printquota.c,v 1.4 2011/03/06 22:36:07 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -59,7 +59,7 @@
 #include 
 #include 
 
-#include 
+#include "printquota.h"
 
 /*
  * convert 64bit value to a printable string
@@ -138,13 +138,12 @@
 	return buf;
 }
 
-#if 0
 /*
  * Calculate the grace period and return a precise string for it,
  * either in seconds or in format xWyDzHtMuS
  */
 const char *
-timepprt(char *buf, size_t len, time_t seconds, int hflag, int space)
+timepprt(char *buf, size_t len, time_t seconds, int hflag)
 {
 	ssize_t i = 0;
 
@@ -158,7 +157,7 @@
 		seconds = seconds % WEEK;
 	}
 
-	if (remain < 3 || seconds == 0)
+	if (len - i < 3 || seconds == 0)
 		return buf;
 
 	if ((seconds / DAY) > 0) {
@@ -166,7 +165,7 @@
 		seconds = seconds % DAY;
 	}
 
-	if (remain < 4 || seconds == 0)
+	if (len - i < 4 || seconds == 0)
 		return buf;
 
 	if ((seconds / HOUR) > 0) {
@@ -174,7 +173,7 @@
 		seconds = seconds % HOUR;
 	}
 
-	if (remain < 4 || seconds == 0)
+	if (len - i < 4 || seconds == 0)
 		return buf;
 
 	if ((seconds / MINUTE) > 0) {
@@ -183,7 +182,7 @@
 		seconds = seconds % MINUTE;
 	}
 
-	if (remain < 4 || seconds == 0)
+	if (len - i < 4 || seconds == 0)
 		return buf;
 
 	(void)snprintf(buf + i, len - i, "%" PRId64 "S", seconds);
@@ -272,4 +271,3 @@
 		*val = btodb(*val);
 	return ret;
 }
-#endif
Index: src/usr.bin/quota/printquota.h
diff -u src/usr.bin/quota/printquota.h:1.3 src/usr.bin/quota/printquota.h:1.4
--- src/usr.bin/quota/printquota.h:1.3	Sun Mar  6 15:47:59 2011
+++ src/usr.bin/quota/printquota.h	Sun Mar  6 17:36:07 2011
@@ -1,10 +1,7 @@
-/*	$NetBSD: printquota.h,v 1.3 2011/03/06 20:47:59 christos Exp $ */
+/*	$NetBSD: printquota.h,v 1.4 2011/03/06 22:36:07 christos Exp $ */
 
 const char *intprt(char *, size_t, uint64_t, int, int);
 const char *timeprt(char *, size_t, time_t, time_t);
-#if 0
-const char *timepprt(time_t, int, int);
+const char *timepprt(char *, size_t, time_t, int);
 int timeprd(const char *, time_t *);
 int intrd(char *str, uint64_t *val, u_int);
-#endif
-

I

CVS commit: src/usr.bin/quota

2011-03-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar  6 20:47:59 UTC 2011

Modified Files:
src/usr.bin/quota: Makefile getvfsquota.c getvfsquota.h printquota.c
printquota.h quota.c

Log Message:
- WARNS=4
- KNF
- don't cast malloc
- don't use static buffers
- fix types
- remove extra \n's from errors
- fix prototypes


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/quota/Makefile
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/quota/getvfsquota.c \
src/usr.bin/quota/getvfsquota.h src/usr.bin/quota/printquota.c \
src/usr.bin/quota/printquota.h
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/quota/quota.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.bin/quota/Makefile
diff -u src/usr.bin/quota/Makefile:1.7 src/usr.bin/quota/Makefile:1.8
--- src/usr.bin/quota/Makefile:1.7	Sun Mar  6 12:08:42 2011
+++ src/usr.bin/quota/Makefile	Sun Mar  6 15:47:59 2011
@@ -1,6 +1,7 @@
-#	$NetBSD: Makefile,v 1.7 2011/03/06 17:08:42 bouyer Exp $	
+#	$NetBSD: Makefile,v 1.8 2011/03/06 20:47:59 christos Exp $	
 #	from: @(#)Makefile	8.1 (Berkeley) 6/6/93
 
+WARNS ?= 4
 .include 
 PROG=	quota
 SRCS=	quota.c printquota.c getvfsquota.c

Index: src/usr.bin/quota/getvfsquota.c
diff -u src/usr.bin/quota/getvfsquota.c:1.2 src/usr.bin/quota/getvfsquota.c:1.3
--- src/usr.bin/quota/getvfsquota.c:1.2	Sun Mar  6 12:08:42 2011
+++ src/usr.bin/quota/getvfsquota.c	Sun Mar  6 15:47:59 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: getvfsquota.c,v 1.2 2011/03/06 17:08:42 bouyer Exp $ */
+/*	$NetBSD: getvfsquota.c,v 1.3 2011/03/06 20:47:59 christos Exp $ */
 
 /*-
   * Copyright (c) 2011 Manuel Bouyer
@@ -29,7 +29,7 @@
   */
 
 #include 
-__RCSID("$NetBSD: getvfsquota.c,v 1.2 2011/03/06 17:08:42 bouyer Exp $");
+__RCSID("$NetBSD: getvfsquota.c,v 1.3 2011/03/06 20:47:59 christos Exp $");
 
 #include 
 #include 
@@ -49,13 +49,12 @@
 /* retrieve quotas from vfs, for the given user id */
 int
 getvfsquota(const char *mp, struct quota2_entry *q2e, int8_t *versp,
-long id, int type, int defaultq, int debug)
+uint32_t id, int type, int defaultq, int debug)
 {
 	prop_dictionary_t dict, data, cmd;
 	prop_array_t cmds, datas;
 	prop_object_iterator_t iter;
 	struct plistref pref;
-	int error;
 	int8_t error8;
 	bool ret;
 	int retval = 0;
@@ -95,17 +94,14 @@
 	if (quotactl(mp, &pref) != 0)
 		err(1, "quotactl");
 	
-	if ((error = prop_dictionary_recv_syscall(&pref, &dict)) != 0) {
-		errx(1, "prop_dictionary_recv_syscall: %s\n",
-		strerror(error));
-	}
+	if ((errno = prop_dictionary_recv_syscall(&pref, &dict)) != 0)
+		err(1, "prop_dictionary_recv_syscall");
 	if (debug)
 		printf("reply from kernel:\n%s\n",
 		prop_dictionary_externalize(dict));
-	if ((error = quota2_get_cmds(dict, &cmds)) != 0) {
-		errx(1, "quota2_get_cmds: %s\n",
-		strerror(error));
-	}
+	if ((errno = quota2_get_cmds(dict, &cmds)) != 0)
+		err(1, "quota2_get_cmds");
+
 	iter = prop_array_iterator(cmds);
 	if (iter == NULL)
 		err(1, "prop_array_iterator(cmds)");
@@ -120,20 +116,17 @@
 
 		if (error8) {
 			if (error8 != ENOENT && error8 != ENODEV) {
+errno = error8;
 if (defaultq) {
-	fprintf(stderr,
-	"get default %s quota: %s\n",
-	qfextension[type],
-	strerror(error8));
+	warn("get default %s quota",
+	qfextension[type]);
 } else {
-	fprintf(stderr,
-	"get %s quota for %ld: %s\n",
-	qfextension[type], id,
-	strerror(error8));
+	warn("get %s quota for %u",
+	qfextension[type], id);
 }
 			}
 			prop_object_release(dict);
-			return (0);
+			return 0;
 		}
 		datas = prop_dictionary_get(cmd, "data");
 		if (datas == NULL)
@@ -156,11 +149,9 @@
 			if (data == NULL)
 err(1, "prop_array_get(data)");
 
-			error = quota2_dict_get_q2e_usage(data, q2e);
-			if (error) {
-errx(1, "quota2_dict_get_q2e_usage: %s\n",
-strerror(error));
-			}
+			errno = quota2_dict_get_q2e_usage(data, q2e);
+			if (errno)
+err(1, "quota2_dict_get_q2e_usage");
 			retval = 1;
 		}
 	}
Index: src/usr.bin/quota/getvfsquota.h
diff -u src/usr.bin/quota/getvfsquota.h:1.2 src/usr.bin/quota/getvfsquota.h:1.3
--- src/usr.bin/quota/getvfsquota.h:1.2	Sun Mar  6 12:08:42 2011
+++ src/usr.bin/quota/getvfsquota.h	Sun Mar  6 15:47:59 2011
@@ -1,6 +1,6 @@
-/*	$NetBSD: getvfsquota.h,v 1.2 2011/03/06 17:08:42 bouyer Exp $ */
+/*	$NetBSD: getvfsquota.h,v 1.3 2011/03/06 20:47:59 christos Exp $ */
 
 int getvfsquota(const char *, struct quota2_entry *, int8_t *,
-long, int, int, int);
+uint32_t, int, int, int);
 
 extern const char *qfextension[];
Index: src/usr.bin/quota/printquota.c
diff -u src/usr.bin/quota/printquota.c:1.2 src/usr.bin/quota/printquota.c:1.3
--- src/usr.bin/quota/printquota.c:1.2	Sun Mar  6 12:08:42 2011
+++ src/usr.bin/quota/printquota.c	Sun Mar  6 15:47:59 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: printquota.c,v 1.2 2011/03/06 17:08:42 bouyer E

CVS commit: src/usr.bin/quota

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

Modified Files:
src/usr.bin/quota: quota.1

Log Message:
Sort options. Split "file system" like usual. Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/quota/quota.1

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

Modified files:

Index: src/usr.bin/quota/quota.1
diff -u src/usr.bin/quota/quota.1:1.15 src/usr.bin/quota/quota.1:1.16
--- src/usr.bin/quota/quota.1:1.15	Sun Mar  6 17:08:42 2011
+++ src/usr.bin/quota/quota.1	Sun Mar  6 17:25:32 2011
@@ -1,4 +1,4 @@
-.\"	$NetBSD: quota.1,v 1.15 2011/03/06 17:08:42 bouyer Exp $
+.\"	$NetBSD: quota.1,v 1.16 2011/03/06 17:25:32 wiz Exp $
 .\"
 .\" Copyright (c) 1983, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -32,7 +32,7 @@
 .\"
 .\"	from: @(#)quota.1	8.1 (Berkeley) 6/6/93
 .\"
-.Dd June 6, 1993
+.Dd March 6, 2011
 .Dt QUOTA 1
 .Os
 .Sh NAME
@@ -40,28 +40,19 @@
 .Nd display disk usage and limits
 .Sh SYNOPSIS
 .Nm
-.Op Fl D
-.Op Fl h
-.Op Fl g
-.Op Fl u
+.Op Fl Dghu
 .Op Fl v | Fl q
 .Nm
-.Op Fl D
-.Op Fl h
-.Op Fl u
+.Op Fl Dhu
 .Op Fl v | Fl q
 .Ar user
 .Nm
-.Op Fl D
-.Op Fl h
-.Op Fl g
+.Op Fl Dgh
 .Op Fl v | Fl q
 .Ar group
 .Nm
 .Fl d
-.Op Fl D
-.Op Fl h
-.Op Fl g
+.Op Fl Dgh
 .Op Fl v | Fl q
 .Sh DESCRIPTION
 .Nm
@@ -71,27 +62,24 @@
 Options:
 .Pp
 .Bl -tag -width Ds
-.It Fl h
-Numbers are displayed in a human readable format.
+.It Fl D
+Debug: print plist sent to and received from kernel.
+.It Fl d
+Query the kernel for default user or group quota instead of a specific
+user or group.
 .It Fl g
-Print group quotas for the group
-of which the user is a member.
+Print group quotas for the group of which the user is a member.
 The optional
 .Fl u
 flag is equivalent to the default.
+.It Fl h
+Numbers are displayed in a human readable format.
+.It Fl q
+Print a more terse message, containing only information
+on file systems where usage is over quota.
 .It Fl v
 .Nm
-will display quotas on filesystems
-where no storage is allocated.
-.It Fl q
-Print a more terse message,
-containing only information
-on filesystems where usage is over quota.
-.It Fl d
-Query the kernel for default user or group quota instead of a specific
-user or group
-.It Fl D
-Debug: print plist sent to and received from kernel.
+will display quotas on file systems where no storage is allocated.
 .El
 .Pp
 Specifying both
@@ -123,8 +111,8 @@
 flag.
 .Pp
 .Nm
-tries to report the quotas of all mounted filesystems.
-If the filesystem is mounted via
+tries to report the quotas of all mounted file systems.
+If the file system is mounted via
 .Em NFS
 it will attempt to contact the
 .Xr rpc.rquotad 8
@@ -133,7 +121,7 @@
 server.
 If
 .Nm
-exits with a non-zero status, one or more filesystems
+exits with a non-zero status, one or more file systems
 are over quota.
 .Sh SEE ALSO
 .Xr quotactl 2 ,



CVS commit: src/usr.bin/quota

2009-04-12 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Mon Apr 13 04:16:38 UTC 2009

Modified Files:
src/usr.bin/quota: quota.c

Log Message:
Fix -Wcast-qual and -Wshadow issues


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/quota/quota.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.bin/quota/quota.c
diff -u src/usr.bin/quota/quota.c:1.32 src/usr.bin/quota/quota.c:1.33
--- src/usr.bin/quota/quota.c:1.32	Mon Jul 21 14:19:25 2008
+++ src/usr.bin/quota/quota.c	Mon Apr 13 04:16:38 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota.c,v 1.32 2008/07/21 14:19:25 lukem Exp $	*/
+/*	$NetBSD: quota.c,v 1.33 2009/04/13 04:16:38 lukem Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)quota.c	8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: quota.c,v 1.32 2008/07/21 14:19:25 lukem Exp $");
+__RCSID("$NetBSD: quota.c,v 1.33 2009/04/13 04:16:38 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -75,8 +75,8 @@
 #include 
 #include 
 
-char *qfname = QUOTAFILENAME;
-char *qfextension[] = INITQFNAMES;
+const char *qfname = QUOTAFILENAME;
+const char *qfextension[] = INITQFNAMES;
 
 struct quotause {
 	struct	quotause *next;
@@ -101,7 +101,7 @@
 void	showquotas __P((int, u_long, const char *));
 void	showuid __P((uid_t));
 void	showusrname __P((const char *));
-char   *timeprt __P((time_t seconds));
+const char *timeprt __P((time_t seconds));
 int	ufshasquota __P((struct fstab *, int, char **));
 void	usage __P((void));
 
@@ -311,7 +311,7 @@
 {
 	struct quotause *qup;
 	struct quotause *quplist;
-	char *msgi, *msgb, *nam;
+	const char *msgi, *msgb, *nam;
 	int lines = 0;
 	static time_t now;
 
@@ -325,7 +325,7 @@
 		qup->dqblk.dqb_bsoftlimit == 0 &&
 		qup->dqblk.dqb_bhardlimit == 0)
 			continue;
-		msgi = (char *)0;
+		msgi = NULL;
 		if (qup->dqblk.dqb_ihardlimit &&
 		qup->dqblk.dqb_curinodes >= qup->dqblk.dqb_ihardlimit)
 			msgi = "File limit reached on";
@@ -336,7 +336,7 @@
 			else
 msgi = "Over file quota on";
 		}
-		msgb = (char *)0;
+		msgb = NULL;
 		if (qup->dqblk.dqb_bhardlimit &&
 		qup->dqblk.dqb_curblocks >= qup->dqblk.dqb_bhardlimit)
 			msgb = "Block limit reached on";
@@ -351,12 +351,12 @@
 			}
 		}
 		if (qflag) {
-			if ((msgi != (char *)0 || msgb != (char *)0) &&
+			if ((msgi != NULL || msgb != NULL) &&
 			lines++ == 0)
 heading(type, id, name, "");
-			if (msgi != (char *)0)
+			if (msgi != NULL)
 printf("\t%s %s\n", msgi, qup->fsname);
-			if (msgb != (char *)0)
+			if (msgb != NULL)
 printf("\t%s %s\n", msgb, qup->fsname);
 			continue;
 		}
@@ -374,19 +374,19 @@
 			, nam
 			, (int)(dbtob((u_quad_t)qup->dqblk.dqb_curblocks)
 / 1024)
-			, (msgb == (char *)0) ? ' ' : '*'
+			, (msgb == NULL) ? ' ' : '*'
 			, (int)(dbtob((u_quad_t)qup->dqblk.dqb_bsoftlimit)
 / 1024)
 			, (int)(dbtob((u_quad_t)qup->dqblk.dqb_bhardlimit)
 / 1024)
-			, (msgb == (char *)0) ? ""
+			, (msgb == NULL) ? ""
 			: timeprt(qup->dqblk.dqb_btime));
 			printf("%8d%c%7d%8d%8s\n"
 			, qup->dqblk.dqb_curinodes
-			, (msgi == (char *)0) ? ' ' : '*'
+			, (msgi == NULL) ? ' ' : '*'
 			, qup->dqblk.dqb_isoftlimit
 			, qup->dqblk.dqb_ihardlimit
-			, (msgi == (char *)0) ? ""
+			, (msgi == NULL) ? ""
 			: timeprt(qup->dqblk.dqb_itime)
 			);
 			continue;
@@ -423,7 +423,7 @@
 /*
  * Calculate the grace period and return a printable string for it.
  */
-char *
+const char *
 timeprt(seconds)
 	time_t seconds;
 {
@@ -710,7 +710,7 @@
 	struct timeval timeout, tottimeout;
  
 	CLIENT *client = NULL;
-	int socket = RPC_ANYSOCK;
+	int sock = RPC_ANYSOCK;
  
 	if ((hp = gethostbyname(host)) == NULL)
 		return ((int) RPC_UNKNOWNHOST);
@@ -721,7 +721,7 @@
 	server_addr.sin_port =  0;
 
 	if ((client = clntudp_create(&server_addr, prognum,
-	versnum, timeout, &socket)) == NULL)
+	versnum, timeout, &sock)) == NULL)
 		return ((int) rpc_createerr.cf_stat);
 
 	client->cl_auth = authunix_create_default();