| @@ -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, |