CVS commit: src/lib/libquota

2022-04-26 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Apr 26 15:36:42 UTC 2022

Modified Files:
src/lib/libquota: quota_oldfiles.c

Log Message:
Fix default quota file names, both user and group quota used the
same default name "QUOTAFILENAME, names[USRQUOTA])" resulting in
diagnostic assertion and possibly corrupted quota data.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libquota/quota_oldfiles.c

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

Modified files:

Index: src/lib/libquota/quota_oldfiles.c
diff -u src/lib/libquota/quota_oldfiles.c:1.9 src/lib/libquota/quota_oldfiles.c:1.10
--- src/lib/libquota/quota_oldfiles.c:1.9	Fri Feb 24 18:00:09 2012
+++ src/lib/libquota/quota_oldfiles.c	Tue Apr 26 15:36:42 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_oldfiles.c,v 1.9 2012/02/24 18:00:09 njoly Exp $	*/
+/*	$NetBSD: quota_oldfiles.c,v 1.10 2022/04/26 15:36:42 hannken Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -33,7 +33,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: quota_oldfiles.c,v 1.9 2012/02/24 18:00:09 njoly Exp $");
+__RCSID("$NetBSD: quota_oldfiles.c,v 1.10 2022/04/26 15:36:42 hannken Exp $");
 
 #include 
 #include 
@@ -255,7 +255,7 @@ __quota_oldfiles_defquotafile(struct quo
 
 	(void)snprintf(buf, maxlen, "%s/%s.%s",
 		   qh->qh_mountpoint,
-		   QUOTAFILENAME, names[USRQUOTA]);
+		   QUOTAFILENAME, names[idtype]);
 }
 
 const char *



CVS commit: src/lib/libquota

2022-04-26 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Apr 26 15:36:42 UTC 2022

Modified Files:
src/lib/libquota: quota_oldfiles.c

Log Message:
Fix default quota file names, both user and group quota used the
same default name "QUOTAFILENAME, names[USRQUOTA])" resulting in
diagnostic assertion and possibly corrupted quota data.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libquota/quota_oldfiles.c

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



CVS commit: src/lib/libquota

2016-01-30 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Jan 30 16:31:28 UTC 2016

Modified Files:
src/lib/libquota: quota_nfs.c

Log Message:
Some NFS servers return RPC_PROGNOTREGISTERED instead of RPC_PROGVERSMISMATCH
when they don't support EXT_RQUOTAVERS but support RQUOTAVERS, so
retry with RQUOTAVERS for both RPC_PROGNOTREGISTERED and RPC_PROGVERSMISMATCH
return code.
Fix issue against a NetApp server reported by 6bone on current-users


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libquota/quota_nfs.c

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

Modified files:

Index: src/lib/libquota/quota_nfs.c
diff -u src/lib/libquota/quota_nfs.c:1.4 src/lib/libquota/quota_nfs.c:1.5
--- src/lib/libquota/quota_nfs.c:1.4	Wed Jun 11 08:43:01 2014
+++ src/lib/libquota/quota_nfs.c	Sat Jan 30 16:31:28 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_nfs.c,v 1.4 2014/06/11 08:43:01 martin Exp $	*/
+/*	$NetBSD: quota_nfs.c,v 1.5 2016/01/30 16:31:28 bouyer Exp $	*/
 /*-
   * Copyright (c) 2011 Manuel Bouyer
   * All rights reserved.
@@ -26,7 +26,7 @@
   */
 
 #include 
-__RCSID("$NetBSD: quota_nfs.c,v 1.4 2014/06/11 08:43:01 martin Exp $");
+__RCSID("$NetBSD: quota_nfs.c,v 1.5 2016/01/30 16:31:28 bouyer Exp $");
 
 #include 
 #include  /* XXX for DEV_BSIZE */
@@ -179,7 +179,8 @@ __quota_nfs_get(struct quotahandle *qh, 
 	ret = callaurpc(host, RQUOTAPROG, EXT_RQUOTAVERS,
 	RQUOTAPROC_GETQUOTA, (xdrproc_t)xdr_ext_getquota_args,
 	_gq_args, (xdrproc_t)xdr_getquota_rslt, _rslt);
-	if (ret == RPC_PROGVERSMISMATCH && rpcqtype == RQUOTA_USRQUOTA) {
+	if ((ret == RPC_PROGVERSMISMATCH || ret == RPC_PROGNOTREGISTERED)
+	&& rpcqtype == RQUOTA_USRQUOTA) {
 		/* try RQUOTAVERS */
 		gq_args.gqa_pathp = path;
 		gq_args.gqa_uid = qk->qk_id;



CVS commit: src/lib/libquota

2016-01-30 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Jan 30 16:31:28 UTC 2016

Modified Files:
src/lib/libquota: quota_nfs.c

Log Message:
Some NFS servers return RPC_PROGNOTREGISTERED instead of RPC_PROGVERSMISMATCH
when they don't support EXT_RQUOTAVERS but support RQUOTAVERS, so
retry with RQUOTAVERS for both RPC_PROGNOTREGISTERED and RPC_PROGVERSMISMATCH
return code.
Fix issue against a NetApp server reported by 6bone on current-users


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libquota/quota_nfs.c

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



CVS commit: src/lib/libquota

2014-06-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jun 11 08:43:01 UTC 2014

Modified Files:
src/lib/libquota: quota_nfs.c

Log Message:
Some more errno remapping: if the NFS server is unreachable because we have
no route to it, assume there are no quotas. While this might sound like
an impossible scenario, it actually happens inside rump tests when we have
a virtual shmif network but are querying quotas for / which happens to
be on NFS (but of course outside of the shmif setup).
This fixes tests/fs/nfs/t_rquotad on diskless clients.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libquota/quota_nfs.c

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

Modified files:

Index: src/lib/libquota/quota_nfs.c
diff -u src/lib/libquota/quota_nfs.c:1.3 src/lib/libquota/quota_nfs.c:1.4
--- src/lib/libquota/quota_nfs.c:1.3	Thu Jun  5 13:14:23 2014
+++ src/lib/libquota/quota_nfs.c	Wed Jun 11 08:43:01 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_nfs.c,v 1.3 2014/06/05 13:14:23 martin Exp $	*/
+/*	$NetBSD: quota_nfs.c,v 1.4 2014/06/11 08:43:01 martin Exp $	*/
 /*-
   * Copyright (c) 2011 Manuel Bouyer
   * All rights reserved.
@@ -26,7 +26,7 @@
   */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: quota_nfs.c,v 1.3 2014/06/05 13:14:23 martin Exp $);
+__RCSID($NetBSD: quota_nfs.c,v 1.4 2014/06/11 08:43:01 martin Exp $);
 
 #include sys/types.h
 #include sys/param.h /* XXX for DEV_BSIZE */
@@ -191,9 +191,21 @@ __quota_nfs_get(struct quotahandle *qh, 
 	free(host);
 
 	if (ret != RPC_SUCCESS) {
-		/* if the file server does not support any quotas at all,
-		   return ENOENT */
-		errno = sverrno == ENOTCONN ? ENOENT : sverrno;
+		/*
+		 * Remap some error codes for callers convenience:
+		 *  - if the file server does not support any quotas at all,
+		 *return ENOENT
+		 *  - if the server can not be reached something is very
+		 *wrong - or we are run inside a virtual rump network
+		 *but querying an NFS mount from the host. Make sure
+		 *to fail silently and return ENOENT as well.
+		 */
+		if (ret == RPC_SYSTEMERROR
+		 rpc_createerr.cf_error.re_errno == EHOSTUNREACH)
+			sverrno = ENOENT;
+		else if (sverrno == ENOTCONN)
+			sverrno = ENOENT;
+		errno = sverrno;
 		return -1;
 	}
 



CVS commit: src/lib/libquota

2014-06-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jun 11 08:43:01 UTC 2014

Modified Files:
src/lib/libquota: quota_nfs.c

Log Message:
Some more errno remapping: if the NFS server is unreachable because we have
no route to it, assume there are no quotas. While this might sound like
an impossible scenario, it actually happens inside rump tests when we have
a virtual shmif network but are querying quotas for / which happens to
be on NFS (but of course outside of the shmif setup).
This fixes tests/fs/nfs/t_rquotad on diskless clients.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libquota/quota_nfs.c

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



CVS commit: src/lib/libquota

2014-06-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jun  5 13:14:23 UTC 2014

Modified Files:
src/lib/libquota: quota_nfs.c

Log Message:
If a rpc for quota values fails with ENOTCONN translate this to ENOENT - we
certainly don't have any quotas if they are disabled on the file server.
This silences warnings from things like quota -u -v when NFS mounts
are present and no quotas are in use on the file server.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libquota/quota_nfs.c

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

Modified files:

Index: src/lib/libquota/quota_nfs.c
diff -u src/lib/libquota/quota_nfs.c:1.2 src/lib/libquota/quota_nfs.c:1.3
--- src/lib/libquota/quota_nfs.c:1.2	Mon Jan 30 06:39:26 2012
+++ src/lib/libquota/quota_nfs.c	Thu Jun  5 13:14:23 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_nfs.c,v 1.2 2012/01/30 06:39:26 dholland Exp $	*/
+/*	$NetBSD: quota_nfs.c,v 1.3 2014/06/05 13:14:23 martin Exp $	*/
 /*-
   * Copyright (c) 2011 Manuel Bouyer
   * All rights reserved.
@@ -26,7 +26,7 @@
   */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: quota_nfs.c,v 1.2 2012/01/30 06:39:26 dholland Exp $);
+__RCSID($NetBSD: quota_nfs.c,v 1.3 2014/06/05 13:14:23 martin Exp $);
 
 #include sys/types.h
 #include sys/param.h /* XXX for DEV_BSIZE */
@@ -191,7 +191,9 @@ __quota_nfs_get(struct quotahandle *qh, 
 	free(host);
 
 	if (ret != RPC_SUCCESS) {
-		errno = sverrno;
+		/* if the file server does not support any quotas at all,
+		   return ENOENT */
+		errno = sverrno == ENOTCONN ? ENOENT : sverrno;
 		return -1;
 	}
 



CVS commit: src/lib/libquota

2014-06-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jun  5 13:14:23 UTC 2014

Modified Files:
src/lib/libquota: quota_nfs.c

Log Message:
If a rpc for quota values fails with ENOTCONN translate this to ENOENT - we
certainly don't have any quotas if they are disabled on the file server.
This silences warnings from things like quota -u -v when NFS mounts
are present and no quotas are in use on the file server.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libquota/quota_nfs.c

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



CVS commit: src/lib/libquota

2012-02-24 Thread Nicolas Joly
Module Name:src
Committed By:   njoly
Date:   Fri Feb 24 18:00:09 UTC 2012

Modified Files:
src/lib/libquota: quota_oldfiles.c

Log Message:
Check if fstab file exists before trying to parse it, to avoid
warnings from {get,set}fsent() functions if missing.

dholland ok.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/libquota/quota_oldfiles.c

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

Modified files:

Index: src/lib/libquota/quota_oldfiles.c
diff -u src/lib/libquota/quota_oldfiles.c:1.8 src/lib/libquota/quota_oldfiles.c:1.9
--- src/lib/libquota/quota_oldfiles.c:1.8	Wed Feb  1 06:12:37 2012
+++ src/lib/libquota/quota_oldfiles.c	Fri Feb 24 18:00:09 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_oldfiles.c,v 1.8 2012/02/01 06:12:37 dholland Exp $	*/
+/*	$NetBSD: quota_oldfiles.c,v 1.9 2012/02/24 18:00:09 njoly Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -33,7 +33,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: quota_oldfiles.c,v 1.8 2012/02/01 06:12:37 dholland Exp $);
+__RCSID($NetBSD: quota_oldfiles.c,v 1.9 2012/02/24 18:00:09 njoly Exp $);
 
 #include sys/types.h
 #include sys/stat.h
@@ -205,6 +205,13 @@ __quota_oldfiles_load_fstab(void)
 	}
 
 	/*
+	 * Check if fstab file exists before trying to parse it.
+	 * Avoid warnings from {get,set}fsent() if missing.
+	 */
+	if (access(_PATH_FSTAB, F_OK) == -1  errno == ENOENT)
+		return;
+
+	/*
 	 * XXX: should be able to handle ext2fs quota1 files too
 	 *
 	 * XXX: should use getfsent_r(), but there isn't one.



CVS commit: src/lib/libquota

2012-02-24 Thread Nicolas Joly
Module Name:src
Committed By:   njoly
Date:   Fri Feb 24 18:00:09 UTC 2012

Modified Files:
src/lib/libquota: quota_oldfiles.c

Log Message:
Check if fstab file exists before trying to parse it, to avoid
warnings from {get,set}fsent() functions if missing.

dholland ok.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/libquota/quota_oldfiles.c

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



CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: libquota.3

Log Message:
Bump date for previous.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libquota/libquota.3

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



CVS commit: src/lib/libquota

2012-02-01 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Wed Feb  1 17:53:23 UTC 2012

Modified Files:
src/lib/libquota: shlib_version

Log Message:
Bump libquota.so major version (to 1)


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libquota/shlib_version

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

Modified files:

Index: src/lib/libquota/shlib_version
diff -u src/lib/libquota/shlib_version:1.3 src/lib/libquota/shlib_version:1.4
--- src/lib/libquota/shlib_version:1.3	Mon Jan 30 16:52:15 2012
+++ src/lib/libquota/shlib_version	Wed Feb  1 17:53:23 2012
@@ -1,5 +1,5 @@
-#	$NetBSD: shlib_version,v 1.3 2012/01/30 16:52:15 dholland Exp $
+#	$NetBSD: shlib_version,v 1.4 2012/02/01 17:53:23 dholland Exp $
 #	Remember to update distrib/sets/lists/{base,comp} when changing
 #
-major=0
-minor=2
+major=1
+minor=0



CVS commit: src/lib/libquota

2012-02-01 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Wed Feb  1 17:53:23 UTC 2012

Modified Files:
src/lib/libquota: shlib_version

Log Message:
Bump libquota.so major version (to 1)


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libquota/shlib_version

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



CVS commit: src/lib/libquota

2012-01-31 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Wed Feb  1 06:12:37 UTC 2012

Modified Files:
src/lib/libquota: quota_oldfiles.c

Log Message:
Add missing RCSID().


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libquota/quota_oldfiles.c

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

Modified files:

Index: src/lib/libquota/quota_oldfiles.c
diff -u src/lib/libquota/quota_oldfiles.c:1.7 src/lib/libquota/quota_oldfiles.c:1.8
--- src/lib/libquota/quota_oldfiles.c:1.7	Wed Feb  1 05:46:46 2012
+++ src/lib/libquota/quota_oldfiles.c	Wed Feb  1 06:12:37 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_oldfiles.c,v 1.7 2012/02/01 05:46:46 dholland Exp $	*/
+/*	$NetBSD: quota_oldfiles.c,v 1.8 2012/02/01 06:12:37 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -32,6 +32,9 @@
  * SUCH DAMAGE.
  */
 
+#include sys/cdefs.h
+__RCSID($NetBSD: quota_oldfiles.c,v 1.8 2012/02/01 06:12:37 dholland Exp $);
+
 #include sys/types.h
 #include sys/stat.h
 #include stdio.h



CVS commit: src/lib/libquota

2012-01-31 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Wed Feb  1 06:19:05 UTC 2012

Modified Files:
src/lib/libquota: quota_kernel.c

Log Message:
Fix stupid bug in cursor_getn - it's supposed to return the number of
values retrieved, but it was returning 0 on success. Fortunately nothing
was using it yet.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libquota/quota_kernel.c

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

Modified files:

Index: src/lib/libquota/quota_kernel.c
diff -u src/lib/libquota/quota_kernel.c:1.3 src/lib/libquota/quota_kernel.c:1.4
--- src/lib/libquota/quota_kernel.c:1.3	Wed Feb  1 05:46:46 2012
+++ src/lib/libquota/quota_kernel.c	Wed Feb  1 06:19:05 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_kernel.c,v 1.3 2012/02/01 05:46:46 dholland Exp $	*/
+/*	$NetBSD: quota_kernel.c,v 1.4 2012/02/01 06:19:05 dholland Exp $	*/
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: quota_kernel.c,v 1.3 2012/02/01 05:46:46 dholland Exp $);
+__RCSID($NetBSD: quota_kernel.c,v 1.4 2012/02/01 06:19:05 dholland Exp $);
 
 #include stdlib.h
 #include err.h
@@ -299,13 +299,22 @@ __quota_kernel_cursor_getn(struct quotah
 	struct quotactl_args args;
 	unsigned ret;
 
+	if (maxnum  INT_MAX) {
+		/* joker, eh? */
+		errno = EINVAL;
+		return -1;
+	}
+
 	args.qc_op = QUOTACTL_CURSORGET;
 	args.u.cursorget.qc_cursor = cursor-kcursor;
 	args.u.cursorget.qc_keys = keys;
 	args.u.cursorget.qc_vals = vals;
 	args.u.cursorget.qc_maxnum = maxnum;
 	args.u.cursorget.qc_ret = ret;
-	return __quotactl(qh-qh_mountpoint, args);
+	if (__quotactl(qh-qh_mountpoint, args)  0) {
+		return -1;
+	}
+	return ret;
 }
 
 int



CVS commit: src/lib/libquota

2012-01-31 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Wed Feb  1 06:12:37 UTC 2012

Modified Files:
src/lib/libquota: quota_oldfiles.c

Log Message:
Add missing RCSID().


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libquota/quota_oldfiles.c

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



CVS commit: src/lib/libquota

2012-01-31 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Wed Feb  1 06:19:05 UTC 2012

Modified Files:
src/lib/libquota: quota_kernel.c

Log Message:
Fix stupid bug in cursor_getn - it's supposed to return the number of
values retrieved, but it was returning 0 on success. Fortunately nothing
was using it yet.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libquota/quota_kernel.c

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



CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: shlib_version

Log Message:
Bump libquota minor version (version is now 0.2) because I added some stuff.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libquota/shlib_version

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

Modified files:

Index: src/lib/libquota/shlib_version
diff -u src/lib/libquota/shlib_version:1.2 src/lib/libquota/shlib_version:1.3
--- src/lib/libquota/shlib_version:1.2	Mon Jan  9 15:24:38 2012
+++ src/lib/libquota/shlib_version	Mon Jan 30 16:52:15 2012
@@ -1,5 +1,5 @@
-#	$NetBSD: shlib_version,v 1.2 2012/01/09 15:24:38 dholland Exp $
+#	$NetBSD: shlib_version,v 1.3 2012/01/30 16:52:15 dholland Exp $
 #	Remember to update distrib/sets/lists/{base,comp} when changing
 #
 major=0
-minor=1
+minor=2



CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: getufsquota.c

Log Message:
This will need its own compat copy of some of the strings from
quotaprop.h even after the latter goes away.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libquota/getufsquota.c

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

Modified files:

Index: src/lib/libquota/getufsquota.c
diff -u src/lib/libquota/getufsquota.c:1.6 src/lib/libquota/getufsquota.c:1.7
--- src/lib/libquota/getufsquota.c:1.6	Mon Jan  9 15:31:11 2012
+++ src/lib/libquota/getufsquota.c	Mon Jan 30 19:19:55 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: getufsquota.c,v 1.6 2012/01/09 15:31:11 dholland Exp $ */
+/*	$NetBSD: getufsquota.c,v 1.7 2012/01/30 19:19:55 dholland Exp $ */
 
 /*-
   * Copyright (c) 2011 Manuel Bouyer
@@ -27,17 +27,20 @@
   */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: getufsquota.c,v 1.6 2012/01/09 15:31:11 dholland Exp $);
+__RCSID($NetBSD: getufsquota.c,v 1.7 2012/01/30 19:19:55 dholland Exp $);
 
 #include string.h
 #include errno.h
 
 #include quota/quota.h
-#include quota/quotaprop.h	/* for QUOTADICT_CLASS_* strings */
 #include quota.h
 
 #include quotapvt.h
 
+/* Some strings passed to getufsquota() and friends */
+#define QUOTADICT_CLASS_USER user
+#define QUOTADICT_CLASS_GROUP group
+
 /*
  * Return true if QV contains any actual information.
  *



CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: shlib_version

Log Message:
Bump libquota minor version (version is now 0.2) because I added some stuff.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libquota/shlib_version

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



CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: getufsquota.c

Log Message:
This will need its own compat copy of some of the strings from
quotaprop.h even after the latter goes away.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libquota/getufsquota.c

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



CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: quota_oldfiles.c

Log Message:
Fix silly bug reading fstab.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libquota/quota_oldfiles.c

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

Modified files:

Index: src/lib/libquota/quota_oldfiles.c
diff -u src/lib/libquota/quota_oldfiles.c:1.3 src/lib/libquota/quota_oldfiles.c:1.4
--- src/lib/libquota/quota_oldfiles.c:1.3	Wed Jan 25 17:43:37 2012
+++ src/lib/libquota/quota_oldfiles.c	Mon Jan 30 06:15:22 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_oldfiles.c,v 1.3 2012/01/25 17:43:37 dholland Exp $	*/
+/*	$NetBSD: quota_oldfiles.c,v 1.4 2012/01/30 06:15:22 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -119,7 +119,7 @@ static int
 __quota_oldfiles_fill_fstabentry(const struct fstab *fs,
  struct oldfiles_fstabentry *ofe)
 {
-	char buf[sizeof(fs-fs_mntops)];
+	char buf[256];
 	char *opt, *state, *s;
 	int serrno;
 	int ret = 0;



CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: quota_nfs.c

Log Message:
Remove redundant break statement.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libquota/quota_nfs.c

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

Modified files:

Index: src/lib/libquota/quota_nfs.c
diff -u src/lib/libquota/quota_nfs.c:1.1 src/lib/libquota/quota_nfs.c:1.2
--- src/lib/libquota/quota_nfs.c:1.1	Mon Jan  9 15:29:56 2012
+++ src/lib/libquota/quota_nfs.c	Mon Jan 30 06:39:26 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_nfs.c,v 1.1 2012/01/09 15:29:56 dholland Exp $	*/
+/*	$NetBSD: quota_nfs.c,v 1.2 2012/01/30 06:39:26 dholland Exp $	*/
 /*-
   * Copyright (c) 2011 Manuel Bouyer
   * All rights reserved.
@@ -26,7 +26,7 @@
   */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: quota_nfs.c,v 1.1 2012/01/09 15:29:56 dholland Exp $);
