xref: /titanic_41/usr/src/uts/common/nfs/nfs.h (revision b59b3655028aeb11832ad679eb5c2577c2b75235)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
23  * Copyright (c) 2013 by Delphix. All rights reserved.
24  * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
25  */
26 
27 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
28 /*	  All Rights Reserved  	*/
29 
30 #ifndef	_NFS_NFS_H
31 #define	_NFS_NFS_H
32 
33 /*	nfs.h 2.38 88/08/19 SMI 	*/
34 
35 #include <sys/isa_defs.h>
36 #include <sys/vfs.h>
37 #include <sys/stream.h>
38 #include <rpc/types.h>
39 #include <sys/types32.h>
40 #ifdef _KERNEL
41 #include <rpc/rpc_rdma.h>
42 #include <rpc/rpc.h>
43 #include <sys/fcntl.h>
44 #include <sys/kstat.h>
45 #include <sys/dirent.h>
46 #include <sys/zone.h>
47 #include <sys/tsol/label.h>
48 #include <sys/nvpair.h>
49 #include <nfs/mount.h>
50 #include <sys/vfs_opreg.h>
51 #endif
52 #include <vm/page.h>
53 #include <rpc/rpc_sztypes.h>
54 #include <sys/sysmacros.h>
55 #ifdef	__cplusplus
56 extern "C" {
57 #endif
58 
59 /*
60  * remote file service numbers
61  */
62 #define	NFS_PROGRAM	((rpcprog_t)100003)
63 #define	NFS_VERSMIN	((rpcvers_t)2)
64 #define	NFS_VERSMAX	((rpcvers_t)4)
65 #define	NFS_VERSION	((rpcvers_t)2)
66 #define	NFS_PORT	2049
67 
68 /*
69  * Used to determine registration and service handling of versions
70  */
71 #define	NFS_VERSMIN_DEFAULT	((rpcvers_t)2)
72 #define	NFS_VERSMAX_DEFAULT	((rpcvers_t)4)
73 
74 extern rpcvers_t nfs_versmin;
75 extern rpcvers_t nfs_versmax;
76 
77 /*
78  * Default delegation setting for the server ==> "on"
79  */
80 #define	NFS_SERVER_DELEGATION_DEFAULT	(TRUE)
81 
82 /* Maximum size of data portion of a remote request */
83 #define	NFS_MAXDATA	8192
84 #define	NFS_MAXNAMLEN	255
85 #define	NFS_MAXPATHLEN	1024
86 
87 /*
88  * Rpc retransmission parameters
89  */
90 #define	NFS_TIMEO	11	/* initial timeout for clts in 10th of a sec */
91 #define	NFS_RETRIES	5	/* times to retry request */
92 #define	NFS_COTS_TIMEO	600	/* initial timeout for cots in 10th of a sec */
93 
94 /*
95  * The value of UID_NOBODY/GID_NOBODY presented to the world via NFS.
96  * UID_NOBODY/GID_NOBODY is translated to NFS_UID_NOBODY/NFS_GID_NOBODY
97  * when being sent out over the network and NFS_UID_NOBODY/NFS_GID_NOBODY
98  * is translated to UID_NOBODY/GID_NOBODY when received.
99  */
100 #define	NFS_UID_NOBODY	-2
101 #define	NFS_GID_NOBODY	-2
102 
103 /*
104  * maximum transfer size for different interfaces
105  */
106 #define	ECTSIZE	2048
107 #define	IETSIZE	8192
108 
109 /*
110  * WebNFS error status
111  */
112 enum wnfsstat {
113 	WNFSERR_CLNT_FLAVOR = 20001	/* invalid client sec flavor */
114 };
115 
116 /*
117  * Error status
118  * Should include all possible net errors.
119  * For now we just cast errno into an enum nfsstat.
120  */
121 enum nfsstat {
122 	NFS_OK = 0,			/* no error */
123 	NFSERR_PERM = 1,		/* Not owner */
124 	NFSERR_NOENT = 2,		/* No such file or directory */
125 	NFSERR_IO = 5,			/* I/O error */
126 	NFSERR_NXIO = 6,		/* No such device or address */
127 	NFSERR_ACCES = 13,		/* Permission denied */
128 	NFSERR_EXIST = 17,		/* File exists */
129 	NFSERR_XDEV = 18,		/* Cross-device link */
130 	NFSERR_NODEV = 19,		/* No such device */
131 	NFSERR_NOTDIR = 20,		/* Not a directory */
132 	NFSERR_ISDIR = 21,		/* Is a directory */
133 	NFSERR_INVAL = 22,		/* Invalid argument */
134 	NFSERR_FBIG = 27,		/* File too large */
135 	NFSERR_NOSPC = 28,		/* No space left on device */
136 	NFSERR_ROFS = 30,		/* Read-only file system */
137 	NFSERR_OPNOTSUPP = 45,		/* Operation not supported */
138 	NFSERR_NAMETOOLONG = 63,	/* File name too long */
139 	NFSERR_NOTEMPTY = 66,		/* Directory not empty */
140 	NFSERR_DQUOT = 69,		/* Disc quota exceeded */
141 	NFSERR_STALE = 70,		/* Stale NFS file handle */
142 	NFSERR_REMOTE = 71,		/* Object is remote */
143 	NFSERR_WFLUSH = 99		/* write cache flushed */
144 };
145 
146 typedef enum nfsstat nfsstat;
147 
148 /*
149  * File types
150  */
151 enum nfsftype {
152 	NFNON,
153 	NFREG,		/* regular file */
154 	NFDIR,		/* directory */
155 	NFBLK,		/* block special */
156 	NFCHR,		/* character special */
157 	NFLNK,		/* symbolic link */
158 	NFSOC		/* socket */
159 };
160 
161 /*
162  * Macros for converting device numbers to and from the format
163  * SunOS 4.x used. SVR4 uses 14 bit majors and 18 bits minors,
164  * SunOS 4.x used 8 bit majors and 8 bit minors. It isn't sufficient
165  * to use the cmpdev() and expdev() macros because they only compress
166  * 7 bit (and smaller) majors. We must compress 8 bit majors too.
167  * If the major or minor exceeds 8 bits, then we send it out in
168  * full 32 bit format and hope that the peer can deal with it.
169  */
170 
171 #define	SO4_BITSMAJOR	8	/* # of SunOS 4.x major device bits */
172 #define	SO4_BITSMINOR	8	/* # of SunOS 4.x minor device bits */
173 #define	SO4_MAXMAJ	0xff	/* SunOS 4.x max major value */
174 #define	SO4_MAXMIN	0xff	/* SunOS 4.x max minor value */
175 
176 /*
177  * Convert to over-the-wire device number format
178  */
179 #define	nfsv2_cmpdev(x) \
180 	((uint32_t) \
181 	((getmajor(x) > SO4_MAXMAJ || getminor(x) > SO4_MAXMIN) ? NODEV : \
182 	((getmajor(x) << SO4_BITSMINOR) | (getminor(x) & SO4_MAXMIN))))
183 
184 /*
185  * Convert from over-the-wire format to SVR4 device number format
186  */
187 #define	nfsv2_expdev(x) \
188 	makedevice((((x) >> SO4_BITSMINOR) & SO4_MAXMAJ), (x) & SO4_MAXMIN)
189 
190 /*
191  * Special kludge for fifos (named pipes)  [to adhere to NFS Protocol Spec]
192  *
193  * VFIFO is not in the protocol spec (VNON will be replaced by VFIFO)
194  * so the over-the-wire representation is VCHR with a '-1' device number.
195  *
196  * NOTE: This kludge becomes unnecessary with the Protocol Revision,
197  *	 but it may be necessary to support it (backwards compatibility).
198  */
199 #define	NFS_FIFO_TYPE	NFCHR
200 #define	NFS_FIFO_MODE	S_IFCHR
201 #define	NFS_FIFO_DEV	((uint32_t)-1)
202 
203 /* identify fifo in nfs attributes */
204 #define	NA_ISFIFO(NA)	(((NA)->na_type == NFS_FIFO_TYPE) && \
205 			    ((NA)->na_rdev == NFS_FIFO_DEV))
206 
207 /* set fifo in nfs attributes */
208 #define	NA_SETFIFO(NA)	{ \
209 		(NA)->na_type = NFS_FIFO_TYPE; \
210 		(NA)->na_rdev = NFS_FIFO_DEV; \
211 		(NA)->na_mode = ((NA)->na_mode & ~S_IFMT) | NFS_FIFO_MODE; \
212 		}
213 
214 /*
215  * Check for time overflow using a kernel tunable to determine whether
216  * we should accept or reject an unsigned 32-bit time value. Time value in NFS
217  * v2/3 protocol is unsigned 32 bit, but ILP32 kernel only allows 31 bits.
218  * In nfsv4, time value is a signed 64 bit, so needs to be checked for
219  * overflow as well (e.g. for setattr). So define the tunable as follows:
220  * nfs_allow_preepoch_time is TRUE if pre-epoch (negative) times are allowed
221  * and is FALSE (the default) otherwise. For nfsv2/3 this means that
222  * if negative times are allowed, the uint32_t time value is interpreted
223  * as a signed int, otherwise as a large positive number. For nfsv4,
224  * we use the value as is - except that if negative times are not allowed,
225  * we will not accept a negative value otw.
226  *
227  * So for nfsv2/3 (uint32_t):
228  *
229  * If nfs_allow_preepoch_time is
230  * FALSE, the maximum time value is INT32_MAX for 32-bit kernels and
231  * UINT32_MAX for 64-bit kernels (to allow times larger than 2038)
232  * and the minimum is zero. Note that in that case, a 32-bit application
233  * running on a 64-bit kernel will not be able to access files with
234  * the larger time values.
235  * If nfs_allow_preepoch_time is TRUE, the maximum time value is INT32_MAX
236  * for both kernel configurations and the minimum is INT32_MIN.
237  *
238  * And for nfsv4 (int64_t):
239  *
240  * nfsv4 allows for negative values in the protocol, and has a 64-bit
241  * time field, so nfs_allow_preepoch_time can be ignored.
242  */
243 #ifdef _KERNEL
244 
245 extern bool_t		nfs_allow_preepoch_time;
246 
247 #ifdef _LP64
248 
249 /*
250  * If no negative otw values are allowed, may use the full 32-bits of the
251  * time to represent time later than 2038, by presenting the value as an
252  * unsigned (but this can only be used by 64-bit apps due to cstat32
253  * restrictions). If negative values are allowed, cannot represent times
254  * after 2038. Either way, all 32 bits have a valid representation.
255  */
256 
257 /* Check if nfstime4 seconds (int64_t) can be stored in the system time */
258 #define	NFS4_TIME_OK(tt)	TRUE
259 
260 
261 #define	NFS3_TIME_OVERFLOW(tt)	(FALSE)
262 #define	NFS2_TIME_OVERFLOW(tt)	(FALSE)
263 
264 /*
265  * check if a time_t (int64_t) is ok when preepoch times are allowed -
266  * nfsv2/3: every 32-bit value is accepted, but can't overflow 64->32.
267  * nfsv4: every value is valid.
268  */
269 #define	NFS_PREEPOCH_TIME_T_OK(tt)					\
270 	(((tt) >= (time_t)INT32_MIN) && ((tt) <= (time_t)INT32_MAX))
271 
272 /*
273  * check if a time_t (int64_t) is ok when preepoch times are not allowed -
274  * nfsv2/3: every positive 32-bit value is accepted, but can't overflow 64->32.
275  * nfsv4: every value is valid.
276  */
277 #define	NFS_NO_PREEPOCH_TIME_T_OK(tt)					\
278 	(((tt) >= 0) && ((tt) <= (time_t)(ulong_t)UINT32_MAX))
279 
280 #else /* not _LP64 */
281 
282 /*
283  * Cannot represent times after 2038 in a 32-bit kernel, but we may wish to
284  * restrict the use of negative values (which violate the protocol).
285  * So if negative times allowed, all uint32 time values are valid. Otherwise
286  * only those which are less than INT32_MAX (msb=0).
287  *
288  * NFSv4 uses int64_t for the time, so in a 32-bit kernel the nfsv4 value
289  * must fit in an int32_t.
290  */
291 
292 /* Only allow signed 32-bit time values */
293 
294 /* Check if an nfstime4 (int64_t) can be stored in the system time */
295 #define	NFS4_TIME_OK(tt)						\
296 	(((tt) <= INT32_MAX) &&	((tt) >= INT32_MIN))
297 
298 #define	NFS3_TIME_OVERFLOW(tt)	((tt) > INT32_MAX)
299 #define	NFS2_TIME_OVERFLOW(tt)	((tt) > INT32_MAX)
300 
301 /*
302  * check if a time_t (int32_t) is ok when preepoch times are allowed -
303  * every 32-bit value is accepted
304  */
305 #define	NFS_PREEPOCH_TIME_T_OK(tt)	TRUE
306 
307 /*
308  * check if a time_t (int32_t) is ok when preepoch times are not allowed -
309  * only positive values are accepted.
310  */
311 #define	NFS_NO_PREEPOCH_TIME_T_OK(tt)	((tt) >= 0)
312 
313 #endif /* _LP64 */
314 
315 /* Check if an nfstime3 (uint32_t) can be stored in the system time */
316 #define	NFS3_TIME_OK(tt)						\
317 	(nfs_allow_preepoch_time || (!NFS3_TIME_OVERFLOW(tt)))
318 
319 /* Check if an nfs2_timeval (uint32_t) can be stored in the system time. */
320 #define	NFS2_TIME_OK(tt)						\
321 	(nfs_allow_preepoch_time || (!NFS2_TIME_OVERFLOW(tt)))
322 
323 /*
324  * Test if time_t (signed long) can be sent over the wire - for v2/3 only if:
325  * 1. The time value can fit in a uint32_t; and
326  * 2. Either the time value is positive or allow preepoch times.
327  * No restrictions for nfsv4.
328  */
329 #define	NFS_TIME_T_OK(tt)						\
330 	(nfs_allow_preepoch_time ?					\
331 		NFS_PREEPOCH_TIME_T_OK(tt) : NFS_NO_PREEPOCH_TIME_T_OK(tt))
332 
333 #define	NFS4_TIME_T_OK(tt)		TRUE
334 
335 /* Test if all attr times are valid */
336 #define	NFS_VAP_TIME_OK(vap)						\
337 	(nfs_allow_preepoch_time ?					\
338 		(NFS_PREEPOCH_TIME_T_OK((vap)->va_atime.tv_sec) &&	\
339 		NFS_PREEPOCH_TIME_T_OK((vap)->va_mtime.tv_sec) &&	\
340 		NFS_PREEPOCH_TIME_T_OK((vap)->va_ctime.tv_sec)) :	\
341 		(NFS_NO_PREEPOCH_TIME_T_OK((vap)->va_atime.tv_sec) &&	\
342 		NFS_NO_PREEPOCH_TIME_T_OK((vap)->va_mtime.tv_sec) &&	\
343 		NFS_NO_PREEPOCH_TIME_T_OK((vap)->va_ctime.tv_sec)))
344 
345 #define	NFS4_VAP_TIME_OK(vap)			TRUE
346 
347 /*
348  * To extend the sign or not extend the sign, that is the question.
349  * Note: The correct way is to code a macro:
350  * #define	NFS_TIME_T_CONVERT(tt)					\
351  *	(nfs_allow_preepoch_time ? (int32_t)(tt) : (uint32_t)(tt))
352  * But the 64-bit compiler does not extend the sign in that case (why?)
353  * so we'll do it the ugly way...
354  */
355 #define	NFS_TIME_T_CONVERT(systt, tt)		\
356 	if (nfs_allow_preepoch_time) {		\
357 		systt = (int32_t)(tt);		\
358 	} else {				\
359 		systt = (uint32_t)(tt);		\
360 	}
361 
362 /* macro to check for overflowed time attribute fields - version 3 */
363 #define	NFS3_FATTR_TIME_OK(attrs)			\
364 	(NFS3_TIME_OK((attrs)->atime.seconds) &&	\
365 	NFS3_TIME_OK((attrs)->mtime.seconds) &&		\
366 	NFS3_TIME_OK((attrs)->ctime.seconds))
367 
368 /* macro to check for overflowed time attribute fields - version 2 */
369 #define	NFS2_FATTR_TIME_OK(attrs)			\
370 	(NFS2_TIME_OK((attrs)->na_atime.tv_sec) &&	\
371 	NFS2_TIME_OK((attrs)->na_mtime.tv_sec) &&	\
372 	NFS2_TIME_OK((attrs)->na_ctime.tv_sec))
373 
374 /* Check that a size3 value is not overflowed */
375 #define	NFS3_SIZE_OK(size)	((size) <= MAXOFFSET_T)
376 
377 #endif /* _KERNEL */
378 
379 /*
380  * Size of an fhandle in bytes
381  */
382 #define	NFS_FHSIZE	32
383 
384 struct nfs_fid {
385 	ushort_t nf_len;
386 	ushort_t nf_pad;
387 	char	nf_data[NFS_FHSIZE];
388 };
389 
390 /*
391  * "Legacy" filehandles use NFS_FHMAXDATA (10) byte fids. Filesystems that
392  * return a larger fid than NFS_FHMAXDATA, such as ZFS's .zfs snapshot
393  * directory, can use up to (((64 - 8) / 2) - 2) bytes for their fid.
394  * This currently holds for both NFSv3 and NFSv4.
395  */
396 #define	NFS_FHMAXDATA		10
397 #define	NFS_FH3MAXDATA		26
398 #define	NFS_FH4MAXDATA		26
399 
400 /*
401  * The original nfs file handle size for version 3 was 32 which was
402  * the same in version 2; now we're making it bigger to to deal with
403  * ZFS snapshot FIDs.
404  *
405  * If the size of fhandle3_t changes or if Version 3 uses some other
406  * filehandle format, this constant may need to change.
407  */
408 
409 #define	NFS3_OLDFHSIZE	32
410 #define	NFS3_MAXFHSIZE	64
411 
412 /*
413  * This is the actual definition of a legacy filehandle.  There is some
414  * dependence on this layout in NFS-related code, particularly in the
415  * user-level lock manager, so be careful about changing it.
416  *
417  * Currently only NFSv2 uses this structure.
418  */
419 
420 typedef struct svcfh {
421 	fsid_t	fh_fsid;			/* filesystem id */
422 	ushort_t fh_len;			/* file number length */
423 	char	fh_data[NFS_FHMAXDATA];		/* and data */
424 	ushort_t fh_xlen;			/* export file number length */
425 	char	fh_xdata[NFS_FHMAXDATA];	/* and data */
426 } fhandle_t;
427 
428 /*
429  * This is the in-memory structure for an NFSv3 extended filehandle.
430  */
431 typedef struct {
432 	fsid_t	_fh3_fsid;			/* filesystem id */
433 	ushort_t _fh3_len;			/* file number length */
434 	char	_fh3_data[NFS_FH3MAXDATA];		/* and data */
435 	ushort_t _fh3_xlen;			/* export file number length */
436 	char	_fh3_xdata[NFS_FH3MAXDATA];	/* and data */
437 } fhandle3_t;
438 
439 /*
440  * This is the in-memory structure for an NFSv4 extended filehandle.
441  */
442 typedef struct {
443 	fsid_t	fhx_fsid;			/* filesystem id */
444 	ushort_t fhx_len;			/* file number length */
445 	char	fhx_data[NFS_FH4MAXDATA];	/* and data */
446 	ushort_t fhx_xlen;			/* export file number length */
447 	char	fhx_xdata[NFS_FH4MAXDATA];	/* and data */
448 } fhandle4_t;
449 
450 /*
451  * Arguments to remote write and writecache
452  */
453 /*
454  * The `over the wire' representation of the first four arguments.
455  */
456 struct otw_nfswriteargs {
457 	fhandle_t	otw_wa_fhandle;
458 	uint32_t	otw_wa_begoff;
459 	uint32_t	otw_wa_offset;
460 	uint32_t	otw_wa_totcount;
461 };
462 
463 struct nfswriteargs {
464 	struct otw_nfswriteargs *wa_args;	/* ptr to the otw arguments */
465 	struct otw_nfswriteargs wa_args_buf;	/* space for otw arguments */
466 	uint32_t	wa_count;
467 	char		*wa_data;	/* data to write (up to NFS_MAXDATA) */
468 	mblk_t		*wa_mblk;	/* pointer to mblks containing data */
469 #ifdef _KERNEL
470 	/* rdma related info */
471 	struct clist	*wa_rlist;
472 	CONN		*wa_conn;
473 #endif /* _KERNEL */
474 };
475 #define	wa_fhandle	wa_args->otw_wa_fhandle
476 #define	wa_begoff	wa_args->otw_wa_begoff
477 #define	wa_offset	wa_args->otw_wa_offset
478 #define	wa_totcount	wa_args->otw_wa_totcount
479 
480 /*
481  * NFS timeval struct using unsigned int as specified in V2 protocol.
482  * tv_sec and tv_usec used to match existing code.
483  */
484 struct nfs2_timeval {
485 	uint32_t tv_sec;
486 	uint32_t tv_usec;
487 };
488 typedef struct nfs2_timeval nfs2_timeval;
489 
490 /*
491  * File attributes
492  */
493 struct nfsfattr {
494 	enum nfsftype	na_type;	/* file type */
495 	uint32_t	na_mode;	/* protection mode bits */
496 	uint32_t	na_nlink;	/* # hard links */
497 	uint32_t	na_uid;		/* owner user id */
498 	uint32_t	na_gid;		/* owner group id */
499 	uint32_t	na_size;	/* file size in bytes */
500 	uint32_t	na_blocksize;	/* preferred block size */
501 	uint32_t	na_rdev;	/* special device # */
502 	uint32_t	na_blocks;	/* Kb of disk used by file */
503 	uint32_t	na_fsid;	/* device # */
504 	uint32_t	na_nodeid;	/* inode # */
505 	struct nfs2_timeval na_atime;	/* time of last access */
506 	struct nfs2_timeval na_mtime;	/* time of last modification */
507 	struct nfs2_timeval na_ctime;	/* time of last change */
508 };
509 
510 #define	n2v_type(x)	(NA_ISFIFO(x) ? VFIFO : nf_to_vt[(x)->na_type])
511 #define	n2v_rdev(x)	(NA_ISFIFO(x) ? 0 : (x)->na_rdev)
512 
513 /*
514  * Arguments to remote read
515  */
516 struct nfsreadargs {
517 	fhandle_t	ra_fhandle;	/* handle for file */
518 	uint32_t	ra_offset;	/* byte offset in file */
519 	uint32_t	ra_count;	/* immediate read count */
520 	uint32_t	ra_totcount;	/* total read cnt (from this offset) */
521 #ifdef _KERNEL
522 	/* used in rdma transports */
523 	caddr_t		ra_data;	/* destination for read data */
524 	struct clist	*ra_wlist;
525 	CONN		*ra_conn;
526 #endif
527 };
528 
529 /*
530  * Status OK portion of remote read reply
531  */
532 struct nfsrrok {
533 	struct nfsfattr	rrok_attr;	/* attributes, need for pagin */
534 	uint32_t	rrok_count;	/* bytes of data */
535 	char		*rrok_data;	/* data (up to NFS_MAXDATA bytes) */
536 	uint_t		rrok_bufsize;	/* size of kmem_alloc'd buffer */
537 	mblk_t		*rrok_mp;	/* mblk_t contains data for reply */
538 #ifdef _KERNEL
539 	uint_t		rrok_wlist_len;
540 	struct clist    *rrok_wlist;
541 #endif
542 };
543 
544 /*
545  * Reply from remote read
546  */
547 struct nfsrdresult {
548 	nfsstat	rr_status;			/* status of read */
549 	union {
550 		struct nfsrrok	rr_ok_u;	/* attributes, need for pagin */
551 	} rr_u;
552 };
553 #define	rr_ok		rr_u.rr_ok_u
554 #define	rr_attr		rr_u.rr_ok_u.rrok_attr
555 #define	rr_count	rr_u.rr_ok_u.rrok_count
556 #define	rr_bufsize	rr_u.rr_ok_u.rrok_bufsize
557 #define	rr_data		rr_u.rr_ok_u.rrok_data
558 #define	rr_mp		rr_u.rr_ok_u.rrok_mp
559 
560 /*
561  * File attributes which can be set
562  */
563 struct nfssattr {
564 	uint32_t	sa_mode;	/* protection mode bits */
565 	uint32_t	sa_uid;		/* owner user id */
566 	uint32_t	sa_gid;		/* owner group id */
567 	uint32_t	sa_size;	/* file size in bytes */
568 	struct nfs2_timeval sa_atime;	/* time of last access */
569 	struct nfs2_timeval sa_mtime;	/* time of last modification */
570 };
571 
572 
573 /*
574  * Reply status with file attributes
575  */
576 struct nfsattrstat {
577 	nfsstat	ns_status;			/* reply status */
578 	union {
579 		struct nfsfattr ns_attr_u;	/* NFS_OK: file attributes */
580 	} ns_u;
581 };
582 #define	ns_attr	ns_u.ns_attr_u
583 
584 
585 /*
586  * NFS_OK part of read sym link reply union
587  */
588 struct nfssrok {
589 	uint32_t srok_count;	/* size of string */
590 	char	*srok_data;	/* string (up to NFS_MAXPATHLEN bytes) */
591 };
592 
593 /*
594  * Result of reading symbolic link
595  */
596 struct nfsrdlnres {
597 	nfsstat	rl_status;			/* status of symlink read */
598 	union {
599 		struct nfssrok	rl_srok_u;	/* name of linked to */
600 	} rl_u;
601 };
602 #define	rl_srok		rl_u.rl_srok_u
603 #define	rl_count	rl_u.rl_srok_u.srok_count
604 #define	rl_data		rl_u.rl_srok_u.srok_data
605 
606 
607 /*
608  * Arguments to readdir
609  */
610 struct nfsrddirargs {
611 	fhandle_t rda_fh;	/* directory handle */
612 	uint32_t rda_offset;	/* offset in directory (opaque) */
613 	uint32_t rda_count;	/* number of directory bytes to read */
614 };
615 
616 /*
617  * NFS_OK part of readdir result
618  */
619 struct nfsrdok {
620 	uint32_t rdok_offset;		/* next offset (opaque) */
621 	uint32_t rdok_size;		/* size in bytes of entries */
622 	bool_t	rdok_eof;		/* true if last entry is in result */
623 	struct dirent64 *rdok_entries;	/* variable number of entries */
624 };
625 
626 /*
627  * Readdir result
628  */
629 struct nfsrddirres {
630 	nfsstat	rd_status;
631 	uint_t		rd_bufsize;	/* client request size (not xdr'ed) */
632 	union {
633 		struct nfsrdok rd_rdok_u;
634 	} rd_u;
635 };
636 #define	rd_rdok		rd_u.rd_rdok_u
637 #define	rd_offset	rd_u.rd_rdok_u.rdok_offset
638 #define	rd_size		rd_u.rd_rdok_u.rdok_size
639 #define	rd_eof		rd_u.rd_rdok_u.rdok_eof
640 #define	rd_entries	rd_u.rd_rdok_u.rdok_entries
641 
642 
643 /*
644  * Arguments for directory operations
645  */
646 struct nfsdiropargs {
647 	fhandle_t	*da_fhandle;	/* pointer to directory file handle */
648 	char		*da_name;	/* name (up to NFS_MAXNAMLEN bytes) */
649 	fhandle_t	da_fhandle_buf;	/* directory file handle */
650 	int		da_flags;	/* flags, see below */
651 };
652 #define	DA_FREENAME	1
653 
654 /*
655  * NFS_OK part of directory operation result
656  */
657 struct  nfsdrok {
658 	fhandle_t	drok_fhandle;	/* result file handle */
659 	struct nfsfattr	drok_attr;	/* result file attributes */
660 };
661 
662 /*
663  * Results from directory operation
664  */
665 struct  nfsdiropres {
666 	nfsstat	dr_status;			/* result status */
667 	union {
668 		struct  nfsdrok	dr_drok_u;	/* NFS_OK result */
669 	} dr_u;
670 };
671 #define	dr_drok		dr_u.dr_drok_u
672 #define	dr_fhandle	dr_u.dr_drok_u.drok_fhandle
673 #define	dr_attr		dr_u.dr_drok_u.drok_attr
674 
675 /*
676  * arguments to setattr
677  */
678 struct nfssaargs {
679 	fhandle_t	saa_fh;		/* fhandle of file to be set */
680 	struct nfssattr	saa_sa;		/* new attributes */
681 };
682 
683 /*
684  * arguments to create and mkdir
685  */
686 struct nfscreatargs {
687 	struct nfsdiropargs	ca_da;	/* file name to create and parent dir */
688 	struct nfssattr		*ca_sa;	/* initial attributes */
689 	struct nfssattr		ca_sa_buf;	/* space to store attributes */
690 };
691 
692 /*
693  * arguments to link
694  */
695 struct nfslinkargs {
696 	fhandle_t		*la_from;	/* old file */
697 	fhandle_t		la_from_buf;	/* old file */
698 	struct nfsdiropargs	la_to;		/* new file and parent dir */
699 };
700 
701 /*
702  * arguments to rename
703  */
704 struct nfsrnmargs {
705 	struct nfsdiropargs rna_from;	/* old file and parent dir */
706 	struct nfsdiropargs rna_to;	/* new file and parent dir */
707 };
708 
709 /*
710  * arguments to symlink
711  */
712 struct nfsslargs {
713 	struct nfsdiropargs	sla_from;	/* old file and parent dir */
714 	char			*sla_tnm;	/* new name */
715 	int			sla_tnm_flags;	/* flags for name */
716 	struct nfssattr		*sla_sa;	/* attributes */
717 	struct nfssattr		sla_sa_buf;	/* attributes buffer */
718 };
719 #define	SLA_FREETNM	1
720 
721 /*
722  * NFS_OK part of statfs operation
723  */
724 struct nfsstatfsok {
725 	uint32_t fsok_tsize;	/* preferred transfer size in bytes */
726 	uint32_t fsok_bsize;	/* fundamental file system block size */
727 	uint32_t fsok_blocks;	/* total blocks in file system */
728 	uint32_t fsok_bfree;	/* free blocks in fs */
729 	uint32_t fsok_bavail;	/* free blocks avail to non-superuser */
730 };
731 
732 /*
733  * Results of statfs operation
734  */
735 struct nfsstatfs {
736 	nfsstat	fs_status;			/* result status */
737 	union {
738 		struct	nfsstatfsok fs_fsok_u;	/* NFS_OK result */
739 	} fs_u;
740 };
741 #define	fs_fsok		fs_u.fs_fsok_u
742 #define	fs_tsize	fs_u.fs_fsok_u.fsok_tsize
743 #define	fs_bsize	fs_u.fs_fsok_u.fsok_bsize
744 #define	fs_blocks	fs_u.fs_fsok_u.fsok_blocks
745 #define	fs_bfree	fs_u.fs_fsok_u.fsok_bfree
746 #define	fs_bavail	fs_u.fs_fsok_u.fsok_bavail
747 
748 #ifdef _KERNEL
749 /*
750  * XDR routines for handling structures defined above
751  */
752 extern bool_t	xdr_attrstat(XDR *, struct nfsattrstat *);
753 extern bool_t	xdr_fastattrstat(XDR *, struct nfsattrstat *);
754 extern bool_t	xdr_creatargs(XDR *, struct nfscreatargs *);
755 extern bool_t	xdr_diropargs(XDR *, struct nfsdiropargs *);
756 extern bool_t	xdr_diropres(XDR *, struct nfsdiropres *);
757 extern bool_t	xdr_fastdiropres(XDR *, struct nfsdiropres *);
758 extern bool_t	xdr_drok(XDR *, struct nfsdrok *);
759 #ifdef _LITTLE_ENDIAN
760 extern bool_t	xdr_fastdrok(XDR *, struct nfsdrok *);
761 extern bool_t	xdr_fastfattr(XDR *, struct nfsfattr *);
762 #endif
763 extern bool_t	xdr_fattr(XDR *, struct nfsfattr *);
764 extern bool_t	xdr_fhandle(XDR *, fhandle_t *);
765 extern bool_t	xdr_fastfhandle(XDR *, fhandle_t **);
766 extern bool_t	xdr_linkargs(XDR *, struct nfslinkargs *);
767 extern bool_t	xdr_rddirargs(XDR *, struct nfsrddirargs *);
768 extern bool_t	xdr_putrddirres(XDR *, struct nfsrddirres *);
769 extern bool_t	xdr_getrddirres(XDR *, struct nfsrddirres *);
770 extern bool_t	xdr_rdlnres(XDR *, struct nfsrdlnres *);
771 extern bool_t	xdr_rdresult(XDR *, struct nfsrdresult *);
772 extern bool_t	xdr_readargs(XDR *, struct nfsreadargs *);
773 extern bool_t	xdr_readlink(XDR *, fhandle_t *);
774 extern bool_t	xdr_rnmargs(XDR *, struct nfsrnmargs *);
775 extern bool_t	xdr_rrok(XDR *, struct nfsrrok *);
776 extern bool_t	xdr_saargs(XDR *, struct nfssaargs *);
777 extern bool_t	xdr_sattr(XDR *, struct nfssattr *);
778 extern bool_t	xdr_slargs(XDR *, struct nfsslargs *);
779 extern bool_t	xdr_srok(XDR *, struct nfssrok *);
780 extern bool_t	xdr_nfs2_timeval(XDR *, struct nfs2_timeval *);
781 extern bool_t	xdr_writeargs(XDR *, struct nfswriteargs *);
782 extern bool_t	xdr_fsok(XDR *, struct nfsstatfsok *);
783 #ifdef _LITTLE_ENDIAN
784 extern bool_t	xdr_fastfsok(XDR *, struct nfsstatfsok *);
785 extern bool_t	xdr_fastenum(XDR *, enum_t *);
786 #endif
787 extern bool_t	xdr_statfs(XDR *, struct nfsstatfs *);
788 extern bool_t	xdr_faststatfs(XDR *, struct nfsstatfs *);
789 #endif
790 
791 /*
792  * Remote file service routines
793  */
794 #define	RFS_NULL	0
795 #define	RFS_GETATTR	1
796 #define	RFS_SETATTR	2
797 #define	RFS_ROOT	3
798 #define	RFS_LOOKUP	4
799 #define	RFS_READLINK	5
800 #define	RFS_READ	6
801 #define	RFS_WRITECACHE	7
802 #define	RFS_WRITE	8
803 #define	RFS_CREATE	9
804 #define	RFS_REMOVE	10
805 #define	RFS_RENAME	11
806 #define	RFS_LINK	12
807 #define	RFS_SYMLINK	13
808 #define	RFS_MKDIR	14
809 #define	RFS_RMDIR	15
810 #define	RFS_READDIR	16
811 #define	RFS_STATFS	17
812 #define	RFS_NPROC	18
813 
814 #ifdef _KERNEL
815 /*
816  * The NFS Version 2 service procedures
817  */
818 struct exportinfo;	/* defined in nfs/export.h */
819 struct servinfo;	/* defined in nfs/nfs_clnt.h */
820 struct mntinfo;		/* defined in nfs/nfs_clnt.h */
821 
822 extern void	rfs_getattr(fhandle_t *, struct nfsattrstat *,
823     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
824 extern void	*rfs_getattr_getfh(fhandle_t *);
825 extern void	rfs_setattr(struct nfssaargs *, struct nfsattrstat *,
826     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
827 extern void	*rfs_setattr_getfh(struct nfssaargs *);
828 extern void	rfs_lookup(struct nfsdiropargs *, struct nfsdiropres *,
829     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
830 extern void	*rfs_lookup_getfh(struct nfsdiropargs *);
831 extern void	rfs_readlink(fhandle_t *, struct nfsrdlnres *,
832     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
833 extern void	*rfs_readlink_getfh(fhandle_t *);
834 extern void	rfs_rlfree(struct nfsrdlnres *);
835 extern void	rfs_read(struct nfsreadargs *, struct nfsrdresult *,
836     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
837 extern void	*rfs_read_getfh(struct nfsreadargs *);
838 extern void	rfs_rdfree(struct nfsrdresult *);
839 extern void	rfs_write_sync(struct nfswriteargs *, struct nfsattrstat *,
840     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
841 extern void	rfs_write(struct nfswriteargs *, struct nfsattrstat *,
842     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
843 extern void	*rfs_write_getfh(struct nfswriteargs *);
844 extern void	rfs_create(struct nfscreatargs *, struct nfsdiropres *,
845     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
846 extern void	*rfs_create_getfh(struct nfscreatargs *);
847 extern void	rfs_remove(struct nfsdiropargs *, enum nfsstat *,
848     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
849 extern void	*rfs_remove_getfh(struct nfsdiropargs *);
850 extern void	rfs_rename(struct nfsrnmargs *, enum nfsstat *,
851     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
852 extern void	*rfs_rename_getfh(struct nfsrnmargs *);
853 extern void	rfs_link(struct nfslinkargs *, enum nfsstat *,
854     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
855 extern void	*rfs_link_getfh(struct nfslinkargs *);
856 extern void	rfs_symlink(struct nfsslargs *, enum nfsstat *,
857     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
858 extern void	*rfs_symlink_getfh(struct nfsslargs *);
859 extern void	rfs_mkdir(struct nfscreatargs *, struct nfsdiropres *,
860     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
861 extern void	*rfs_mkdir_getfh(struct nfscreatargs *);
862 extern void	rfs_rmdir(struct nfsdiropargs *, enum nfsstat *,
863     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
864 extern void	*rfs_rmdir_getfh(struct nfsdiropargs *);
865 extern void	rfs_readdir(struct nfsrddirargs *, struct nfsrddirres *,
866     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
867 extern void	*rfs_readdir_getfh(struct nfsrddirargs *);
868 extern void	rfs_rddirfree(struct nfsrddirres *);
869 extern void	rfs_statfs(fhandle_t *, struct nfsstatfs *, struct exportinfo *,
870     struct svc_req *, cred_t *, bool_t);
871 extern void	*rfs_statfs_getfh(fhandle_t *);
872 extern void	rfs_srvrinit(void);
873 extern void	rfs_srvrfini(void);
874 
875 /*
876  * flags to define path types during Multi Component Lookups
877  * using the public filehandle
878  */
879 #define	URLPATH		0x01	/* Universal Resource Locator path */
880 #define	NATIVEPATH	0x02	/* Native path, i.e., via mount protocol */
881 #define	SECURITY_QUERY	0x04	/* Security query */
882 
883 /* index for svstat_ptr */
884 enum nfs_svccounts {NFS_CALLS, NFS_BADCALLS, NFS_REFERRALS, NFS_REFERLINKS};
885 
886 /*	function defs for NFS kernel */
887 extern int	nfs_waitfor_purge_complete(vnode_t *);
888 extern int	nfs_validate_caches(vnode_t *, cred_t *);
889 extern void	nfs_purge_caches(vnode_t *, int, cred_t *);
890 extern void	nfs_purge_rddir_cache(vnode_t *);
891 extern void	nfs_attrcache(vnode_t *, struct nfsfattr *, hrtime_t);
892 extern int	nfs_cache_fattr(vnode_t *, struct nfsfattr *, vattr_t *,
893     hrtime_t, cred_t *);
894 extern void	nfs_attr_cache(vnode_t *, vattr_t *, hrtime_t, cred_t *);
895 extern void	nfs_attrcache_va(vnode_t *, struct vattr *);
896 extern int	nfs_getattr_otw(vnode_t *, struct vattr *, cred_t *);
897 extern int	nfsgetattr(vnode_t *, struct vattr *, cred_t *);
898 extern int	nattr_to_vattr(vnode_t *, struct nfsfattr *, struct vattr *);
899 extern void	nfs_async_manager(struct vfs *);
900 extern void	nfs_async_manager_stop(struct vfs *);
901 extern void	nfs_async_stop(struct vfs *);
902 extern int	nfs_async_stop_sig(struct vfs *);
903 extern int	nfs_clntinit(void);
904 extern void	nfs_clntfini(void);
905 extern int	nfstsize(void);
906 extern int	nfs_srvinit(void);
907 extern void	nfs_srvfini(void);
908 extern int	vattr_to_sattr(struct vattr *, struct nfssattr *);
909 extern void	setdiropargs(struct nfsdiropargs *, char *, vnode_t *);
910 extern int	setdirgid(vnode_t *, gid_t *, cred_t *);
911 extern int	setdirmode(vnode_t *, mode_t *, cred_t *);
912 extern int	newnum(void);
913 extern char	*newname(void);
914 extern int	nfs_subrinit(void);
915 extern void	nfs_subrfini(void);
916 extern enum nfsstat puterrno(int);
917 extern int	geterrno(enum nfsstat);
918 extern int	nfsinit(int, char *);
919 extern void	nfsfini(void);
920 extern int	nfs_vfsinit(void);
921 extern void	nfs_vfsfini(void);
922 extern int	nfs_dump(vnode_t *, caddr_t, offset_t, offset_t,
923     caller_context_t *);
924 extern void	nfs_perror(int, char *, ...);
925 extern void	nfs_cmn_err(int, int, char *, ...);
926 extern int	nfs_addcllock(vnode_t *, struct flock64 *);
927 extern void	nfs_rmcllock(vnode_t *, struct flock64 *);
928 extern void	nfs_lockrelease(vnode_t *, int, offset_t, cred_t *);
929 extern int	vattr_to_nattr(struct vattr *, struct nfsfattr *);
930 extern int	mount_root(char *, char *, int, struct nfs_args *, int *);
931 extern void	nfs_lockcompletion(vnode_t *, int);
932 extern void	nfs_add_locking_id(vnode_t *, pid_t, int, char *, int);
933 extern void	nfs3copyfh(caddr_t, vnode_t *);
934 extern void	nfscopyfh(caddr_t, vnode_t *);
935 extern int	nfs3lookup(vnode_t *, char *, vnode_t **, struct pathname *,
936     int, vnode_t *, cred_t *, int);
937 extern int	nfslookup(vnode_t *, char *, vnode_t **, struct pathname *, int,
938     vnode_t *, cred_t *, int);
939 extern void	sv_free(struct servinfo *);
940 extern int	nfsauth_access(struct exportinfo *, struct svc_req *, cred_t *,
941     uid_t *, gid_t *);
942 extern void	nfsauth_init(void);
943 extern void	nfsauth_fini(void);
944 extern int	nfs_setopts(vnode_t *, model_t, struct nfs_args *);
945 extern int	nfs_mount_label_policy(vfs_t *, struct netbuf *,
946     struct knetconfig *, cred_t *);
947 extern boolean_t nfs_has_ctty(void);
948 extern void	nfs_srv_stop_all(void);
949 extern void	nfs_srv_quiesce_all(void);
950 extern int	rfs4_dss_setpaths(char *, size_t);
951 extern int	nfs_setmod_check(page_t *);
952 
953 extern time_t	rfs4_lease_time;
954 extern time_t	rfs4_grace_period;
955 extern nvlist_t	*rfs4_dss_paths, *rfs4_dss_oldpaths;
956 
957 extern kstat_named_t	*global_svstat_ptr[];
958 
959 extern krwlock_t	rroklock;
960 extern vtype_t		nf_to_vt[];
961 extern kstat_named_t	*rfsproccnt_v2_ptr;
962 extern kmutex_t		nfs_minor_lock;
963 extern int		nfs_major;
964 extern int		nfs_minor;
965 extern vfsops_t		*nfs_vfsops;
966 extern struct vnodeops	*nfs_vnodeops;
967 extern const struct fs_operation_def nfs_vnodeops_template[];
968 extern int		nfsfstyp;
969 extern void		(*nfs_srv_quiesce_func)(void);
970 extern int		(*nfs_srv_dss_func)(char *, size_t);
971 
972 /*
973  * Per-zone stats as consumed by nfsstat(1m)
974  */
975 struct nfs_version_stats {
976 	kstat_named_t	*aclreqcnt_ptr;		/* nfs_acl:0:aclreqcnt_v? */
977 	kstat_named_t	*aclproccnt_ptr;	/* nfs_acl:0:aclproccnt_v? */
978 	kstat_named_t	*rfsreqcnt_ptr;		/* nfs:0:rfsreqcnt_v? */
979 	kstat_named_t	*rfsproccnt_ptr;	/* nfs:0:rfsproccnt_v? */
980 };
981 
982 /*
983  * A bit of asymmetry: nfs:0:nfs_client isn't part of this structure.
984  */
985 struct nfs_stats {
986 	kstat_named_t		*nfs_stats_svstat_ptr[NFS_VERSMAX + 1];
987 	struct nfs_version_stats	nfs_stats_v2;
988 	struct nfs_version_stats	nfs_stats_v3;
989 	struct nfs_version_stats	nfs_stats_v4;
990 };
991 
992 /*
993  * Key used to retrieve counters.
994  */
995 extern zone_key_t nfsstat_zone_key;
996 
997 /*
998  * Zone callback functions.
999  */
1000 extern void	*nfsstat_zone_init(zoneid_t);
1001 extern void	nfsstat_zone_fini(zoneid_t, void *);
1002 
1003 #endif	/* _KERNEL */
1004 
1005 /*
1006  * Version 3 declarations and definitions.
1007  */
1008 
1009 #define	NFS3_FHSIZE 64
1010 #define	NFS3_COOKIEVERFSIZE 8
1011 #define	NFS3_CREATEVERFSIZE 8
1012 #define	NFS3_WRITEVERFSIZE 8
1013 
1014 typedef char *filename3;
1015 
1016 typedef char *nfspath3;
1017 
1018 #define	nfs3nametoolong	((char *)-1)
1019 
1020 typedef uint64 fileid3;
1021 
1022 typedef uint64 cookie3;
1023 
1024 typedef uint32 uid3;
1025 
1026 typedef uint32 gid3;
1027 
1028 typedef uint64 size3;
1029 
1030 typedef uint64 offset3;
1031 
1032 typedef uint32 mode3;
1033 
1034 typedef uint32 count3;
1035 
1036 /*
1037  * These three are really opaque arrays, but we treat them as
1038  * uint64 for efficiency sake
1039  */
1040 typedef uint64 cookieverf3;
1041 
1042 typedef uint64 createverf3;
1043 
1044 typedef uint64 writeverf3;
1045 
1046 typedef struct nfs_fh3 {
1047 	uint_t fh3_length;
1048 	union nfs_fh3_u {
1049 		struct nfs_fh3_i {
1050 			fhandle3_t fh3_i;
1051 		} nfs_fh3_i;
1052 		char data[NFS3_FHSIZE];
1053 	} fh3_u;
1054 	uint_t fh3_flags;
1055 } nfs_fh3;
1056 #define	fh3_fsid	fh3_u.nfs_fh3_i.fh3_i._fh3_fsid
1057 #define	fh3_len		fh3_u.nfs_fh3_i.fh3_i._fh3_len
1058 #define	fh3_data	fh3_u.nfs_fh3_i.fh3_i._fh3_data
1059 #define	fh3_xlen	fh3_u.nfs_fh3_i.fh3_i._fh3_xlen
1060 #define	fh3_xdata	fh3_u.nfs_fh3_i.fh3_i._fh3_xdata
1061 #define	FH3TOFIDP(fh)	((fid_t *)&((fh)->fh3_len))
1062 #define	FH3TOXFIDP(fh)	((fid_t *)&((fh)->fh3_xlen))
1063 
1064 /*
1065  * nfs_fh3.fh3_flags values
1066  */
1067 #define	FH_WEBNFS	0x1	/* fh is WebNFS overloaded - see makefh3_ol() */
1068 
1069 /*
1070  * Two elements were added to the
1071  * diropargs3 structure for performance (xdr-inlining).
1072  * They are not included as part of the args
1073  * that are encoded or decoded:
1074  * dirp - ptr to the nfs_fh3
1075  * flag indicating when to free the name that was
1076  * allocated during decode.
1077  */
1078 struct diropargs3 {
1079 	nfs_fh3 *dirp;
1080 	nfs_fh3 dir;
1081 	filename3 name;
1082 	int flags;
1083 };
1084 typedef struct diropargs3 diropargs3;
1085 
1086 struct nfstime3 {
1087 	uint32 seconds;
1088 	uint32 nseconds;
1089 };
1090 typedef struct nfstime3 nfstime3;
1091 
1092 struct specdata3 {
1093 	uint32 specdata1;
1094 	uint32 specdata2;
1095 };
1096 typedef struct specdata3 specdata3;
1097 
1098 enum nfsstat3 {
1099 	NFS3_OK = 0,
1100 	NFS3ERR_PERM = 1,
1101 	NFS3ERR_NOENT = 2,
1102 	NFS3ERR_IO = 5,
1103 	NFS3ERR_NXIO = 6,
1104 	NFS3ERR_ACCES = 13,
1105 	NFS3ERR_EXIST = 17,
1106 	NFS3ERR_XDEV = 18,
1107 	NFS3ERR_NODEV = 19,
1108 	NFS3ERR_NOTDIR = 20,
1109 	NFS3ERR_ISDIR = 21,
1110 	NFS3ERR_INVAL = 22,
1111 	NFS3ERR_FBIG = 27,
1112 	NFS3ERR_NOSPC = 28,
1113 	NFS3ERR_ROFS = 30,
1114 	NFS3ERR_MLINK = 31,
1115 	NFS3ERR_NAMETOOLONG = 63,
1116 	NFS3ERR_NOTEMPTY = 66,
1117 	NFS3ERR_DQUOT = 69,
1118 	NFS3ERR_STALE = 70,
1119 	NFS3ERR_REMOTE = 71,
1120 	NFS3ERR_BADHANDLE = 10001,
1121 	NFS3ERR_NOT_SYNC = 10002,
1122 	NFS3ERR_BAD_COOKIE = 10003,
1123 	NFS3ERR_NOTSUPP = 10004,
1124 	NFS3ERR_TOOSMALL = 10005,
1125 	NFS3ERR_SERVERFAULT = 10006,
1126 	NFS3ERR_BADTYPE = 10007,
1127 	NFS3ERR_JUKEBOX = 10008
1128 };
1129 typedef enum nfsstat3 nfsstat3;
1130 
1131 enum ftype3 {
1132 	NF3REG = 1,
1133 	NF3DIR = 2,
1134 	NF3BLK = 3,
1135 	NF3CHR = 4,
1136 	NF3LNK = 5,
1137 	NF3SOCK = 6,
1138 	NF3FIFO = 7
1139 };
1140 typedef enum ftype3 ftype3;
1141 
1142 struct fattr3 {
1143 	ftype3 type;
1144 	mode3 mode;
1145 	uint32 nlink;
1146 	uid3 uid;
1147 	gid3 gid;
1148 	size3 size;
1149 	size3 used;
1150 	specdata3 rdev;
1151 	uint64 fsid;
1152 	fileid3 fileid;
1153 	nfstime3 atime;
1154 	nfstime3 mtime;
1155 	nfstime3 ctime;
1156 };
1157 typedef struct fattr3 fattr3;
1158 
1159 #define	NFS3_SIZEOF_FATTR3	(21)
1160 
1161 #ifdef _KERNEL
1162 struct fattr3_res {
1163 	nfsstat3 status;
1164 	vattr_t *vap;
1165 	vnode_t *vp;
1166 };
1167 typedef struct fattr3_res fattr3_res;
1168 #endif /* _KERNEL */
1169 
1170 struct post_op_attr {
1171 	bool_t attributes;
1172 	fattr3 attr;
1173 };
1174 typedef struct post_op_attr post_op_attr;
1175 
1176 #ifdef _KERNEL
1177 struct post_op_vattr {
1178 	bool_t		attributes;
1179 	fattr3_res	fres;
1180 };
1181 typedef struct post_op_vattr post_op_vattr;
1182 #endif /* _KERNEL */
1183 
1184 struct wcc_attr {
1185 	size3 size;
1186 	nfstime3 mtime;
1187 	nfstime3 ctime;
1188 };
1189 typedef struct wcc_attr wcc_attr;
1190 
1191 struct pre_op_attr {
1192 	bool_t attributes;
1193 	wcc_attr attr;
1194 };
1195 typedef struct pre_op_attr pre_op_attr;
1196 
1197 struct wcc_data {
1198 	pre_op_attr before;
1199 	post_op_attr after;
1200 };
1201 typedef struct wcc_data wcc_data;
1202 
1203 struct post_op_fh3 {
1204 	bool_t handle_follows;
1205 	nfs_fh3 handle;
1206 };
1207 typedef struct post_op_fh3 post_op_fh3;
1208 
1209 enum time_how {
1210 	DONT_CHANGE = 0,
1211 	SET_TO_SERVER_TIME = 1,
1212 	SET_TO_CLIENT_TIME = 2
1213 };
1214 typedef enum time_how time_how;
1215 
1216 struct set_mode3 {
1217 	bool_t set_it;
1218 	mode3 mode;
1219 };
1220 typedef struct set_mode3 set_mode3;
1221 
1222 struct set_uid3 {
1223 	bool_t set_it;
1224 	uid3 uid;
1225 };
1226 typedef struct set_uid3 set_uid3;
1227 
1228 struct set_gid3 {
1229 	bool_t set_it;
1230 	gid3 gid;
1231 };
1232 typedef struct set_gid3 set_gid3;
1233 
1234 struct set_size3 {
1235 	bool_t set_it;
1236 	size3 size;
1237 };
1238 typedef struct set_size3 set_size3;
1239 
1240 struct set_atime {
1241 	time_how set_it;
1242 	nfstime3 atime;
1243 };
1244 typedef struct set_atime set_atime;
1245 
1246 struct set_mtime {
1247 	time_how set_it;
1248 	nfstime3 mtime;
1249 };
1250 typedef struct set_mtime set_mtime;
1251 
1252 struct sattr3 {
1253 	set_mode3 mode;
1254 	set_uid3 uid;
1255 	set_gid3 gid;
1256 	set_size3 size;
1257 	set_atime atime;
1258 	set_mtime mtime;
1259 };
1260 typedef struct sattr3 sattr3;
1261 
1262 /*
1263  * A couple of defines to make resok and resfail look like the
1264  * correct things in a response type independent manner.
1265  */
1266 #define	resok	res_u.ok
1267 #define	resfail	res_u.fail
1268 
1269 struct GETATTR3args {
1270 	nfs_fh3 object;
1271 };
1272 typedef struct GETATTR3args GETATTR3args;
1273 
1274 struct GETATTR3resok {
1275 	fattr3 obj_attributes;
1276 };
1277 typedef struct GETATTR3resok GETATTR3resok;
1278 
1279 struct GETATTR3res {
1280 	nfsstat3 status;
1281 	union {
1282 		GETATTR3resok ok;
1283 	} res_u;
1284 };
1285 typedef struct GETATTR3res GETATTR3res;
1286 
1287 #ifdef _KERNEL
1288 struct GETATTR3vres {
1289 	nfsstat3 status;
1290 	fattr3_res fres;
1291 };
1292 typedef struct GETATTR3vres GETATTR3vres;
1293 #endif /* _KERNEL */
1294 
1295 struct sattrguard3 {
1296 	bool_t check;
1297 	nfstime3 obj_ctime;
1298 };
1299 typedef struct sattrguard3 sattrguard3;
1300 
1301 struct SETATTR3args {
1302 	nfs_fh3 object;
1303 	sattr3 new_attributes;
1304 	sattrguard3 guard;
1305 };
1306 typedef struct SETATTR3args SETATTR3args;
1307 
1308 struct SETATTR3resok {
1309 	wcc_data obj_wcc;
1310 };
1311 typedef struct SETATTR3resok SETATTR3resok;
1312 
1313 struct SETATTR3resfail {
1314 	wcc_data obj_wcc;
1315 };
1316 typedef struct SETATTR3resfail SETATTR3resfail;
1317 
1318 struct SETATTR3res {
1319 	nfsstat3 status;
1320 	union {
1321 		SETATTR3resok ok;
1322 		SETATTR3resfail fail;
1323 	} res_u;
1324 };
1325 typedef struct SETATTR3res SETATTR3res;
1326 
1327 struct LOOKUP3args {
1328 	diropargs3 what;
1329 };
1330 typedef struct LOOKUP3args LOOKUP3args;
1331 
1332 struct LOOKUP3resok {
1333 	nfs_fh3 object;
1334 	post_op_attr obj_attributes;
1335 	post_op_attr dir_attributes;
1336 };
1337 typedef struct LOOKUP3resok LOOKUP3resok;
1338 
1339 struct LOOKUP3resfail {
1340 	post_op_attr dir_attributes;
1341 };
1342 typedef struct LOOKUP3resfail LOOKUP3resfail;
1343 
1344 struct LOOKUP3res {
1345 	nfsstat3 status;
1346 	union {
1347 		LOOKUP3resok ok;
1348 		LOOKUP3resfail fail;
1349 	} res_u;
1350 };
1351 typedef struct LOOKUP3res LOOKUP3res;
1352 
1353 #ifdef _KERNEL
1354 struct LOOKUP3vres {
1355 	nfsstat3 status;
1356 	nfs_fh3 object;
1357 	post_op_vattr dir_attributes;
1358 	post_op_vattr obj_attributes;
1359 };
1360 typedef struct LOOKUP3vres LOOKUP3vres;
1361 #endif /* _KERNEL */
1362 
1363 struct ACCESS3args {
1364 	nfs_fh3 object;
1365 	uint32 access;
1366 };
1367 typedef struct ACCESS3args ACCESS3args;
1368 #define	ACCESS3_READ 0x1
1369 #define	ACCESS3_LOOKUP 0x2
1370 #define	ACCESS3_MODIFY 0x4
1371 #define	ACCESS3_EXTEND 0x8
1372 #define	ACCESS3_DELETE 0x10
1373 #define	ACCESS3_EXECUTE 0x20
1374 
1375 struct ACCESS3resok {
1376 	post_op_attr obj_attributes;
1377 	uint32 access;
1378 };
1379 typedef struct ACCESS3resok ACCESS3resok;
1380 
1381 struct ACCESS3resfail {
1382 	post_op_attr obj_attributes;
1383 };
1384 typedef struct ACCESS3resfail ACCESS3resfail;
1385 
1386 struct ACCESS3res {
1387 	nfsstat3 status;
1388 	union {
1389 		ACCESS3resok ok;
1390 		ACCESS3resfail fail;
1391 	} res_u;
1392 };
1393 typedef struct ACCESS3res ACCESS3res;
1394 
1395 struct READLINK3args {
1396 	nfs_fh3 symlink;
1397 };
1398 typedef struct READLINK3args READLINK3args;
1399 
1400 struct READLINK3resok {
1401 	post_op_attr symlink_attributes;
1402 	nfspath3 data;
1403 };
1404 typedef struct READLINK3resok READLINK3resok;
1405 
1406 struct READLINK3resfail {
1407 	post_op_attr symlink_attributes;
1408 };
1409 typedef struct READLINK3resfail READLINK3resfail;
1410 
1411 struct READLINK3res {
1412 	nfsstat3 status;
1413 	union {
1414 		READLINK3resok ok;
1415 		READLINK3resfail fail;
1416 	} res_u;
1417 };
1418 typedef struct READLINK3res READLINK3res;
1419 
1420 struct READ3args {
1421 	nfs_fh3 file;
1422 	offset3 offset;
1423 	count3 count;
1424 #ifdef _KERNEL
1425 	/* for read using rdma */
1426 	char *res_data_val_alt;
1427 	struct uio *res_uiop;
1428 	struct clist *wlist;
1429 	CONN *conn;
1430 #endif
1431 };
1432 typedef struct READ3args READ3args;
1433 
1434 struct READ3resok {
1435 	post_op_attr file_attributes;
1436 	count3 count;
1437 	bool_t eof;
1438 	struct {
1439 		uint_t data_len;
1440 		char *data_val;
1441 		mblk_t *mp;
1442 	} data;
1443 	uint_t size;
1444 #ifdef _KERNEL
1445 	uint_t wlist_len;
1446 	struct clist *wlist;
1447 	frtn_t zcopy;
1448 #endif
1449 };
1450 typedef struct READ3resok READ3resok;
1451 
1452 struct READ3resfail {
1453 	post_op_attr file_attributes;
1454 };
1455 typedef struct READ3resfail READ3resfail;
1456 
1457 struct READ3res {
1458 	nfsstat3 status;
1459 	union {
1460 		READ3resok ok;
1461 		READ3resfail fail;
1462 	} res_u;
1463 };
1464 typedef struct READ3res READ3res;
1465 
1466 #ifdef _KERNEL
1467 /*
1468  * READ3 reply that directly decodes fattr3 directly into vattr
1469  */
1470 struct READ3vres {
1471 	nfsstat3 status;
1472 	struct post_op_vattr pov;
1473 	count3 count;
1474 	bool_t eof;
1475 	struct {
1476 		uint_t data_len;
1477 		char *data_val;
1478 	} data;
1479 	uint_t size;
1480 
1481 	uint_t wlist_len;
1482 	struct clist *wlist;
1483 };
1484 typedef struct READ3vres READ3vres;
1485 #endif /* _KERNEL */
1486 
1487 /*
1488  * READ3 reply that uiomoves data directly into a struct uio
1489  * ignores any attributes returned
1490  */
1491 struct READ3uiores {
1492 	nfsstat3 status;
1493 	count3 count;
1494 	bool_t eof;
1495 	struct uio *uiop;
1496 	uint_t size;		/* maximum reply size */
1497 #ifdef _KERNEL
1498 	uint_t wlist_len;
1499 	struct clist *wlist;
1500 #endif
1501 };
1502 typedef struct READ3uiores READ3uiores;
1503 
1504 enum stable_how {
1505 	UNSTABLE = 0,
1506 	DATA_SYNC = 1,
1507 	FILE_SYNC = 2
1508 };
1509 typedef enum stable_how stable_how;
1510 
1511 struct WRITE3args {
1512 	nfs_fh3 file;
1513 	offset3 offset;
1514 	count3 count;
1515 	stable_how stable;
1516 	struct {
1517 		uint_t data_len;
1518 		char *data_val;
1519 	} data;
1520 	mblk_t *mblk;
1521 #ifdef _KERNEL
1522 	struct clist *rlist;
1523 	CONN *conn;
1524 #endif
1525 };
1526 typedef struct WRITE3args WRITE3args;
1527 
1528 struct WRITE3resok {
1529 	wcc_data file_wcc;
1530 	count3 count;
1531 	stable_how committed;
1532 	writeverf3 verf;
1533 };
1534 typedef struct WRITE3resok WRITE3resok;
1535 
1536 struct WRITE3resfail {
1537 	wcc_data file_wcc;
1538 };
1539 typedef struct WRITE3resfail WRITE3resfail;
1540 
1541 struct WRITE3res {
1542 	nfsstat3 status;
1543 	union {
1544 		WRITE3resok ok;
1545 		WRITE3resfail fail;
1546 	} res_u;
1547 };
1548 typedef struct WRITE3res WRITE3res;
1549 
1550 enum createmode3 {
1551 	UNCHECKED = 0,
1552 	GUARDED = 1,
1553 	EXCLUSIVE = 2
1554 };
1555 typedef enum createmode3 createmode3;
1556 
1557 struct createhow3 {
1558 	createmode3 mode;
1559 	union {
1560 		sattr3 obj_attributes;
1561 		createverf3 verf;
1562 	} createhow3_u;
1563 };
1564 typedef struct createhow3 createhow3;
1565 
1566 struct CREATE3args {
1567 	diropargs3 where;
1568 	createhow3 how;
1569 };
1570 typedef struct CREATE3args CREATE3args;
1571 
1572 struct CREATE3resok {
1573 	post_op_fh3 obj;
1574 	post_op_attr obj_attributes;
1575 	wcc_data dir_wcc;
1576 };
1577 typedef struct CREATE3resok CREATE3resok;
1578 
1579 struct CREATE3resfail {
1580 	wcc_data dir_wcc;
1581 };
1582 typedef struct CREATE3resfail CREATE3resfail;
1583 
1584 struct CREATE3res {
1585 	nfsstat3 status;
1586 	union {
1587 		CREATE3resok ok;
1588 		CREATE3resfail fail;
1589 	} res_u;
1590 };
1591 typedef struct CREATE3res CREATE3res;
1592 
1593 struct MKDIR3args {
1594 	diropargs3 where;
1595 	sattr3 attributes;
1596 };
1597 typedef struct MKDIR3args MKDIR3args;
1598 
1599 struct MKDIR3resok {
1600 	post_op_fh3 obj;
1601 	post_op_attr obj_attributes;
1602 	wcc_data dir_wcc;
1603 };
1604 typedef struct MKDIR3resok MKDIR3resok;
1605 
1606 struct MKDIR3resfail {
1607 	wcc_data dir_wcc;
1608 };
1609 typedef struct MKDIR3resfail MKDIR3resfail;
1610 
1611 struct MKDIR3res {
1612 	nfsstat3 status;
1613 	union {
1614 		MKDIR3resok ok;
1615 		MKDIR3resfail fail;
1616 	} res_u;
1617 };
1618 typedef struct MKDIR3res MKDIR3res;
1619 
1620 struct symlinkdata3 {
1621 	sattr3 symlink_attributes;
1622 	nfspath3 symlink_data;
1623 };
1624 typedef struct symlinkdata3 symlinkdata3;
1625 
1626 struct SYMLINK3args {
1627 	diropargs3 where;
1628 	symlinkdata3 symlink;
1629 };
1630 typedef struct SYMLINK3args SYMLINK3args;
1631 
1632 struct SYMLINK3resok {
1633 	post_op_fh3 obj;
1634 	post_op_attr obj_attributes;
1635 	wcc_data dir_wcc;
1636 };
1637 typedef struct SYMLINK3resok SYMLINK3resok;
1638 
1639 struct SYMLINK3resfail {
1640 	wcc_data dir_wcc;
1641 };
1642 typedef struct SYMLINK3resfail SYMLINK3resfail;
1643 
1644 struct SYMLINK3res {
1645 	nfsstat3 status;
1646 	union {
1647 		SYMLINK3resok ok;
1648 		SYMLINK3resfail fail;
1649 	} res_u;
1650 };
1651 typedef struct SYMLINK3res SYMLINK3res;
1652 
1653 struct devicedata3 {
1654 	sattr3 dev_attributes;
1655 	specdata3 spec;
1656 };
1657 typedef struct devicedata3 devicedata3;
1658 
1659 struct mknoddata3 {
1660 	ftype3 type;
1661 	union {
1662 		devicedata3 device;
1663 		sattr3 pipe_attributes;
1664 	} mknoddata3_u;
1665 };
1666 typedef struct mknoddata3 mknoddata3;
1667 
1668 struct MKNOD3args {
1669 	diropargs3 where;
1670 	mknoddata3 what;
1671 };
1672 typedef struct MKNOD3args MKNOD3args;
1673 
1674 struct MKNOD3resok {
1675 	post_op_fh3 obj;
1676 	post_op_attr obj_attributes;
1677 	wcc_data dir_wcc;
1678 };
1679 typedef struct MKNOD3resok MKNOD3resok;
1680 
1681 struct MKNOD3resfail {
1682 	wcc_data dir_wcc;
1683 };
1684 typedef struct MKNOD3resfail MKNOD3resfail;
1685 
1686 struct MKNOD3res {
1687 	nfsstat3 status;
1688 	union {
1689 		MKNOD3resok ok;
1690 		MKNOD3resfail fail;
1691 	} res_u;
1692 };
1693 typedef struct MKNOD3res MKNOD3res;
1694 
1695 struct REMOVE3args {
1696 	diropargs3 object;
1697 };
1698 typedef struct REMOVE3args REMOVE3args;
1699 
1700 struct REMOVE3resok {
1701 	wcc_data dir_wcc;
1702 };
1703 typedef struct REMOVE3resok REMOVE3resok;
1704 
1705 struct REMOVE3resfail {
1706 	wcc_data dir_wcc;
1707 };
1708 typedef struct REMOVE3resfail REMOVE3resfail;
1709 
1710 struct REMOVE3res {
1711 	nfsstat3 status;
1712 	union {
1713 		REMOVE3resok ok;
1714 		REMOVE3resfail fail;
1715 	} res_u;
1716 };
1717 typedef struct REMOVE3res REMOVE3res;
1718 
1719 struct RMDIR3args {
1720 	diropargs3 object;
1721 };
1722 typedef struct RMDIR3args RMDIR3args;
1723 
1724 struct RMDIR3resok {
1725 	wcc_data dir_wcc;
1726 };
1727 typedef struct RMDIR3resok RMDIR3resok;
1728 
1729 struct RMDIR3resfail {
1730 	wcc_data dir_wcc;
1731 };
1732 typedef struct RMDIR3resfail RMDIR3resfail;
1733 
1734 struct RMDIR3res {
1735 	nfsstat3 status;
1736 	union {
1737 		RMDIR3resok ok;
1738 		RMDIR3resfail fail;
1739 	} res_u;
1740 };
1741 typedef struct RMDIR3res RMDIR3res;
1742 
1743 struct RENAME3args {
1744 	diropargs3 from;
1745 	diropargs3 to;
1746 };
1747 typedef struct RENAME3args RENAME3args;
1748 
1749 struct RENAME3resok {
1750 	wcc_data fromdir_wcc;
1751 	wcc_data todir_wcc;
1752 };
1753 typedef struct RENAME3resok RENAME3resok;
1754 
1755 struct RENAME3resfail {
1756 	wcc_data fromdir_wcc;
1757 	wcc_data todir_wcc;
1758 };
1759 typedef struct RENAME3resfail RENAME3resfail;
1760 
1761 struct RENAME3res {
1762 	nfsstat3 status;
1763 	union {
1764 		RENAME3resok ok;
1765 		RENAME3resfail fail;
1766 	} res_u;
1767 };
1768 typedef struct RENAME3res RENAME3res;
1769 
1770 struct LINK3args {
1771 	nfs_fh3 file;
1772 	diropargs3 link;
1773 };
1774 typedef struct LINK3args LINK3args;
1775 
1776 struct LINK3resok {
1777 	post_op_attr file_attributes;
1778 	wcc_data linkdir_wcc;
1779 };
1780 typedef struct LINK3resok LINK3resok;
1781 
1782 struct LINK3resfail {
1783 	post_op_attr file_attributes;
1784 	wcc_data linkdir_wcc;
1785 };
1786 typedef struct LINK3resfail LINK3resfail;
1787 
1788 struct LINK3res {
1789 	nfsstat3 status;
1790 	union {
1791 		LINK3resok ok;
1792 		LINK3resfail fail;
1793 	} res_u;
1794 };
1795 typedef struct LINK3res LINK3res;
1796 
1797 struct READDIR3args {
1798 	nfs_fh3 dir;
1799 	cookie3 cookie;
1800 	cookieverf3 cookieverf;
1801 	count3 count;
1802 };
1803 typedef struct READDIR3args READDIR3args;
1804 
1805 struct entry3 {
1806 	fileid3 fileid;
1807 	filename3 name;
1808 	cookie3 cookie;
1809 	struct entry3 *nextentry;
1810 };
1811 typedef struct entry3 entry3;
1812 
1813 struct dirlist3 {
1814 	entry3 *entries;
1815 	bool_t eof;
1816 };
1817 typedef struct dirlist3 dirlist3;
1818 
1819 struct READDIR3resok {
1820 	post_op_attr dir_attributes;
1821 	cookieverf3 cookieverf;
1822 	dirlist3 reply;
1823 	uint_t size;
1824 	uint_t count;
1825 	uint_t freecount;
1826 	cookie3 cookie;
1827 };
1828 typedef struct READDIR3resok READDIR3resok;
1829 
1830 struct READDIR3resfail {
1831 	post_op_attr dir_attributes;
1832 };
1833 typedef struct READDIR3resfail READDIR3resfail;
1834 
1835 struct READDIR3res {
1836 	nfsstat3 status;
1837 	union {
1838 		READDIR3resok ok;
1839 		READDIR3resfail fail;
1840 	} res_u;
1841 };
1842 typedef struct READDIR3res READDIR3res;
1843 
1844 #ifdef _KERNEL
1845 struct READDIR3vres {
1846 	nfsstat3 status;
1847 	post_op_vattr dir_attributes;
1848 	cookieverf3 cookieverf;
1849 	dirent64_t *entries;			/* decoded dirent64s */
1850 	uint_t size;				/* actual size of entries */
1851 	uint_t entries_size;			/* max size of entries */
1852 	off64_t loff;				/* last offset/cookie */
1853 	bool_t eof;				/* End of directory */
1854 };
1855 typedef struct READDIR3vres READDIR3vres;
1856 #endif /* _KERNEL */
1857 
1858 struct READDIRPLUS3args {
1859 	nfs_fh3 dir;
1860 	cookie3 cookie;
1861 	cookieverf3 cookieverf;
1862 	count3 dircount;
1863 	count3 maxcount;
1864 };
1865 typedef struct READDIRPLUS3args READDIRPLUS3args;
1866 
1867 struct entryplus3 {
1868 	fileid3 fileid;
1869 	filename3 name;
1870 	cookie3 cookie;
1871 	post_op_attr name_attributes;
1872 	post_op_fh3 name_handle;
1873 	struct entryplus3 *nextentry;
1874 };
1875 typedef struct entryplus3 entryplus3;
1876 
1877 struct dirlistplus3 {
1878 	entryplus3 *entries;
1879 	bool_t eof;
1880 };
1881 typedef struct dirlistplus3 dirlistplus3;
1882 
1883 struct entryplus3_info {
1884 	post_op_attr attr;
1885 	post_op_fh3 fh;
1886 	uint_t namelen;
1887 };
1888 typedef struct entryplus3_info entryplus3_info;
1889 
1890 struct READDIRPLUS3resok {
1891 	post_op_attr dir_attributes;
1892 	cookieverf3 cookieverf;
1893 	dirlistplus3 reply;
1894 	uint_t size;
1895 	uint_t count;
1896 	uint_t maxcount;
1897 	entryplus3_info *infop;
1898 };
1899 typedef struct READDIRPLUS3resok READDIRPLUS3resok;
1900 
1901 struct READDIRPLUS3resfail {
1902 	post_op_attr dir_attributes;
1903 };
1904 typedef struct READDIRPLUS3resfail READDIRPLUS3resfail;
1905 
1906 struct READDIRPLUS3res {
1907 	nfsstat3 status;
1908 	union {
1909 		READDIRPLUS3resok ok;
1910 		READDIRPLUS3resfail fail;
1911 	} res_u;
1912 };
1913 typedef struct READDIRPLUS3res READDIRPLUS3res;
1914 
1915 #ifdef _KERNEL
1916 struct entryplus3_va_fh {
1917 	int va_valid;
1918 	int fh_valid;
1919 	vattr_t va;
1920 	nfs_fh3 fh;
1921 	char *d_name;		/* back pointer into entries */
1922 };
1923 
1924 struct READDIRPLUS3vres {
1925 	nfsstat3 status;
1926 	post_op_vattr dir_attributes;
1927 	cookieverf3 cookieverf;
1928 	dirent64_t *entries;			/* decoded dirent64s */
1929 	uint_t size;				/* actual size of entries */
1930 	uint_t entries_size;			/* max size of entries */
1931 	bool_t eof;				/* End of directory */
1932 	off64_t loff;				/* last offset/cookie */
1933 	cred_t *credentials;			/* caller's credentials */
1934 	hrtime_t time;				/* time of READDIRPLUS call */
1935 };
1936 typedef struct READDIRPLUS3vres READDIRPLUS3vres;
1937 #endif /* _KERNEL */
1938 
1939 struct FSSTAT3args {
1940 	nfs_fh3 fsroot;
1941 };
1942 typedef struct FSSTAT3args FSSTAT3args;
1943 
1944 struct FSSTAT3resok {
1945 	post_op_attr obj_attributes;
1946 	size3 tbytes;
1947 	size3 fbytes;
1948 	size3 abytes;
1949 	size3 tfiles;
1950 	size3 ffiles;
1951 	size3 afiles;
1952 	uint32 invarsec;
1953 };
1954 typedef struct FSSTAT3resok FSSTAT3resok;
1955 
1956 struct FSSTAT3resfail {
1957 	post_op_attr obj_attributes;
1958 };
1959 typedef struct FSSTAT3resfail FSSTAT3resfail;
1960 
1961 struct FSSTAT3res {
1962 	nfsstat3 status;
1963 	union {
1964 		FSSTAT3resok ok;
1965 		FSSTAT3resfail fail;
1966 	} res_u;
1967 };
1968 typedef struct FSSTAT3res FSSTAT3res;
1969 
1970 struct FSINFO3args {
1971 	nfs_fh3 fsroot;
1972 };
1973 typedef struct FSINFO3args FSINFO3args;
1974 
1975 struct FSINFO3resok {
1976 	post_op_attr obj_attributes;
1977 	uint32 rtmax;
1978 	uint32 rtpref;
1979 	uint32 rtmult;
1980 	uint32 wtmax;
1981 	uint32 wtpref;
1982 	uint32 wtmult;
1983 	uint32 dtpref;
1984 	size3 maxfilesize;
1985 	nfstime3 time_delta;
1986 	uint32 properties;
1987 };
1988 typedef struct FSINFO3resok FSINFO3resok;
1989 
1990 struct FSINFO3resfail {
1991 	post_op_attr obj_attributes;
1992 };
1993 typedef struct FSINFO3resfail FSINFO3resfail;
1994 #define	FSF3_LINK 0x1
1995 #define	FSF3_SYMLINK 0x2
1996 #define	FSF3_HOMOGENEOUS 0x8
1997 #define	FSF3_CANSETTIME 0x10
1998 
1999 struct FSINFO3res {
2000 	nfsstat3 status;
2001 	union {
2002 		FSINFO3resok ok;
2003 		FSINFO3resfail fail;
2004 	} res_u;
2005 };
2006 typedef struct FSINFO3res FSINFO3res;
2007 
2008 struct PATHCONF3args {
2009 	nfs_fh3 object;
2010 };
2011 typedef struct PATHCONF3args PATHCONF3args;
2012 
2013 struct nfs3_pathconf_info {
2014 	uint32 link_max;
2015 	uint32 name_max;
2016 	bool_t no_trunc;
2017 	bool_t chown_restricted;
2018 	bool_t case_insensitive;
2019 	bool_t case_preserving;
2020 };
2021 typedef struct nfs3_pathconf_info nfs3_pathconf_info;
2022 
2023 struct PATHCONF3resok {
2024 	post_op_attr obj_attributes;
2025 	nfs3_pathconf_info info;
2026 };
2027 typedef struct PATHCONF3resok PATHCONF3resok;
2028 
2029 struct PATHCONF3resfail {
2030 	post_op_attr obj_attributes;
2031 };
2032 typedef struct PATHCONF3resfail PATHCONF3resfail;
2033 
2034 struct PATHCONF3res {
2035 	nfsstat3 status;
2036 	union {
2037 		PATHCONF3resok ok;
2038 		PATHCONF3resfail fail;
2039 	} res_u;
2040 };
2041 typedef struct PATHCONF3res PATHCONF3res;
2042 
2043 struct COMMIT3args {
2044 	nfs_fh3 file;
2045 	offset3 offset;
2046 	count3 count;
2047 };
2048 typedef struct COMMIT3args COMMIT3args;
2049 
2050 struct COMMIT3resok {
2051 	wcc_data file_wcc;
2052 	writeverf3 verf;
2053 };
2054 typedef struct COMMIT3resok COMMIT3resok;
2055 
2056 struct COMMIT3resfail {
2057 	wcc_data file_wcc;
2058 };
2059 typedef struct COMMIT3resfail COMMIT3resfail;
2060 
2061 struct COMMIT3res {
2062 	nfsstat3 status;
2063 	union {
2064 		COMMIT3resok ok;
2065 		COMMIT3resfail fail;
2066 	} res_u;
2067 };
2068 typedef struct COMMIT3res COMMIT3res;
2069 
2070 #define	NFS3_PROGRAM ((rpcprog_t)100003)
2071 #define	NFS_V3 ((rpcvers_t)3)
2072 #define	NFSPROC3_NULL ((rpcproc_t)0)
2073 #define	NFSPROC3_GETATTR ((rpcproc_t)1)
2074 #define	NFSPROC3_SETATTR ((rpcproc_t)2)
2075 #define	NFSPROC3_LOOKUP ((rpcproc_t)3)
2076 #define	NFSPROC3_ACCESS ((rpcproc_t)4)
2077 #define	NFSPROC3_READLINK ((rpcproc_t)5)
2078 #define	NFSPROC3_READ ((rpcproc_t)6)
2079 #define	NFSPROC3_WRITE ((rpcproc_t)7)
2080 #define	NFSPROC3_CREATE ((rpcproc_t)8)
2081 #define	NFSPROC3_MKDIR ((rpcproc_t)9)
2082 #define	NFSPROC3_SYMLINK ((rpcproc_t)10)
2083 #define	NFSPROC3_MKNOD ((rpcproc_t)11)
2084 #define	NFSPROC3_REMOVE ((rpcproc_t)12)
2085 #define	NFSPROC3_RMDIR ((rpcproc_t)13)
2086 #define	NFSPROC3_RENAME ((rpcproc_t)14)
2087 #define	NFSPROC3_LINK ((rpcproc_t)15)
2088 #define	NFSPROC3_READDIR ((rpcproc_t)16)
2089 #define	NFSPROC3_READDIRPLUS ((rpcproc_t)17)
2090 #define	NFSPROC3_FSSTAT ((rpcproc_t)18)
2091 #define	NFSPROC3_FSINFO ((rpcproc_t)19)
2092 #define	NFSPROC3_PATHCONF ((rpcproc_t)20)
2093 #define	NFSPROC3_COMMIT ((rpcproc_t)21)
2094 
2095 #ifndef _KERNEL
2096 extern void		*nfsproc3_null_3();
2097 extern GETATTR3res	*nfsproc3_getattr_3();
2098 extern SETATTR3res	*nfsproc3_setattr_3();
2099 extern LOOKUP3res	*nfsproc3_lookup_3();
2100 extern ACCESS3res	*nfsproc3_access_3();
2101 extern READLINK3res	*nfsproc3_readlink_3();
2102 extern READ3res	*nfsproc3_read_3();
2103 extern WRITE3res	*nfsproc3_write_3();
2104 extern CREATE3res	*nfsproc3_create_3();
2105 extern MKDIR3res	*nfsproc3_mkdir_3();
2106 extern SYMLINK3res	*nfsproc3_symlink_3();
2107 extern MKNOD3res	*nfsproc3_mknod_3();
2108 extern REMOVE3res	*nfsproc3_remove_3();
2109 extern RMDIR3res	*nfsproc3_rmdir_3();
2110 extern RENAME3res	*nfsproc3_rename_3();
2111 extern LINK3res	*nfsproc3_link_3();
2112 extern READDIR3res	*nfsproc3_readdir_3();
2113 extern READDIRPLUS3res	*nfsproc3_readdirplus_3();
2114 extern FSSTAT3res	*nfsproc3_fsstat_3();
2115 extern FSINFO3res	*nfsproc3_fsinfo_3();
2116 extern PATHCONF3res	*nfsproc3_pathconf_3();
2117 extern COMMIT3res	*nfsproc3_commit_3();
2118 #endif	/* !_KERNEL */
2119 
2120 #ifdef _KERNEL
2121 /* the NFS Version 3 XDR functions */
2122 
2123 extern bool_t xdr_nfs_fh3(XDR *, nfs_fh3 *);
2124 extern bool_t xdr_nfslog_nfs_fh3(XDR *, nfs_fh3 *);
2125 extern bool_t xdr_nfs_fh3_server(XDR *, nfs_fh3 *);
2126 extern bool_t xdr_diropargs3(XDR *, diropargs3 *);
2127 extern bool_t xdr_post_op_attr(XDR *, post_op_attr *);
2128 extern bool_t xdr_post_op_fh3(XDR *, post_op_fh3 *);
2129 extern bool_t xdr_GETATTR3res(XDR *, GETATTR3res *);
2130 extern bool_t xdr_GETATTR3vres(XDR *, GETATTR3vres *);
2131 extern bool_t xdr_SETATTR3args(XDR *, SETATTR3args *);
2132 extern bool_t xdr_SETATTR3res(XDR *, SETATTR3res *);
2133 extern bool_t xdr_LOOKUP3res(XDR *, LOOKUP3res *);
2134 extern bool_t xdr_LOOKUP3vres(XDR *, LOOKUP3vres *);
2135 extern bool_t xdr_ACCESS3args(XDR *, ACCESS3args *);
2136 extern bool_t xdr_ACCESS3res(XDR *, ACCESS3res *);
2137 extern bool_t xdr_READLINK3args(XDR *, READLINK3args *);
2138 extern bool_t xdr_READLINK3res(XDR *, READLINK3res *);
2139 extern bool_t xdr_READ3args(XDR *, READ3args *);
2140 extern bool_t xdr_READ3res(XDR *, READ3res *);
2141 extern bool_t xdr_READ3vres(XDR *, READ3vres *);
2142 extern bool_t xdr_READ3uiores(XDR *, READ3uiores *);
2143 extern bool_t xdr_WRITE3args(XDR *, WRITE3args *);
2144 extern bool_t xdr_WRITE3res(XDR *, WRITE3res *);
2145 extern bool_t xdr_CREATE3args(XDR *, CREATE3args *);
2146 extern bool_t xdr_CREATE3res(XDR *, CREATE3res *);
2147 extern bool_t xdr_MKDIR3args(XDR *, MKDIR3args *);
2148 extern bool_t xdr_MKDIR3res(XDR *, MKDIR3res *);
2149 extern bool_t xdr_SYMLINK3args(XDR *, SYMLINK3args *);
2150 extern bool_t xdr_SYMLINK3res(XDR *, SYMLINK3res *);
2151 extern bool_t xdr_MKNOD3args(XDR *, MKNOD3args *);
2152 extern bool_t xdr_MKNOD3res(XDR *, MKNOD3res *);
2153 extern bool_t xdr_REMOVE3res(XDR *, REMOVE3res *);
2154 extern bool_t xdr_RMDIR3resfail(XDR *, RMDIR3resfail *);
2155 extern bool_t xdr_RMDIR3res(XDR *, RMDIR3res *);
2156 extern bool_t xdr_RENAME3args(XDR *, RENAME3args *);
2157 extern bool_t xdr_RENAME3res(XDR *, RENAME3res *);
2158 extern bool_t xdr_LINK3args(XDR *, LINK3args *);
2159 extern bool_t xdr_LINK3res(XDR *, LINK3res *);
2160 extern bool_t xdr_READDIR3args(XDR *, READDIR3args *);
2161 extern bool_t xdr_READDIR3res(XDR *, READDIR3res *);
2162 extern bool_t xdr_READDIR3vres(XDR *, READDIR3vres *);
2163 extern bool_t xdr_READDIRPLUS3args(XDR *, READDIRPLUS3args *);
2164 extern bool_t xdr_READDIRPLUS3res(XDR *, READDIRPLUS3res *);
2165 extern bool_t xdr_READDIRPLUS3vres(XDR *, READDIRPLUS3vres *);
2166 extern bool_t xdr_FSSTAT3res(XDR *, FSSTAT3res *);
2167 extern bool_t xdr_FSINFO3res(XDR *, FSINFO3res *);
2168 extern bool_t xdr_PATHCONF3res(XDR *, PATHCONF3res *);
2169 extern bool_t xdr_COMMIT3args(XDR *, COMMIT3args *);
2170 extern bool_t xdr_COMMIT3res(XDR *, COMMIT3res *);
2171 extern bool_t xdr_fastnfs_fh3(XDR *, nfs_fh3 **);
2172 
2173 /*
2174  * The NFS Version 3 service procedures.
2175  */
2176 struct exportinfo;	/* defined in nfs/export.h */
2177 struct servinfo;	/* defined in nfs/nfs_clnt.h */
2178 struct mntinfo;		/* defined in nfs/nfs_clnt.h */
2179 struct sec_ol;		/* defined in nfs/export.h */
2180 
2181 extern void	rfs3_getattr(GETATTR3args *, GETATTR3res *, struct exportinfo *,
2182     struct svc_req *, cred_t *, bool_t);
2183 extern void	*rfs3_getattr_getfh(GETATTR3args *);
2184 extern void	rfs3_setattr(SETATTR3args *, SETATTR3res *, struct exportinfo *,
2185     struct svc_req *, cred_t *, bool_t);
2186 extern void	*rfs3_setattr_getfh(SETATTR3args *);
2187 extern void	rfs3_lookup(LOOKUP3args *, LOOKUP3res *, struct exportinfo *,
2188     struct svc_req *, cred_t *, bool_t);
2189 extern void	*rfs3_lookup_getfh(LOOKUP3args *);
2190 extern void	rfs3_access(ACCESS3args *, ACCESS3res *, struct exportinfo *,
2191     struct svc_req *, cred_t *, bool_t);
2192 extern void	*rfs3_access_getfh(ACCESS3args *);
2193 extern void	rfs3_readlink(READLINK3args *, READLINK3res *,
2194     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
2195 extern void	*rfs3_readlink_getfh(READLINK3args *);
2196 extern void	rfs3_readlink_free(READLINK3res *);
2197 extern void	rfs3_read(READ3args *, READ3res *, struct exportinfo *,
2198     struct svc_req *, cred_t *, bool_t);
2199 extern void	*rfs3_read_getfh(READ3args *);
2200 extern void	rfs3_read_free(READ3res *);
2201 extern void	rfs3_write(WRITE3args *, WRITE3res *, struct exportinfo *,
2202     struct svc_req *, cred_t *, bool_t);
2203 extern void	*rfs3_write_getfh(WRITE3args *);
2204 extern void	rfs3_create(CREATE3args *, CREATE3res *, struct exportinfo *,
2205     struct svc_req *, cred_t *, bool_t);
2206 extern void	*rfs3_create_getfh(CREATE3args *);
2207 extern void	rfs3_mkdir(MKDIR3args *, MKDIR3res *, struct exportinfo *,
2208     struct svc_req *, cred_t *, bool_t);
2209 extern void	*rfs3_mkdir_getfh(MKDIR3args *);
2210 extern void	rfs3_symlink(SYMLINK3args *, SYMLINK3res *, struct exportinfo *,
2211     struct svc_req *, cred_t *, bool_t);
2212 extern void	*rfs3_symlink_getfh(SYMLINK3args *);
2213 extern void	rfs3_mknod(MKNOD3args *, MKNOD3res *, struct exportinfo *,
2214     struct svc_req *, cred_t *, bool_t);
2215 extern void	*rfs3_mknod_getfh(MKNOD3args *);
2216 extern void	rfs3_remove(REMOVE3args *, REMOVE3res *, struct exportinfo *,
2217     struct svc_req *, cred_t *, bool_t);
2218 extern void	*rfs3_remove_getfh(REMOVE3args *);
2219 extern void	rfs3_rmdir(RMDIR3args *, RMDIR3res *, struct exportinfo *,
2220     struct svc_req *, cred_t *, bool_t);
2221 extern void	*rfs3_rmdir_getfh(RMDIR3args *);
2222 extern void	rfs3_rename(RENAME3args *, RENAME3res *, struct exportinfo *,
2223     struct svc_req *, cred_t *, bool_t);
2224 extern void	*rfs3_rename_getfh(RENAME3args *);
2225 extern void	rfs3_link(LINK3args *, LINK3res *, struct exportinfo *,
2226     struct svc_req *, cred_t *, bool_t);
2227 extern void	*rfs3_link_getfh(LINK3args *);
2228 extern void	rfs3_readdir(READDIR3args *, READDIR3res *, struct exportinfo *,
2229     struct svc_req *, cred_t *, bool_t);
2230 extern void	*rfs3_readdir_getfh(READDIR3args *);
2231 extern void	rfs3_readdir_free(READDIR3res *);
2232 extern void	rfs3_readdirplus(READDIRPLUS3args *, READDIRPLUS3res *,
2233     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
2234 extern void	*rfs3_readdirplus_getfh(READDIRPLUS3args *);
2235 extern void	rfs3_readdirplus_free(READDIRPLUS3res *);
2236 extern void	rfs3_fsstat(FSSTAT3args *, FSSTAT3res *, struct exportinfo *,
2237     struct svc_req *, cred_t *, bool_t);
2238 extern void	*rfs3_fsstat_getfh(FSSTAT3args *);
2239 extern void	rfs3_fsinfo(FSINFO3args *, FSINFO3res *, struct exportinfo *,
2240     struct svc_req *, cred_t *, bool_t);
2241 extern void	*rfs3_fsinfo_getfh(FSINFO3args *);
2242 extern void	rfs3_pathconf(PATHCONF3args *, PATHCONF3res *,
2243     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
2244 extern void	*rfs3_pathconf_getfh(PATHCONF3args *);
2245 extern void	rfs3_commit(COMMIT3args *, COMMIT3res *, struct exportinfo *,
2246     struct svc_req *, cred_t *, bool_t);
2247 extern void	*rfs3_commit_getfh(COMMIT3args *);
2248 extern void	rfs3_srvrinit(void);
2249 extern void	rfs3_srvrfini(void);
2250 
2251 extern int	nfs3_validate_caches(vnode_t *, cred_t *);
2252 extern void	nfs3_cache_post_op_attr(vnode_t *, post_op_attr *, hrtime_t,
2253     cred_t *);
2254 extern void	nfs3_cache_post_op_vattr(vnode_t *, post_op_vattr *, hrtime_t,
2255     cred_t *);
2256 extern void	nfs3_cache_wcc_data(vnode_t *, wcc_data *, hrtime_t, cred_t *);
2257 extern void	nfs3_attrcache(vnode_t *, fattr3 *, hrtime_t);
2258 extern int	nfs3_cache_fattr3(vnode_t *, fattr3 *, vattr_t *, hrtime_t,
2259     cred_t *);
2260 extern int	nfs3_getattr_otw(vnode_t *, struct vattr *, cred_t *);
2261 extern int	nfs3getattr(vnode_t *, struct vattr *, cred_t *);
2262 extern int	fattr3_to_vattr(vnode_t *, fattr3 *, struct vattr *);
2263 extern int	nfs3tsize(void);
2264 extern uint_t	nfs3_tsize(struct knetconfig *);
2265 extern uint_t	rfs3_tsize(struct svc_req *);
2266 extern int	vattr_to_sattr3(struct vattr *, sattr3 *);
2267 extern void	setdiropargs3(diropargs3 *, char *, vnode_t *);
2268 extern enum nfsstat3 puterrno3(int);
2269 extern int	geterrno3(enum nfsstat3);
2270 extern int	nfs3init(int, char *);
2271 extern void	nfs3fini(void);
2272 extern int	nfs3_vfsinit(void);
2273 extern void	nfs3_vfsfini(void);
2274 extern void	vattr_to_post_op_attr(struct vattr *, post_op_attr *);
2275 extern void	mblk_to_iov(mblk_t *, int, struct iovec *);
2276 extern int	rfs_publicfh_mclookup(char *, vnode_t *, cred_t *, vnode_t **,
2277     struct exportinfo **, struct sec_ol *);
2278 extern int	rfs_pathname(char *, vnode_t **, vnode_t **, vnode_t *,
2279     cred_t *, int);
2280 
2281 extern vtype_t		nf3_to_vt[];
2282 extern kstat_named_t	*rfsproccnt_v3_ptr;
2283 extern vfsops_t		*nfs3_vfsops;
2284 extern struct vnodeops	*nfs3_vnodeops;
2285 extern const struct fs_operation_def nfs3_vnodeops_template[];
2286 
2287 /*
2288  * Some servers do not properly update the attributes of the
2289  * directory when changes are made.  To allow interoperability
2290  * with these broken servers, the nfs_disable_rddir_cache
2291  * parameter can be used to disable readdir response caching.
2292  */
2293 extern int		nfs_disable_rddir_cache;
2294 
2295 /*
2296  * External functions called by the v2/v3 code into the v4 code
2297  */
2298 extern void	nfs4_clnt_init(void);
2299 extern void	nfs4_clnt_fini(void);
2300 
2301 /*
2302  * Does NFS4 server have a vnode delegated?  TRUE if so, FALSE if not.
2303  */
2304 extern bool_t	rfs4_check_delegated(int mode, vnode_t *, bool_t trunc);
2305 /*
2306  * VOP_GETATTR call. If a NFS4 delegation is present on the supplied vnode
2307  * call back to the delegated client to get attributes for AT_MTIME and
2308  * AT_SIZE. Invoke VOP_GETATTR to get all other attributes or all attributes
2309  * if no delegation is present.
2310  */
2311 extern int	rfs4_delegated_getattr(vnode_t *, vattr_t *, int, cred_t *);
2312 extern void	rfs4_hold_deleg_policy(void);
2313 extern void	rfs4_rele_deleg_policy(void);
2314 
2315 extern int	do_xattr_exists_check(vnode_t *, ulong_t *, cred_t *);
2316 
2317 extern ts_label_t *nfs_getflabel(vnode_t *, struct exportinfo *);
2318 extern boolean_t do_rfs_label_check(bslabel_t *, vnode_t *, int,
2319     struct exportinfo *);
2320 
2321 /*
2322  * Copy Reduction support.
2323  * xuio_t wrapper with additional private data.
2324  */
2325 
2326 typedef struct nfs_xuio {
2327 	xuio_t nu_uio;
2328 	vnode_t *nu_vp;
2329 	uint_t nu_ref;
2330 	frtn_t nu_frtn;
2331 } nfs_xuio_t;
2332 
2333 extern xuio_t	*rfs_setup_xuio(vnode_t *);
2334 extern mblk_t	*uio_to_mblk(uio_t *);
2335 extern mblk_t	*rfs_read_alloc(uint_t, struct iovec **, int *);
2336 extern void	rfs_rndup_mblks(mblk_t *, uint_t, int);
2337 extern void	rfs_free_xuio(void *);
2338 
2339 #endif	/* _KERNEL */
2340 
2341 #ifdef	__cplusplus
2342 }
2343 #endif
2344 
2345 #endif	/* _NFS_NFS_H */
2346