Sun Aug 10 06:52:15 2014 UTC ()
Rebase.


(tls)
diff -r1.4 -r1.4.18.1 src/lib/libquota/quota_kernel.c
diff -r1.2 -r1.2.18.1 src/lib/libquota/quota_nfs.c

cvs diff -r1.4 -r1.4.18.1 src/lib/libquota/quota_kernel.c (expand / switch to unified diff)

--- src/lib/libquota/quota_kernel.c 2012/02/01 06:19:05 1.4
+++ src/lib/libquota/quota_kernel.c 2014/08/10 06:52:15 1.4.18.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: quota_kernel.c,v 1.4 2012/02/01 06:19:05 dholland Exp $ */ 1/* $NetBSD: quota_kernel.c,v 1.4.18.1 2014/08/10 06:52:15 tls Exp $ */
2/*- 2/*-
3 * Copyright (c) 2012 The NetBSD Foundation, Inc. 3 * Copyright (c) 2012 The NetBSD Foundation, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * This code is derived from software contributed to The NetBSD Foundation 6 * This code is derived from software contributed to The NetBSD Foundation
7 * by David A. Holland. 7 * by David A. Holland.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -19,27 +19,27 @@ @@ -19,27 +19,27 @@
19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE. 28 * POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31#include <sys/cdefs.h> 31#include <sys/cdefs.h>
32__RCSID("$NetBSD: quota_kernel.c,v 1.4 2012/02/01 06:19:05 dholland Exp $"); 32__RCSID("$NetBSD: quota_kernel.c,v 1.4.18.1 2014/08/10 06:52:15 tls Exp $");
33 33
34#include <stdlib.h> 34#include <stdlib.h>
35#include <err.h> 35#include <err.h>
36#include <errno.h> 36#include <errno.h>
37#include <limits.h> 37#include <limits.h>
38 38
39#include <quota.h> 39#include <quota.h>
40#include <sys/quotactl.h> 40#include <sys/quotactl.h>
41 41
42#include "quotapvt.h" 42#include "quotapvt.h"
43 43
44struct kernel_quotacursor { 44struct kernel_quotacursor {
45 /* just wrap the kernel interface type */ 45 /* just wrap the kernel interface type */
@@ -210,28 +210,28 @@ __quota_kernel_put(struct quotahandle *q @@ -210,28 +210,28 @@ __quota_kernel_put(struct quotahandle *q
210 struct quotactl_args args; 210 struct quotactl_args args;
211 211
212 args.qc_op = QUOTACTL_PUT; 212 args.qc_op = QUOTACTL_PUT;
213 args.u.put.qc_key = qk; 213 args.u.put.qc_key = qk;
214 args.u.put.qc_val = qv; 214 args.u.put.qc_val = qv;
215 return __quotactl(qh->qh_mountpoint, &args); 215 return __quotactl(qh->qh_mountpoint, &args);
216} 216}
217 217
218int 218int
219__quota_kernel_delete(struct quotahandle *qh, const struct quotakey *qk) 219__quota_kernel_delete(struct quotahandle *qh, const struct quotakey *qk)
220{ 220{
221 struct quotactl_args args; 221 struct quotactl_args args;
222 222
223 args.qc_op = QUOTACTL_DELETE; 223 args.qc_op = QUOTACTL_DEL;
224 args.u.delete.qc_key = qk; 224 args.u.del.qc_key = qk;
225 return __quotactl(qh->qh_mountpoint, &args); 225 return __quotactl(qh->qh_mountpoint, &args);
226} 226}
227 227
228struct kernel_quotacursor * 228struct kernel_quotacursor *
229__quota_kernel_cursor_create(struct quotahandle *qh) 229__quota_kernel_cursor_create(struct quotahandle *qh)
230{ 230{
231 struct quotactl_args args; 231 struct quotactl_args args;
232 struct kernel_quotacursor *cursor; 232 struct kernel_quotacursor *cursor;
233 int sverrno; 233 int sverrno;
234 234
235 cursor = malloc(sizeof(*cursor)); 235 cursor = malloc(sizeof(*cursor));
236 if (cursor == NULL) { 236 if (cursor == NULL) {
237 return NULL; 237 return NULL;

cvs diff -r1.2 -r1.2.18.1 src/lib/libquota/quota_nfs.c (expand / switch to unified diff)

--- src/lib/libquota/quota_nfs.c 2012/01/30 06:39:26 1.2
+++ src/lib/libquota/quota_nfs.c 2014/08/10 06:52:15 1.2.18.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: quota_nfs.c,v 1.2 2012/01/30 06:39:26 dholland Exp $ */ 1/* $NetBSD: quota_nfs.c,v 1.2.18.1 2014/08/10 06:52:15 tls Exp $ */
2/*- 2/*-
3 * Copyright (c) 2011 Manuel Bouyer 3 * Copyright (c) 2011 Manuel Bouyer
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -16,27 +16,27 @@ @@ -16,27 +16,27 @@
16 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 16 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE. 25 * POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28#include <sys/cdefs.h> 28#include <sys/cdefs.h>
29__RCSID("$NetBSD: quota_nfs.c,v 1.2 2012/01/30 06:39:26 dholland Exp $"); 29__RCSID("$NetBSD: quota_nfs.c,v 1.2.18.1 2014/08/10 06:52:15 tls Exp $");
30 30
31#include <sys/types.h> 31#include <sys/types.h>
32#include <sys/param.h> /* XXX for DEV_BSIZE */ 32#include <sys/param.h> /* XXX for DEV_BSIZE */
33#include <stdlib.h> 33#include <stdlib.h>
34#include <string.h> 34#include <string.h>
35#include <limits.h> 35#include <limits.h>
36#include <netdb.h> 36#include <netdb.h>
37#include <errno.h> 37#include <errno.h>
38 38
39#include <rpc/rpc.h> 39#include <rpc/rpc.h>
40#include <rpc/pmap_prot.h> 40#include <rpc/pmap_prot.h>
41#include <rpcsvc/rquota.h> 41#include <rpcsvc/rquota.h>
42 42
@@ -181,26 +181,40 @@ __quota_nfs_get(struct quotahandle *qh,  @@ -181,26 +181,40 @@ __quota_nfs_get(struct quotahandle *qh,
181 &ext_gq_args, (xdrproc_t)xdr_getquota_rslt, &gq_rslt); 181 &ext_gq_args, (xdrproc_t)xdr_getquota_rslt, &gq_rslt);
182 if (ret == RPC_PROGVERSMISMATCH && rpcqtype == RQUOTA_USRQUOTA) { 182 if (ret == RPC_PROGVERSMISMATCH && rpcqtype == RQUOTA_USRQUOTA) {
183 /* try RQUOTAVERS */ 183 /* try RQUOTAVERS */
184 gq_args.gqa_pathp = path; 184 gq_args.gqa_pathp = path;
185 gq_args.gqa_uid = qk->qk_id; 185 gq_args.gqa_uid = qk->qk_id;
186 ret = callaurpc(host, RQUOTAPROG, RQUOTAVERS, 186 ret = callaurpc(host, RQUOTAPROG, RQUOTAVERS,
187 RQUOTAPROC_GETQUOTA, (xdrproc_t)xdr_getquota_args, 187 RQUOTAPROC_GETQUOTA, (xdrproc_t)xdr_getquota_args,
188 &gq_args, (xdrproc_t)xdr_getquota_rslt, &gq_rslt); 188 &gq_args, (xdrproc_t)xdr_getquota_rslt, &gq_rslt);
189 } 189 }
190 sverrno = errno; 190 sverrno = errno;
191 free(host); 191 free(host);
192 192
193 if (ret != RPC_SUCCESS) { 193 if (ret != RPC_SUCCESS) {
 194 /*
 195 * Remap some error codes for callers convenience:
 196 * - if the file server does not support any quotas at all,
 197 * return ENOENT
 198 * - if the server can not be reached something is very
 199 * wrong - or we are run inside a virtual rump network
 200 * but querying an NFS mount from the host. Make sure
 201 * to fail silently and return ENOENT as well.
 202 */
 203 if (ret == RPC_SYSTEMERROR
 204 && rpc_createerr.cf_error.re_errno == EHOSTUNREACH)
 205 sverrno = ENOENT;
 206 else if (sverrno == ENOTCONN)
 207 sverrno = ENOENT;
194 errno = sverrno; 208 errno = sverrno;
195 return -1; 209 return -1;
196 } 210 }
197 211
198 switch (gq_rslt.status) { 212 switch (gq_rslt.status) {
199 case Q_NOQUOTA: 213 case Q_NOQUOTA:
200 quotaval_clear(qv); 214 quotaval_clear(qv);
201 return 0; 215 return 0;
202 case Q_EPERM: 216 case Q_EPERM:
203 errno = EACCES; 217 errno = EACCES;
204 return -1; 218 return -1;
205 case Q_OK: 219 case Q_OK:
206 rquota_to_quotavals(&gq_rslt.getquota_rslt_u.gqr_rquota, 220 rquota_to_quotavals(&gq_rslt.getquota_rslt_u.gqr_rquota,