+__RCSID($NetBSD: quota_nfs.c,v 1.2 2012/01/30 06:39:26 dholland Exp $);
 
 #include sys/types.h
 #include sys/param.h /* XXX for DEV_BSIZE */
@@ -199,7 +199,6 @@ __quota_nfs_get(struct quotahandle *qh, 
 	case Q_NOQUOTA:
 		quotaval_clear(qv);
 		return 0;
-		break;
 	case Q_EPERM:
 		errno = EACCES;
 		return -1;



CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: quota_oldfiles.c

Log Message:
Fix silly bug reading fstab.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libquota/quota_oldfiles.c

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



CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: quota_nfs.c

Log Message:
Remove redundant break statement.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libquota/quota_nfs.c

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



CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: quota_cursor.c quota_delete.c quota_get.c
quota_oldfiles.c quota_open.c quota_put.c quota_schema.c quotapvt.h

Log Message:
Improve how quota_open() works and generally improve function
dispatching. Allow access to the quota files via the oldfiles code if
quotaon hasn't run yet. Change the latter so it calls getfsent() up
front (and only once) to make it easier to avoid whacking caller
state.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libquota/quota_cursor.c \
src/lib/libquota/quota_get.c src/lib/libquota/quota_schema.c
cvs rdiff -u -r1.2 -r1.3 src/lib/libquota/quota_delete.c \
src/lib/libquota/quota_oldfiles.c src/lib/libquota/quota_put.c
cvs rdiff -u -r1.4 -r1.5 src/lib/libquota/quota_open.c
cvs rdiff -u -r1.9 -r1.10 src/lib/libquota/quotapvt.h

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

Modified files:

Index: src/lib/libquota/quota_cursor.c
diff -u src/lib/libquota/quota_cursor.c:1.3 src/lib/libquota/quota_cursor.c:1.4
--- src/lib/libquota/quota_cursor.c:1.3	Mon Jan  9 15:41:58 2012
+++ src/lib/libquota/quota_cursor.c	Wed Jan 25 17:43:37 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_cursor.c,v 1.3 2012/01/09 15:41:58 dholland Exp $	*/
+/*	$NetBSD: quota_cursor.c,v 1.4 2012/01/25 17:43:37 dholland Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: quota_cursor.c,v 1.3 2012/01/09 15:41:58 dholland Exp $);
+__RCSID($NetBSD: quota_cursor.c,v 1.4 2012/01/25 17:43:37 dholland Exp $);
 
 #include stdlib.h
 #include errno.h
@@ -44,20 +44,31 @@ quota_opencursor(struct quotahandle *qh)
 	int8_t version;
 	int serrno;
 
-	if (qh-qh_isnfs) {
+	switch (qh-qh_mode) {
+	case QUOTA_MODE_NFS:
 		errno = EOPNOTSUPP;
 		return NULL;
-	}
 
-	if (__quota_proplib_getversion(qh, version)) {
-		return NULL;
+	case QUOTA_MODE_PROPLIB:
+		if (__quota_proplib_getversion(qh, version)) {
+			return NULL;
+		}
+		break;
+
+	case QUOTA_MODE_OLDFILES:
+		version = 1;
+		break;
+
+	default:
+		errno = EINVAL;
+		break;
 	}
 
 	/*
 	 * For the time being at least the version 1 kernel code
 	 * cannot do cursors.
 	 */
-	if (version == 1  !qh-qh_hasoldfiles) {
+	if (version == 1  !qh-qh_oldfilesopen) {
 		if (__quota_oldfiles_initialize(qh)) {
 			return NULL;
 		}
Index: src/lib/libquota/quota_get.c
diff -u src/lib/libquota/quota_get.c:1.3 src/lib/libquota/quota_get.c:1.4
--- src/lib/libquota/quota_get.c:1.3	Mon Jan  9 15:29:55 2012
+++ src/lib/libquota/quota_get.c	Wed Jan 25 17:43:37 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_get.c,v 1.3 2012/01/09 15:29:55 dholland Exp $	*/
+/*	$NetBSD: quota_get.c,v 1.4 2012/01/25 17:43:37 dholland Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,9 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: quota_get.c,v 1.3 2012/01/09 15:29:55 dholland Exp $);
+__RCSID($NetBSD: quota_get.c,v 1.4 2012/01/25 17:43:37 dholland Exp $);
+
+#include errno.h
 
 #include quota.h
 #include quotapvt.h
@@ -47,9 +49,19 @@ quotaval_clear(struct quotaval *qv)
 int
 quota_get(struct quotahandle *qh, const struct quotakey *qk, struct quotaval *qv)
 {
-	if (qh-qh_isnfs) {
+	switch (qh-qh_mode) {
+	case QUOTA_MODE_NFS:
 		return __quota_nfs_get(qh, qk, qv);
-	} else {
+
+	case QUOTA_MODE_PROPLIB:
 		return __quota_proplib_get(qh, qk, qv);
+
+	case QUOTA_MODE_OLDFILES:
+		return __quota_oldfiles_get(qh, qk, qv);
+
+	default:
+		break;
 	}
+	errno = EINVAL;
+	return -1;
 }
Index: src/lib/libquota/quota_schema.c
diff -u src/lib/libquota/quota_schema.c:1.3 src/lib/libquota/quota_schema.c:1.4
--- src/lib/libquota/quota_schema.c:1.3	Wed Jan 25 01:22:57 2012
+++ src/lib/libquota/quota_schema.c	Wed Jan 25 17:43:37 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_schema.c,v 1.3 2012/01/25 01:22:57 dholland Exp $	*/
+/*	$NetBSD: quota_schema.c,v 1.4 2012/01/25 17:43:37 dholland Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: quota_schema.c,v 1.3 2012/01/25 01:22:57 dholland Exp $);
+__RCSID($NetBSD: quota_schema.c,v 1.4 2012/01/25 17:43:37 dholland Exp $);
 
 #include sys/types.h
 #include sys/statvfs.h
@@ -47,45 +47,132 @@ __RCSID($NetBSD: quota_schema.c,v 1.3 2
 const char *
 quota_getimplname(struct quotahandle *qh)
 {
-	if (qh-qh_isnfs) {
+	switch (qh-qh_mode) {
+	case QUOTA_MODE_NFS:
 		/* XXX this should maybe report the rquotad protocol version */
 		return nfs via rquotad;
-	} else {
+
+	case QUOTA_MODE_PROPLIB:
+		return __quota_proplib_getimplname(qh);
+
+	case QUOTA_MODE_OLDFILES:
 		return __quota_proplib_getimplname(qh);
+
+	default:
+		break;
 	}
+	errno = EINVAL;
+	return NULL;
 }
 
 /* 

CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: Makefile

Log Message:
Add a preliminary man page for libquota.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/libquota/Makefile

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

Modified files:

Index: src/lib/libquota/Makefile
diff -u src/lib/libquota/Makefile:1.5 src/lib/libquota/Makefile:1.6
--- src/lib/libquota/Makefile:1.5	Mon Jan  9 15:41:58 2012
+++ src/lib/libquota/Makefile	Wed Jan 25 17:45:13 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.5 2012/01/09 15:41:58 dholland Exp $
+#	$NetBSD: Makefile,v 1.6 2012/01/25 17:45:13 dholland Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/4/93
 
 .include bsd.own.mk
@@ -12,7 +12,6 @@ LIBDPLIBS+= prop  ${.CURDIR}/../libp
 LIBDPLIBS+= rpcsvc  ${.CURDIR}/../librpcsvc
 
 SRCS+=	getfsquota.c getnfsquota.c getufsquota.c
-MAN=
 
 SRCS+=	quota_open.c
 SRCS+=	quota_schema.c
@@ -22,4 +21,27 @@ SRCS+=	quota_proplib.c
 SRCS+=	quota_nfs.c
 SRCS+=	quota_oldfiles.c
 
+MAN=	libquota.3
+MLINKS=	libquota.3 quota_close.3 \
+	libquota.3 quota_delete.3 \
+	libquota.3 quota_get.3 \
+	libquota.3 quota_getimplname.3 \
+	libquota.3 quota_getmountdevice.3 \
+	libquota.3 quota_getmountpoint.3 \
+	libquota.3 quota_getnumidtypes.3 \
+	libquota.3 quota_getnumobjtypes.3 \
+	libquota.3 quota_idtype_getname.3 \
+	libquota.3 quota_objtype_getname.3 \
+	libquota.3 quota_objtype_isbytes.3 \
+	libquota.3 quota_open.3 \
+	libquota.3 quota_opencursor.3 \
+	libquota.3 quota_put.3 \
+	libquota.3 quotacursor_atend.3 \
+	libquota.3 quotacursor_close.3 \
+	libquota.3 quotacursor_get.3 \
+	libquota.3 quotacursor_getn.3 \
+	libquota.3 quotacursor_rewind.3 \
+	libquota.3 quotacursor_skipidtype.3 \
+	libquota.3 quotaval_clear.3
+
 .include bsd.lib.mk



CVS commit: src/lib/libquota

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

Added Files:
src/lib/libquota: libquota.3

Log Message:
duh, forgot to cvs add


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/lib/libquota/libquota.3

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

Added files:

Index: src/lib/libquota/libquota.3
diff -u /dev/null src/lib/libquota/libquota.3:1.1
--- /dev/null	Wed Jan 25 21:11:45 2012
+++ src/lib/libquota/libquota.3	Wed Jan 25 21:11:45 2012
@@ -0,0 +1,405 @@
+.\	$NetBSD: libquota.3,v 1.1 2012/01/25 21:11:45 dholland Exp $
+.\
+.\ Copyright (c) 2012 The NetBSD Foundation, Inc.
+.\ All rights reserved.
+.\
+.\ This code is derived from software contributed to The NetBSD Foundation
+.\ by David A. Holland.
+.\
+.\ Redistribution and use in source and binary forms, with or without
+.\ modification, are permitted provided that the following conditions
+.\ are met:
+.\ 1. Redistributions of source code must retain the above copyright
+.\notice, this list of conditions and the following disclaimer.
+.\ 2. Redistributions in binary form must reproduce the above copyright
+.\notice, this list of conditions and the following disclaimer in the
+.\documentation and/or other materials provided with the distribution.
+.\
+.\ THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\ PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\ POSSIBILITY OF SUCH DAMAGE.
+.Dd January 24, 2012
+.Dt LIBQUOTA 3
+.Os
+.Sh NAME
+.Nm libquota ,
+.Nm quota_open ,
+.Nm quota_close ,
+.Nm quota_getmountdevice ,
+.Nm quota_getmountpoint ,
+.Nm quota_getimplname ,
+.Nm quota_getnumidtypes ,
+.Nm quota_getnumobjtypes ,
+.Nm quota_idtype_getname ,
+.Nm quota_objtype_getname ,
+.Nm quota_objtype_isbytes ,
+.Nm quota_get ,
+.Nm quota_put ,
+.Nm quota_delete ,
+.Nm quota_opencursor ,
+.Nm quotacursor_close ,
+.Nm quotacursor_skipidtype ,
+.Nm quotacursor_get ,
+.Nm quotacursor_getn ,
+.Nm quotacursor_atend ,
+.Nm quotacursor_rewind ,
+.Nm quotaval_clear
+.Nd disk quota access and control library
+.Sh LIBRARY
+.Lb libquota
+.Sh SYNOPSIS
+.In quota.h
+.Ft struct quotahandle *
+.Fn quota_open const char *path
+.Ft void
+.Fn quota_close struct quotahandle *qh
+.Ft const char *
+.Fn quota_getmountdevice struct quotahandle *qh
+.Ft const char *
+.Fn quota_getmountpoint struct quotahandle *qh
+.Ft const char *
+.Fn quota_getimplname struct quotahandle *qh
+.Ft unsigned
+.Fn quota_getnumidtypes struct quotahandle *qh
+.Ft unsigned
+.Fn quota_getnumobjtypes struct quotahandle *qh
+.Ft const char *
+.Fn quota_idtype_getname struct quotahandle *qh int idtype
+.Ft const char *
+.Fn quota_objtype_getname struct quotahandle *qh int objtype
+.Ft int
+.Fn quota_objtype_isbytes struct quotahandle *qh int objtype
+.Ft int
+.Fn quota_get struct quotahandle *qh const struct quotakey *key struct quotaval *val
+.Ft int
+.Fn quota_put struct quotahandle *qh const struct quotakey *key const struct quotaval *val
+.Ft int
+.Fn quota_delete struct quotahandle *qh const struct quotakey *key
+.Ft struct quotacursor *
+.Fn quota_opencursor struct quotahandle *qh
+.Ft void
+.Fn quotacursor_close struct quotacursor *qc
+.Ft int
+.Fn quotacursor_skipidtype struct quotacursor *qc int idtype
+.Ft int
+.Fn quotacursor_get struct quotacursor *qc struct quotakey *key const struct quotaval *val
+.Ft int
+.Fn quotacursor_getn struct quotacursor *qc struct quotakey *keys const struct quotaval *vals unsigned maxnum
+.Ft int
+.Fn quotacursor_atend struct quotacursor *qc
+.Ft int
+.Fn quotacursor_rewind struct quotacursor *qc
+.Ft void
+.Fn quotaval_clear struct quotaval *qv
+.Sh DESCRIPTION
+The
+.Nm
+library provides uniform access to disk quota functionality across all
+file systems and file system types.
+Programs should be linked with
+.Fl lquota lrpcsvc .
+.Pp
+Quota information is organized as a key/value store, where the key
+names a particular limit and the value contains information about that
+limit.
+The information includes a configured
+.Em soft limit ,
+.Em hard limit ,
+and
+.Em grace time ,
+as well as the current usage and the expire time of any pending grace
+period.
+The soft limit may be exceeded temporarily, but only for the length of
+time specified; after that further usage is 

CVS commit: src/lib/libquota

2012-01-25 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Jan 25 21:58:43 UTC 2012

Modified Files:
src/lib/libquota: libquota.3

Log Message:
Use more markup. Fix xrefs. Sort ERRORS. Fix typos. Remove trailing
whitespace. Fix minus symbol (\-, not -).


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libquota/libquota.3

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

Modified files:

Index: src/lib/libquota/libquota.3
diff -u src/lib/libquota/libquota.3:1.1 src/lib/libquota/libquota.3:1.2
--- src/lib/libquota/libquota.3:1.1	Wed Jan 25 21:11:45 2012
+++ src/lib/libquota/libquota.3	Wed Jan 25 21:58:43 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: libquota.3,v 1.1 2012/01/25 21:11:45 dholland Exp $
+.\	$NetBSD: libquota.3,v 1.2 2012/01/25 21:58:43 wiz Exp $
 .\
 .\ Copyright (c) 2012 The NetBSD Foundation, Inc.
 .\ All rights reserved.
@@ -162,7 +162,7 @@ The hard limit.
 .It uint64_t qv_usage
 The current usage.
 .It int64_t qv_expiretime
-The time 
+The time
 .Pq in time_t terms
 at which the current grace period, if any, expires.
 .It int64_t qv_grace
@@ -226,7 +226,9 @@ The
 .Fa path
 may be any file or file system object on the desired volume.
 On success, returns a quota handle for further use.
-On failure, returns NULL and sets
+On failure, returns
+.Dv NULL
+and sets
 .Dv errno .
 .It Fn quota_close
 Close a quota handle previously created with
@@ -234,12 +236,12 @@ Close a quota handle previously created 
 .It Fn quota_getmountdevice
 Return the path of the device the target volume is mounted from.
 This is retrieved with
-.Xr statvfs 3 .
+.Xr statvfs 2 .
 .It Fn quota_getmountpoint
 Return the path in the directory tree where the target volume is
 mounted.
 This is retrieved with
-.Xr statvfs 3 .
+.Xr statvfs 2 .
 .It Fn quota_getimplname
 Return a human-readable string describing the underlying quota
 implementation.
@@ -269,7 +271,7 @@ Return, in
 .Fa val ,
 the quota information associated with the quota key
 .Fa key .
-On failure, returns -1 and sets
+On failure, returns \-1 and sets
 .Dv errno .
 .It Fn quota_put
 Update the quota information associated with the quota key
@@ -286,7 +288,7 @@ or
 .Xr fsck 8
 must be used.
 Also note that sufficient privilege is required.
-On failure, returns -1 and sets
+On failure, returns \-1 and sets
 .Dv errno .
 .It Fn quota_delete
 Remove the quota information associated with the quota key
@@ -294,14 +296,16 @@ Remove the quota information associated 
 Depending on the backend implementation this might just blank it out
 or might physically remove the quota record from disk.
 Note that sufficient privilege is required.
-On failure, returns -1 and sets
+On failure, returns \-1 and sets
 .Dv errno .
 .It Fn quota_opencursor
 Prepare to iterate the store by creating a cursor.
 The cursor starts at the beginning of the store.
 On success, returns a pointer to a cursor object that can be used with
 the quotacursor calls.
-On failure, returns NULL and sets
+On failure, returns
+.Dv NULL
+and sets
 .Dv errno .
 .It Fn quotacursor_close
 Destroy a cursor previously created with
@@ -309,11 +313,11 @@ Destroy a cursor previously created with
 This releases internal storage.
 .It Fn quotacursor_skipidtype
 Hint to the implementation that the caller is not interested in
-retriving records with ID type
+retrieving records with ID type
 .Fa idtype .
 As this is a hint, the implementation may ignore it; the caller should
 still be prepared to receive and ignore such records.
-On failure, returns -1 and sets
+On failure, returns \-1 and sets
 .Dv errno .
 .It Fn quotacursor_get
 Retrieve the next record
@@ -321,7 +325,7 @@ Retrieve the next record
 from a cursor.
 Note that records are not guaranteed to be returned in any particular
 order.
-On failure, returns -1 and sets
+On failure, returns \-1 and sets
 .Dv errno .
 .It Fn quotacursor_getn
 Retrieve the next several keys and values from a cursor.
@@ -333,7 +337,7 @@ and
 .Fa vals
 arguments.
 Returns the number of records retrieved.
-On failure, returns -1 and sets
+On failure, returns \-1 and sets
 .Dv errno .
 .It Fn quotacursor_atend
 Returns true if the cursor has reached the end of the quota store.
@@ -351,39 +355,38 @@ to the default empty state.
 .\ can be generated inside file systems.
 Error conditions include:
 .Bl -tag -width Er
-.It Bq Er EOPNOTSUPP
+.\ .It Bq Er EBUSY
+.\ .Fn quota_quotaon
+.\ was attempted on a volume that is not a quota v1 volume.
+.It Bq Er EDEADLK
+An inconsistency was detected during
+.Fn quotacursor_get
+or
+.Fn quotacursor_getn .
+The application should discard information collected so far and use
+.Fn quotacursor_rewind
+to start the iteration over.
+.It Bq Er ENOENT
+The quota information requested from
+.Fn quota_get
+does not exist.
+.It Bq Er ENXIO
 The
 .Fa path
 passed to
 .Fn quota_open
-was on a volume that has no quota support.
-.It Bq Er ENXIO
+was on a volume whose quota support is not 

CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: quota_cursor.c quota_delete.c quota_get.c
quota_oldfiles.c quota_open.c quota_put.c quota_schema.c quotapvt.h

Log Message:
Improve how quota_open() works and generally improve function
dispatching. Allow access to the quota files via the oldfiles code if
quotaon hasn't run yet. Change the latter so it calls getfsent() up
front (and only once) to make it easier to avoid whacking caller
state.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libquota/quota_cursor.c \
src/lib/libquota/quota_get.c src/lib/libquota/quota_schema.c
cvs rdiff -u -r1.2 -r1.3 src/lib/libquota/quota_delete.c \
src/lib/libquota/quota_oldfiles.c src/lib/libquota/quota_put.c
cvs rdiff -u -r1.4 -r1.5 src/lib/libquota/quota_open.c
cvs rdiff -u -r1.9 -r1.10 src/lib/libquota/quotapvt.h

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



CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: Makefile

Log Message:
Add a preliminary man page for libquota.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/libquota/Makefile

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



CVS commit: src/lib/libquota

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

Added Files:
src/lib/libquota: libquota.3

Log Message:
duh, forgot to cvs add


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/lib/libquota/libquota.3

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



CVS commit: src/lib/libquota

2012-01-25 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Jan 25 21:58:43 UTC 2012

Modified Files:
src/lib/libquota: libquota.3

Log Message:
Use more markup. Fix xrefs. Sort ERRORS. Fix typos. Remove trailing
whitespace. Fix minus symbol (\-, not -).


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libquota/libquota.3

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



CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: quota_proplib.c quota_schema.c quotapvt.h

Log Message:
Move some more stuff technically specific to the proplib kernel
interface into the source file for using the proplib kernel interface.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libquota/quota_proplib.c
cvs rdiff -u -r1.2 -r1.3 src/lib/libquota/quota_schema.c
cvs rdiff -u -r1.8 -r1.9 src/lib/libquota/quotapvt.h

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

Modified files:

Index: src/lib/libquota/quota_proplib.c
diff -u src/lib/libquota/quota_proplib.c:1.6 src/lib/libquota/quota_proplib.c:1.7
--- src/lib/libquota/quota_proplib.c:1.6	Mon Jan  9 15:43:19 2012
+++ src/lib/libquota/quota_proplib.c	Wed Jan 25 01:22:56 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_proplib.c,v 1.6 2012/01/09 15:43:19 dholland Exp $	*/
+/*	$NetBSD: quota_proplib.c,v 1.7 2012/01/25 01:22:56 dholland Exp $	*/
 /*-
   * Copyright (c) 2011 Manuel Bouyer
   * All rights reserved.
@@ -26,7 +26,7 @@
   */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: quota_proplib.c,v 1.6 2012/01/09 15:43:19 dholland Exp $);
