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