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