+__RCSID($NetBSD: quota_proplib.c,v 1.7 2012/01/25 01:22:56 dholland Exp $);
 
 #include stdlib.h
 #include string.h
@@ -180,6 +180,47 @@ __quota_proplib_getimplname(struct quota
 	return unknown;
 }
 
+unsigned
+__quota_proplib_getnumidtypes(void)
+{
+	return QUOTA_NCLASS;
+}
+
+const char *
+__quota_proplib_idtype_getname(int idtype)
+{
+	if (idtype  0 || idtype = QUOTA_NCLASS) {
+		return NULL;
+	}
+	return ufs_quota_class_names[idtype];
+}
+
+unsigned
+__quota_proplib_getnumobjtypes(void)
+{
+	return QUOTA_NLIMITS;
+}
+
+const char *
+__quota_proplib_objtype_getname(int objtype)
+{
+	if (objtype  0 || objtype = QUOTA_NLIMITS) {
+		return NULL;
+	}
+	return ufs_quota_limit_names[objtype];
+}
+
+int
+__quota_proplib_objtype_isbytes(int objtype)
+{
+	switch (objtype) {
+		case QUOTA_LIMIT_BLOCK: return 1;
+		case QUOTA_LIMIT_FILE: return 0;
+		default: break;
+	}
+	return 0;
+}
+
 static int
 __quota_proplib_extractval(int objtype, prop_dictionary_t data,
 			   struct quotaval *qv)

