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