nfs_nfsdsubs.c revision 1.1 1 1.1 dholland /* $NetBSD: nfs_nfsdsubs.c,v 1.1 2013/09/30 07:19:49 dholland Exp $ */
2 1.1 dholland /*-
3 1.1 dholland * Copyright (c) 1989, 1993
4 1.1 dholland * The Regents of the University of California. All rights reserved.
5 1.1 dholland *
6 1.1 dholland * This code is derived from software contributed to Berkeley by
7 1.1 dholland * Rick Macklem at The University of Guelph.
8 1.1 dholland *
9 1.1 dholland * Redistribution and use in source and binary forms, with or without
10 1.1 dholland * modification, are permitted provided that the following conditions
11 1.1 dholland * are met:
12 1.1 dholland * 1. Redistributions of source code must retain the above copyright
13 1.1 dholland * notice, this list of conditions and the following disclaimer.
14 1.1 dholland * 2. Redistributions in binary form must reproduce the above copyright
15 1.1 dholland * notice, this list of conditions and the following disclaimer in the
16 1.1 dholland * documentation and/or other materials provided with the distribution.
17 1.1 dholland * 4. Neither the name of the University nor the names of its contributors
18 1.1 dholland * may be used to endorse or promote products derived from this software
19 1.1 dholland * without specific prior written permission.
20 1.1 dholland *
21 1.1 dholland * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 1.1 dholland * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 1.1 dholland * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 1.1 dholland * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 1.1 dholland * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 1.1 dholland * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 1.1 dholland * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 1.1 dholland * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 1.1 dholland * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 1.1 dholland * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 1.1 dholland * SUCH DAMAGE.
32 1.1 dholland *
33 1.1 dholland */
34 1.1 dholland
35 1.1 dholland #include <sys/cdefs.h>
36 1.1 dholland /* __FBSDID("FreeBSD: head/sys/fs/nfsserver/nfs_nfsdsubs.c 228260 2011-12-04 16:33:04Z rmacklem "); */
37 1.1 dholland __RCSID("$NetBSD: nfs_nfsdsubs.c,v 1.1 2013/09/30 07:19:49 dholland Exp $");
38 1.1 dholland
39 1.1 dholland #ifndef APPLEKEXT
40 1.1 dholland /*
41 1.1 dholland * These functions support the macros and help fiddle mbuf chains for
42 1.1 dholland * the nfs op functions. They do things like create the rpc header and
43 1.1 dholland * copy data between mbuf chains and uio lists.
44 1.1 dholland */
45 1.1 dholland #include <fs/nfs/nfsport.h>
46 1.1 dholland
47 1.1 dholland extern u_int32_t newnfs_true, newnfs_false;
48 1.1 dholland extern int nfs_pubfhset;
49 1.1 dholland extern struct nfsclienthashhead nfsclienthash[NFSCLIENTHASHSIZE];
50 1.1 dholland extern struct nfslockhashhead nfslockhash[NFSLOCKHASHSIZE];
51 1.1 dholland extern int nfsrv_useacl;
52 1.1 dholland extern uid_t nfsrv_defaultuid;
53 1.1 dholland extern gid_t nfsrv_defaultgid;
54 1.1 dholland
55 1.1 dholland char nfs_v2pubfh[NFSX_V2FH];
56 1.1 dholland static nfstype newnfsv2_type[9] = { NFNON, NFREG, NFDIR, NFBLK, NFCHR, NFLNK,
57 1.1 dholland NFNON, NFCHR, NFNON };
58 1.1 dholland extern nfstype nfsv34_type[9];
59 1.1 dholland #endif /* !APPLEKEXT */
60 1.1 dholland
61 1.1 dholland SYSCTL_DECL(_vfs_nfsd);
62 1.1 dholland
63 1.1 dholland static int disable_checkutf8 = 0;
64 1.1 dholland SYSCTL_INT(_vfs_nfsd, OID_AUTO, disable_checkutf8, CTLFLAG_RW,
65 1.1 dholland &disable_checkutf8, 0,
66 1.1 dholland "Disable the NFSv4 check for a UTF8 compliant name");
67 1.1 dholland
68 1.1 dholland static char nfsrv_hexdigit(char, int *);
69 1.1 dholland
70 1.1 dholland /*
71 1.1 dholland * Maps errno values to nfs error numbers.
72 1.1 dholland * Use NFSERR_IO as the catch all for ones not specifically defined in
73 1.1 dholland * RFC 1094.
74 1.1 dholland */
75 1.1 dholland static u_char nfsrv_v2errmap[ELAST] = {
76 1.1 dholland NFSERR_PERM, NFSERR_NOENT, NFSERR_IO, NFSERR_IO, NFSERR_IO,
77 1.1 dholland NFSERR_NXIO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
78 1.1 dholland NFSERR_IO, NFSERR_IO, NFSERR_ACCES, NFSERR_IO, NFSERR_IO,
79 1.1 dholland NFSERR_IO, NFSERR_EXIST, NFSERR_IO, NFSERR_NODEV, NFSERR_NOTDIR,
80 1.1 dholland NFSERR_ISDIR, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
81 1.1 dholland NFSERR_IO, NFSERR_FBIG, NFSERR_NOSPC, NFSERR_IO, NFSERR_ROFS,
82 1.1 dholland NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
83 1.1 dholland NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
84 1.1 dholland NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
85 1.1 dholland NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
86 1.1 dholland NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
87 1.1 dholland NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
88 1.1 dholland NFSERR_IO, NFSERR_IO, NFSERR_NAMETOL, NFSERR_IO, NFSERR_IO,
89 1.1 dholland NFSERR_NOTEMPTY, NFSERR_IO, NFSERR_IO, NFSERR_DQUOT, NFSERR_STALE,
90 1.1 dholland NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
91 1.1 dholland NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
92 1.1 dholland NFSERR_IO,
93 1.1 dholland };
94 1.1 dholland
95 1.1 dholland /*
96 1.1 dholland * Maps errno values to nfs error numbers.
97 1.1 dholland * Although it is not obvious whether or not NFS clients really care if
98 1.1 dholland * a returned error value is in the specified list for the procedure, the
99 1.1 dholland * safest thing to do is filter them appropriately. For Version 2, the
100 1.1 dholland * X/Open XNFS document is the only specification that defines error values
101 1.1 dholland * for each RPC (The RFC simply lists all possible error values for all RPCs),
102 1.1 dholland * so I have decided to not do this for Version 2.
103 1.1 dholland * The first entry is the default error return and the rest are the valid
104 1.1 dholland * errors for that RPC in increasing numeric order.
105 1.1 dholland */
106 1.1 dholland static short nfsv3err_null[] = {
107 1.1 dholland 0,
108 1.1 dholland 0,
109 1.1 dholland };
110 1.1 dholland
111 1.1 dholland static short nfsv3err_getattr[] = {
112 1.1 dholland NFSERR_IO,
113 1.1 dholland NFSERR_IO,
114 1.1 dholland NFSERR_STALE,
115 1.1 dholland NFSERR_BADHANDLE,
116 1.1 dholland NFSERR_SERVERFAULT,
117 1.1 dholland NFSERR_DELAY,
118 1.1 dholland 0,
119 1.1 dholland };
120 1.1 dholland
121 1.1 dholland static short nfsv3err_setattr[] = {
122 1.1 dholland NFSERR_IO,
123 1.1 dholland NFSERR_ACCES,
124 1.1 dholland NFSERR_PERM,
125 1.1 dholland NFSERR_IO,
126 1.1 dholland NFSERR_INVAL,
127 1.1 dholland NFSERR_NOSPC,
128 1.1 dholland NFSERR_ROFS,
129 1.1 dholland NFSERR_DQUOT,
130 1.1 dholland NFSERR_STALE,
131 1.1 dholland NFSERR_BADHANDLE,
132 1.1 dholland NFSERR_NOT_SYNC,
133 1.1 dholland NFSERR_SERVERFAULT,
134 1.1 dholland NFSERR_DELAY,
135 1.1 dholland 0,
136 1.1 dholland };
137 1.1 dholland
138 1.1 dholland static short nfsv3err_lookup[] = {
139 1.1 dholland NFSERR_IO,
140 1.1 dholland NFSERR_NOENT,
141 1.1 dholland NFSERR_ACCES,
142 1.1 dholland NFSERR_NAMETOL,
143 1.1 dholland NFSERR_IO,
144 1.1 dholland NFSERR_NOTDIR,
145 1.1 dholland NFSERR_STALE,
146 1.1 dholland NFSERR_BADHANDLE,
147 1.1 dholland NFSERR_SERVERFAULT,
148 1.1 dholland NFSERR_DELAY,
149 1.1 dholland 0,
150 1.1 dholland };
151 1.1 dholland
152 1.1 dholland static short nfsv3err_access[] = {
153 1.1 dholland NFSERR_IO,
154 1.1 dholland NFSERR_IO,
155 1.1 dholland NFSERR_STALE,
156 1.1 dholland NFSERR_BADHANDLE,
157 1.1 dholland NFSERR_SERVERFAULT,
158 1.1 dholland NFSERR_DELAY,
159 1.1 dholland 0,
160 1.1 dholland };
161 1.1 dholland
162 1.1 dholland static short nfsv3err_readlink[] = {
163 1.1 dholland NFSERR_IO,
164 1.1 dholland NFSERR_IO,
165 1.1 dholland NFSERR_ACCES,
166 1.1 dholland NFSERR_INVAL,
167 1.1 dholland NFSERR_STALE,
168 1.1 dholland NFSERR_BADHANDLE,
169 1.1 dholland NFSERR_NOTSUPP,
170 1.1 dholland NFSERR_SERVERFAULT,
171 1.1 dholland NFSERR_DELAY,
172 1.1 dholland 0,
173 1.1 dholland };
174 1.1 dholland
175 1.1 dholland static short nfsv3err_read[] = {
176 1.1 dholland NFSERR_IO,
177 1.1 dholland NFSERR_IO,
178 1.1 dholland NFSERR_NXIO,
179 1.1 dholland NFSERR_ACCES,
180 1.1 dholland NFSERR_INVAL,
181 1.1 dholland NFSERR_STALE,
182 1.1 dholland NFSERR_BADHANDLE,
183 1.1 dholland NFSERR_SERVERFAULT,
184 1.1 dholland NFSERR_DELAY,
185 1.1 dholland 0,
186 1.1 dholland };
187 1.1 dholland
188 1.1 dholland static short nfsv3err_write[] = {
189 1.1 dholland NFSERR_IO,
190 1.1 dholland NFSERR_IO,
191 1.1 dholland NFSERR_ACCES,
192 1.1 dholland NFSERR_NOSPC,
193 1.1 dholland NFSERR_INVAL,
194 1.1 dholland NFSERR_FBIG,
195 1.1 dholland NFSERR_ROFS,
196 1.1 dholland NFSERR_DQUOT,
197 1.1 dholland NFSERR_STALE,
198 1.1 dholland NFSERR_BADHANDLE,
199 1.1 dholland NFSERR_SERVERFAULT,
200 1.1 dholland NFSERR_DELAY,
201 1.1 dholland 0,
202 1.1 dholland };
203 1.1 dholland
204 1.1 dholland static short nfsv3err_create[] = {
205 1.1 dholland NFSERR_IO,
206 1.1 dholland NFSERR_EXIST,
207 1.1 dholland NFSERR_NAMETOL,
208 1.1 dholland NFSERR_ACCES,
209 1.1 dholland NFSERR_IO,
210 1.1 dholland NFSERR_NOTDIR,
211 1.1 dholland NFSERR_NOSPC,
212 1.1 dholland NFSERR_ROFS,
213 1.1 dholland NFSERR_DQUOT,
214 1.1 dholland NFSERR_STALE,
215 1.1 dholland NFSERR_BADHANDLE,
216 1.1 dholland NFSERR_NOTSUPP,
217 1.1 dholland NFSERR_SERVERFAULT,
218 1.1 dholland NFSERR_DELAY,
219 1.1 dholland 0,
220 1.1 dholland };
221 1.1 dholland
222 1.1 dholland static short nfsv3err_mkdir[] = {
223 1.1 dholland NFSERR_IO,
224 1.1 dholland NFSERR_EXIST,
225 1.1 dholland NFSERR_ACCES,
226 1.1 dholland NFSERR_NAMETOL,
227 1.1 dholland NFSERR_IO,
228 1.1 dholland NFSERR_NOTDIR,
229 1.1 dholland NFSERR_NOSPC,
230 1.1 dholland NFSERR_ROFS,
231 1.1 dholland NFSERR_DQUOT,
232 1.1 dholland NFSERR_STALE,
233 1.1 dholland NFSERR_BADHANDLE,
234 1.1 dholland NFSERR_NOTSUPP,
235 1.1 dholland NFSERR_SERVERFAULT,
236 1.1 dholland NFSERR_DELAY,
237 1.1 dholland 0,
238 1.1 dholland };
239 1.1 dholland
240 1.1 dholland static short nfsv3err_symlink[] = {
241 1.1 dholland NFSERR_IO,
242 1.1 dholland NFSERR_ACCES,
243 1.1 dholland NFSERR_EXIST,
244 1.1 dholland NFSERR_NAMETOL,
245 1.1 dholland NFSERR_NOSPC,
246 1.1 dholland NFSERR_IO,
247 1.1 dholland NFSERR_NOTDIR,
248 1.1 dholland NFSERR_ROFS,
249 1.1 dholland NFSERR_DQUOT,
250 1.1 dholland NFSERR_STALE,
251 1.1 dholland NFSERR_BADHANDLE,
252 1.1 dholland NFSERR_NOTSUPP,
253 1.1 dholland NFSERR_SERVERFAULT,
254 1.1 dholland NFSERR_DELAY,
255 1.1 dholland 0,
256 1.1 dholland };
257 1.1 dholland
258 1.1 dholland static short nfsv3err_mknod[] = {
259 1.1 dholland NFSERR_IO,
260 1.1 dholland NFSERR_ACCES,
261 1.1 dholland NFSERR_EXIST,
262 1.1 dholland NFSERR_NAMETOL,
263 1.1 dholland NFSERR_NOSPC,
264 1.1 dholland NFSERR_IO,
265 1.1 dholland NFSERR_NOTDIR,
266 1.1 dholland NFSERR_ROFS,
267 1.1 dholland NFSERR_DQUOT,
268 1.1 dholland NFSERR_STALE,
269 1.1 dholland NFSERR_BADHANDLE,
270 1.1 dholland NFSERR_NOTSUPP,
271 1.1 dholland NFSERR_SERVERFAULT,
272 1.1 dholland NFSERR_DELAY,
273 1.1 dholland NFSERR_BADTYPE,
274 1.1 dholland 0,
275 1.1 dholland };
276 1.1 dholland
277 1.1 dholland static short nfsv3err_remove[] = {
278 1.1 dholland NFSERR_IO,
279 1.1 dholland NFSERR_NOENT,
280 1.1 dholland NFSERR_ACCES,
281 1.1 dholland NFSERR_NAMETOL,
282 1.1 dholland NFSERR_IO,
283 1.1 dholland NFSERR_NOTDIR,
284 1.1 dholland NFSERR_ROFS,
285 1.1 dholland NFSERR_STALE,
286 1.1 dholland NFSERR_BADHANDLE,
287 1.1 dholland NFSERR_SERVERFAULT,
288 1.1 dholland NFSERR_DELAY,
289 1.1 dholland 0,
290 1.1 dholland };
291 1.1 dholland
292 1.1 dholland static short nfsv3err_rmdir[] = {
293 1.1 dholland NFSERR_IO,
294 1.1 dholland NFSERR_NOENT,
295 1.1 dholland NFSERR_ACCES,
296 1.1 dholland NFSERR_NOTDIR,
297 1.1 dholland NFSERR_NAMETOL,
298 1.1 dholland NFSERR_IO,
299 1.1 dholland NFSERR_EXIST,
300 1.1 dholland NFSERR_INVAL,
301 1.1 dholland NFSERR_ROFS,
302 1.1 dholland NFSERR_NOTEMPTY,
303 1.1 dholland NFSERR_STALE,
304 1.1 dholland NFSERR_BADHANDLE,
305 1.1 dholland NFSERR_NOTSUPP,
306 1.1 dholland NFSERR_SERVERFAULT,
307 1.1 dholland NFSERR_DELAY,
308 1.1 dholland 0,
309 1.1 dholland };
310 1.1 dholland
311 1.1 dholland static short nfsv3err_rename[] = {
312 1.1 dholland NFSERR_IO,
313 1.1 dholland NFSERR_NOENT,
314 1.1 dholland NFSERR_ACCES,
315 1.1 dholland NFSERR_EXIST,
316 1.1 dholland NFSERR_NAMETOL,
317 1.1 dholland NFSERR_XDEV,
318 1.1 dholland NFSERR_IO,
319 1.1 dholland NFSERR_NOTDIR,
320 1.1 dholland NFSERR_ISDIR,
321 1.1 dholland NFSERR_INVAL,
322 1.1 dholland NFSERR_NOSPC,
323 1.1 dholland NFSERR_ROFS,
324 1.1 dholland NFSERR_MLINK,
325 1.1 dholland NFSERR_NOTEMPTY,
326 1.1 dholland NFSERR_DQUOT,
327 1.1 dholland NFSERR_STALE,
328 1.1 dholland NFSERR_BADHANDLE,
329 1.1 dholland NFSERR_NOTSUPP,
330 1.1 dholland NFSERR_SERVERFAULT,
331 1.1 dholland NFSERR_DELAY,
332 1.1 dholland 0,
333 1.1 dholland };
334 1.1 dholland
335 1.1 dholland static short nfsv3err_link[] = {
336 1.1 dholland NFSERR_IO,
337 1.1 dholland NFSERR_ACCES,
338 1.1 dholland NFSERR_EXIST,
339 1.1 dholland NFSERR_NAMETOL,
340 1.1 dholland NFSERR_IO,
341 1.1 dholland NFSERR_XDEV,
342 1.1 dholland NFSERR_NOTDIR,
343 1.1 dholland NFSERR_INVAL,
344 1.1 dholland NFSERR_NOSPC,
345 1.1 dholland NFSERR_ROFS,
346 1.1 dholland NFSERR_MLINK,
347 1.1 dholland NFSERR_DQUOT,
348 1.1 dholland NFSERR_STALE,
349 1.1 dholland NFSERR_BADHANDLE,
350 1.1 dholland NFSERR_NOTSUPP,
351 1.1 dholland NFSERR_SERVERFAULT,
352 1.1 dholland NFSERR_DELAY,
353 1.1 dholland 0,
354 1.1 dholland };
355 1.1 dholland
356 1.1 dholland static short nfsv3err_readdir[] = {
357 1.1 dholland NFSERR_IO,
358 1.1 dholland NFSERR_ACCES,
359 1.1 dholland NFSERR_NOTDIR,
360 1.1 dholland NFSERR_IO,
361 1.1 dholland NFSERR_STALE,
362 1.1 dholland NFSERR_BADHANDLE,
363 1.1 dholland NFSERR_BAD_COOKIE,
364 1.1 dholland NFSERR_TOOSMALL,
365 1.1 dholland NFSERR_SERVERFAULT,
366 1.1 dholland NFSERR_DELAY,
367 1.1 dholland 0,
368 1.1 dholland };
369 1.1 dholland
370 1.1 dholland static short nfsv3err_readdirplus[] = {
371 1.1 dholland NFSERR_IO,
372 1.1 dholland NFSERR_ACCES,
373 1.1 dholland NFSERR_NOTDIR,
374 1.1 dholland NFSERR_IO,
375 1.1 dholland NFSERR_STALE,
376 1.1 dholland NFSERR_BADHANDLE,
377 1.1 dholland NFSERR_BAD_COOKIE,
378 1.1 dholland NFSERR_NOTSUPP,
379 1.1 dholland NFSERR_TOOSMALL,
380 1.1 dholland NFSERR_SERVERFAULT,
381 1.1 dholland NFSERR_DELAY,
382 1.1 dholland 0,
383 1.1 dholland };
384 1.1 dholland
385 1.1 dholland static short nfsv3err_fsstat[] = {
386 1.1 dholland NFSERR_IO,
387 1.1 dholland NFSERR_IO,
388 1.1 dholland NFSERR_STALE,
389 1.1 dholland NFSERR_BADHANDLE,
390 1.1 dholland NFSERR_SERVERFAULT,
391 1.1 dholland NFSERR_DELAY,
392 1.1 dholland 0,
393 1.1 dholland };
394 1.1 dholland
395 1.1 dholland static short nfsv3err_fsinfo[] = {
396 1.1 dholland NFSERR_STALE,
397 1.1 dholland NFSERR_STALE,
398 1.1 dholland NFSERR_BADHANDLE,
399 1.1 dholland NFSERR_SERVERFAULT,
400 1.1 dholland NFSERR_DELAY,
401 1.1 dholland 0,
402 1.1 dholland };
403 1.1 dholland
404 1.1 dholland static short nfsv3err_pathconf[] = {
405 1.1 dholland NFSERR_STALE,
406 1.1 dholland NFSERR_STALE,
407 1.1 dholland NFSERR_BADHANDLE,
408 1.1 dholland NFSERR_SERVERFAULT,
409 1.1 dholland NFSERR_DELAY,
410 1.1 dholland 0,
411 1.1 dholland };
412 1.1 dholland
413 1.1 dholland static short nfsv3err_commit[] = {
414 1.1 dholland NFSERR_IO,
415 1.1 dholland NFSERR_IO,
416 1.1 dholland NFSERR_STALE,
417 1.1 dholland NFSERR_BADHANDLE,
418 1.1 dholland NFSERR_SERVERFAULT,
419 1.1 dholland NFSERR_DELAY,
420 1.1 dholland 0,
421 1.1 dholland };
422 1.1 dholland
423 1.1 dholland static short *nfsrv_v3errmap[] = {
424 1.1 dholland nfsv3err_null,
425 1.1 dholland nfsv3err_getattr,
426 1.1 dholland nfsv3err_setattr,
427 1.1 dholland nfsv3err_lookup,
428 1.1 dholland nfsv3err_access,
429 1.1 dholland nfsv3err_readlink,
430 1.1 dholland nfsv3err_read,
431 1.1 dholland nfsv3err_write,
432 1.1 dholland nfsv3err_create,
433 1.1 dholland nfsv3err_mkdir,
434 1.1 dholland nfsv3err_symlink,
435 1.1 dholland nfsv3err_mknod,
436 1.1 dholland nfsv3err_remove,
437 1.1 dholland nfsv3err_rmdir,
438 1.1 dholland nfsv3err_rename,
439 1.1 dholland nfsv3err_link,
440 1.1 dholland nfsv3err_readdir,
441 1.1 dholland nfsv3err_readdirplus,
442 1.1 dholland nfsv3err_fsstat,
443 1.1 dholland nfsv3err_fsinfo,
444 1.1 dholland nfsv3err_pathconf,
445 1.1 dholland nfsv3err_commit,
446 1.1 dholland };
447 1.1 dholland
448 1.1 dholland /*
449 1.1 dholland * And the same for V4.
450 1.1 dholland */
451 1.1 dholland static short nfsv4err_null[] = {
452 1.1 dholland 0,
453 1.1 dholland 0,
454 1.1 dholland };
455 1.1 dholland
456 1.1 dholland static short nfsv4err_access[] = {
457 1.1 dholland NFSERR_IO,
458 1.1 dholland NFSERR_ACCES,
459 1.1 dholland NFSERR_BADHANDLE,
460 1.1 dholland NFSERR_BADXDR,
461 1.1 dholland NFSERR_DELAY,
462 1.1 dholland NFSERR_FHEXPIRED,
463 1.1 dholland NFSERR_INVAL,
464 1.1 dholland NFSERR_IO,
465 1.1 dholland NFSERR_MOVED,
466 1.1 dholland NFSERR_NOFILEHANDLE,
467 1.1 dholland NFSERR_RESOURCE,
468 1.1 dholland NFSERR_SERVERFAULT,
469 1.1 dholland NFSERR_STALE,
470 1.1 dholland 0,
471 1.1 dholland };
472 1.1 dholland
473 1.1 dholland static short nfsv4err_close[] = {
474 1.1 dholland NFSERR_EXPIRED,
475 1.1 dholland NFSERR_ADMINREVOKED,
476 1.1 dholland NFSERR_BADHANDLE,
477 1.1 dholland NFSERR_BADSEQID,
478 1.1 dholland NFSERR_BADSTATEID,
479 1.1 dholland NFSERR_BADXDR,
480 1.1 dholland NFSERR_DELAY,
481 1.1 dholland NFSERR_EXPIRED,
482 1.1 dholland NFSERR_FHEXPIRED,
483 1.1 dholland NFSERR_INVAL,
484 1.1 dholland NFSERR_ISDIR,
485 1.1 dholland NFSERR_LEASEMOVED,
486 1.1 dholland NFSERR_LOCKSHELD,
487 1.1 dholland NFSERR_MOVED,
488 1.1 dholland NFSERR_NOFILEHANDLE,
489 1.1 dholland NFSERR_OLDSTATEID,
490 1.1 dholland NFSERR_RESOURCE,
491 1.1 dholland NFSERR_SERVERFAULT,
492 1.1 dholland NFSERR_STALE,
493 1.1 dholland NFSERR_STALESTATEID,
494 1.1 dholland 0,
495 1.1 dholland };
496 1.1 dholland
497 1.1 dholland static short nfsv4err_commit[] = {
498 1.1 dholland NFSERR_IO,
499 1.1 dholland NFSERR_ACCES,
500 1.1 dholland NFSERR_BADHANDLE,
501 1.1 dholland NFSERR_BADXDR,
502 1.1 dholland NFSERR_FHEXPIRED,
503 1.1 dholland NFSERR_INVAL,
504 1.1 dholland NFSERR_IO,
505 1.1 dholland NFSERR_ISDIR,
506 1.1 dholland NFSERR_MOVED,
507 1.1 dholland NFSERR_NOFILEHANDLE,
508 1.1 dholland NFSERR_RESOURCE,
509 1.1 dholland NFSERR_ROFS,
510 1.1 dholland NFSERR_SERVERFAULT,
511 1.1 dholland NFSERR_STALE,
512 1.1 dholland 0,
513 1.1 dholland };
514 1.1 dholland
515 1.1 dholland static short nfsv4err_create[] = {
516 1.1 dholland NFSERR_IO,
517 1.1 dholland NFSERR_ACCES,
518 1.1 dholland NFSERR_ATTRNOTSUPP,
519 1.1 dholland NFSERR_BADCHAR,
520 1.1 dholland NFSERR_BADHANDLE,
521 1.1 dholland NFSERR_BADNAME,
522 1.1 dholland NFSERR_BADOWNER,
523 1.1 dholland NFSERR_BADTYPE,
524 1.1 dholland NFSERR_BADXDR,
525 1.1 dholland NFSERR_DELAY,
526 1.1 dholland NFSERR_DQUOT,
527 1.1 dholland NFSERR_EXIST,
528 1.1 dholland NFSERR_FHEXPIRED,
529 1.1 dholland NFSERR_INVAL,
530 1.1 dholland NFSERR_IO,
531 1.1 dholland NFSERR_MOVED,
532 1.1 dholland NFSERR_NAMETOL,
533 1.1 dholland NFSERR_NOFILEHANDLE,
534 1.1 dholland NFSERR_NOSPC,
535 1.1 dholland NFSERR_NOTDIR,
536 1.1 dholland NFSERR_PERM,
537 1.1 dholland NFSERR_RESOURCE,
538 1.1 dholland NFSERR_ROFS,
539 1.1 dholland NFSERR_SERVERFAULT,
540 1.1 dholland NFSERR_STALE,
541 1.1 dholland 0,
542 1.1 dholland };
543 1.1 dholland
544 1.1 dholland static short nfsv4err_delegpurge[] = {
545 1.1 dholland NFSERR_SERVERFAULT,
546 1.1 dholland NFSERR_BADXDR,
547 1.1 dholland NFSERR_NOTSUPP,
548 1.1 dholland NFSERR_LEASEMOVED,
549 1.1 dholland NFSERR_MOVED,
550 1.1 dholland NFSERR_RESOURCE,
551 1.1 dholland NFSERR_SERVERFAULT,
552 1.1 dholland NFSERR_STALECLIENTID,
553 1.1 dholland 0,
554 1.1 dholland };
555 1.1 dholland
556 1.1 dholland static short nfsv4err_delegreturn[] = {
557 1.1 dholland NFSERR_SERVERFAULT,
558 1.1 dholland NFSERR_ADMINREVOKED,
559 1.1 dholland NFSERR_BADSTATEID,
560 1.1 dholland NFSERR_BADXDR,
561 1.1 dholland NFSERR_EXPIRED,
562 1.1 dholland NFSERR_INVAL,
563 1.1 dholland NFSERR_LEASEMOVED,
564 1.1 dholland NFSERR_MOVED,
565 1.1 dholland NFSERR_NOFILEHANDLE,
566 1.1 dholland NFSERR_NOTSUPP,
567 1.1 dholland NFSERR_OLDSTATEID,
568 1.1 dholland NFSERR_RESOURCE,
569 1.1 dholland NFSERR_SERVERFAULT,
570 1.1 dholland NFSERR_STALE,
571 1.1 dholland NFSERR_STALESTATEID,
572 1.1 dholland 0,
573 1.1 dholland };
574 1.1 dholland
575 1.1 dholland static short nfsv4err_getattr[] = {
576 1.1 dholland NFSERR_IO,
577 1.1 dholland NFSERR_ACCES,
578 1.1 dholland NFSERR_BADHANDLE,
579 1.1 dholland NFSERR_BADXDR,
580 1.1 dholland NFSERR_DELAY,
581 1.1 dholland NFSERR_FHEXPIRED,
582 1.1 dholland NFSERR_INVAL,
583 1.1 dholland NFSERR_IO,
584 1.1 dholland NFSERR_MOVED,
585 1.1 dholland NFSERR_NOFILEHANDLE,
586 1.1 dholland NFSERR_RESOURCE,
587 1.1 dholland NFSERR_SERVERFAULT,
588 1.1 dholland NFSERR_STALE,
589 1.1 dholland 0,
590 1.1 dholland };
591 1.1 dholland
592 1.1 dholland static short nfsv4err_getfh[] = {
593 1.1 dholland NFSERR_BADHANDLE,
594 1.1 dholland NFSERR_BADHANDLE,
595 1.1 dholland NFSERR_FHEXPIRED,
596 1.1 dholland NFSERR_MOVED,
597 1.1 dholland NFSERR_NOFILEHANDLE,
598 1.1 dholland NFSERR_RESOURCE,
599 1.1 dholland NFSERR_SERVERFAULT,
600 1.1 dholland NFSERR_STALE,
601 1.1 dholland 0,
602 1.1 dholland };
603 1.1 dholland
604 1.1 dholland static short nfsv4err_link[] = {
605 1.1 dholland NFSERR_IO,
606 1.1 dholland NFSERR_ACCES,
607 1.1 dholland NFSERR_BADCHAR,
608 1.1 dholland NFSERR_BADHANDLE,
609 1.1 dholland NFSERR_BADNAME,
610 1.1 dholland NFSERR_BADXDR,
611 1.1 dholland NFSERR_DELAY,
612 1.1 dholland NFSERR_DQUOT,
613 1.1 dholland NFSERR_EXIST,
614 1.1 dholland NFSERR_FHEXPIRED,
615 1.1 dholland NFSERR_FILEOPEN,
616 1.1 dholland NFSERR_INVAL,
617 1.1 dholland NFSERR_IO,
618 1.1 dholland NFSERR_ISDIR,
619 1.1 dholland NFSERR_MLINK,
620 1.1 dholland NFSERR_MOVED,
621 1.1 dholland NFSERR_NAMETOL,
622 1.1 dholland NFSERR_NOENT,
623 1.1 dholland NFSERR_NOFILEHANDLE,
624 1.1 dholland NFSERR_NOSPC,
625 1.1 dholland NFSERR_NOTDIR,
626 1.1 dholland NFSERR_NOTSUPP,
627 1.1 dholland NFSERR_RESOURCE,
628 1.1 dholland NFSERR_ROFS,
629 1.1 dholland NFSERR_SERVERFAULT,
630 1.1 dholland NFSERR_STALE,
631 1.1 dholland NFSERR_WRONGSEC,
632 1.1 dholland NFSERR_XDEV,
633 1.1 dholland 0,
634 1.1 dholland };
635 1.1 dholland
636 1.1 dholland static short nfsv4err_lock[] = {
637 1.1 dholland NFSERR_SERVERFAULT,
638 1.1 dholland NFSERR_ACCES,
639 1.1 dholland NFSERR_ADMINREVOKED,
640 1.1 dholland NFSERR_BADHANDLE,
641 1.1 dholland NFSERR_BADRANGE,
642 1.1 dholland NFSERR_BADSEQID,
643 1.1 dholland NFSERR_BADSTATEID,
644 1.1 dholland NFSERR_BADXDR,
645 1.1 dholland NFSERR_DEADLOCK,
646 1.1 dholland NFSERR_DELAY,
647 1.1 dholland NFSERR_DENIED,
648 1.1 dholland NFSERR_EXPIRED,
649 1.1 dholland NFSERR_FHEXPIRED,
650 1.1 dholland NFSERR_GRACE,
651 1.1 dholland NFSERR_INVAL,
652 1.1 dholland NFSERR_ISDIR,
653 1.1 dholland NFSERR_LEASEMOVED,
654 1.1 dholland NFSERR_LOCKNOTSUPP,
655 1.1 dholland NFSERR_LOCKRANGE,
656 1.1 dholland NFSERR_MOVED,
657 1.1 dholland NFSERR_NOFILEHANDLE,
658 1.1 dholland NFSERR_NOGRACE,
659 1.1 dholland NFSERR_OLDSTATEID,
660 1.1 dholland NFSERR_OPENMODE,
661 1.1 dholland NFSERR_RECLAIMBAD,
662 1.1 dholland NFSERR_RECLAIMCONFLICT,
663 1.1 dholland NFSERR_RESOURCE,
664 1.1 dholland NFSERR_SERVERFAULT,
665 1.1 dholland NFSERR_STALE,
666 1.1 dholland NFSERR_STALECLIENTID,
667 1.1 dholland NFSERR_STALESTATEID,
668 1.1 dholland 0,
669 1.1 dholland };
670 1.1 dholland
671 1.1 dholland static short nfsv4err_lockt[] = {
672 1.1 dholland NFSERR_SERVERFAULT,
673 1.1 dholland NFSERR_ACCES,
674 1.1 dholland NFSERR_BADHANDLE,
675 1.1 dholland NFSERR_BADRANGE,
676 1.1 dholland NFSERR_BADXDR,
677 1.1 dholland NFSERR_DELAY,
678 1.1 dholland NFSERR_DENIED,
679 1.1 dholland NFSERR_FHEXPIRED,
680 1.1 dholland NFSERR_GRACE,
681 1.1 dholland NFSERR_INVAL,
682 1.1 dholland NFSERR_ISDIR,
683 1.1 dholland NFSERR_LEASEMOVED,
684 1.1 dholland NFSERR_LOCKRANGE,
685 1.1 dholland NFSERR_MOVED,
686 1.1 dholland NFSERR_NOFILEHANDLE,
687 1.1 dholland NFSERR_RESOURCE,
688 1.1 dholland NFSERR_SERVERFAULT,
689 1.1 dholland NFSERR_STALE,
690 1.1 dholland NFSERR_STALECLIENTID,
691 1.1 dholland 0,
692 1.1 dholland };
693 1.1 dholland
694 1.1 dholland static short nfsv4err_locku[] = {
695 1.1 dholland NFSERR_SERVERFAULT,
696 1.1 dholland NFSERR_ACCES,
697 1.1 dholland NFSERR_ADMINREVOKED,
698 1.1 dholland NFSERR_BADHANDLE,
699 1.1 dholland NFSERR_BADRANGE,
700 1.1 dholland NFSERR_BADSEQID,
701 1.1 dholland NFSERR_BADSTATEID,
702 1.1 dholland NFSERR_BADXDR,
703 1.1 dholland NFSERR_EXPIRED,
704 1.1 dholland NFSERR_FHEXPIRED,
705 1.1 dholland NFSERR_GRACE,
706 1.1 dholland NFSERR_INVAL,
707 1.1 dholland NFSERR_ISDIR,
708 1.1 dholland NFSERR_LEASEMOVED,
709 1.1 dholland NFSERR_LOCKRANGE,
710 1.1 dholland NFSERR_MOVED,
711 1.1 dholland NFSERR_NOFILEHANDLE,
712 1.1 dholland NFSERR_OLDSTATEID,
713 1.1 dholland NFSERR_RESOURCE,
714 1.1 dholland NFSERR_SERVERFAULT,
715 1.1 dholland NFSERR_STALE,
716 1.1 dholland NFSERR_STALESTATEID,
717 1.1 dholland 0,
718 1.1 dholland };
719 1.1 dholland
720 1.1 dholland static short nfsv4err_lookup[] = {
721 1.1 dholland NFSERR_IO,
722 1.1 dholland NFSERR_ACCES,
723 1.1 dholland NFSERR_BADCHAR,
724 1.1 dholland NFSERR_BADHANDLE,
725 1.1 dholland NFSERR_BADNAME,
726 1.1 dholland NFSERR_BADXDR,
727 1.1 dholland NFSERR_FHEXPIRED,
728 1.1 dholland NFSERR_INVAL,
729 1.1 dholland NFSERR_IO,
730 1.1 dholland NFSERR_MOVED,
731 1.1 dholland NFSERR_NAMETOL,
732 1.1 dholland NFSERR_NOENT,
733 1.1 dholland NFSERR_NOFILEHANDLE,
734 1.1 dholland NFSERR_NOTDIR,
735 1.1 dholland NFSERR_RESOURCE,
736 1.1 dholland NFSERR_SERVERFAULT,
737 1.1 dholland NFSERR_STALE,
738 1.1 dholland NFSERR_SYMLINK,
739 1.1 dholland NFSERR_WRONGSEC,
740 1.1 dholland 0,
741 1.1 dholland };
742 1.1 dholland
743 1.1 dholland static short nfsv4err_lookupp[] = {
744 1.1 dholland NFSERR_IO,
745 1.1 dholland NFSERR_ACCES,
746 1.1 dholland NFSERR_BADHANDLE,
747 1.1 dholland NFSERR_FHEXPIRED,
748 1.1 dholland NFSERR_IO,
749 1.1 dholland NFSERR_MOVED,
750 1.1 dholland NFSERR_NOENT,
751 1.1 dholland NFSERR_NOFILEHANDLE,
752 1.1 dholland NFSERR_NOTDIR,
753 1.1 dholland NFSERR_RESOURCE,
754 1.1 dholland NFSERR_SERVERFAULT,
755 1.1 dholland NFSERR_STALE,
756 1.1 dholland 0,
757 1.1 dholland };
758 1.1 dholland
759 1.1 dholland static short nfsv4err_nverify[] = {
760 1.1 dholland NFSERR_IO,
761 1.1 dholland NFSERR_ACCES,
762 1.1 dholland NFSERR_ATTRNOTSUPP,
763 1.1 dholland NFSERR_BADCHAR,
764 1.1 dholland NFSERR_BADHANDLE,
765 1.1 dholland NFSERR_BADXDR,
766 1.1 dholland NFSERR_DELAY,
767 1.1 dholland NFSERR_FHEXPIRED,
768 1.1 dholland NFSERR_INVAL,
769 1.1 dholland NFSERR_IO,
770 1.1 dholland NFSERR_MOVED,
771 1.1 dholland NFSERR_NOFILEHANDLE,
772 1.1 dholland NFSERR_RESOURCE,
773 1.1 dholland NFSERR_SAME,
774 1.1 dholland NFSERR_SERVERFAULT,
775 1.1 dholland NFSERR_STALE,
776 1.1 dholland 0,
777 1.1 dholland };
778 1.1 dholland
779 1.1 dholland static short nfsv4err_open[] = {
780 1.1 dholland NFSERR_IO,
781 1.1 dholland NFSERR_ACCES,
782 1.1 dholland NFSERR_ADMINREVOKED,
783 1.1 dholland NFSERR_ATTRNOTSUPP,
784 1.1 dholland NFSERR_BADCHAR,
785 1.1 dholland NFSERR_BADHANDLE,
786 1.1 dholland NFSERR_BADNAME,
787 1.1 dholland NFSERR_BADOWNER,
788 1.1 dholland NFSERR_BADSEQID,
789 1.1 dholland NFSERR_BADXDR,
790 1.1 dholland NFSERR_DELAY,
791 1.1 dholland NFSERR_DQUOT,
792 1.1 dholland NFSERR_EXIST,
793 1.1 dholland NFSERR_EXPIRED,
794 1.1 dholland NFSERR_FHEXPIRED,
795 1.1 dholland NFSERR_GRACE,
796 1.1 dholland NFSERR_IO,
797 1.1 dholland NFSERR_INVAL,
798 1.1 dholland NFSERR_ISDIR,
799 1.1 dholland NFSERR_LEASEMOVED,
800 1.1 dholland NFSERR_MOVED,
801 1.1 dholland NFSERR_NAMETOL,
802 1.1 dholland NFSERR_NOENT,
803 1.1 dholland NFSERR_NOFILEHANDLE,
804 1.1 dholland NFSERR_NOGRACE,
805 1.1 dholland NFSERR_NOSPC,
806 1.1 dholland NFSERR_NOTDIR,
807 1.1 dholland NFSERR_NOTSUPP,
808 1.1 dholland NFSERR_PERM,
809 1.1 dholland NFSERR_RECLAIMBAD,
810 1.1 dholland NFSERR_RECLAIMCONFLICT,
811 1.1 dholland NFSERR_RESOURCE,
812 1.1 dholland NFSERR_ROFS,
813 1.1 dholland NFSERR_SERVERFAULT,
814 1.1 dholland NFSERR_SHAREDENIED,
815 1.1 dholland NFSERR_STALE,
816 1.1 dholland NFSERR_STALECLIENTID,
817 1.1 dholland NFSERR_SYMLINK,
818 1.1 dholland NFSERR_WRONGSEC,
819 1.1 dholland 0,
820 1.1 dholland };
821 1.1 dholland
822 1.1 dholland static short nfsv4err_openattr[] = {
823 1.1 dholland NFSERR_IO,
824 1.1 dholland NFSERR_ACCES,
825 1.1 dholland NFSERR_BADHANDLE,
826 1.1 dholland NFSERR_BADXDR,
827 1.1 dholland NFSERR_DELAY,
828 1.1 dholland NFSERR_DQUOT,
829 1.1 dholland NFSERR_FHEXPIRED,
830 1.1 dholland NFSERR_IO,
831 1.1 dholland NFSERR_MOVED,
832 1.1 dholland NFSERR_NOENT,
833 1.1 dholland NFSERR_NOFILEHANDLE,
834 1.1 dholland NFSERR_NOSPC,
835 1.1 dholland NFSERR_NOTSUPP,
836 1.1 dholland NFSERR_RESOURCE,
837 1.1 dholland NFSERR_ROFS,
838 1.1 dholland NFSERR_SERVERFAULT,
839 1.1 dholland NFSERR_STALE,
840 1.1 dholland 0,
841 1.1 dholland };
842 1.1 dholland
843 1.1 dholland static short nfsv4err_openconfirm[] = {
844 1.1 dholland NFSERR_SERVERFAULT,
845 1.1 dholland NFSERR_ADMINREVOKED,
846 1.1 dholland NFSERR_BADHANDLE,
847 1.1 dholland NFSERR_BADSEQID,
848 1.1 dholland NFSERR_BADSTATEID,
849 1.1 dholland NFSERR_BADXDR,
850 1.1 dholland NFSERR_EXPIRED,
851 1.1 dholland NFSERR_FHEXPIRED,
852 1.1 dholland NFSERR_INVAL,
853 1.1 dholland NFSERR_ISDIR,
854 1.1 dholland NFSERR_MOVED,
855 1.1 dholland NFSERR_NOFILEHANDLE,
856 1.1 dholland NFSERR_OLDSTATEID,
857 1.1 dholland NFSERR_RESOURCE,
858 1.1 dholland NFSERR_SERVERFAULT,
859 1.1 dholland NFSERR_STALE,
860 1.1 dholland NFSERR_STALESTATEID,
861 1.1 dholland 0,
862 1.1 dholland };
863 1.1 dholland
864 1.1 dholland static short nfsv4err_opendowngrade[] = {
865 1.1 dholland NFSERR_SERVERFAULT,
866 1.1 dholland NFSERR_ADMINREVOKED,
867 1.1 dholland NFSERR_BADHANDLE,
868 1.1 dholland NFSERR_BADSEQID,
869 1.1 dholland NFSERR_BADSTATEID,
870 1.1 dholland NFSERR_BADXDR,
871 1.1 dholland NFSERR_EXPIRED,
872 1.1 dholland NFSERR_FHEXPIRED,
873 1.1 dholland NFSERR_INVAL,
874 1.1 dholland NFSERR_MOVED,
875 1.1 dholland NFSERR_NOFILEHANDLE,
876 1.1 dholland NFSERR_OLDSTATEID,
877 1.1 dholland NFSERR_RESOURCE,
878 1.1 dholland NFSERR_SERVERFAULT,
879 1.1 dholland NFSERR_STALE,
880 1.1 dholland NFSERR_STALESTATEID,
881 1.1 dholland 0,
882 1.1 dholland };
883 1.1 dholland
884 1.1 dholland static short nfsv4err_putfh[] = {
885 1.1 dholland NFSERR_SERVERFAULT,
886 1.1 dholland NFSERR_BADHANDLE,
887 1.1 dholland NFSERR_BADXDR,
888 1.1 dholland NFSERR_FHEXPIRED,
889 1.1 dholland NFSERR_MOVED,
890 1.1 dholland NFSERR_RESOURCE,
891 1.1 dholland NFSERR_SERVERFAULT,
892 1.1 dholland NFSERR_STALE,
893 1.1 dholland NFSERR_WRONGSEC,
894 1.1 dholland 0,
895 1.1 dholland };
896 1.1 dholland
897 1.1 dholland static short nfsv4err_putpubfh[] = {
898 1.1 dholland NFSERR_SERVERFAULT,
899 1.1 dholland NFSERR_RESOURCE,
900 1.1 dholland NFSERR_SERVERFAULT,
901 1.1 dholland NFSERR_WRONGSEC,
902 1.1 dholland 0,
903 1.1 dholland };
904 1.1 dholland
905 1.1 dholland static short nfsv4err_putrootfh[] = {
906 1.1 dholland NFSERR_SERVERFAULT,
907 1.1 dholland NFSERR_RESOURCE,
908 1.1 dholland NFSERR_SERVERFAULT,
909 1.1 dholland NFSERR_WRONGSEC,
910 1.1 dholland 0,
911 1.1 dholland };
912 1.1 dholland
913 1.1 dholland static short nfsv4err_read[] = {
914 1.1 dholland NFSERR_IO,
915 1.1 dholland NFSERR_ACCES,
916 1.1 dholland NFSERR_ADMINREVOKED,
917 1.1 dholland NFSERR_BADHANDLE,
918 1.1 dholland NFSERR_BADSTATEID,
919 1.1 dholland NFSERR_BADXDR,
920 1.1 dholland NFSERR_DELAY,
921 1.1 dholland NFSERR_EXPIRED,
922 1.1 dholland NFSERR_FHEXPIRED,
923 1.1 dholland NFSERR_GRACE,
924 1.1 dholland NFSERR_IO,
925 1.1 dholland NFSERR_INVAL,
926 1.1 dholland NFSERR_ISDIR,
927 1.1 dholland NFSERR_LEASEMOVED,
928 1.1 dholland NFSERR_LOCKED,
929 1.1 dholland NFSERR_MOVED,
930 1.1 dholland NFSERR_NOFILEHANDLE,
931 1.1 dholland NFSERR_NXIO,
932 1.1 dholland NFSERR_OLDSTATEID,
933 1.1 dholland NFSERR_OPENMODE,
934 1.1 dholland NFSERR_RESOURCE,
935 1.1 dholland NFSERR_SERVERFAULT,
936 1.1 dholland NFSERR_STALE,
937 1.1 dholland NFSERR_STALESTATEID,
938 1.1 dholland 0,
939 1.1 dholland };
940 1.1 dholland
941 1.1 dholland static short nfsv4err_readdir[] = {
942 1.1 dholland NFSERR_IO,
943 1.1 dholland NFSERR_ACCES,
944 1.1 dholland NFSERR_BADHANDLE,
945 1.1 dholland NFSERR_BAD_COOKIE,
946 1.1 dholland NFSERR_BADXDR,
947 1.1 dholland NFSERR_DELAY,
948 1.1 dholland NFSERR_FHEXPIRED,
949 1.1 dholland NFSERR_INVAL,
950 1.1 dholland NFSERR_IO,
951 1.1 dholland NFSERR_MOVED,
952 1.1 dholland NFSERR_NOFILEHANDLE,
953 1.1 dholland NFSERR_NOTDIR,
954 1.1 dholland NFSERR_NOTSAME,
955 1.1 dholland NFSERR_RESOURCE,
956 1.1 dholland NFSERR_SERVERFAULT,
957 1.1 dholland NFSERR_STALE,
958 1.1 dholland NFSERR_TOOSMALL,
959 1.1 dholland 0,
960 1.1 dholland };
961 1.1 dholland
962 1.1 dholland static short nfsv4err_readlink[] = {
963 1.1 dholland NFSERR_IO,
964 1.1 dholland NFSERR_ACCES,
965 1.1 dholland NFSERR_BADHANDLE,
966 1.1 dholland NFSERR_DELAY,
967 1.1 dholland NFSERR_FHEXPIRED,
968 1.1 dholland NFSERR_INVAL,
969 1.1 dholland NFSERR_IO,
970 1.1 dholland NFSERR_ISDIR,
971 1.1 dholland NFSERR_MOVED,
972 1.1 dholland NFSERR_NOFILEHANDLE,
973 1.1 dholland NFSERR_NOTSUPP,
974 1.1 dholland NFSERR_RESOURCE,
975 1.1 dholland NFSERR_SERVERFAULT,
976 1.1 dholland NFSERR_STALE,
977 1.1 dholland 0,
978 1.1 dholland };
979 1.1 dholland
980 1.1 dholland static short nfsv4err_remove[] = {
981 1.1 dholland NFSERR_IO,
982 1.1 dholland NFSERR_ACCES,
983 1.1 dholland NFSERR_BADCHAR,
984 1.1 dholland NFSERR_BADHANDLE,
985 1.1 dholland NFSERR_BADNAME,
986 1.1 dholland NFSERR_BADXDR,
987 1.1 dholland NFSERR_DELAY,
988 1.1 dholland NFSERR_FHEXPIRED,
989 1.1 dholland NFSERR_FILEOPEN,
990 1.1 dholland NFSERR_INVAL,
991 1.1 dholland NFSERR_IO,
992 1.1 dholland NFSERR_MOVED,
993 1.1 dholland NFSERR_NAMETOL,
994 1.1 dholland NFSERR_NOENT,
995 1.1 dholland NFSERR_NOFILEHANDLE,
996 1.1 dholland NFSERR_NOTDIR,
997 1.1 dholland NFSERR_NOTEMPTY,
998 1.1 dholland NFSERR_RESOURCE,
999 1.1 dholland NFSERR_ROFS,
1000 1.1 dholland NFSERR_SERVERFAULT,
1001 1.1 dholland NFSERR_STALE,
1002 1.1 dholland 0,
1003 1.1 dholland };
1004 1.1 dholland
1005 1.1 dholland static short nfsv4err_rename[] = {
1006 1.1 dholland NFSERR_IO,
1007 1.1 dholland NFSERR_ACCES,
1008 1.1 dholland NFSERR_BADCHAR,
1009 1.1 dholland NFSERR_BADHANDLE,
1010 1.1 dholland NFSERR_BADNAME,
1011 1.1 dholland NFSERR_BADXDR,
1012 1.1 dholland NFSERR_DELAY,
1013 1.1 dholland NFSERR_DQUOT,
1014 1.1 dholland NFSERR_EXIST,
1015 1.1 dholland NFSERR_FHEXPIRED,
1016 1.1 dholland NFSERR_FILEOPEN,
1017 1.1 dholland NFSERR_INVAL,
1018 1.1 dholland NFSERR_IO,
1019 1.1 dholland NFSERR_MOVED,
1020 1.1 dholland NFSERR_NAMETOL,
1021 1.1 dholland NFSERR_NOENT,
1022 1.1 dholland NFSERR_NOFILEHANDLE,
1023 1.1 dholland NFSERR_NOSPC,
1024 1.1 dholland NFSERR_NOTDIR,
1025 1.1 dholland NFSERR_NOTEMPTY,
1026 1.1 dholland NFSERR_RESOURCE,
1027 1.1 dholland NFSERR_ROFS,
1028 1.1 dholland NFSERR_SERVERFAULT,
1029 1.1 dholland NFSERR_STALE,
1030 1.1 dholland NFSERR_WRONGSEC,
1031 1.1 dholland NFSERR_XDEV,
1032 1.1 dholland 0,
1033 1.1 dholland };
1034 1.1 dholland
1035 1.1 dholland static short nfsv4err_renew[] = {
1036 1.1 dholland NFSERR_SERVERFAULT,
1037 1.1 dholland NFSERR_ACCES,
1038 1.1 dholland NFSERR_ADMINREVOKED,
1039 1.1 dholland NFSERR_BADXDR,
1040 1.1 dholland NFSERR_CBPATHDOWN,
1041 1.1 dholland NFSERR_EXPIRED,
1042 1.1 dholland NFSERR_LEASEMOVED,
1043 1.1 dholland NFSERR_RESOURCE,
1044 1.1 dholland NFSERR_SERVERFAULT,
1045 1.1 dholland NFSERR_STALECLIENTID,
1046 1.1 dholland 0,
1047 1.1 dholland };
1048 1.1 dholland
1049 1.1 dholland static short nfsv4err_restorefh[] = {
1050 1.1 dholland NFSERR_SERVERFAULT,
1051 1.1 dholland NFSERR_BADHANDLE,
1052 1.1 dholland NFSERR_FHEXPIRED,
1053 1.1 dholland NFSERR_MOVED,
1054 1.1 dholland NFSERR_RESOURCE,
1055 1.1 dholland NFSERR_RESTOREFH,
1056 1.1 dholland NFSERR_SERVERFAULT,
1057 1.1 dholland NFSERR_STALE,
1058 1.1 dholland NFSERR_WRONGSEC,
1059 1.1 dholland 0,
1060 1.1 dholland };
1061 1.1 dholland
1062 1.1 dholland static short nfsv4err_savefh[] = {
1063 1.1 dholland NFSERR_SERVERFAULT,
1064 1.1 dholland NFSERR_BADHANDLE,
1065 1.1 dholland NFSERR_FHEXPIRED,
1066 1.1 dholland NFSERR_MOVED,
1067 1.1 dholland NFSERR_NOFILEHANDLE,
1068 1.1 dholland NFSERR_RESOURCE,
1069 1.1 dholland NFSERR_SERVERFAULT,
1070 1.1 dholland NFSERR_STALE,
1071 1.1 dholland 0,
1072 1.1 dholland };
1073 1.1 dholland
1074 1.1 dholland static short nfsv4err_secinfo[] = {
1075 1.1 dholland NFSERR_SERVERFAULT,
1076 1.1 dholland NFSERR_ACCES,
1077 1.1 dholland NFSERR_BADCHAR,
1078 1.1 dholland NFSERR_BADHANDLE,
1079 1.1 dholland NFSERR_BADNAME,
1080 1.1 dholland NFSERR_BADXDR,
1081 1.1 dholland NFSERR_FHEXPIRED,
1082 1.1 dholland NFSERR_INVAL,
1083 1.1 dholland NFSERR_MOVED,
1084 1.1 dholland NFSERR_NAMETOL,
1085 1.1 dholland NFSERR_NOENT,
1086 1.1 dholland NFSERR_NOFILEHANDLE,
1087 1.1 dholland NFSERR_NOTDIR,
1088 1.1 dholland NFSERR_RESOURCE,
1089 1.1 dholland NFSERR_SERVERFAULT,
1090 1.1 dholland NFSERR_STALE,
1091 1.1 dholland 0,
1092 1.1 dholland };
1093 1.1 dholland
1094 1.1 dholland static short nfsv4err_setattr[] = {
1095 1.1 dholland NFSERR_IO,
1096 1.1 dholland NFSERR_ACCES,
1097 1.1 dholland NFSERR_ADMINREVOKED,
1098 1.1 dholland NFSERR_ATTRNOTSUPP,
1099 1.1 dholland NFSERR_BADCHAR,
1100 1.1 dholland NFSERR_BADHANDLE,
1101 1.1 dholland NFSERR_BADOWNER,
1102 1.1 dholland NFSERR_BADSTATEID,
1103 1.1 dholland NFSERR_BADXDR,
1104 1.1 dholland NFSERR_DELAY,
1105 1.1 dholland NFSERR_DQUOT,
1106 1.1 dholland NFSERR_EXPIRED,
1107 1.1 dholland NFSERR_FBIG,
1108 1.1 dholland NFSERR_FHEXPIRED,
1109 1.1 dholland NFSERR_GRACE,
1110 1.1 dholland NFSERR_INVAL,
1111 1.1 dholland NFSERR_IO,
1112 1.1 dholland NFSERR_ISDIR,
1113 1.1 dholland NFSERR_LOCKED,
1114 1.1 dholland NFSERR_MOVED,
1115 1.1 dholland NFSERR_NOFILEHANDLE,
1116 1.1 dholland NFSERR_NOSPC,
1117 1.1 dholland NFSERR_OLDSTATEID,
1118 1.1 dholland NFSERR_OPENMODE,
1119 1.1 dholland NFSERR_PERM,
1120 1.1 dholland NFSERR_RESOURCE,
1121 1.1 dholland NFSERR_ROFS,
1122 1.1 dholland NFSERR_SERVERFAULT,
1123 1.1 dholland NFSERR_STALE,
1124 1.1 dholland NFSERR_STALESTATEID,
1125 1.1 dholland 0,
1126 1.1 dholland };
1127 1.1 dholland
1128 1.1 dholland static short nfsv4err_setclientid[] = {
1129 1.1 dholland NFSERR_SERVERFAULT,
1130 1.1 dholland NFSERR_BADXDR,
1131 1.1 dholland NFSERR_CLIDINUSE,
1132 1.1 dholland NFSERR_INVAL,
1133 1.1 dholland NFSERR_RESOURCE,
1134 1.1 dholland NFSERR_SERVERFAULT,
1135 1.1 dholland 0,
1136 1.1 dholland };
1137 1.1 dholland
1138 1.1 dholland static short nfsv4err_setclientidconfirm[] = {
1139 1.1 dholland NFSERR_SERVERFAULT,
1140 1.1 dholland NFSERR_BADXDR,
1141 1.1 dholland NFSERR_CLIDINUSE,
1142 1.1 dholland NFSERR_RESOURCE,
1143 1.1 dholland NFSERR_SERVERFAULT,
1144 1.1 dholland NFSERR_STALECLIENTID,
1145 1.1 dholland 0,
1146 1.1 dholland };
1147 1.1 dholland
1148 1.1 dholland static short nfsv4err_verify[] = {
1149 1.1 dholland NFSERR_SERVERFAULT,
1150 1.1 dholland NFSERR_ACCES,
1151 1.1 dholland NFSERR_ATTRNOTSUPP,
1152 1.1 dholland NFSERR_BADCHAR,
1153 1.1 dholland NFSERR_BADHANDLE,
1154 1.1 dholland NFSERR_BADXDR,
1155 1.1 dholland NFSERR_DELAY,
1156 1.1 dholland NFSERR_FHEXPIRED,
1157 1.1 dholland NFSERR_INVAL,
1158 1.1 dholland NFSERR_MOVED,
1159 1.1 dholland NFSERR_NOFILEHANDLE,
1160 1.1 dholland NFSERR_NOTSAME,
1161 1.1 dholland NFSERR_RESOURCE,
1162 1.1 dholland NFSERR_SERVERFAULT,
1163 1.1 dholland NFSERR_STALE,
1164 1.1 dholland 0,
1165 1.1 dholland };
1166 1.1 dholland
1167 1.1 dholland static short nfsv4err_write[] = {
1168 1.1 dholland NFSERR_IO,
1169 1.1 dholland NFSERR_ACCES,
1170 1.1 dholland NFSERR_ADMINREVOKED,
1171 1.1 dholland NFSERR_BADHANDLE,
1172 1.1 dholland NFSERR_BADSTATEID,
1173 1.1 dholland NFSERR_BADXDR,
1174 1.1 dholland NFSERR_DELAY,
1175 1.1 dholland NFSERR_DQUOT,
1176 1.1 dholland NFSERR_EXPIRED,
1177 1.1 dholland NFSERR_FBIG,
1178 1.1 dholland NFSERR_FHEXPIRED,
1179 1.1 dholland NFSERR_GRACE,
1180 1.1 dholland NFSERR_INVAL,
1181 1.1 dholland NFSERR_IO,
1182 1.1 dholland NFSERR_ISDIR,
1183 1.1 dholland NFSERR_LEASEMOVED,
1184 1.1 dholland NFSERR_LOCKED,
1185 1.1 dholland NFSERR_MOVED,
1186 1.1 dholland NFSERR_NOFILEHANDLE,
1187 1.1 dholland NFSERR_NOSPC,
1188 1.1 dholland NFSERR_NXIO,
1189 1.1 dholland NFSERR_OLDSTATEID,
1190 1.1 dholland NFSERR_OPENMODE,
1191 1.1 dholland NFSERR_RESOURCE,
1192 1.1 dholland NFSERR_ROFS,
1193 1.1 dholland NFSERR_SERVERFAULT,
1194 1.1 dholland NFSERR_STALE,
1195 1.1 dholland NFSERR_STALESTATEID,
1196 1.1 dholland 0,
1197 1.1 dholland };
1198 1.1 dholland
1199 1.1 dholland static short nfsv4err_releaselockowner[] = {
1200 1.1 dholland NFSERR_SERVERFAULT,
1201 1.1 dholland NFSERR_ADMINREVOKED,
1202 1.1 dholland NFSERR_BADXDR,
1203 1.1 dholland NFSERR_EXPIRED,
1204 1.1 dholland NFSERR_LEASEMOVED,
1205 1.1 dholland NFSERR_LOCKSHELD,
1206 1.1 dholland NFSERR_RESOURCE,
1207 1.1 dholland NFSERR_SERVERFAULT,
1208 1.1 dholland NFSERR_STALECLIENTID,
1209 1.1 dholland 0,
1210 1.1 dholland };
1211 1.1 dholland
1212 1.1 dholland static short *nfsrv_v4errmap[] = {
1213 1.1 dholland nfsv4err_null,
1214 1.1 dholland nfsv4err_null,
1215 1.1 dholland nfsv4err_null,
1216 1.1 dholland nfsv4err_access,
1217 1.1 dholland nfsv4err_close,
1218 1.1 dholland nfsv4err_commit,
1219 1.1 dholland nfsv4err_create,
1220 1.1 dholland nfsv4err_delegpurge,
1221 1.1 dholland nfsv4err_delegreturn,
1222 1.1 dholland nfsv4err_getattr,
1223 1.1 dholland nfsv4err_getfh,
1224 1.1 dholland nfsv4err_link,
1225 1.1 dholland nfsv4err_lock,
1226 1.1 dholland nfsv4err_lockt,
1227 1.1 dholland nfsv4err_locku,
1228 1.1 dholland nfsv4err_lookup,
1229 1.1 dholland nfsv4err_lookupp,
1230 1.1 dholland nfsv4err_nverify,
1231 1.1 dholland nfsv4err_open,
1232 1.1 dholland nfsv4err_openattr,
1233 1.1 dholland nfsv4err_openconfirm,
1234 1.1 dholland nfsv4err_opendowngrade,
1235 1.1 dholland nfsv4err_putfh,
1236 1.1 dholland nfsv4err_putpubfh,
1237 1.1 dholland nfsv4err_putrootfh,
1238 1.1 dholland nfsv4err_read,
1239 1.1 dholland nfsv4err_readdir,
1240 1.1 dholland nfsv4err_readlink,
1241 1.1 dholland nfsv4err_remove,
1242 1.1 dholland nfsv4err_rename,
1243 1.1 dholland nfsv4err_renew,
1244 1.1 dholland nfsv4err_restorefh,
1245 1.1 dholland nfsv4err_savefh,
1246 1.1 dholland nfsv4err_secinfo,
1247 1.1 dholland nfsv4err_setattr,
1248 1.1 dholland nfsv4err_setclientid,
1249 1.1 dholland nfsv4err_setclientidconfirm,
1250 1.1 dholland nfsv4err_verify,
1251 1.1 dholland nfsv4err_write,
1252 1.1 dholland nfsv4err_releaselockowner,
1253 1.1 dholland };
1254 1.1 dholland
1255 1.1 dholland /*
1256 1.1 dholland * A fiddled version of m_adj() that ensures null fill to a long
1257 1.1 dholland * boundary and only trims off the back end
1258 1.1 dholland */
1259 1.1 dholland APPLESTATIC void
1260 1.1 dholland nfsrv_adj(mbuf_t mp, int len, int nul)
1261 1.1 dholland {
1262 1.1 dholland mbuf_t m;
1263 1.1 dholland int count, i;
1264 1.1 dholland char *cp;
1265 1.1 dholland
1266 1.1 dholland /*
1267 1.1 dholland * Trim from tail. Scan the mbuf chain,
1268 1.1 dholland * calculating its length and finding the last mbuf.
1269 1.1 dholland * If the adjustment only affects this mbuf, then just
1270 1.1 dholland * adjust and return. Otherwise, rescan and truncate
1271 1.1 dholland * after the remaining size.
1272 1.1 dholland */
1273 1.1 dholland count = 0;
1274 1.1 dholland m = mp;
1275 1.1 dholland for (;;) {
1276 1.1 dholland count += mbuf_len(m);
1277 1.1 dholland if (mbuf_next(m) == NULL)
1278 1.1 dholland break;
1279 1.1 dholland m = mbuf_next(m);
1280 1.1 dholland }
1281 1.1 dholland if (mbuf_len(m) > len) {
1282 1.1 dholland mbuf_setlen(m, mbuf_len(m) - len);
1283 1.1 dholland if (nul > 0) {
1284 1.1 dholland cp = NFSMTOD(m, caddr_t) + mbuf_len(m) - nul;
1285 1.1 dholland for (i = 0; i < nul; i++)
1286 1.1 dholland *cp++ = '\0';
1287 1.1 dholland }
1288 1.1 dholland return;
1289 1.1 dholland }
1290 1.1 dholland count -= len;
1291 1.1 dholland if (count < 0)
1292 1.1 dholland count = 0;
1293 1.1 dholland /*
1294 1.1 dholland * Correct length for chain is "count".
1295 1.1 dholland * Find the mbuf with last data, adjust its length,
1296 1.1 dholland * and toss data from remaining mbufs on chain.
1297 1.1 dholland */
1298 1.1 dholland for (m = mp; m; m = mbuf_next(m)) {
1299 1.1 dholland if (mbuf_len(m) >= count) {
1300 1.1 dholland mbuf_setlen(m, count);
1301 1.1 dholland if (nul > 0) {
1302 1.1 dholland cp = NFSMTOD(m, caddr_t) + mbuf_len(m) - nul;
1303 1.1 dholland for (i = 0; i < nul; i++)
1304 1.1 dholland *cp++ = '\0';
1305 1.1 dholland }
1306 1.1 dholland break;
1307 1.1 dholland }
1308 1.1 dholland count -= mbuf_len(m);
1309 1.1 dholland }
1310 1.1 dholland for (m = mbuf_next(m); m; m = mbuf_next(m))
1311 1.1 dholland mbuf_setlen(m, 0);
1312 1.1 dholland }
1313 1.1 dholland
1314 1.1 dholland /*
1315 1.1 dholland * Make these functions instead of macros, so that the kernel text size
1316 1.1 dholland * doesn't get too big...
1317 1.1 dholland */
1318 1.1 dholland APPLESTATIC void
1319 1.1 dholland nfsrv_wcc(struct nfsrv_descript *nd, int before_ret,
1320 1.1 dholland struct nfsvattr *before_nvap, int after_ret, struct nfsvattr *after_nvap)
1321 1.1 dholland {
1322 1.1 dholland u_int32_t *tl;
1323 1.1 dholland
1324 1.1 dholland if (before_ret) {
1325 1.1 dholland NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
1326 1.1 dholland *tl = newnfs_false;
1327 1.1 dholland } else {
1328 1.1 dholland NFSM_BUILD(tl, u_int32_t *, 7 * NFSX_UNSIGNED);
1329 1.1 dholland *tl++ = newnfs_true;
1330 1.1 dholland txdr_hyper(before_nvap->na_size, tl);
1331 1.1 dholland tl += 2;
1332 1.1 dholland txdr_nfsv3time(&(before_nvap->na_mtime), tl);
1333 1.1 dholland tl += 2;
1334 1.1 dholland txdr_nfsv3time(&(before_nvap->na_ctime), tl);
1335 1.1 dholland }
1336 1.1 dholland nfsrv_postopattr(nd, after_ret, after_nvap);
1337 1.1 dholland }
1338 1.1 dholland
1339 1.1 dholland APPLESTATIC void
1340 1.1 dholland nfsrv_postopattr(struct nfsrv_descript *nd, int after_ret,
1341 1.1 dholland struct nfsvattr *after_nvap)
1342 1.1 dholland {
1343 1.1 dholland u_int32_t *tl;
1344 1.1 dholland
1345 1.1 dholland NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
1346 1.1 dholland if (after_ret)
1347 1.1 dholland *tl = newnfs_false;
1348 1.1 dholland else {
1349 1.1 dholland *tl = newnfs_true;
1350 1.1 dholland nfsrv_fillattr(nd, after_nvap);
1351 1.1 dholland }
1352 1.1 dholland }
1353 1.1 dholland
1354 1.1 dholland /*
1355 1.1 dholland * Fill in file attributes for V2 and 3. For V4, call a separate
1356 1.1 dholland * routine that sifts through all the attribute bits.
1357 1.1 dholland */
1358 1.1 dholland APPLESTATIC void
1359 1.1 dholland nfsrv_fillattr(struct nfsrv_descript *nd, struct nfsvattr *nvap)
1360 1.1 dholland {
1361 1.1 dholland struct nfs_fattr *fp;
1362 1.1 dholland int fattr_size;
1363 1.1 dholland
1364 1.1 dholland /*
1365 1.1 dholland * Build space for the attribute structure.
1366 1.1 dholland */
1367 1.1 dholland if (nd->nd_flag & ND_NFSV3)
1368 1.1 dholland fattr_size = NFSX_V3FATTR;
1369 1.1 dholland else
1370 1.1 dholland fattr_size = NFSX_V2FATTR;
1371 1.1 dholland NFSM_BUILD(fp, struct nfs_fattr *, fattr_size);
1372 1.1 dholland
1373 1.1 dholland /*
1374 1.1 dholland * Now just fill it all in.
1375 1.1 dholland */
1376 1.1 dholland fp->fa_nlink = txdr_unsigned(nvap->na_nlink);
1377 1.1 dholland fp->fa_uid = txdr_unsigned(nvap->na_uid);
1378 1.1 dholland fp->fa_gid = txdr_unsigned(nvap->na_gid);
1379 1.1 dholland if (nd->nd_flag & ND_NFSV3) {
1380 1.1 dholland fp->fa_type = vtonfsv34_type(nvap->na_type);
1381 1.1 dholland fp->fa_mode = vtonfsv34_mode(nvap->na_mode);
1382 1.1 dholland txdr_hyper(nvap->na_size, &fp->fa3_size);
1383 1.1 dholland txdr_hyper(nvap->na_bytes, &fp->fa3_used);
1384 1.1 dholland fp->fa3_rdev.specdata1 = txdr_unsigned(NFSMAJOR(nvap->na_rdev));
1385 1.1 dholland fp->fa3_rdev.specdata2 = txdr_unsigned(NFSMINOR(nvap->na_rdev));
1386 1.1 dholland fp->fa3_fsid.nfsuquad[0] = 0;
1387 1.1 dholland fp->fa3_fsid.nfsuquad[1] = txdr_unsigned(nvap->na_fsid);
1388 1.1 dholland fp->fa3_fileid.nfsuquad[0] = 0;
1389 1.1 dholland fp->fa3_fileid.nfsuquad[1] = txdr_unsigned(nvap->na_fileid);
1390 1.1 dholland txdr_nfsv3time(&nvap->na_atime, &fp->fa3_atime);
1391 1.1 dholland txdr_nfsv3time(&nvap->na_mtime, &fp->fa3_mtime);
1392 1.1 dholland txdr_nfsv3time(&nvap->na_ctime, &fp->fa3_ctime);
1393 1.1 dholland } else {
1394 1.1 dholland fp->fa_type = vtonfsv2_type(nvap->na_type);
1395 1.1 dholland fp->fa_mode = vtonfsv2_mode(nvap->na_type, nvap->na_mode);
1396 1.1 dholland fp->fa2_size = txdr_unsigned(nvap->na_size);
1397 1.1 dholland fp->fa2_blocksize = txdr_unsigned(nvap->na_blocksize);
1398 1.1 dholland if (nvap->na_type == VFIFO)
1399 1.1 dholland fp->fa2_rdev = 0xffffffff;
1400 1.1 dholland else
1401 1.1 dholland fp->fa2_rdev = txdr_unsigned(nvap->na_rdev);
1402 1.1 dholland fp->fa2_blocks = txdr_unsigned(nvap->na_bytes / NFS_FABLKSIZE);
1403 1.1 dholland fp->fa2_fsid = txdr_unsigned(nvap->na_fsid);
1404 1.1 dholland fp->fa2_fileid = txdr_unsigned(nvap->na_fileid);
1405 1.1 dholland txdr_nfsv2time(&nvap->na_atime, &fp->fa2_atime);
1406 1.1 dholland txdr_nfsv2time(&nvap->na_mtime, &fp->fa2_mtime);
1407 1.1 dholland txdr_nfsv2time(&nvap->na_ctime, &fp->fa2_ctime);
1408 1.1 dholland }
1409 1.1 dholland }
1410 1.1 dholland
1411 1.1 dholland /*
1412 1.1 dholland * This function gets a file handle out of an mbuf list.
1413 1.1 dholland * It returns 0 for success, EBADRPC otherwise.
1414 1.1 dholland * If sets the third flagp argument to 1 if the file handle is
1415 1.1 dholland * the public file handle.
1416 1.1 dholland * For NFSv4, if the length is incorrect, set nd_repstat == NFSERR_BADHANDLE
1417 1.1 dholland */
1418 1.1 dholland APPLESTATIC int
1419 1.1 dholland nfsrv_mtofh(struct nfsrv_descript *nd, struct nfsrvfh *fhp)
1420 1.1 dholland {
1421 1.1 dholland u_int32_t *tl;
1422 1.1 dholland int error = 0, len, copylen;
1423 1.1 dholland
1424 1.1 dholland if (nd->nd_flag & (ND_NFSV3 | ND_NFSV4)) {
1425 1.1 dholland NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED);
1426 1.1 dholland len = fxdr_unsigned(int, *tl);
1427 1.1 dholland if (len == 0 && nfs_pubfhset && (nd->nd_flag & ND_NFSV3) &&
1428 1.1 dholland nd->nd_procnum == NFSPROC_LOOKUP) {
1429 1.1 dholland nd->nd_flag |= ND_PUBLOOKUP;
1430 1.1 dholland goto nfsmout;
1431 1.1 dholland }
1432 1.1 dholland if (len < NFSRV_MINFH || len > NFSRV_MAXFH) {
1433 1.1 dholland if (nd->nd_flag & ND_NFSV4) {
1434 1.1 dholland if (len > 0 && len <= NFSX_V4FHMAX) {
1435 1.1 dholland error = nfsm_advance(nd, NFSM_RNDUP(len), -1);
1436 1.1 dholland if (error)
1437 1.1 dholland goto nfsmout;
1438 1.1 dholland nd->nd_repstat = NFSERR_BADHANDLE;
1439 1.1 dholland goto nfsmout;
1440 1.1 dholland } else {
1441 1.1 dholland error = EBADRPC;
1442 1.1 dholland goto nfsmout;
1443 1.1 dholland }
1444 1.1 dholland } else {
1445 1.1 dholland error = EBADRPC;
1446 1.1 dholland goto nfsmout;
1447 1.1 dholland }
1448 1.1 dholland }
1449 1.1 dholland copylen = len;
1450 1.1 dholland } else {
1451 1.1 dholland /*
1452 1.1 dholland * For NFSv2, the file handle is always 32 bytes on the
1453 1.1 dholland * wire, but this server only cares about the first
1454 1.1 dholland * NFSRV_MAXFH bytes.
1455 1.1 dholland */
1456 1.1 dholland len = NFSX_V2FH;
1457 1.1 dholland copylen = NFSRV_MAXFH;
1458 1.1 dholland }
1459 1.1 dholland NFSM_DISSECT(tl, u_int32_t *, len);
1460 1.1 dholland if ((nd->nd_flag & ND_NFSV2) && nfs_pubfhset &&
1461 1.1 dholland nd->nd_procnum == NFSPROC_LOOKUP &&
1462 1.1 dholland !NFSBCMP((caddr_t)tl, nfs_v2pubfh, NFSX_V2FH)) {
1463 1.1 dholland nd->nd_flag |= ND_PUBLOOKUP;
1464 1.1 dholland goto nfsmout;
1465 1.1 dholland }
1466 1.1 dholland NFSBCOPY(tl, (caddr_t)fhp->nfsrvfh_data, copylen);
1467 1.1 dholland fhp->nfsrvfh_len = copylen;
1468 1.1 dholland nfsmout:
1469 1.1 dholland NFSEXITCODE2(error, nd);
1470 1.1 dholland return (error);
1471 1.1 dholland }
1472 1.1 dholland
1473 1.1 dholland /*
1474 1.1 dholland * Map errnos to NFS error numbers. For Version 3 and 4 also filter out error
1475 1.1 dholland * numbers not specified for the associated procedure.
1476 1.1 dholland * NFSPROC_NOOP is a special case, where the high order bits of nd_repstat
1477 1.1 dholland * should be cleared. NFSPROC_NOOP is used to return errors when a valid
1478 1.1 dholland * RPC procedure is not involved.
1479 1.1 dholland * Returns the error number in XDR.
1480 1.1 dholland */
1481 1.1 dholland APPLESTATIC int
1482 1.1 dholland nfsd_errmap(struct nfsrv_descript *nd)
1483 1.1 dholland {
1484 1.1 dholland short *defaulterrp, *errp;
1485 1.1 dholland
1486 1.1 dholland if (!nd->nd_repstat)
1487 1.1 dholland return (0);
1488 1.1 dholland if (nd->nd_flag & (ND_NFSV3 | ND_NFSV4)) {
1489 1.1 dholland if (nd->nd_procnum == NFSPROC_NOOP)
1490 1.1 dholland return (txdr_unsigned(nd->nd_repstat & 0xffff));
1491 1.1 dholland if (nd->nd_flag & ND_NFSV3)
1492 1.1 dholland errp = defaulterrp = nfsrv_v3errmap[nd->nd_procnum];
1493 1.1 dholland else if (nd->nd_repstat == EBADRPC)
1494 1.1 dholland return (txdr_unsigned(NFSERR_BADXDR));
1495 1.1 dholland else if (nd->nd_repstat == NFSERR_MINORVERMISMATCH ||
1496 1.1 dholland nd->nd_repstat == NFSERR_OPILLEGAL)
1497 1.1 dholland return (txdr_unsigned(nd->nd_repstat));
1498 1.1 dholland else
1499 1.1 dholland errp = defaulterrp = nfsrv_v4errmap[nd->nd_procnum];
1500 1.1 dholland while (*++errp)
1501 1.1 dholland if (*errp == nd->nd_repstat)
1502 1.1 dholland return (txdr_unsigned(nd->nd_repstat));
1503 1.1 dholland return (txdr_unsigned(*defaulterrp));
1504 1.1 dholland }
1505 1.1 dholland if (nd->nd_repstat <= ELAST)
1506 1.1 dholland return (txdr_unsigned(nfsrv_v2errmap[nd->nd_repstat - 1]));
1507 1.1 dholland return (txdr_unsigned(NFSERR_IO));
1508 1.1 dholland }
1509 1.1 dholland
1510 1.1 dholland /*
1511 1.1 dholland * Check to see if setting a uid/gid is permitted when creating a new
1512 1.1 dholland * file object. (Called when uid and/or gid is specified in the
1513 1.1 dholland * settable attributes for V4.
1514 1.1 dholland */
1515 1.1 dholland APPLESTATIC int
1516 1.1 dholland nfsrv_checkuidgid(struct nfsrv_descript *nd, struct nfsvattr *nvap)
1517 1.1 dholland {
1518 1.1 dholland int error = 0;
1519 1.1 dholland
1520 1.1 dholland /*
1521 1.1 dholland * If not setting either uid nor gid, it's OK.
1522 1.1 dholland */
1523 1.1 dholland if (NFSVNO_NOTSETUID(nvap) && NFSVNO_NOTSETGID(nvap))
1524 1.1 dholland goto out;
1525 1.1 dholland if ((NFSVNO_ISSETUID(nvap) && nvap->na_uid == nfsrv_defaultuid)
1526 1.1 dholland || (NFSVNO_ISSETGID(nvap) && nvap->na_gid == nfsrv_defaultgid)) {
1527 1.1 dholland error = NFSERR_BADOWNER;
1528 1.1 dholland goto out;
1529 1.1 dholland }
1530 1.1 dholland if (nd->nd_cred->cr_uid == 0)
1531 1.1 dholland goto out;
1532 1.1 dholland if ((NFSVNO_ISSETUID(nvap) && nvap->na_uid != nd->nd_cred->cr_uid) ||
1533 1.1 dholland (NFSVNO_ISSETGID(nvap) && nvap->na_gid != nd->nd_cred->cr_gid &&
1534 1.1 dholland !groupmember(nvap->na_gid, nd->nd_cred)))
1535 1.1 dholland error = NFSERR_PERM;
1536 1.1 dholland
1537 1.1 dholland out:
1538 1.1 dholland NFSEXITCODE2(error, nd);
1539 1.1 dholland return (error);
1540 1.1 dholland }
1541 1.1 dholland
1542 1.1 dholland /*
1543 1.1 dholland * and this routine fixes up the settable attributes for V4 if allowed
1544 1.1 dholland * by nfsrv_checkuidgid().
1545 1.1 dholland */
1546 1.1 dholland APPLESTATIC void
1547 1.1 dholland nfsrv_fixattr(struct nfsrv_descript *nd, vnode_t vp,
1548 1.1 dholland struct nfsvattr *nvap, NFSACL_T *aclp, NFSPROC_T *p, nfsattrbit_t *attrbitp,
1549 1.1 dholland struct nfsexstuff *exp)
1550 1.1 dholland {
1551 1.1 dholland int change = 0;
1552 1.1 dholland struct nfsvattr nva;
1553 1.1 dholland uid_t tuid;
1554 1.1 dholland int error;
1555 1.1 dholland nfsattrbit_t nattrbits;
1556 1.1 dholland
1557 1.1 dholland /*
1558 1.1 dholland * Maybe this should be done for V2 and 3 but it never has been
1559 1.1 dholland * and nobody seems to be upset, so I think it's best not to change
1560 1.1 dholland * the V2 and 3 semantics.
1561 1.1 dholland */
1562 1.1 dholland if ((nd->nd_flag & ND_NFSV4) == 0)
1563 1.1 dholland goto out;
1564 1.1 dholland NFSVNO_ATTRINIT(&nva);
1565 1.1 dholland NFSZERO_ATTRBIT(&nattrbits);
1566 1.1 dholland tuid = nd->nd_cred->cr_uid;
1567 1.1 dholland if (NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_OWNER) &&
1568 1.1 dholland NFSVNO_ISSETUID(nvap) &&
1569 1.1 dholland nvap->na_uid != nd->nd_cred->cr_uid) {
1570 1.1 dholland if (nd->nd_cred->cr_uid == 0) {
1571 1.1 dholland nva.na_uid = nvap->na_uid;
1572 1.1 dholland change++;
1573 1.1 dholland NFSSETBIT_ATTRBIT(&nattrbits, NFSATTRBIT_OWNER);
1574 1.1 dholland } else {
1575 1.1 dholland NFSCLRBIT_ATTRBIT(attrbitp, NFSATTRBIT_OWNER);
1576 1.1 dholland }
1577 1.1 dholland }
1578 1.1 dholland if (NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_TIMEACCESSSET) &&
1579 1.1 dholland NFSVNO_ISSETATIME(nvap)) {
1580 1.1 dholland nva.na_atime = nvap->na_atime;
1581 1.1 dholland change++;
1582 1.1 dholland NFSSETBIT_ATTRBIT(&nattrbits, NFSATTRBIT_TIMEACCESSSET);
1583 1.1 dholland }
1584 1.1 dholland if (NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_TIMEMODIFYSET) &&
1585 1.1 dholland NFSVNO_ISSETMTIME(nvap)) {
1586 1.1 dholland nva.na_mtime = nvap->na_mtime;
1587 1.1 dholland change++;
1588 1.1 dholland NFSSETBIT_ATTRBIT(&nattrbits, NFSATTRBIT_TIMEMODIFYSET);
1589 1.1 dholland }
1590 1.1 dholland if (NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_OWNERGROUP) &&
1591 1.1 dholland NFSVNO_ISSETGID(nvap)) {
1592 1.1 dholland if (nvap->na_gid == nd->nd_cred->cr_gid ||
1593 1.1 dholland groupmember(nvap->na_gid, nd->nd_cred)) {
1594 1.1 dholland nd->nd_cred->cr_uid = 0;
1595 1.1 dholland nva.na_gid = nvap->na_gid;
1596 1.1 dholland change++;
1597 1.1 dholland NFSSETBIT_ATTRBIT(&nattrbits, NFSATTRBIT_OWNERGROUP);
1598 1.1 dholland } else {
1599 1.1 dholland NFSCLRBIT_ATTRBIT(attrbitp, NFSATTRBIT_OWNERGROUP);
1600 1.1 dholland }
1601 1.1 dholland }
1602 1.1 dholland if (change) {
1603 1.1 dholland error = nfsvno_setattr(vp, &nva, nd->nd_cred, p, exp);
1604 1.1 dholland if (error) {
1605 1.1 dholland NFSCLRALL_ATTRBIT(attrbitp, &nattrbits);
1606 1.1 dholland }
1607 1.1 dholland }
1608 1.1 dholland if (NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_SIZE) &&
1609 1.1 dholland NFSVNO_ISSETSIZE(nvap) && nvap->na_size != (u_quad_t)0) {
1610 1.1 dholland NFSCLRBIT_ATTRBIT(attrbitp, NFSATTRBIT_SIZE);
1611 1.1 dholland }
1612 1.1 dholland #ifdef NFS4_ACL_EXTATTR_NAME
1613 1.1 dholland if (NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_ACL) &&
1614 1.1 dholland nfsrv_useacl != 0 && aclp != NULL) {
1615 1.1 dholland if (aclp->acl_cnt > 0) {
1616 1.1 dholland error = nfsrv_setacl(vp, aclp, nd->nd_cred, p);
1617 1.1 dholland if (error) {
1618 1.1 dholland NFSCLRBIT_ATTRBIT(attrbitp, NFSATTRBIT_ACL);
1619 1.1 dholland }
1620 1.1 dholland }
1621 1.1 dholland } else
1622 1.1 dholland #endif
1623 1.1 dholland NFSCLRBIT_ATTRBIT(attrbitp, NFSATTRBIT_ACL);
1624 1.1 dholland nd->nd_cred->cr_uid = tuid;
1625 1.1 dholland
1626 1.1 dholland out:
1627 1.1 dholland NFSEXITCODE2(0, nd);
1628 1.1 dholland }
1629 1.1 dholland
1630 1.1 dholland /*
1631 1.1 dholland * Translate an ASCII hex digit to it's binary value. Return -1 if the
1632 1.1 dholland * char isn't a hex digit.
1633 1.1 dholland */
1634 1.1 dholland static char
1635 1.1 dholland nfsrv_hexdigit(char c, int *err)
1636 1.1 dholland {
1637 1.1 dholland
1638 1.1 dholland *err = 0;
1639 1.1 dholland if (c >= '0' && c <= '9')
1640 1.1 dholland return (c - '0');
1641 1.1 dholland if (c >= 'a' && c <= 'f')
1642 1.1 dholland return (c - 'a' + ((char)10));
1643 1.1 dholland if (c >= 'A' && c <= 'F')
1644 1.1 dholland return (c - 'A' + ((char)10));
1645 1.1 dholland /* Not valid ! */
1646 1.1 dholland *err = 1;
1647 1.1 dholland return (1); /* BOGUS */
1648 1.1 dholland }
1649 1.1 dholland
1650 1.1 dholland /*
1651 1.1 dholland * Check to see if NFSERR_MOVED can be returned for this op. Return 1 iff
1652 1.1 dholland * it can be.
1653 1.1 dholland */
1654 1.1 dholland APPLESTATIC int
1655 1.1 dholland nfsrv_errmoved(int op)
1656 1.1 dholland {
1657 1.1 dholland short *errp;
1658 1.1 dholland
1659 1.1 dholland errp = nfsrv_v4errmap[op];
1660 1.1 dholland while (*errp != 0) {
1661 1.1 dholland if (*errp == NFSERR_MOVED)
1662 1.1 dholland return (1);
1663 1.1 dholland errp++;
1664 1.1 dholland }
1665 1.1 dholland return (0);
1666 1.1 dholland }
1667 1.1 dholland
1668 1.1 dholland /*
1669 1.1 dholland * Fill in attributes for a Referral.
1670 1.1 dholland * (Return the number of bytes of XDR created.)
1671 1.1 dholland */
1672 1.1 dholland APPLESTATIC int
1673 1.1 dholland nfsrv_putreferralattr(struct nfsrv_descript *nd, nfsattrbit_t *retbitp,
1674 1.1 dholland struct nfsreferral *refp, int getattr, int *reterrp)
1675 1.1 dholland {
1676 1.1 dholland u_int32_t *tl, *retnump;
1677 1.1 dholland u_char *cp, *cp2;
1678 1.1 dholland int prefixnum, retnum = 0, i, len, bitpos, rderrbit = 0, nonrefbit = 0;
1679 1.1 dholland int fslocationsbit = 0;
1680 1.1 dholland nfsattrbit_t tmpbits, refbits;
1681 1.1 dholland
1682 1.1 dholland NFSREFERRAL_ATTRBIT(&refbits);
1683 1.1 dholland if (getattr)
1684 1.1 dholland NFSCLRBIT_ATTRBIT(&refbits, NFSATTRBIT_RDATTRERROR);
1685 1.1 dholland else if (NFSISSET_ATTRBIT(retbitp, NFSATTRBIT_RDATTRERROR))
1686 1.1 dholland rderrbit = 1;
1687 1.1 dholland if (NFSISSET_ATTRBIT(retbitp, NFSATTRBIT_FSLOCATIONS))
1688 1.1 dholland fslocationsbit = 1;
1689 1.1 dholland
1690 1.1 dholland /*
1691 1.1 dholland * Check for the case where unsupported referral attributes are
1692 1.1 dholland * requested.
1693 1.1 dholland */
1694 1.1 dholland NFSSET_ATTRBIT(&tmpbits, retbitp);
1695 1.1 dholland NFSCLRALL_ATTRBIT(&tmpbits, &refbits);
1696 1.1 dholland if (NFSNONZERO_ATTRBIT(&tmpbits))
1697 1.1 dholland nonrefbit = 1;
1698 1.1 dholland
1699 1.1 dholland if (nonrefbit && !fslocationsbit && (getattr || !rderrbit)) {
1700 1.1 dholland *reterrp = NFSERR_MOVED;
1701 1.1 dholland return (0);
1702 1.1 dholland }
1703 1.1 dholland
1704 1.1 dholland /*
1705 1.1 dholland * Now we can fill in the attributes.
1706 1.1 dholland */
1707 1.1 dholland NFSSET_ATTRBIT(&tmpbits, retbitp);
1708 1.1 dholland NFSCLRNOT_ATTRBIT(&tmpbits, &refbits);
1709 1.1 dholland
1710 1.1 dholland /*
1711 1.1 dholland * Put out the attribute bitmap for the ones being filled in
1712 1.1 dholland * and get the field for the number of attributes returned.
1713 1.1 dholland */
1714 1.1 dholland prefixnum = nfsrv_putattrbit(nd, &tmpbits);
1715 1.1 dholland NFSM_BUILD(retnump, u_int32_t *, NFSX_UNSIGNED);
1716 1.1 dholland prefixnum += NFSX_UNSIGNED;
1717 1.1 dholland
1718 1.1 dholland /*
1719 1.1 dholland * Now, loop around filling in the attributes for each bit set.
1720 1.1 dholland */
1721 1.1 dholland for (bitpos = 0; bitpos < NFSATTRBIT_MAX; bitpos++) {
1722 1.1 dholland if (NFSISSET_ATTRBIT(&tmpbits, bitpos)) {
1723 1.1 dholland switch (bitpos) {
1724 1.1 dholland case NFSATTRBIT_TYPE:
1725 1.1 dholland NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
1726 1.1 dholland *tl = txdr_unsigned(NFDIR);
1727 1.1 dholland retnum += NFSX_UNSIGNED;
1728 1.1 dholland break;
1729 1.1 dholland case NFSATTRBIT_FSID:
1730 1.1 dholland NFSM_BUILD(tl, u_int32_t *, NFSX_V4FSID);
1731 1.1 dholland *tl++ = 0;
1732 1.1 dholland *tl++ = txdr_unsigned(NFSV4ROOT_FSID0);
1733 1.1 dholland *tl++ = 0;
1734 1.1 dholland *tl = txdr_unsigned(NFSV4ROOT_REFERRAL);
1735 1.1 dholland retnum += NFSX_V4FSID;
1736 1.1 dholland break;
1737 1.1 dholland case NFSATTRBIT_RDATTRERROR:
1738 1.1 dholland NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
1739 1.1 dholland if (nonrefbit)
1740 1.1 dholland *tl = txdr_unsigned(NFSERR_MOVED);
1741 1.1 dholland else
1742 1.1 dholland *tl = 0;
1743 1.1 dholland retnum += NFSX_UNSIGNED;
1744 1.1 dholland break;
1745 1.1 dholland case NFSATTRBIT_FSLOCATIONS:
1746 1.1 dholland retnum += nfsm_strtom(nd, "/", 1);
1747 1.1 dholland NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
1748 1.1 dholland *tl = txdr_unsigned(refp->nfr_srvcnt);
1749 1.1 dholland retnum += NFSX_UNSIGNED;
1750 1.1 dholland cp = refp->nfr_srvlist;
1751 1.1 dholland for (i = 0; i < refp->nfr_srvcnt; i++) {
1752 1.1 dholland NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
1753 1.1 dholland *tl = txdr_unsigned(1);
1754 1.1 dholland retnum += NFSX_UNSIGNED;
1755 1.1 dholland cp2 = STRCHR(cp, ':');
1756 1.1 dholland if (cp2 != NULL)
1757 1.1 dholland len = cp2 - cp;
1758 1.1 dholland else
1759 1.1 dholland len = 1;
1760 1.1 dholland retnum += nfsm_strtom(nd, cp, len);
1761 1.1 dholland if (cp2 != NULL)
1762 1.1 dholland cp = cp2 + 1;
1763 1.1 dholland cp2 = STRCHR(cp, ',');
1764 1.1 dholland if (cp2 != NULL)
1765 1.1 dholland len = cp2 - cp;
1766 1.1 dholland else
1767 1.1 dholland len = strlen(cp);
1768 1.1 dholland retnum += nfsm_strtom(nd, cp, len);
1769 1.1 dholland if (cp2 != NULL)
1770 1.1 dholland cp = cp2 + 1;
1771 1.1 dholland }
1772 1.1 dholland break;
1773 1.1 dholland case NFSATTRBIT_MOUNTEDONFILEID:
1774 1.1 dholland NFSM_BUILD(tl, u_int32_t *, NFSX_HYPER);
1775 1.1 dholland *tl++ = 0;
1776 1.1 dholland *tl = txdr_unsigned(refp->nfr_dfileno);
1777 1.1 dholland retnum += NFSX_HYPER;
1778 1.1 dholland break;
1779 1.1 dholland default:
1780 1.1 dholland printf("EEK! Bad V4 refattr bitpos=%d\n", bitpos);
1781 1.1 dholland };
1782 1.1 dholland }
1783 1.1 dholland }
1784 1.1 dholland *retnump = txdr_unsigned(retnum);
1785 1.1 dholland return (retnum + prefixnum);
1786 1.1 dholland }
1787 1.1 dholland
1788 1.1 dholland /*
1789 1.1 dholland * Parse a file name out of a request.
1790 1.1 dholland */
1791 1.1 dholland APPLESTATIC int
1792 1.1 dholland nfsrv_parsename(struct nfsrv_descript *nd, char *bufp, u_long *hashp,
1793 1.1 dholland NFSPATHLEN_T *outlenp)
1794 1.1 dholland {
1795 1.1 dholland char *fromcp, *tocp, val = '\0';
1796 1.1 dholland mbuf_t md;
1797 1.1 dholland int i;
1798 1.1 dholland int rem, len, error = 0, pubtype = 0, outlen = 0, percent = 0;
1799 1.1 dholland char digit;
1800 1.1 dholland u_int32_t *tl;
1801 1.1 dholland u_long hash = 0;
1802 1.1 dholland
1803 1.1 dholland if (hashp != NULL)
1804 1.1 dholland *hashp = 0;
1805 1.1 dholland tocp = bufp;
1806 1.1 dholland /*
1807 1.1 dholland * For V4, check for lookup parent.
1808 1.1 dholland * Otherwise, get the component name.
1809 1.1 dholland */
1810 1.1 dholland if ((nd->nd_flag & ND_NFSV4) && nd->nd_procnum == NFSV4OP_LOOKUPP) {
1811 1.1 dholland *tocp++ = '.';
1812 1.1 dholland hash += ((u_char)'.');
1813 1.1 dholland *tocp++ = '.';
1814 1.1 dholland hash += ((u_char)'.');
1815 1.1 dholland outlen = 2;
1816 1.1 dholland } else {
1817 1.1 dholland /*
1818 1.1 dholland * First, get the name length.
1819 1.1 dholland */
1820 1.1 dholland NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED);
1821 1.1 dholland len = fxdr_unsigned(int, *tl);
1822 1.1 dholland if (len > NFS_MAXNAMLEN) {
1823 1.1 dholland nd->nd_repstat = NFSERR_NAMETOL;
1824 1.1 dholland error = 0;
1825 1.1 dholland goto nfsmout;
1826 1.1 dholland } else if (len <= 0) {
1827 1.1 dholland nd->nd_repstat = NFSERR_INVAL;
1828 1.1 dholland error = 0;
1829 1.1 dholland goto nfsmout;
1830 1.1 dholland }
1831 1.1 dholland
1832 1.1 dholland /*
1833 1.1 dholland * Now, copy the component name into the buffer.
1834 1.1 dholland */
1835 1.1 dholland fromcp = nd->nd_dpos;
1836 1.1 dholland md = nd->nd_md;
1837 1.1 dholland rem = NFSMTOD(md, caddr_t) + mbuf_len(md) - fromcp;
1838 1.1 dholland for (i = 0; i < len; i++) {
1839 1.1 dholland while (rem == 0) {
1840 1.1 dholland md = mbuf_next(md);
1841 1.1 dholland if (md == NULL) {
1842 1.1 dholland error = EBADRPC;
1843 1.1 dholland goto nfsmout;
1844 1.1 dholland }
1845 1.1 dholland fromcp = NFSMTOD(md, caddr_t);
1846 1.1 dholland rem = mbuf_len(md);
1847 1.1 dholland }
1848 1.1 dholland if (*fromcp == '\0') {
1849 1.1 dholland nd->nd_repstat = EACCES;
1850 1.1 dholland error = 0;
1851 1.1 dholland goto nfsmout;
1852 1.1 dholland }
1853 1.1 dholland /*
1854 1.1 dholland * For lookups on the public filehandle, do some special
1855 1.1 dholland * processing on the name. (The public file handle is the
1856 1.1 dholland * root of the public file system for this server.)
1857 1.1 dholland */
1858 1.1 dholland if (nd->nd_flag & ND_PUBLOOKUP) {
1859 1.1 dholland /*
1860 1.1 dholland * If the first char is ASCII, it is a canonical
1861 1.1 dholland * path, otherwise it is a native path. (RFC2054
1862 1.1 dholland * doesn't actually state what it is if the first
1863 1.1 dholland * char isn't ASCII or 0x80, so I assume native.)
1864 1.1 dholland * pubtype == 1 -> native path
1865 1.1 dholland * pubtype == 2 -> canonical path
1866 1.1 dholland */
1867 1.1 dholland if (i == 0) {
1868 1.1 dholland if (*fromcp & 0x80) {
1869 1.1 dholland /*
1870 1.1 dholland * Since RFC2054 doesn't indicate
1871 1.1 dholland * that a native path of just 0x80
1872 1.1 dholland * isn't allowed, I'll replace the
1873 1.1 dholland * 0x80 with '/' instead of just
1874 1.1 dholland * throwing it away.
1875 1.1 dholland */
1876 1.1 dholland *fromcp = '/';
1877 1.1 dholland pubtype = 1;
1878 1.1 dholland } else {
1879 1.1 dholland pubtype = 2;
1880 1.1 dholland }
1881 1.1 dholland }
1882 1.1 dholland /*
1883 1.1 dholland * '/' only allowed in a native path
1884 1.1 dholland */
1885 1.1 dholland if (*fromcp == '/' && pubtype != 1) {
1886 1.1 dholland nd->nd_repstat = EACCES;
1887 1.1 dholland error = 0;
1888 1.1 dholland goto nfsmout;
1889 1.1 dholland }
1890 1.1 dholland
1891 1.1 dholland /*
1892 1.1 dholland * For the special case of 2 hex digits after a
1893 1.1 dholland * '%' in an absolute path, calculate the value.
1894 1.1 dholland * percent == 1 -> indicates "get first hex digit"
1895 1.1 dholland * percent == 2 -> indicates "get second hex digit"
1896 1.1 dholland */
1897 1.1 dholland if (percent > 0) {
1898 1.1 dholland digit = nfsrv_hexdigit(*fromcp, &error);
1899 1.1 dholland if (error) {
1900 1.1 dholland nd->nd_repstat = EACCES;
1901 1.1 dholland error = 0;
1902 1.1 dholland goto nfsmout;
1903 1.1 dholland }
1904 1.1 dholland if (percent == 1) {
1905 1.1 dholland val = (digit << 4);
1906 1.1 dholland percent = 2;
1907 1.1 dholland } else {
1908 1.1 dholland val += digit;
1909 1.1 dholland percent = 0;
1910 1.1 dholland *tocp++ = val;
1911 1.1 dholland hash += ((u_char)val);
1912 1.1 dholland outlen++;
1913 1.1 dholland }
1914 1.1 dholland } else {
1915 1.1 dholland if (*fromcp == '%' && pubtype == 2) {
1916 1.1 dholland /*
1917 1.1 dholland * Must be followed by 2 hex digits
1918 1.1 dholland */
1919 1.1 dholland if ((len - i) < 3) {
1920 1.1 dholland nd->nd_repstat = EACCES;
1921 1.1 dholland error = 0;
1922 1.1 dholland goto nfsmout;
1923 1.1 dholland }
1924 1.1 dholland percent = 1;
1925 1.1 dholland } else {
1926 1.1 dholland *tocp++ = *fromcp;
1927 1.1 dholland hash += ((u_char)*fromcp);
1928 1.1 dholland outlen++;
1929 1.1 dholland }
1930 1.1 dholland }
1931 1.1 dholland } else {
1932 1.1 dholland /*
1933 1.1 dholland * Normal, non lookup on public, name.
1934 1.1 dholland */
1935 1.1 dholland if (*fromcp == '/') {
1936 1.1 dholland if (nd->nd_flag & ND_NFSV4)
1937 1.1 dholland nd->nd_repstat = NFSERR_BADNAME;
1938 1.1 dholland else
1939 1.1 dholland nd->nd_repstat = EACCES;
1940 1.1 dholland error = 0;
1941 1.1 dholland goto nfsmout;
1942 1.1 dholland }
1943 1.1 dholland hash += ((u_char)*fromcp);
1944 1.1 dholland *tocp++ = *fromcp;
1945 1.1 dholland outlen++;
1946 1.1 dholland }
1947 1.1 dholland fromcp++;
1948 1.1 dholland rem--;
1949 1.1 dholland }
1950 1.1 dholland nd->nd_md = md;
1951 1.1 dholland nd->nd_dpos = fromcp;
1952 1.1 dholland i = NFSM_RNDUP(len) - len;
1953 1.1 dholland if (i > 0) {
1954 1.1 dholland if (rem >= i) {
1955 1.1 dholland nd->nd_dpos += i;
1956 1.1 dholland } else {
1957 1.1 dholland error = nfsm_advance(nd, i, rem);
1958 1.1 dholland if (error)
1959 1.1 dholland goto nfsmout;
1960 1.1 dholland }
1961 1.1 dholland }
1962 1.1 dholland
1963 1.1 dholland /*
1964 1.1 dholland * For v4, don't allow lookups of '.' or '..' and
1965 1.1 dholland * also check for non-utf8 strings.
1966 1.1 dholland */
1967 1.1 dholland if (nd->nd_flag & ND_NFSV4) {
1968 1.1 dholland if ((outlen == 1 && bufp[0] == '.') ||
1969 1.1 dholland (outlen == 2 && bufp[0] == '.' &&
1970 1.1 dholland bufp[1] == '.')) {
1971 1.1 dholland nd->nd_repstat = NFSERR_BADNAME;
1972 1.1 dholland error = 0;
1973 1.1 dholland goto nfsmout;
1974 1.1 dholland }
1975 1.1 dholland if (disable_checkutf8 == 0 &&
1976 1.1 dholland nfsrv_checkutf8((u_int8_t *)bufp, outlen)) {
1977 1.1 dholland nd->nd_repstat = NFSERR_INVAL;
1978 1.1 dholland error = 0;
1979 1.1 dholland goto nfsmout;
1980 1.1 dholland }
1981 1.1 dholland }
1982 1.1 dholland }
1983 1.1 dholland *tocp = '\0';
1984 1.1 dholland *outlenp = (size_t)outlen;
1985 1.1 dholland if (hashp != NULL)
1986 1.1 dholland *hashp = hash;
1987 1.1 dholland nfsmout:
1988 1.1 dholland NFSEXITCODE2(error, nd);
1989 1.1 dholland return (error);
1990 1.1 dholland }
1991 1.1 dholland
1992 1.1 dholland /*
1993 1.1 dholland * Check the tcp socket sequence number has been acknowledged.
1994 1.1 dholland */
1995 1.1 dholland int
1996 1.1 dholland nfsrv_checksockseqnum(struct socket *so, tcp_seq tcpseqval)
1997 1.1 dholland {
1998 1.1 dholland tcp_seq maxseq, unaseq;
1999 1.1 dholland int error, ret;
2000 1.1 dholland
2001 1.1 dholland error = nfsrv_getsocksndseq(so, &maxseq, &unaseq);
2002 1.1 dholland if (error)
2003 1.1 dholland return (0);
2004 1.1 dholland ret = SEQ_GEQ(unaseq, tcpseqval);
2005 1.1 dholland return (ret);
2006 1.1 dholland }
2007 1.1 dholland
2008 1.1 dholland /*
2009 1.1 dholland * Get the tcp sequence number to be acknowledged.
2010 1.1 dholland */
2011 1.1 dholland int
2012 1.1 dholland nfsrv_getsockseqnum(struct socket *so, tcp_seq *tcpseqp)
2013 1.1 dholland {
2014 1.1 dholland tcp_seq maxseq, unaseq;
2015 1.1 dholland u_int sbcc;
2016 1.1 dholland int error;
2017 1.1 dholland
2018 1.1 dholland sbcc = so->so_snd.sb_cc;
2019 1.1 dholland error = nfsrv_getsocksndseq(so, &maxseq, &unaseq);
2020 1.1 dholland if (error)
2021 1.1 dholland return (0);
2022 1.1 dholland /*
2023 1.1 dholland * Set the seq# to a value that will
2024 1.1 dholland * be at least the end of the reply.
2025 1.1 dholland * When this sequence# is acknowledged
2026 1.1 dholland * by the client, the client has received
2027 1.1 dholland * the reply.
2028 1.1 dholland */
2029 1.1 dholland *tcpseqp = sbcc + maxseq;
2030 1.1 dholland return (1);
2031 1.1 dholland }
2032 1.1 dholland
2033 1.1 dholland void
2034 1.1 dholland nfsd_init(void)
2035 1.1 dholland {
2036 1.1 dholland int i;
2037 1.1 dholland static int inited = 0;
2038 1.1 dholland
2039 1.1 dholland if (inited)
2040 1.1 dholland return;
2041 1.1 dholland inited = 1;
2042 1.1 dholland
2043 1.1 dholland /*
2044 1.1 dholland * Initialize client queues. Don't free/reinitialize
2045 1.1 dholland * them when nfsds are restarted.
2046 1.1 dholland */
2047 1.1 dholland for (i = 0; i < NFSCLIENTHASHSIZE; i++)
2048 1.1 dholland LIST_INIT(&nfsclienthash[i]);
2049 1.1 dholland for (i = 0; i < NFSLOCKHASHSIZE; i++)
2050 1.1 dholland LIST_INIT(&nfslockhash[i]);
2051 1.1 dholland
2052 1.1 dholland /* and the v2 pubfh should be all zeros */
2053 1.1 dholland NFSBZERO(nfs_v2pubfh, NFSX_V2FH);
2054 1.1 dholland }
2055 1.1 dholland
2056 1.1 dholland /*
2057 1.1 dholland * Check the v4 root exports.
2058 1.1 dholland * Return 0 if ok, 1 otherwise.
2059 1.1 dholland */
2060 1.1 dholland int
2061 1.1 dholland nfsd_checkrootexp(struct nfsrv_descript *nd)
2062 1.1 dholland {
2063 1.1 dholland
2064 1.1 dholland if ((nd->nd_flag & (ND_GSS | ND_EXAUTHSYS)) == ND_EXAUTHSYS)
2065 1.1 dholland return (0);
2066 1.1 dholland if ((nd->nd_flag & (ND_GSSINTEGRITY | ND_EXGSSINTEGRITY)) ==
2067 1.1 dholland (ND_GSSINTEGRITY | ND_EXGSSINTEGRITY))
2068 1.1 dholland return (0);
2069 1.1 dholland if ((nd->nd_flag & (ND_GSSPRIVACY | ND_EXGSSPRIVACY)) ==
2070 1.1 dholland (ND_GSSPRIVACY | ND_EXGSSPRIVACY))
2071 1.1 dholland return (0);
2072 1.1 dholland if ((nd->nd_flag & (ND_GSS | ND_GSSINTEGRITY | ND_GSSPRIVACY |
2073 1.1 dholland ND_EXGSS)) == (ND_GSS | ND_EXGSS))
2074 1.1 dholland return (0);
2075 1.1 dholland return (1);
2076 1.1 dholland }
2077 1.1 dholland
2078