Index: src/lib/libquota/quota_schema.c
diff -u src/lib/libquota/quota_schema.c:1.2 src/lib/libquota/quota_schema.c:1.3
--- src/lib/libquota/quota_schema.c:1.2	Mon Jan  9 15:34:34 2012
+++ src/lib/libquota/quota_schema.c	Wed Jan 25 01:22:57 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_schema.c,v 1.2 2012/01/09 15:34:34 dholland Exp $	*/
+/*	$NetBSD: quota_schema.c,v 1.3 2012/01/25 01:22:57 dholland Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: quota_schema.c,v 1.2 2012/01/09 15:34:34 dholland Exp $);
+__RCSID($NetBSD: quota_schema.c,v 1.3 2012/01/25 01:22:57 dholland Exp $);
 
 #include sys/types.h
 #include sys/statvfs.h
@@ -38,7 +38,6 @@ __RCSID($NetBSD: quota_schema.c,v 1.2 2
 #include errno.h
 
 #include quota.h
-#include quota/quotaprop.h
 #include quotapvt.h
 
 /*
@@ -60,44 +59,33 @@ quota_getimplname(struct quotahandle *qh
 unsigned
 quota_getnumidtypes(struct quotahandle *qh)
 {
-	return QUOTA_NCLASS;
+	return __quota_proplib_getnumidtypes();
 }
 
 /* ARGSUSED */
 const char *
 quota_idtype_getname(struct quotahandle *qh, int idtype)
 {
-	if (idtype  0 || idtype = QUOTA_NCLASS) {
-		return NULL;
-	}
-	return ufs_quota_class_names[idtype];
+	return __quota_proplib_idtype_getname(idtype);
 }
 
 /* ARGSUSED */
 unsigned
 quota_getnumobjtypes(struct quotahandle *qh)
 {
-	return QUOTA_NLIMITS;
+	return __quota_proplib_getnumobjtypes();
 }
 
 /* ARGSUSED */
 const char *
 quota_objtype_getname(struct quotahandle *qh, int objtype)
 {
-	if (objtype  0 || objtype = QUOTA_NLIMITS) {
-		return NULL;
-	}
-	return ufs_quota_limit_names[objtype];
+	return __quota_proplib_objtype_getname(objtype);
 }
 
 /* ARGSUSED */
 int
 quota_objtype_isbytes(struct quotahandle *qh, int objtype)
 {
-	switch (objtype) {
-		case QUOTA_LIMIT_BLOCK: return 1;
-		case QUOTA_LIMIT_FILE: return 0;
-		default: break;
-	}
-	return 0;
+	return __quota_proplib_objtype_isbytes(objtype);
 }

Index: src/lib/libquota/quotapvt.h
diff -u src/lib/libquota/quotapvt.h:1.8 src/lib/libquota/quotapvt.h:1.9
--- src/lib/libquota/quotapvt.h:1.8	Mon Jan  9 15:45:19 2012
+++ src/lib/libquota/quotapvt.h	Wed Jan 25 01:22:57 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quotapvt.h,v 1.8 2012/01/09 15:45:19 dholland Exp $	*/
+/*	$NetBSD: quotapvt.h,v 1.9 2012/01/25 01:22:57 dholland Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -54,6 +54,11 @@ struct quotacursor {
 /* proplib kernel interface */
 int __quota_proplib_getversion(struct quotahandle *qh, int8_t *version_ret);
 const char *__quota_proplib_getimplname(struct quotahandle *);
+unsigned __quota_proplib_getnumidtypes(void);
+const char 

CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: quota_proplib.c quota_schema.c quotapvt.h

Log Message:
Move some more stuff technically specific to the proplib kernel
interface into the source file for using the proplib kernel interface.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libquota/quota_proplib.c
cvs rdiff -u -r1.2 -r1.3 src/lib/libquota/quota_schema.c
cvs rdiff -u -r1.8 -r1.9 src/lib/libquota/quotapvt.h

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



CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: Makefile
Added Files:
src/lib/libquota: quota_cursor.c quota_delete.c quota_get.c
quota_open.c quota_put.c quota_schema.c

Log Message:
Add stub entry points of the entire new quota interface. These fail or
do nothing for the time being; however, putting them all in up front
avoids the need to do multiple bumps of the libquota.so version.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libquota/Makefile
cvs rdiff -u -r0 -r1.1 src/lib/libquota/quota_cursor.c \
src/lib/libquota/quota_delete.c src/lib/libquota/quota_get.c \
src/lib/libquota/quota_open.c src/lib/libquota/quota_put.c \
src/lib/libquota/quota_schema.c

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

Modified files:

Index: src/lib/libquota/Makefile
diff -u src/lib/libquota/Makefile:1.1 src/lib/libquota/Makefile:1.2
--- src/lib/libquota/Makefile:1.1	Thu Mar 24 17:05:43 2011
+++ src/lib/libquota/Makefile	Mon Jan  9 15:22:38 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.1 2011/03/24 17:05:43 bouyer Exp $
+#	$NetBSD: Makefile,v 1.2 2012/01/09 15:22:38 dholland Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/4/93
 
 .include bsd.own.mk
@@ -14,4 +14,9 @@ LIBDPLIBS+= rpcsvc  ${.CURDIR}/../li
 SRCS+=	getfsquota.c getnfsquota.c getufsquota.c
 MAN=
 
+SRCS+=	quota_open.c
+SRCS+=	quota_schema.c
+SRCS+=	quota_get.c quota_put.c quota_delete.c
+SRCS+=	quota_cursor.c
+
 .include bsd.lib.mk

Added files:

Index: src/lib/libquota/quota_cursor.c
diff -u /dev/null src/lib/libquota/quota_cursor.c:1.1
--- /dev/null	Mon Jan  9 15:22:39 2012
+++ src/lib/libquota/quota_cursor.c	Mon Jan  9 15:22:38 2012
@@ -0,0 +1,93 @@
+/*	$NetBSD: quota_cursor.c,v 1.1 2012/01/09 15:22:38 dholland Exp $	*/
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by David A. Holland.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include sys/cdefs.h
+__RCSID($NetBSD: quota_cursor.c,v 1.1 2012/01/09 15:22:38 dholland Exp $);
+
+#include stdlib.h
+#include errno.h
+
+#include quota.h
+
+/* ARGSUSED */
+struct quotacursor *
+quota_opencursor(struct quotahandle *qh)
+{
+	errno = ENOSYS;
+	return NULL;
+}
+
+/* ARGSUSED */
+void
+quotacursor_close(struct quotacursor *qc)
+{
+}
+
+/* ARGSUSED */
+int
+quotacursor_skipidtype(struct quotacursor *qc, unsigned idtype)
+{
+	errno = ENOSYS;
+	return -1;
+}
+
+/* ARGSUSED */
+int
+quotacursor_get(struct quotacursor *qc,
+		struct quotakey *qk_ret, struct quotaval *qv_ret)
+{
+	errno = ENOSYS;
+	return -1;
+}
+
+/* ARGSUSED */
+int
+quotacursor_getn(struct quotacursor *qc,
+		 struct quotakey *keys, struct quotaval *vals, 
+		 unsigned maxnum)
+{
+	errno = ENOSYS;
+	return -1;
+}
+
+/* ARGSUSED */
+int
+quotacursor_atend(struct quotacursor *qc)
+{
+	return 0;
+}
+
+/* ARGSUSED */
+int
+quotacursor_rewind(struct quotacursor *qc)
+{
+	errno = ENOSYS;
+	return -1;
+}
Index: src/lib/libquota/quota_delete.c
diff -u /dev/null src/lib/libquota/quota_delete.c:1.1
--- /dev/null	Mon Jan  9 15:22:39 2012
+++ src/lib/libquota/quota_delete.c	Mon Jan  9 15:22:38 2012
@@ -0,0 +1,44 @@
+/*	$NetBSD: quota_delete.c,v 1.1 2012/01/09 15:22:38 dholland Exp $	*/
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by David A. Holland.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided 

CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: Makefile quota_get.c quota_open.c
Added Files:
src/lib/libquota: quota_proplib.c quotapvt.h

Log Message:
Add initial versions of quota_open(), quota_close(), quota_get(),
calling proplib code mostly taken from getufsquota().

Correct the proplib refcount handling in the code from getufsquota(),
where it was (as far as I can tell) wrong.

Avoid doing illegal and unsafe casts from (struct quotaval *)
to (uint64_t *).


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libquota/Makefile
cvs rdiff -u -r1.1 -r1.2 src/lib/libquota/quota_get.c \
src/lib/libquota/quota_open.c
cvs rdiff -u -r0 -r1.1 src/lib/libquota/quota_proplib.c \
src/lib/libquota/quotapvt.h

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

Modified files:

Index: src/lib/libquota/Makefile
diff -u src/lib/libquota/Makefile:1.2 src/lib/libquota/Makefile:1.3
--- src/lib/libquota/Makefile:1.2	Mon Jan  9 15:22:38 2012
+++ src/lib/libquota/Makefile	Mon Jan  9 15:27:04 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.2 2012/01/09 15:22:38 dholland Exp $
+#	$NetBSD: Makefile,v 1.3 2012/01/09 15:27:04 dholland Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/4/93
 
 .include bsd.own.mk
@@ -18,5 +18,6 @@ SRCS+=	quota_open.c
 SRCS+=	quota_schema.c
 SRCS+=	quota_get.c quota_put.c quota_delete.c
 SRCS+=	quota_cursor.c
+SRCS+=	quota_proplib.c
 
 .include bsd.lib.mk

Index: src/lib/libquota/quota_get.c
diff -u src/lib/libquota/quota_get.c:1.1 src/lib/libquota/quota_get.c:1.2
--- src/lib/libquota/quota_get.c:1.1	Mon Jan  9 15:22:38 2012
+++ src/lib/libquota/quota_get.c	Mon Jan  9 15:27:04 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_get.c,v 1.1 2012/01/09 15:22:38 dholland Exp $	*/
+/*	$NetBSD: quota_get.c,v 1.2 2012/01/09 15:27:04 dholland Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,22 +29,23 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: quota_get.c,v 1.1 2012/01/09 15:22:38 dholland Exp $);
-
-#include errno.h
+__RCSID($NetBSD: quota_get.c,v 1.2 2012/01/09 15:27:04 dholland Exp $);
 
 #include quota.h
+#include quotapvt.h
 
-/* ARGSUSED */
 void
 quotaval_clear(struct quotaval *qv)
 {
+	qv-qv_hardlimit = QUOTA_NOLIMIT;
+	qv-qv_softlimit = QUOTA_NOLIMIT;
+	qv-qv_usage = 0;
+	qv-qv_expiretime = QUOTA_NOTIME;
+	qv-qv_grace = QUOTA_NOTIME;
 }
 
-/* ARGSUSED */
 int
 quota_get(struct quotahandle *qh, const struct quotakey *qk, struct quotaval *qv)
 {
-	errno = ENOSYS;
-	return -1;
+	return __quota_proplib_get(qh, qk, qv);
 }
Index: src/lib/libquota/quota_open.c
diff -u src/lib/libquota/quota_open.c:1.1 src/lib/libquota/quota_open.c:1.2
--- src/lib/libquota/quota_open.c:1.1	Mon Jan  9 15:22:38 2012
+++ src/lib/libquota/quota_open.c	Mon Jan  9 15:27:04 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_open.c,v 1.1 2012/01/09 15:22:38 dholland Exp $	*/
+/*	$NetBSD: quota_open.c,v 1.2 2012/01/09 15:27:04 dholland Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,26 +29,39 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: quota_open.c,v 1.1 2012/01/09 15:22:38 dholland Exp $);
+__RCSID($NetBSD: quota_open.c,v 1.2 2012/01/09 15:27:04 dholland Exp $);
 
+#include stdlib.h
 #include string.h
 #include errno.h
 
 #include quota.h
+#include quotapvt.h
 
-/* ARGSUSED */
 struct quotahandle *
 quota_open(const char *path)
 {
-	errno = ENOSYS;
-	return NULL;
+	struct quotahandle *qh;
+	int serrno;
+
+	qh = malloc(sizeof(*qh));
+	if (qh == NULL) {
+		return NULL;
+	}
+	qh-qh_mountpoint = strdup(path);
+	if (qh-qh_mountpoint == NULL) {
+		serrno = errno;
+		free(qh);
+		errno = serrno;
+		return NULL;
+	}
+	return qh;
 }
 
 const char *
 quota_getmountpoint(struct quotahandle *qh)
 {
-	errno = ENOSYS;
-	return NULL;
+	return qh-qh_mountpoint;
 }
 
 const char *
@@ -58,8 +71,9 @@ quota_getmountdevice(struct quotahandle 
 	return NULL;
 }
 
-/* ARGSUSED */
 void
 quota_close(struct quotahandle *qh)
 {
+	free(qh-qh_mountpoint);
+	free(qh);
 }

Added files:

Index: src/lib/libquota/quota_proplib.c
diff -u /dev/null src/lib/libquota/quota_proplib.c:1.1
--- /dev/null	Mon Jan  9 15:27:05 2012
+++ src/lib/libquota/quota_proplib.c	Mon Jan  9 15:27:04 2012
@@ -0,0 +1,306 @@
+/*	$NetBSD: quota_proplib.c,v 1.1 2012/01/09 15:27:04 dholland Exp $	*/
+/*-
+  * Copyright (c) 2011 Manuel Bouyer
+  * All rights reserved.
+  *
+  * Redistribution and use in source and binary forms, with or without
+  * modification, are permitted provided that the following conditions
+  * are met:
+  * 1. Redistributions of source code must retain the above copyright
+  *notice, this list of conditions and the following disclaimer.
+  * 2. Redistributions in binary form must reproduce the above copyright
+  *notice, this list of conditions and the following disclaimer in the
+  *documentation 

CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: getufsquota.c

Log Message:
Rework getufsquota() in terms of the new quota API.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libquota/getufsquota.c

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

Modified files:

Index: src/lib/libquota/getufsquota.c
diff -u src/lib/libquota/getufsquota.c:1.4 src/lib/libquota/getufsquota.c:1.5
--- src/lib/libquota/getufsquota.c:1.4	Fri Nov 25 16:55:05 2011
+++ src/lib/libquota/getufsquota.c	Mon Jan  9 15:28:31 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: getufsquota.c,v 1.4 2011/11/25 16:55:05 dholland Exp $ */
+/*	$NetBSD: getufsquota.c,v 1.5 2012/01/09 15:28:31 dholland Exp $ */
 
 /*-
   * Copyright (c) 2011 Manuel Bouyer
@@ -27,24 +27,95 @@
   */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: getufsquota.c,v 1.4 2011/11/25 16:55:05 dholland Exp $);
+__RCSID($NetBSD: getufsquota.c,v 1.5 2012/01/09 15:28:31 dholland Exp $);
 
+#include sys/types.h
 #include stdio.h
 #include stdlib.h
+#include string.h
 #include errno.h
 #include err.h
-#include string.h
-
-#include sys/types.h
 
 #include quota/quotaprop.h
 #include quota/quota.h
 
-/* retrieve quotas with ufs semantics from vfs, for the given user id */
+#include quota.h
+
+/*
+ * Return true if QV contains any actual information.
+ *
+ * XXX when qv_grace is not available it should be set to QUOTA_NOTIME,
+ * not zero, but this is currently not always the case.
+ */
+static int
+quotaval_nonempty(const struct quotaval *qv)
+{
+	if (qv-qv_hardlimit != QUOTA_NOLIMIT ||
+	qv-qv_softlimit != QUOTA_NOLIMIT ||
+	qv-qv_usage != 0 ||
+	qv-qv_expiretime != QUOTA_NOTIME ||
+	(qv-qv_grace != QUOTA_NOTIME  qv-qv_grace != 0)) {
+		return 1;
+	}
+	return 0;
+}
+
+/*
+ * retrieve quotas with ufs semantics from vfs, for the given user id
+ *
+ * What this actually does is: for mount point MP, and id ID, which
+ * can be either a uid or a gid depending on what string CLASS
+ * contains, fetch both block and file quotas and store them in QV,
+ * namely in qv[0] and qv[1] respectively.
+ */
 int
 getufsquota(const char *mp, struct quotaval *qv, uid_t id,
 const char *class)
 {
+#if 1
+	struct quotakey qk;
+	struct quotahandle *qh;
+
+	qh = quota_open(mp);
+	if (qh == NULL) {
+		return -1;
+	}
+
+	qk.qk_id = id;
+	if (!strcmp(class, QUOTADICT_CLASS_USER)) {
+		qk.qk_idtype = QUOTA_IDTYPE_USER;
+	} else if (!strcmp(class, QUOTADICT_CLASS_GROUP)) {
+		qk.qk_idtype = QUOTA_IDTYPE_GROUP;
+	} else {
+		errno = EINVAL;
+		return -1;
+	}
+
+	/*
+	 * Use explicit indexes on qv[] to make sure this continues
+	 * to work the way it used to (for compat) independent of
+	 * what might happen to the symbolic constants.
+	 */
+
+	qk.qk_objtype = QUOTA_OBJTYPE_BLOCKS;
+	if (quota_get(qh, qk, qv[0])  0) {
+		return -1;
+	}
+
+	qk.qk_objtype = QUOTA_OBJTYPE_FILES;
+	if (quota_get(qh, qk, qv[1])  0) {
+		return -1;
+	}
+
+	quota_close(qh);
+
+	if (quotaval_nonempty(qv[0]) || quotaval_nonempty(qv[1])) {
+		return 1;
+	}
+
+	return 0;
+
+#else /* old code for reference */
 	prop_dictionary_t dict, data, cmd;
 	prop_array_t cmds, datas;
 	struct plistref pref;
@@ -175,4 +246,5 @@ end_cmds:
 end_dict:
 	prop_object_release(dict);
 	return -1;
+#endif
 }



CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: Makefile quota_get.c quota_open.c quotapvt.h
Added Files:
src/lib/libquota: quota_nfs.c

Log Message:
Add quota_nfs.c and implement quota_get() for nfs, using
code from getnfsquota().

Also implement quota_getmountdevice().


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libquota/Makefile
cvs rdiff -u -r1.2 -r1.3 src/lib/libquota/quota_get.c \
src/lib/libquota/quota_open.c
cvs rdiff -u -r0 -r1.1 src/lib/libquota/quota_nfs.c
cvs rdiff -u -r1.1 -r1.2 src/lib/libquota/quotapvt.h

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

Modified files:

Index: src/lib/libquota/Makefile
diff -u src/lib/libquota/Makefile:1.3 src/lib/libquota/Makefile:1.4
--- src/lib/libquota/Makefile:1.3	Mon Jan  9 15:27:04 2012
+++ src/lib/libquota/Makefile	Mon Jan  9 15:29:55 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.3 2012/01/09 15:27:04 dholland Exp $
+#	$NetBSD: Makefile,v 1.4 2012/01/09 15:29:55 dholland Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/4/93
 
 .include bsd.own.mk
@@ -19,5 +19,6 @@ SRCS+=	quota_schema.c
 SRCS+=	quota_get.c quota_put.c quota_delete.c
 SRCS+=	quota_cursor.c
 SRCS+=	quota_proplib.c
+SRCS+=	quota_nfs.c
 
 .include bsd.lib.mk

Index: src/lib/libquota/quota_get.c
diff -u src/lib/libquota/quota_get.c:1.2 src/lib/libquota/quota_get.c:1.3
--- src/lib/libquota/quota_get.c:1.2	Mon Jan  9 15:27:04 2012
+++ src/lib/libquota/quota_get.c	Mon Jan  9 15:29:55 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_get.c,v 1.2 2012/01/09 15:27:04 dholland Exp $	*/
+/*	$NetBSD: quota_get.c,v 1.3 2012/01/09 15:29:55 dholland Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: quota_get.c,v 1.2 2012/01/09 15:27:04 dholland Exp $);
+__RCSID($NetBSD: quota_get.c,v 1.3 2012/01/09 15:29:55 dholland Exp $);
 
 #include quota.h
 #include quotapvt.h
@@ -47,5 +47,9 @@ quotaval_clear(struct quotaval *qv)
 int
 quota_get(struct quotahandle *qh, const struct quotakey *qk, struct quotaval *qv)
 {
-	return __quota_proplib_get(qh, qk, qv);
+	if (qh-qh_isnfs) {
+		return __quota_nfs_get(qh, qk, qv);
+	} else {
+		return __quota_proplib_get(qh, qk, qv);
+	}
 }
Index: src/lib/libquota/quota_open.c
diff -u src/lib/libquota/quota_open.c:1.2 src/lib/libquota/quota_open.c:1.3
--- src/lib/libquota/quota_open.c:1.2	Mon Jan  9 15:27:04 2012
+++ src/lib/libquota/quota_open.c	Mon Jan  9 15:29:56 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_open.c,v 1.2 2012/01/09 15:27:04 dholland Exp $	*/
+/*	$NetBSD: quota_open.c,v 1.3 2012/01/09 15:29:56 dholland Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,8 +29,10 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: quota_open.c,v 1.2 2012/01/09 15:27:04 dholland Exp $);
+__RCSID($NetBSD: quota_open.c,v 1.3 2012/01/09 15:29:56 dholland Exp $);
 
+#include sys/types.h
+#include sys/statvfs.h
 #include stdlib.h
 #include string.h
 #include errno.h
@@ -41,20 +43,64 @@ __RCSID($NetBSD: quota_open.c,v 1.2 201
 struct quotahandle *
 quota_open(const char *path)
 {
+
+	struct statvfs stv;
 	struct quotahandle *qh;
+	int isnfs;
 	int serrno;
 
+	if (statvfs(path, stv)  0) {
+		return NULL;
+	}
+
+	/*
+	 * We need to know up front if the volume is NFS. If so, we
+	 * don't go to the kernel at all but instead do RPCs to the
+	 * NFS server's rpc.rquotad. Therefore, don't check the
+	 * mount flags for quota support or do anything else that
+	 * reaches the kernel.
+	 */
+	
+	if (!strcmp(stv.f_fstypename, nfs)) {
+		isnfs = 1;
+	} else {
+		isnfs = 0;
+		if ((stv.f_flag  ST_QUOTA) == 0) {
+			/* XXX: correct errno? */
+			errno = EOPNOTSUPP;
+			return NULL;
+		}
+	}
+
 	qh = malloc(sizeof(*qh));
 	if (qh == NULL) {
 		return NULL;
 	}
-	qh-qh_mountpoint = strdup(path);
+
+	/*
+	 * Get the mount point from statvfs; this way the passed-in
+	 * path can be any path on the volume.
+	 */
+
+	qh-qh_mountpoint = strdup(stv.f_mntonname);
 	if (qh-qh_mountpoint == NULL) {
 		serrno = errno;
 		free(qh);
 		errno = serrno;
 		return NULL;
 	}
+
+	qh-qh_mountdevice = strdup(stv.f_mntfromname);
+	if (qh-qh_mountdevice == NULL) {
+		serrno = errno;
+		free(qh-qh_mountpoint);
+		free(qh);
+		errno = serrno;
+		return NULL;
+	}
+
+	qh-qh_isnfs = isnfs;
+
 	return qh;
 }
 
@@ -67,13 +113,13 @@ quota_getmountpoint(struct quotahandle *
 const char *
 quota_getmountdevice(struct quotahandle *qh)
 {
-	errno = ENOSYS;
-	return NULL;
+	return qh-qh_mountdevice;
 }
 
 void
 quota_close(struct quotahandle *qh)
 {
+	free(qh-qh_mountdevice);
 	free(qh-qh_mountpoint);
 	free(qh);
 }

Index: src/lib/libquota/quotapvt.h
diff -u src/lib/libquota/quotapvt.h:1.1 src/lib/libquota/quotapvt.h:1.2
--- src/lib/libquota/quotapvt.h:1.1	Mon Jan  9 15:27:04 2012
+++ src/lib/libquota/quotapvt.h	Mon Jan  9 

CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: getfsquota.c getnfsquota.c getufsquota.c quotapvt.h

Log Message:
Redo getfsquota() and getnfsquota() using the new API.

Change the previous getufsquota() to __quota_getquota() and call it
from all three functions: getfsquota(), getufsquota(), and getnfsquota().


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libquota/getfsquota.c
cvs rdiff -u -r1.4 -r1.5 src/lib/libquota/getnfsquota.c
cvs rdiff -u -r1.5 -r1.6 src/lib/libquota/getufsquota.c
cvs rdiff -u -r1.2 -r1.3 src/lib/libquota/quotapvt.h

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

Modified files:

Index: src/lib/libquota/getfsquota.c
diff -u src/lib/libquota/getfsquota.c:1.3 src/lib/libquota/getfsquota.c:1.4
--- src/lib/libquota/getfsquota.c:1.3	Fri Nov 25 16:55:05 2011
+++ src/lib/libquota/getfsquota.c	Mon Jan  9 15:31:11 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: getfsquota.c,v 1.3 2011/11/25 16:55:05 dholland Exp $ */
+/*	$NetBSD: getfsquota.c,v 1.4 2012/01/09 15:31:11 dholland Exp $ */
 
 /*-
   * Copyright (c) 2011 Manuel Bouyer
@@ -27,39 +27,20 @@
   */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: getfsquota.c,v 1.3 2011/11/25 16:55:05 dholland Exp $);
+__RCSID($NetBSD: getfsquota.c,v 1.4 2012/01/09 15:31:11 dholland Exp $);
 
-#include stdio.h
-#include stdlib.h
-#include errno.h
-#include err.h
-#include string.h
+#include quota.h
+#include quota/quota.h
 
-#include sys/types.h
-#include sys/statvfs.h
+#include quotapvt.h
 
-#include quota/quotaprop.h
-#include quota/quota.h
 
-/* retrieve quotas with ufs semantics from vfs, for the given user id */
+/*
+ * retrieve quotas with ufs semantics from vfs, for the given user id
+ */
 int
 getfsquota(const char *path, struct quotaval *qv, uid_t id,
 const char *class)
 {
-	struct statvfs v;
-
-	if (statvfs(path, v)  0) {
-		return -1;
-	}
-	if (strcmp(v.f_fstypename, nfs) == 0)
-		return getnfsquota(v.f_mntfromname, qv, id, class);
-	else {
-		if ((v.f_flag  ST_QUOTA) == 0)
-			return 0;
-		/*
-		 * assume all quota-enabled local filesystems have UFS
-		 * semantic for now
-		 */
-		return getufsquota(v.f_mntonname, qv, id, class);
-	}
+	return __quota_getquota(path, qv, id, class);
 }

Index: src/lib/libquota/getnfsquota.c
diff -u src/lib/libquota/getnfsquota.c:1.4 src/lib/libquota/getnfsquota.c:1.5
--- src/lib/libquota/getnfsquota.c:1.4	Fri Nov 25 16:55:05 2011
+++ src/lib/libquota/getnfsquota.c	Mon Jan  9 15:31:11 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: getnfsquota.c,v 1.4 2011/11/25 16:55:05 dholland Exp $	*/
+/*	$NetBSD: getnfsquota.c,v 1.5 2012/01/09 15:31:11 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,170 +42,84 @@ __COPYRIGHT(@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = @(#)quota.c	8.4 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: getnfsquota.c,v 1.4 2011/11/25 16:55:05 dholland Exp $);
+__RCSID($NetBSD: getnfsquota.c,v 1.5 2012/01/09 15:31:11 dholland Exp $);
 #endif
 #endif /* not lint */
 
-/*
- * Disk quota reporting program.
- */
-#include sys/param.h
 #include sys/types.h
-#include sys/socket.h
-
-#include ctype.h
-#include err.h
-#include errno.h
-#include netdb.h
-#include stdio.h
+#include sys/mount.h
 #include stdlib.h
 #include string.h
-#include time.h
-#include unistd.h
+#include errno.h
 
+#include quota.h
 #include quota/quota.h
-#include quota/quotaprop.h
 
-#include rpc/rpc.h
-#include rpc/pmap_prot.h
-#include rpcsvc/rquota.h
-
-/* convert a rquota limit to our semantic */
-static uint64_t
-rqlim2qlim(uint32_t lim)
-{
-	if (lim == 0)
-		return UQUAD_MAX;
-	else
-		return (lim - 1);
-}
- 
-static int
-callaurpc(const char *host, rpcprog_t prognum, rpcvers_t versnum,
-rpcproc_t procnum, xdrproc_t inproc, void *in, xdrproc_t outproc, void *out)
-{
-	struct sockaddr_in server_addr;
-	enum clnt_stat clnt_stat;
-	struct hostent *hp;
-	struct timeval timeout, tottimeout;
- 
-	CLIENT *client = NULL;
-	int sock = RPC_ANYSOCK;
- 
-	if ((hp = gethostbyname(host)) == NULL)
-		return (int) RPC_UNKNOWNHOST;
-	timeout.tv_usec = 0;
-	timeout.tv_sec = 6;
-	memmove(server_addr.sin_addr, hp-h_addr, hp-h_length);
-	server_addr.sin_family = AF_INET;
-	server_addr.sin_port =  0;
-
-	if ((client = clntudp_create(server_addr, prognum,
-	versnum, timeout, sock)) == NULL)
-		return (int) rpc_createerr.cf_stat;
-
-	client-cl_auth = authunix_create_default();
-	tottimeout.tv_sec = 25;
-	tottimeout.tv_usec = 0;
-	clnt_stat = clnt_call(client, procnum, inproc, in,
-	outproc, out, tottimeout);
- 
-	return (int) clnt_stat;
-}
+#include quotapvt.h
 
 int
 getnfsquota(const char *mp, struct quotaval *qv,
 uint32_t id, const char *class)
 {
-	struct getquota_args gq_args;
-	struct ext_getquota_args ext_gq_args;
-	struct getquota_rslt gq_rslt;
-	struct timeval tv;
-	char *host, *path;
-	int ret, rpcqtype;
-
-	if (strcmp(class, QUOTADICT_CLASS_USER) == 

CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: quota_proplib.c

Log Message:
Handle default ID case in quota_get(), based on logic found in
/usr/bin/quota.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libquota/quota_proplib.c

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

Modified files:

Index: src/lib/libquota/quota_proplib.c
diff -u src/lib/libquota/quota_proplib.c:1.1 src/lib/libquota/quota_proplib.c:1.2
--- src/lib/libquota/quota_proplib.c:1.1	Mon Jan  9 15:27:04 2012
+++ src/lib/libquota/quota_proplib.c	Mon Jan  9 15:32:38 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_proplib.c,v 1.1 2012/01/09 15:27:04 dholland Exp $	*/
+/*	$NetBSD: quota_proplib.c,v 1.2 2012/01/09 15:32:38 dholland Exp $	*/
 /*-
   * Copyright (c) 2011 Manuel Bouyer
   * All rights reserved.
@@ -26,7 +26,7 @@
   */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: quota_proplib.c,v 1.1 2012/01/09 15:27:04 dholland Exp $);
+__RCSID($NetBSD: quota_proplib.c,v 1.2 2012/01/09 15:32:38 dholland Exp $);
 
 #include string.h
 #include errno.h
@@ -73,10 +73,18 @@ __quota_proplib_get(struct quotahandle *
 		errno = ENOMEM;
 		return -1;
 	}
-	if (!prop_dictionary_set_uint32(data, id, qk-qk_id)) {
-		prop_object_release(data);
-		errno = ENOMEM;
-		return -1;
+	if (qk-qk_id == QUOTA_DEFAULTID) {
+		if (!prop_dictionary_set_cstring(data, id, default)) {
+			prop_object_release(data);
+			errno = ENOMEM;
+			return -1;
+		}
+	} else {
+		if (!prop_dictionary_set_uint32(data, id, qk-qk_id)) {
+			prop_object_release(data);
+			errno = ENOMEM;
+			return -1;
+		}
 	}
 
 	datas = prop_array_create();



CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: quota_cursor.c quota_proplib.c quotapvt.h

Log Message:
Implement the libquota cursor interface, using proplib code from repquota.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libquota/quota_cursor.c
cvs rdiff -u -r1.3 -r1.4 src/lib/libquota/quota_proplib.c
cvs rdiff -u -r1.4 -r1.5 src/lib/libquota/quotapvt.h

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

Modified files:

Index: src/lib/libquota/quota_cursor.c
diff -u src/lib/libquota/quota_cursor.c:1.1 src/lib/libquota/quota_cursor.c:1.2
--- src/lib/libquota/quota_cursor.c:1.1	Mon Jan  9 15:22:38 2012
+++ src/lib/libquota/quota_cursor.c	Mon Jan  9 15:40:10 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_cursor.c,v 1.1 2012/01/09 15:22:38 dholland Exp $	*/
+/*	$NetBSD: quota_cursor.c,v 1.2 2012/01/09 15:40:10 dholland Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,65 +29,81 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: quota_cursor.c,v 1.1 2012/01/09 15:22:38 dholland Exp $);
+__RCSID($NetBSD: quota_cursor.c,v 1.2 2012/01/09 15:40:10 dholland Exp $);
 
 #include stdlib.h
 #include errno.h
 
 #include quota.h
+#include quotapvt.h
 
-/* ARGSUSED */
 struct quotacursor *
 quota_opencursor(struct quotahandle *qh)
 {
-	errno = ENOSYS;
-	return NULL;
+	struct quotacursor *qc;
+	int serrno;
+
+	if (qh-qh_isnfs) {
+		errno = EOPNOTSUPP;
+		return NULL;
+	}
+
+	qc = malloc(sizeof(*qc));
+	if (qc == NULL) {
+		return NULL;
+	}
+
+	qc-qc_qh = qh;
+	qc-u.qc_proplib = __quota_proplib_cursor_create();
+
+	if (qc-u.qc_proplib == NULL) {
+		serrno = errno;
+		free(qc);
+		errno = serrno;
+		return NULL;
+	}
+	return qc;
 }
 
-/* ARGSUSED */
 void
 quotacursor_close(struct quotacursor *qc)
 {
+	__quota_proplib_cursor_destroy(qc-u.qc_proplib);
+	free(qc);
 }
 
-/* ARGSUSED */
 int
 quotacursor_skipidtype(struct quotacursor *qc, unsigned idtype)
 {
-	errno = ENOSYS;
-	return -1;
+	return __quota_proplib_cursor_skipidtype(qc-u.qc_proplib, idtype);
 }
 
-/* ARGSUSED */
 int
 quotacursor_get(struct quotacursor *qc,
 		struct quotakey *qk_ret, struct quotaval *qv_ret)
 {
-	errno = ENOSYS;
-	return -1;
+	return __quota_proplib_cursor_get(qc-qc_qh, qc-u.qc_proplib,
+	  qk_ret, qv_ret);
 }
 
-/* ARGSUSED */
 int
 quotacursor_getn(struct quotacursor *qc,
 		 struct quotakey *keys, struct quotaval *vals, 
 		 unsigned maxnum)
 {
-	errno = ENOSYS;
-	return -1;
+	return __quota_proplib_cursor_getn(qc-qc_qh, qc-u.qc_proplib,
+	   keys, vals, maxnum);
 }
 
-/* ARGSUSED */
 int
 quotacursor_atend(struct quotacursor *qc)
 {
-	return 0;
+	return __quota_proplib_cursor_atend(qc-qc_qh,
+	qc-u.qc_proplib);
 }
 
-/* ARGSUSED */
 int
 quotacursor_rewind(struct quotacursor *qc)
 {
-	errno = ENOSYS;
-	return -1;
+	return __quota_proplib_cursor_rewind(qc-u.qc_proplib);
 }

Index: src/lib/libquota/quota_proplib.c
diff -u src/lib/libquota/quota_proplib.c:1.3 src/lib/libquota/quota_proplib.c:1.4
--- src/lib/libquota/quota_proplib.c:1.3	Mon Jan  9 15:34:34 2012
+++ src/lib/libquota/quota_proplib.c	Mon Jan  9 15:40:10 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_proplib.c,v 1.3 2012/01/09 15:34:34 dholland Exp $	*/
+/*	$NetBSD: quota_proplib.c,v 1.4 2012/01/09 15:40:10 dholland Exp $	*/
 /*-
   * Copyright (c) 2011 Manuel Bouyer
   * All rights reserved.
@@ -26,9 +26,11 @@
   */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: quota_proplib.c,v 1.3 2012/01/09 15:34:34 dholland Exp $);
+__RCSID($NetBSD: quota_proplib.c,v 1.4 2012/01/09 15:40:10 dholland Exp $);
 
+#include stdlib.h
 #include string.h
+#include limits.h
 #include errno.h
 #include err.h
 
@@ -38,6 +40,21 @@ __RCSID($NetBSD: quota_proplib.c,v 1.3 
 #include quota/quotaprop.h
 #include quota/quota.h
 
+struct proplib_quotacursor {
+	prop_array_t users;
+	prop_array_t groups;
+
+	unsigned numusers;
+	unsigned numgroups;
+
+	unsigned haveusers;
+	unsigned havegroups;
+
+	unsigned didusers;
+	unsigned pos;
+	unsigned didblocks;
+};
+
 static int
 __quota_proplib_getversion(struct quotahandle *qh, int8_t *version_ret)
 {
@@ -163,6 +180,63 @@ __quota_proplib_getimplname(struct quota
 	return unknown;
 }
 
+static int
+__quota_proplib_extractval(int objtype, prop_dictionary_t data,
+			   struct quotaval *qv)
+{
+	uint64_t vals[UFS_QUOTA_NENTRIES];
+	uint64_t *valptrs[1];
+	int limitcode;
+
+	/*
+	 * So, the way proptoquota64 works is that you pass it an
+	 * array of pointers to uint64. Each of these pointers is
+	 * supposed to point to 5 (UFS_QUOTA_NENTRIES) uint64s. This
+	 * array of pointers is the second argument. The third and
+	 * forth argument are the names of the five values to extract,
+	 * and UFS_QUOTA_NENTRIES. The last two arguments are the
+	 * names assocated with the pointers (QUOTATYPE_LDICT_BLOCK,
+	 * QUOTADICT_LTYPE_FILE) and the number of pointers. 

CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: Makefile quota_cursor.c quota_open.c quota_proplib.c
quotapvt.h
Added Files:
src/lib/libquota: quota_oldfiles.c

Log Message:
Implement fallback direct access to quota1-type quota files.
Uses (mostly) code from repquota. Add some missing pieces that
weren't in repquota.

Use the direct file access code for cursors if proplib reports the
quota version is 1.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libquota/Makefile \
src/lib/libquota/quota_proplib.c
cvs rdiff -u -r1.2 -r1.3 src/lib/libquota/quota_cursor.c
cvs rdiff -u -r0 -r1.1 src/lib/libquota/quota_oldfiles.c
cvs rdiff -u -r1.3 -r1.4 src/lib/libquota/quota_open.c
cvs rdiff -u -r1.5 -r1.6 src/lib/libquota/quotapvt.h

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

Modified files:

Index: src/lib/libquota/Makefile
diff -u src/lib/libquota/Makefile:1.4 src/lib/libquota/Makefile:1.5
--- src/lib/libquota/Makefile:1.4	Mon Jan  9 15:29:55 2012
+++ src/lib/libquota/Makefile	Mon Jan  9 15:41:58 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.4 2012/01/09 15:29:55 dholland Exp $
+#	$NetBSD: Makefile,v 1.5 2012/01/09 15:41:58 dholland Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/4/93
 
 .include bsd.own.mk
@@ -20,5 +20,6 @@ SRCS+=	quota_get.c quota_put.c quota_del
 SRCS+=	quota_cursor.c
 SRCS+=	quota_proplib.c
 SRCS+=	quota_nfs.c
+SRCS+=	quota_oldfiles.c
 
 .include bsd.lib.mk
Index: src/lib/libquota/quota_proplib.c
diff -u src/lib/libquota/quota_proplib.c:1.4 src/lib/libquota/quota_proplib.c:1.5
--- src/lib/libquota/quota_proplib.c:1.4	Mon Jan  9 15:40:10 2012
+++ src/lib/libquota/quota_proplib.c	Mon Jan  9 15:41:58 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_proplib.c,v 1.4 2012/01/09 15:40:10 dholland Exp $	*/
+/*	$NetBSD: quota_proplib.c,v 1.5 2012/01/09 15:41:58 dholland Exp $	*/
 /*-
   * Copyright (c) 2011 Manuel Bouyer
   * All rights reserved.
@@ -26,7 +26,7 @@
   */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: quota_proplib.c,v 1.4 2012/01/09 15:40:10 dholland Exp $);
+__RCSID($NetBSD: quota_proplib.c,v 1.5 2012/01/09 15:41:58 dholland Exp $);
 
 #include stdlib.h
 #include string.h
@@ -55,7 +55,7 @@ struct proplib_quotacursor {
 	unsigned didblocks;
 };
 
-static int
+int
 __quota_proplib_getversion(struct quotahandle *qh, int8_t *version_ret)
 {
 	const char *idtype;

Index: src/lib/libquota/quota_cursor.c
diff -u src/lib/libquota/quota_cursor.c:1.2 src/lib/libquota/quota_cursor.c:1.3
--- src/lib/libquota/quota_cursor.c:1.2	Mon Jan  9 15:40:10 2012
+++ src/lib/libquota/quota_cursor.c	Mon Jan  9 15:41:58 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_cursor.c,v 1.2 2012/01/09 15:40:10 dholland Exp $	*/
+/*	$NetBSD: quota_cursor.c,v 1.3 2012/01/09 15:41:58 dholland Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: quota_cursor.c,v 1.2 2012/01/09 15:40:10 dholland Exp $);
+__RCSID($NetBSD: quota_cursor.c,v 1.3 2012/01/09 15:41:58 dholland Exp $);
 
 #include stdlib.h
 #include errno.h
@@ -41,6 +41,7 @@ struct quotacursor *
 quota_opencursor(struct quotahandle *qh)
 {
 	struct quotacursor *qc;
+	int8_t version;
 	int serrno;
 
 	if (qh-qh_isnfs) {
@@ -48,19 +49,45 @@ quota_opencursor(struct quotahandle *qh)
 		return NULL;
 	}
 
+	if (__quota_proplib_getversion(qh, version)) {
+		return NULL;
+	}
+
+	/*
+	 * For the time being at least the version 1 kernel code
+	 * cannot do cursors.
+	 */
+	if (version == 1  !qh-qh_hasoldfiles) {
+		if (__quota_oldfiles_initialize(qh)) {
+			return NULL;
+		}
+	}
+
 	qc = malloc(sizeof(*qc));
 	if (qc == NULL) {
 		return NULL;
 	}
 
 	qc-qc_qh = qh;
-	qc-u.qc_proplib = __quota_proplib_cursor_create();
 
-	if (qc-u.qc_proplib == NULL) {
-		serrno = errno;
-		free(qc);
-		errno = serrno;
-		return NULL;
+	if (version == 1) {
+		qc-qc_type = QC_OLDFILES;
+		qc-u.qc_oldfiles = __quota_oldfiles_cursor_create(qh);
+		if (qc-u.qc_oldfiles == NULL) {
+			serrno = errno;
+			free(qc);
+			errno = serrno;
+			return NULL;
+		}
+	} else {
+		qc-qc_type = QC_PROPLIB;
+		qc-u.qc_proplib = __quota_proplib_cursor_create();
+		if (qc-u.qc_proplib == NULL) {
+			serrno = errno;
+			free(qc);
+			errno = serrno;
+			return NULL;
+		}
 	}
 	return qc;
 }
@@ -68,22 +95,47 @@ quota_opencursor(struct quotahandle *qh)
 void
 quotacursor_close(struct quotacursor *qc)
 {
-	__quota_proplib_cursor_destroy(qc-u.qc_proplib);
+	switch (qc-qc_type) {
+	case QC_PROPLIB:
+		__quota_proplib_cursor_destroy(qc-u.qc_proplib);
+		break;
+	case QC_OLDFILES:
+		__quota_oldfiles_cursor_destroy(qc-u.qc_oldfiles);
+		break;
+	}
 	free(qc);
 }
 
 int
 quotacursor_skipidtype(struct quotacursor *qc, unsigned idtype)
 {
-	return __quota_proplib_cursor_skipidtype(qc-u.qc_proplib, idtype);
+	switch (qc-qc_type) {
+	case 

CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: quota_delete.c quota_proplib.c quota_put.c quotapvt.h

Log Message:
Implement quota_put() and quota_delete() using code from edquota(8).


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libquota/quota_delete.c \
src/lib/libquota/quota_put.c
cvs rdiff -u -r1.5 -r1.6 src/lib/libquota/quota_proplib.c
cvs rdiff -u -r1.6 -r1.7 src/lib/libquota/quotapvt.h

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

Modified files:

Index: src/lib/libquota/quota_delete.c
diff -u src/lib/libquota/quota_delete.c:1.1 src/lib/libquota/quota_delete.c:1.2
--- src/lib/libquota/quota_delete.c:1.1	Mon Jan  9 15:22:38 2012
+++ src/lib/libquota/quota_delete.c	Mon Jan  9 15:43:19 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_delete.c,v 1.1 2012/01/09 15:22:38 dholland Exp $	*/
+/*	$NetBSD: quota_delete.c,v 1.2 2012/01/09 15:43:19 dholland Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,16 +29,20 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: quota_delete.c,v 1.1 2012/01/09 15:22:38 dholland Exp $);
+__RCSID($NetBSD: quota_delete.c,v 1.2 2012/01/09 15:43:19 dholland Exp $);
 
 #include errno.h
 
 #include quota.h
+#include quotapvt.h
 
-/* ARGSUSED */
 int
 quota_delete(struct quotahandle *qh, const struct quotakey *qk)
 {
-	errno = ENOSYS;
-	return -1;
+	if (qh-qh_isnfs) {
+		errno = EOPNOTSUPP;
+		return -1;
+	} else {
+		return __quota_proplib_delete(qh, qk);
+	}
 }
Index: src/lib/libquota/quota_put.c
diff -u src/lib/libquota/quota_put.c:1.1 src/lib/libquota/quota_put.c:1.2
--- src/lib/libquota/quota_put.c:1.1	Mon Jan  9 15:22:38 2012
+++ src/lib/libquota/quota_put.c	Mon Jan  9 15:43:19 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_put.c,v 1.1 2012/01/09 15:22:38 dholland Exp $	*/
+/*	$NetBSD: quota_put.c,v 1.2 2012/01/09 15:43:19 dholland Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,17 +29,21 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: quota_put.c,v 1.1 2012/01/09 15:22:38 dholland Exp $);
+__RCSID($NetBSD: quota_put.c,v 1.2 2012/01/09 15:43:19 dholland Exp $);
 
 #include errno.h
 
 #include quota.h
+#include quotapvt.h
 
-/* ARGSUSED */
 int
 quota_put(struct quotahandle *qh, const struct quotakey *qk,
 	  const struct quotaval *qv)
 {
-	errno = ENOSYS;
-	return -1;
+	if (qh-qh_isnfs) {
+		errno = EOPNOTSUPP;
+		return -1;
+	} else {
+		return __quota_proplib_put(qh, qk, qv);
+	}
 }

Index: src/lib/libquota/quota_proplib.c
diff -u src/lib/libquota/quota_proplib.c:1.5 src/lib/libquota/quota_proplib.c:1.6
--- src/lib/libquota/quota_proplib.c:1.5	Mon Jan  9 15:41:58 2012
+++ src/lib/libquota/quota_proplib.c	Mon Jan  9 15:43:19 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_proplib.c,v 1.5 2012/01/09 15:41:58 dholland Exp $	*/
+/*	$NetBSD: quota_proplib.c,v 1.6 2012/01/09 15:43:19 dholland Exp $	*/
 /*-
   * Copyright (c) 2011 Manuel Bouyer
   * All rights reserved.
@@ -26,7 +26,7 @@
   */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: quota_proplib.c,v 1.5 2012/01/09 15:41:58 dholland Exp $);
+__RCSID($NetBSD: quota_proplib.c,v 1.6 2012/01/09 15:43:19 dholland Exp $);
 
 #include stdlib.h
 #include string.h
@@ -468,6 +468,239 @@ __quota_proplib_get(struct quotahandle *
 	return 0;
 }
 
+int
+__quota_proplib_put(struct quotahandle *qh, const struct quotakey *qk,
+		const struct quotaval *qv)
+{
+	prop_dictionary_t dict, data, cmd;
+	prop_array_t cmds, datas;
+	struct plistref pref;
+	int8_t error8;
+	uint64_t *valuesp[QUOTA_NLIMITS];
+	const char *idtype;
+	unsigned limitcode, otherlimitcode;
+	unsigned otherobjtype;
+	struct quotakey qk2;
+	struct quotaval qv2;
+
+	switch (qk-qk_idtype) {
+	case QUOTA_IDTYPE_USER:
+		idtype = ufs_quota_class_names[QUOTA_CLASS_USER];
+		break;
+	case QUOTA_IDTYPE_GROUP:
+		idtype = ufs_quota_class_names[QUOTA_CLASS_GROUP];
+		break;
+	default:
+		errno = EINVAL;
+		return -1;
+	}
+
+	switch (qk-qk_objtype) {
+	case QUOTA_OBJTYPE_BLOCKS:
+		limitcode = QUOTA_LIMIT_BLOCK;
+		otherlimitcode = QUOTA_LIMIT_FILE;
+		otherobjtype = QUOTA_OBJTYPE_FILES;
+		break;
+	case QUOTA_OBJTYPE_FILES:
+		limitcode = QUOTA_LIMIT_FILE;
+		otherlimitcode = QUOTA_LIMIT_BLOCK;
+		otherobjtype = QUOTA_OBJTYPE_BLOCKS;
+		break;
+	default:
+		errno = EINVAL;
+		return -1;
+	}
+
+	/* XXX in addition to being invalid/unsafe this also discards const */
+	valuesp[limitcode] = __UNCONST(qv-qv_hardlimit);
+
+	/*
+	 * You cannot set just the block info or just the file info.
+	 * You have to set both together, or EINVAL comes back. So we
+	 * have to fetch the current values for the other object type,
+	 * and stuff both into the RPC packet. Blah. XXX.
+	 */
+	qk2.qk_idtype = qk-qk_idtype;
+	qk2.qk_id = qk-qk_id;
+	qk2.qk_objtype = otherobjtype;
+	if (__quota_proplib_get(qh, qk2, qv2)) {
+		if (errno == 

CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: quota_oldfiles.c quotapvt.h

Log Message:
Implement quota_put and quota_delete for the fallback direct file
access backend.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libquota/quota_oldfiles.c
cvs rdiff -u -r1.7 -r1.8 src/lib/libquota/quotapvt.h

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

Modified files:

Index: src/lib/libquota/quota_oldfiles.c
diff -u src/lib/libquota/quota_oldfiles.c:1.1 src/lib/libquota/quota_oldfiles.c:1.2
--- src/lib/libquota/quota_oldfiles.c:1.1	Mon Jan  9 15:41:58 2012
+++ src/lib/libquota/quota_oldfiles.c	Mon Jan  9 15:45:19 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_oldfiles.c,v 1.1 2012/01/09 15:41:58 dholland Exp $	*/
+/*	$NetBSD: quota_oldfiles.c,v 1.2 2012/01/09 15:45:19 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -64,7 +64,7 @@ struct oldfiles_quotacursor {
 };
 
 static uint64_t
-dqblk_limit(uint32_t val)
+dqblk_getlimit(uint32_t val)
 {
 	if (val == 0) {
 		return QUOTA_NOLIMIT;
@@ -73,11 +73,21 @@ dqblk_limit(uint32_t val)
 	}
 }
 
+static uint32_t
+dqblk_setlimit(uint64_t val)
+{
+	if (val == QUOTA_NOLIMIT  val = 0xUL) {
+		return 0;
+	} else {
+		return (uint32_t)val + 1;
+	}
+}
+
 static void
 dqblk_getblocks(const struct dqblk *dq, struct quotaval *qv)
 {
-	qv-qv_hardlimit = dqblk_limit(dq-dqb_bhardlimit);
-	qv-qv_softlimit = dqblk_limit(dq-dqb_bsoftlimit);
+	qv-qv_hardlimit = dqblk_getlimit(dq-dqb_bhardlimit);
+	qv-qv_softlimit = dqblk_getlimit(dq-dqb_bsoftlimit);
 	qv-qv_usage = dq-dqb_curblocks;
 	qv-qv_expiretime = dq-dqb_btime;
 	qv-qv_grace = QUOTA_NOTIME;
@@ -86,13 +96,33 @@ dqblk_getblocks(const struct dqblk *dq, 
 static void
 dqblk_getfiles(const struct dqblk *dq, struct quotaval *qv)
 {
-	qv-qv_hardlimit = dqblk_limit(dq-dqb_ihardlimit);
-	qv-qv_softlimit = dqblk_limit(dq-dqb_isoftlimit);
+	qv-qv_hardlimit = dqblk_getlimit(dq-dqb_ihardlimit);
+	qv-qv_softlimit = dqblk_getlimit(dq-dqb_isoftlimit);
 	qv-qv_usage = dq-dqb_curinodes;
 	qv-qv_expiretime = dq-dqb_itime;
 	qv-qv_grace = QUOTA_NOTIME;
 }
 
+static void
+dqblk_putblocks(const struct quotaval *qv, struct dqblk *dq)
+{
+	dq-dqb_bhardlimit = dqblk_setlimit(qv-qv_hardlimit);
+	dq-dqb_bsoftlimit = dqblk_setlimit(qv-qv_softlimit);
+	dq-dqb_curblocks = qv-qv_usage;
+	dq-dqb_btime = qv-qv_expiretime;
+	/* ignore qv-qv_grace */
+}
+
+static void
+dqblk_putfiles(const struct quotaval *qv, struct dqblk *dq)
+{
+	dq-dqb_ihardlimit = dqblk_setlimit(qv-qv_hardlimit);
+	dq-dqb_isoftlimit = dqblk_setlimit(qv-qv_softlimit);
+	dq-dqb_curinodes = qv-qv_usage;
+	dq-dqb_itime = qv-qv_expiretime;
+	/* ignore qv-qv_grace */
+}
+
 static int
 __quota_oldfiles_open(struct quotahandle *qh, const char *path, int *fd_ret)
 {
@@ -249,8 +279,11 @@ __quota_oldfiles_doget(struct quotahandl
 	result = pread(file, dq, sizeof(dq), pos);
 	if (result  0) {
 		return -1;
-	}
-	if ((size_t)result != sizeof(dq)) {
+	} else if (result == 0) {
+		/* Past EOF; no quota info on file for this ID */
+		errno = ENOENT;
+		return -1;
+	} else if ((size_t)result != sizeof(dq)) {
 		errno = EFTYPE;
 		return -1;
 	}
@@ -296,6 +329,112 @@ __quota_oldfiles_doget(struct quotahandl
 	return 0;
 }
 
+static int
+__quota_oldfiles_doput(struct quotahandle *qh, const struct quotakey *qk,
+		   const struct quotaval *qv)
+{
+	int file;
+	off_t pos;
+	struct quotaval qv2;
+	struct dqblk dq;
+	ssize_t result;
+
+	switch (qk-qk_idtype) {
+	case QUOTA_IDTYPE_USER:
+		file = qh-qh_userfile;
+		break;
+	case QUOTA_IDTYPE_GROUP:
+		file = qh-qh_groupfile;
+		break;
+	default:
+		errno = EINVAL;
+		return -1;
+	}
+
+	if (qk-qk_id == QUOTA_DEFAULTID) {
+		pos = 0;
+	} else {
+		pos = qk-qk_id * sizeof(struct dqblk);
+	}
+
+	result = pread(file, dq, sizeof(dq), pos);
+	if (result  0) {
+		return -1;
+	} else if (result == 0) {
+		/* Past EOF; fill in a blank dq to start from */
+		dq.dqb_bhardlimit = 0;
+		dq.dqb_bsoftlimit = 0;
+		dq.dqb_curblocks = 0;
+		dq.dqb_ihardlimit = 0;
+		dq.dqb_isoftlimit = 0;
+		dq.dqb_curinodes = 0;
+		dq.dqb_btime = 0;
+		dq.dqb_itime = 0;
+	} else if ((size_t)result != sizeof(dq)) {
+		errno = EFTYPE;
+		return -1;
+	}
+
+	switch (qk-qk_objtype) {
+	case QUOTA_OBJTYPE_BLOCKS:
+		dqblk_getblocks(dq, qv2);
+		break;
+	case QUOTA_OBJTYPE_FILES:
+		dqblk_getfiles(dq, qv2);
+		break;
+	default:
+		errno = EINVAL;
+		return -1;
+	}
+
+	if (qk-qk_id == QUOTA_DEFAULTID) {
+		qv2.qv_hardlimit = qv-qv_hardlimit;
+		qv2.qv_softlimit = qv-qv_softlimit;
+		/* leave qv2.qv_usage unchanged */
+		qv2.qv_expiretime = qv-qv_grace;
+		/* skip qv2.qv_grace */
+
+		/* ignore qv-qv_usage */
+		/* ignore qv-qv_expiretime */
+	} else if (qk-qk_id == 0) {
+		/* leave qv2.qv_hardlimit unchanged */
+		/* leave qv2.qv_softlimit unchanged */
+		qv2.qv_usage = qv-qv_usage;
+		/* leave 

CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: Makefile
Added Files:
src/lib/libquota: quota_cursor.c quota_delete.c quota_get.c
quota_open.c quota_put.c quota_schema.c

Log Message:
Add stub entry points of the entire new quota interface. These fail or
do nothing for the time being; however, putting them all in up front
avoids the need to do multiple bumps of the libquota.so version.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libquota/Makefile
cvs rdiff -u -r0 -r1.1 src/lib/libquota/quota_cursor.c \
src/lib/libquota/quota_delete.c src/lib/libquota/quota_get.c \
src/lib/libquota/quota_open.c src/lib/libquota/quota_put.c \
src/lib/libquota/quota_schema.c

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



CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: Makefile quota_get.c quota_open.c
Added Files:
src/lib/libquota: quota_proplib.c quotapvt.h

Log Message:
Add initial versions of quota_open(), quota_close(), quota_get(),
calling proplib code mostly taken from getufsquota().

Correct the proplib refcount handling in the code from getufsquota(),
where it was (as far as I can tell) wrong.

Avoid doing illegal and unsafe casts from (struct quotaval *)
to (uint64_t *).


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libquota/Makefile
cvs rdiff -u -r1.1 -r1.2 src/lib/libquota/quota_get.c \
src/lib/libquota/quota_open.c
cvs rdiff -u -r0 -r1.1 src/lib/libquota/quota_proplib.c \
src/lib/libquota/quotapvt.h

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



CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: getufsquota.c

Log Message:
Rework getufsquota() in terms of the new quota API.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libquota/getufsquota.c

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



CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: Makefile quota_get.c quota_open.c quotapvt.h
Added Files:
src/lib/libquota: quota_nfs.c

Log Message:
Add quota_nfs.c and implement quota_get() for nfs, using
code from getnfsquota().

Also implement quota_getmountdevice().


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libquota/Makefile
cvs rdiff -u -r1.2 -r1.3 src/lib/libquota/quota_get.c \
src/lib/libquota/quota_open.c
cvs rdiff -u -r0 -r1.1 src/lib/libquota/quota_nfs.c
cvs rdiff -u -r1.1 -r1.2 src/lib/libquota/quotapvt.h

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



CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: getfsquota.c getnfsquota.c getufsquota.c quotapvt.h

Log Message:
Redo getfsquota() and getnfsquota() using the new API.

Change the previous getufsquota() to __quota_getquota() and call it
from all three functions: getfsquota(), getufsquota(), and getnfsquota().


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libquota/getfsquota.c
cvs rdiff -u -r1.4 -r1.5 src/lib/libquota/getnfsquota.c
cvs rdiff -u -r1.5 -r1.6 src/lib/libquota/getufsquota.c
cvs rdiff -u -r1.2 -r1.3 src/lib/libquota/quotapvt.h

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



CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: quota_proplib.c

Log Message:
Handle default ID case in quota_get(), based on logic found in
/usr/bin/quota.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libquota/quota_proplib.c

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



CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: quota_proplib.c quota_schema.c quotapvt.h

Log Message:
Implement the schema-related functions, using proplib code from
/usr/bin/quota.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libquota/quota_proplib.c
cvs rdiff -u -r1.1 -r1.2 src/lib/libquota/quota_schema.c
cvs rdiff -u -r1.3 -r1.4 src/lib/libquota/quotapvt.h

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



CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: quota_cursor.c quota_proplib.c quotapvt.h

Log Message:
Implement the libquota cursor interface, using proplib code from repquota.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libquota/quota_cursor.c
cvs rdiff -u -r1.3 -r1.4 src/lib/libquota/quota_proplib.c
cvs rdiff -u -r1.4 -r1.5 src/lib/libquota/quotapvt.h

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



CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: Makefile quota_cursor.c quota_open.c quota_proplib.c
quotapvt.h
Added Files:
src/lib/libquota: quota_oldfiles.c

Log Message:
Implement fallback direct access to quota1-type quota files.
Uses (mostly) code from repquota. Add some missing pieces that
weren't in repquota.

Use the direct file access code for cursors if proplib reports the
quota version is 1.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libquota/Makefile \
src/lib/libquota/quota_proplib.c
cvs rdiff -u -r1.2 -r1.3 src/lib/libquota/quota_cursor.c
cvs rdiff -u -r0 -r1.1 src/lib/libquota/quota_oldfiles.c
cvs rdiff -u -r1.3 -r1.4 src/lib/libquota/quota_open.c
cvs rdiff -u -r1.5 -r1.6 src/lib/libquota/quotapvt.h

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



CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: quota_delete.c quota_proplib.c quota_put.c quotapvt.h

Log Message:
Implement quota_put() and quota_delete() using code from edquota(8).


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libquota/quota_delete.c \
src/lib/libquota/quota_put.c
cvs rdiff -u -r1.5 -r1.6 src/lib/libquota/quota_proplib.c
cvs rdiff -u -r1.6 -r1.7 src/lib/libquota/quotapvt.h

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



CVS commit: src/lib/libquota

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

Modified Files:
src/lib/libquota: quota_oldfiles.c quotapvt.h

Log Message:
Implement quota_put and quota_delete for the fallback direct file
access backend.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libquota/quota_oldfiles.c
cvs rdiff -u -r1.7 -r1.8 src/lib/libquota/quotapvt.h

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