xref: /onnv-gate/usr/src/uts/common/nfs/nfs.h (revision 13080:fcc1e406c13f)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51610Sthurlow  * Common Development and Distribution License (the "License").
61610Sthurlow  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*13080SPavan.Mettu@Oracle.COM  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
230Sstevel@tonic-gate  */
240Sstevel@tonic-gate 
250Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
260Sstevel@tonic-gate /*	  All Rights Reserved  	*/
270Sstevel@tonic-gate 
280Sstevel@tonic-gate #ifndef	_NFS_NFS_H
290Sstevel@tonic-gate #define	_NFS_NFS_H
300Sstevel@tonic-gate 
310Sstevel@tonic-gate /*	nfs.h 2.38 88/08/19 SMI 	*/
320Sstevel@tonic-gate 
330Sstevel@tonic-gate #include <sys/isa_defs.h>
340Sstevel@tonic-gate #include <sys/vfs.h>
350Sstevel@tonic-gate #include <sys/stream.h>
360Sstevel@tonic-gate #include <rpc/types.h>
370Sstevel@tonic-gate #include <sys/types32.h>
380Sstevel@tonic-gate #ifdef _KERNEL
397387SRobert.Gordon@Sun.COM #include <rpc/rpc_rdma.h>
401676Sjpk #include <rpc/rpc.h>
410Sstevel@tonic-gate #include <sys/fcntl.h>
420Sstevel@tonic-gate #include <sys/kstat.h>
430Sstevel@tonic-gate #include <sys/dirent.h>
441676Sjpk #include <sys/zone.h>
451676Sjpk #include <sys/tsol/label.h>
462035Scalum #include <sys/nvpair.h>
470Sstevel@tonic-gate #include <nfs/mount.h>
489694SScott.Rotondo@Sun.COM #include <sys/vfs_opreg.h>
490Sstevel@tonic-gate #endif
500Sstevel@tonic-gate #include <vm/page.h>
510Sstevel@tonic-gate #include <rpc/rpc_sztypes.h>
520Sstevel@tonic-gate #include <sys/sysmacros.h>
530Sstevel@tonic-gate #ifdef	__cplusplus
540Sstevel@tonic-gate extern "C" {
550Sstevel@tonic-gate #endif
560Sstevel@tonic-gate 
570Sstevel@tonic-gate /*
580Sstevel@tonic-gate  * remote file service numbers
590Sstevel@tonic-gate  */
600Sstevel@tonic-gate #define	NFS_PROGRAM	((rpcprog_t)100003)
610Sstevel@tonic-gate #define	NFS_VERSMIN	((rpcvers_t)2)
620Sstevel@tonic-gate #define	NFS_VERSMAX	((rpcvers_t)4)
630Sstevel@tonic-gate #define	NFS_VERSION	((rpcvers_t)2)
640Sstevel@tonic-gate #define	NFS_PORT	2049
650Sstevel@tonic-gate 
660Sstevel@tonic-gate /*
670Sstevel@tonic-gate  * Used to determine registration and service handling of versions
680Sstevel@tonic-gate  */
690Sstevel@tonic-gate #define	NFS_VERSMIN_DEFAULT	((rpcvers_t)2)
700Sstevel@tonic-gate #define	NFS_VERSMAX_DEFAULT	((rpcvers_t)4)
710Sstevel@tonic-gate 
720Sstevel@tonic-gate extern rpcvers_t nfs_versmin;
730Sstevel@tonic-gate extern rpcvers_t nfs_versmax;
740Sstevel@tonic-gate 
750Sstevel@tonic-gate /*
760Sstevel@tonic-gate  * Default delegation setting for the server ==> "on"
770Sstevel@tonic-gate  */
780Sstevel@tonic-gate #define	NFS_SERVER_DELEGATION_DEFAULT	(TRUE)
790Sstevel@tonic-gate 
800Sstevel@tonic-gate /* Maximum size of data portion of a remote request */
810Sstevel@tonic-gate #define	NFS_MAXDATA	8192
820Sstevel@tonic-gate #define	NFS_MAXNAMLEN	255
830Sstevel@tonic-gate #define	NFS_MAXPATHLEN	1024
840Sstevel@tonic-gate 
850Sstevel@tonic-gate /*
860Sstevel@tonic-gate  * Rpc retransmission parameters
870Sstevel@tonic-gate  */
880Sstevel@tonic-gate #define	NFS_TIMEO	11	/* initial timeout for clts in 10th of a sec */
890Sstevel@tonic-gate #define	NFS_RETRIES	5	/* times to retry request */
900Sstevel@tonic-gate #define	NFS_COTS_TIMEO	600	/* initial timeout for cots in 10th of a sec */
910Sstevel@tonic-gate 
920Sstevel@tonic-gate /*
930Sstevel@tonic-gate  * The value of UID_NOBODY/GID_NOBODY presented to the world via NFS.
940Sstevel@tonic-gate  * UID_NOBODY/GID_NOBODY is translated to NFS_UID_NOBODY/NFS_GID_NOBODY
950Sstevel@tonic-gate  * when being sent out over the network and NFS_UID_NOBODY/NFS_GID_NOBODY
960Sstevel@tonic-gate  * is translated to UID_NOBODY/GID_NOBODY when received.
970Sstevel@tonic-gate  */
980Sstevel@tonic-gate #define	NFS_UID_NOBODY	-2
990Sstevel@tonic-gate #define	NFS_GID_NOBODY	-2
1000Sstevel@tonic-gate 
1010Sstevel@tonic-gate /*
1020Sstevel@tonic-gate  * maximum transfer size for different interfaces
1030Sstevel@tonic-gate  */
1040Sstevel@tonic-gate #define	ECTSIZE	2048
1050Sstevel@tonic-gate #define	IETSIZE	8192
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate /*
1080Sstevel@tonic-gate  * WebNFS error status
1090Sstevel@tonic-gate  */
1100Sstevel@tonic-gate enum wnfsstat {
1110Sstevel@tonic-gate 	WNFSERR_CLNT_FLAVOR = 20001	/* invalid client sec flavor */
1120Sstevel@tonic-gate };
1130Sstevel@tonic-gate 
1140Sstevel@tonic-gate /*
1150Sstevel@tonic-gate  * Error status
1160Sstevel@tonic-gate  * Should include all possible net errors.
1170Sstevel@tonic-gate  * For now we just cast errno into an enum nfsstat.
1180Sstevel@tonic-gate  */
1190Sstevel@tonic-gate enum nfsstat {
1200Sstevel@tonic-gate 	NFS_OK = 0,			/* no error */
1210Sstevel@tonic-gate 	NFSERR_PERM = 1,		/* Not owner */
1220Sstevel@tonic-gate 	NFSERR_NOENT = 2,		/* No such file or directory */
1230Sstevel@tonic-gate 	NFSERR_IO = 5,			/* I/O error */
1240Sstevel@tonic-gate 	NFSERR_NXIO = 6,		/* No such device or address */
1250Sstevel@tonic-gate 	NFSERR_ACCES = 13,		/* Permission denied */
1260Sstevel@tonic-gate 	NFSERR_EXIST = 17,		/* File exists */
1270Sstevel@tonic-gate 	NFSERR_XDEV = 18,		/* Cross-device link */
1280Sstevel@tonic-gate 	NFSERR_NODEV = 19,		/* No such device */
1290Sstevel@tonic-gate 	NFSERR_NOTDIR = 20,		/* Not a directory */
1300Sstevel@tonic-gate 	NFSERR_ISDIR = 21,		/* Is a directory */
1310Sstevel@tonic-gate 	NFSERR_INVAL = 22,		/* Invalid argument */
1320Sstevel@tonic-gate 	NFSERR_FBIG = 27,		/* File too large */
1330Sstevel@tonic-gate 	NFSERR_NOSPC = 28,		/* No space left on device */
1340Sstevel@tonic-gate 	NFSERR_ROFS = 30,		/* Read-only file system */
1350Sstevel@tonic-gate 	NFSERR_OPNOTSUPP = 45,		/* Operation not supported */
1360Sstevel@tonic-gate 	NFSERR_NAMETOOLONG = 63,	/* File name too long */
1370Sstevel@tonic-gate 	NFSERR_NOTEMPTY = 66,		/* Directory not empty */
1380Sstevel@tonic-gate 	NFSERR_DQUOT = 69,		/* Disc quota exceeded */
1390Sstevel@tonic-gate 	NFSERR_STALE = 70,		/* Stale NFS file handle */
1400Sstevel@tonic-gate 	NFSERR_REMOTE = 71,		/* Object is remote */
1410Sstevel@tonic-gate 	NFSERR_WFLUSH = 99		/* write cache flushed */
1420Sstevel@tonic-gate };
1430Sstevel@tonic-gate 
1440Sstevel@tonic-gate typedef enum nfsstat nfsstat;
1450Sstevel@tonic-gate 
1460Sstevel@tonic-gate /*
1470Sstevel@tonic-gate  * File types
1480Sstevel@tonic-gate  */
1490Sstevel@tonic-gate enum nfsftype {
1500Sstevel@tonic-gate 	NFNON,
1510Sstevel@tonic-gate 	NFREG,		/* regular file */
1520Sstevel@tonic-gate 	NFDIR,		/* directory */
1530Sstevel@tonic-gate 	NFBLK,		/* block special */
1540Sstevel@tonic-gate 	NFCHR,		/* character special */
1550Sstevel@tonic-gate 	NFLNK,		/* symbolic link */
1560Sstevel@tonic-gate 	NFSOC		/* socket */
1570Sstevel@tonic-gate };
1580Sstevel@tonic-gate 
1590Sstevel@tonic-gate /*
1600Sstevel@tonic-gate  * Macros for converting device numbers to and from the format
1610Sstevel@tonic-gate  * SunOS 4.x used. SVR4 uses 14 bit majors and 18 bits minors,
1620Sstevel@tonic-gate  * SunOS 4.x used 8 bit majors and 8 bit minors. It isn't sufficient
1630Sstevel@tonic-gate  * to use the cmpdev() and expdev() macros because they only compress
1640Sstevel@tonic-gate  * 7 bit (and smaller) majors. We must compress 8 bit majors too.
1650Sstevel@tonic-gate  * If the major or minor exceeds 8 bits, then we send it out in
1660Sstevel@tonic-gate  * full 32 bit format and hope that the peer can deal with it.
1670Sstevel@tonic-gate  */
1680Sstevel@tonic-gate 
1690Sstevel@tonic-gate #define	SO4_BITSMAJOR	8	/* # of SunOS 4.x major device bits */
1700Sstevel@tonic-gate #define	SO4_BITSMINOR	8	/* # of SunOS 4.x minor device bits */
1710Sstevel@tonic-gate #define	SO4_MAXMAJ	0xff	/* SunOS 4.x max major value */
1720Sstevel@tonic-gate #define	SO4_MAXMIN	0xff	/* SunOS 4.x max minor value */
1730Sstevel@tonic-gate 
1740Sstevel@tonic-gate /*
1750Sstevel@tonic-gate  * Convert to over-the-wire device number format
1760Sstevel@tonic-gate  */
1770Sstevel@tonic-gate #define	nfsv2_cmpdev(x) \
1780Sstevel@tonic-gate 	((uint32_t) \
1790Sstevel@tonic-gate 	((getmajor(x) > SO4_MAXMAJ || getminor(x) > SO4_MAXMIN) ? NODEV : \
1800Sstevel@tonic-gate 	((getmajor(x) << SO4_BITSMINOR) | (getminor(x) & SO4_MAXMIN))))
1810Sstevel@tonic-gate 
1820Sstevel@tonic-gate /*
1830Sstevel@tonic-gate  * Convert from over-the-wire format to SVR4 device number format
1840Sstevel@tonic-gate  */
1850Sstevel@tonic-gate #define	nfsv2_expdev(x) \
1860Sstevel@tonic-gate 	makedevice((((x) >> SO4_BITSMINOR) & SO4_MAXMAJ), (x) & SO4_MAXMIN)
1870Sstevel@tonic-gate 
1880Sstevel@tonic-gate /*
1890Sstevel@tonic-gate  * Special kludge for fifos (named pipes)  [to adhere to NFS Protocol Spec]
1900Sstevel@tonic-gate  *
1910Sstevel@tonic-gate  * VFIFO is not in the protocol spec (VNON will be replaced by VFIFO)
1920Sstevel@tonic-gate  * so the over-the-wire representation is VCHR with a '-1' device number.
1930Sstevel@tonic-gate  *
1940Sstevel@tonic-gate  * NOTE: This kludge becomes unnecessary with the Protocol Revision,
1950Sstevel@tonic-gate  *	 but it may be necessary to support it (backwards compatibility).
1960Sstevel@tonic-gate  */
1970Sstevel@tonic-gate #define	NFS_FIFO_TYPE	NFCHR
1980Sstevel@tonic-gate #define	NFS_FIFO_MODE	S_IFCHR
1990Sstevel@tonic-gate #define	NFS_FIFO_DEV	((uint32_t)-1)
2000Sstevel@tonic-gate 
2010Sstevel@tonic-gate /* identify fifo in nfs attributes */
2020Sstevel@tonic-gate #define	NA_ISFIFO(NA)	(((NA)->na_type == NFS_FIFO_TYPE) && \
2030Sstevel@tonic-gate 			    ((NA)->na_rdev == NFS_FIFO_DEV))
2040Sstevel@tonic-gate 
2050Sstevel@tonic-gate /* set fifo in nfs attributes */
2060Sstevel@tonic-gate #define	NA_SETFIFO(NA)	{ \
2070Sstevel@tonic-gate 		(NA)->na_type = NFS_FIFO_TYPE; \
2080Sstevel@tonic-gate 		(NA)->na_rdev = NFS_FIFO_DEV; \
2090Sstevel@tonic-gate 		(NA)->na_mode = ((NA)->na_mode & ~S_IFMT) | NFS_FIFO_MODE; \
2100Sstevel@tonic-gate 		}
2110Sstevel@tonic-gate 
2120Sstevel@tonic-gate /*
2130Sstevel@tonic-gate  * Check for time overflow using a kernel tunable to determine whether
2140Sstevel@tonic-gate  * we should accept or reject an unsigned 32-bit time value. Time value in NFS
2150Sstevel@tonic-gate  * v2/3 protocol is unsigned 32 bit, but ILP32 kernel only allows 31 bits.
2160Sstevel@tonic-gate  * In nfsv4, time value is a signed 64 bit, so needs to be checked for
2170Sstevel@tonic-gate  * overflow as well (e.g. for setattr). So define the tunable as follows:
2180Sstevel@tonic-gate  * nfs_allow_preepoch_time is TRUE if pre-epoch (negative) times are allowed
2190Sstevel@tonic-gate  * and is FALSE (the default) otherwise. For nfsv2/3 this means that
2200Sstevel@tonic-gate  * if negative times are allowed, the uint32_t time value is interpreted
2210Sstevel@tonic-gate  * as a signed int, otherwise as a large positive number. For nfsv4,
2220Sstevel@tonic-gate  * we use the value as is - except that if negative times are not allowed,
2230Sstevel@tonic-gate  * we will not accept a negative value otw.
2240Sstevel@tonic-gate  *
2250Sstevel@tonic-gate  * So for nfsv2/3 (uint32_t):
2260Sstevel@tonic-gate  *
2270Sstevel@tonic-gate  * If nfs_allow_preepoch_time is
2280Sstevel@tonic-gate  * FALSE, the maximum time value is INT32_MAX for 32-bit kernels and
2290Sstevel@tonic-gate  * UINT32_MAX for 64-bit kernels (to allow times larger than 2038)
2300Sstevel@tonic-gate  * and the minimum is zero. Note that in that case, a 32-bit application
2310Sstevel@tonic-gate  * running on a 64-bit kernel will not be able to access files with
2320Sstevel@tonic-gate  * the larger time values.
2330Sstevel@tonic-gate  * If nfs_allow_preepoch_time is TRUE, the maximum time value is INT32_MAX
2340Sstevel@tonic-gate  * for both kernel configurations and the minimum is INT32_MIN.
2350Sstevel@tonic-gate  *
2360Sstevel@tonic-gate  * And for nfsv4 (int64_t):
2370Sstevel@tonic-gate  *
2380Sstevel@tonic-gate  * nfsv4 allows for negative values in the protocol, and has a 64-bit
2390Sstevel@tonic-gate  * time field, so nfs_allow_preepoch_time can be ignored.
2400Sstevel@tonic-gate  */
2410Sstevel@tonic-gate #ifdef _KERNEL
2420Sstevel@tonic-gate 
2430Sstevel@tonic-gate extern bool_t		nfs_allow_preepoch_time;
2440Sstevel@tonic-gate 
2450Sstevel@tonic-gate #ifdef _LP64
2460Sstevel@tonic-gate 
2470Sstevel@tonic-gate /*
2480Sstevel@tonic-gate  * If no negative otw values are allowed, may use the full 32-bits of the
2490Sstevel@tonic-gate  * time to represent time later than 2038, by presenting the value as an
2500Sstevel@tonic-gate  * unsigned (but this can only be used by 64-bit apps due to cstat32
2515331Samw  * restrictions). If negative values are allowed, cannot represent times
2520Sstevel@tonic-gate  * after 2038. Either way, all 32 bits have a valid representation.
2530Sstevel@tonic-gate  */
2540Sstevel@tonic-gate 
2550Sstevel@tonic-gate /* Check if nfstime4 seconds (int64_t) can be stored in the system time */
2560Sstevel@tonic-gate #define	NFS4_TIME_OK(tt)	TRUE
2570Sstevel@tonic-gate 
2580Sstevel@tonic-gate 
2590Sstevel@tonic-gate #define	NFS3_TIME_OVERFLOW(tt)	(FALSE)
2600Sstevel@tonic-gate #define	NFS2_TIME_OVERFLOW(tt)	(FALSE)
2610Sstevel@tonic-gate 
2620Sstevel@tonic-gate /*
2630Sstevel@tonic-gate  * check if a time_t (int64_t) is ok when preepoch times are allowed -
2640Sstevel@tonic-gate  * nfsv2/3: every 32-bit value is accepted, but can't overflow 64->32.
2650Sstevel@tonic-gate  * nfsv4: every value is valid.
2660Sstevel@tonic-gate  */
2670Sstevel@tonic-gate #define	NFS_PREEPOCH_TIME_T_OK(tt)					\
2680Sstevel@tonic-gate 	(((tt) >= (time_t)INT32_MIN) && ((tt) <= (time_t)INT32_MAX))
2690Sstevel@tonic-gate 
2700Sstevel@tonic-gate /*
2710Sstevel@tonic-gate  * check if a time_t (int64_t) is ok when preepoch times are not allowed -
2720Sstevel@tonic-gate  * nfsv2/3: every positive 32-bit value is accepted, but can't overflow 64->32.
2730Sstevel@tonic-gate  * nfsv4: every value is valid.
2740Sstevel@tonic-gate  */
2750Sstevel@tonic-gate #define	NFS_NO_PREEPOCH_TIME_T_OK(tt)					\
2760Sstevel@tonic-gate 	(((tt) >= 0) && ((tt) <= (time_t)(ulong_t)UINT32_MAX))
2770Sstevel@tonic-gate 
2780Sstevel@tonic-gate #else /* not _LP64 */
2790Sstevel@tonic-gate 
2800Sstevel@tonic-gate /*
2810Sstevel@tonic-gate  * Cannot represent times after 2038 in a 32-bit kernel, but we may wish to
2820Sstevel@tonic-gate  * restrict the use of negative values (which violate the protocol).
2830Sstevel@tonic-gate  * So if negative times allowed, all uint32 time values are valid. Otherwise
2840Sstevel@tonic-gate  * only those which are less than INT32_MAX (msb=0).
2850Sstevel@tonic-gate  *
2860Sstevel@tonic-gate  * NFSv4 uses int64_t for the time, so in a 32-bit kernel the nfsv4 value
2870Sstevel@tonic-gate  * must fit in an int32_t.
2880Sstevel@tonic-gate  */
2890Sstevel@tonic-gate 
2900Sstevel@tonic-gate /* Only allow signed 32-bit time values */
2910Sstevel@tonic-gate 
2920Sstevel@tonic-gate /* Check if an nfstime4 (int64_t) can be stored in the system time */
2930Sstevel@tonic-gate #define	NFS4_TIME_OK(tt)						\
2940Sstevel@tonic-gate 	(((tt) <= INT32_MAX) &&	((tt) >= INT32_MIN))
2950Sstevel@tonic-gate 
2960Sstevel@tonic-gate #define	NFS3_TIME_OVERFLOW(tt)	((tt) > INT32_MAX)
2970Sstevel@tonic-gate #define	NFS2_TIME_OVERFLOW(tt)	((tt) > INT32_MAX)
2980Sstevel@tonic-gate 
2990Sstevel@tonic-gate /*
3000Sstevel@tonic-gate  * check if a time_t (int32_t) is ok when preepoch times are allowed -
3010Sstevel@tonic-gate  * every 32-bit value is accepted
3020Sstevel@tonic-gate  */
3030Sstevel@tonic-gate #define	NFS_PREEPOCH_TIME_T_OK(tt)	TRUE
3040Sstevel@tonic-gate 
3050Sstevel@tonic-gate /*
3060Sstevel@tonic-gate  * check if a time_t (int32_t) is ok when preepoch times are not allowed -
3070Sstevel@tonic-gate  * only positive values are accepted.
3080Sstevel@tonic-gate  */
3090Sstevel@tonic-gate #define	NFS_NO_PREEPOCH_TIME_T_OK(tt)	((tt) >= 0)
3100Sstevel@tonic-gate 
3110Sstevel@tonic-gate #endif /* _LP64 */
3120Sstevel@tonic-gate 
3130Sstevel@tonic-gate /* Check if an nfstime3 (uint32_t) can be stored in the system time */
3140Sstevel@tonic-gate #define	NFS3_TIME_OK(tt)						\
3150Sstevel@tonic-gate 	(nfs_allow_preepoch_time || (!NFS3_TIME_OVERFLOW(tt)))
3160Sstevel@tonic-gate 
3170Sstevel@tonic-gate /* Check if an nfs2_timeval (uint32_t) can be stored in the system time. */
3180Sstevel@tonic-gate #define	NFS2_TIME_OK(tt)						\
3190Sstevel@tonic-gate 	(nfs_allow_preepoch_time || (!NFS2_TIME_OVERFLOW(tt)))
3200Sstevel@tonic-gate 
3210Sstevel@tonic-gate /*
3220Sstevel@tonic-gate  * Test if time_t (signed long) can be sent over the wire - for v2/3 only if:
3230Sstevel@tonic-gate  * 1. The time value can fit in a uint32_t; and
3240Sstevel@tonic-gate  * 2. Either the time value is positive or allow preepoch times.
3250Sstevel@tonic-gate  * No restrictions for nfsv4.
3260Sstevel@tonic-gate  */
3270Sstevel@tonic-gate #define	NFS_TIME_T_OK(tt)						\
3280Sstevel@tonic-gate 	(nfs_allow_preepoch_time ?					\
3290Sstevel@tonic-gate 		NFS_PREEPOCH_TIME_T_OK(tt) : NFS_NO_PREEPOCH_TIME_T_OK(tt))
3300Sstevel@tonic-gate 
3310Sstevel@tonic-gate #define	NFS4_TIME_T_OK(tt)		TRUE
3320Sstevel@tonic-gate 
3330Sstevel@tonic-gate /* Test if all attr times are valid */
3340Sstevel@tonic-gate #define	NFS_VAP_TIME_OK(vap)						\
3350Sstevel@tonic-gate 	(nfs_allow_preepoch_time ?					\
3360Sstevel@tonic-gate 		(NFS_PREEPOCH_TIME_T_OK((vap)->va_atime.tv_sec) &&	\
3370Sstevel@tonic-gate 		NFS_PREEPOCH_TIME_T_OK((vap)->va_mtime.tv_sec) &&	\
3380Sstevel@tonic-gate 		NFS_PREEPOCH_TIME_T_OK((vap)->va_ctime.tv_sec)) :	\
3390Sstevel@tonic-gate 		(NFS_NO_PREEPOCH_TIME_T_OK((vap)->va_atime.tv_sec) &&	\
3400Sstevel@tonic-gate 		NFS_NO_PREEPOCH_TIME_T_OK((vap)->va_mtime.tv_sec) &&	\
3410Sstevel@tonic-gate 		NFS_NO_PREEPOCH_TIME_T_OK((vap)->va_ctime.tv_sec)))
3420Sstevel@tonic-gate 
3430Sstevel@tonic-gate #define	NFS4_VAP_TIME_OK(vap)			TRUE
3440Sstevel@tonic-gate 
3450Sstevel@tonic-gate /*
3460Sstevel@tonic-gate  * To extend the sign or not extend the sign, that is the question.
3470Sstevel@tonic-gate  * Note: The correct way is to code a macro:
3480Sstevel@tonic-gate  * #define	NFS_TIME_T_CONVERT(tt)					\
3490Sstevel@tonic-gate  *	(nfs_allow_preepoch_time ? (int32_t)(tt) : (uint32_t)(tt))
3500Sstevel@tonic-gate  * But the 64-bit compiler does not extend the sign in that case (why?)
3510Sstevel@tonic-gate  * so we'll do it the ugly way...
3520Sstevel@tonic-gate  */
3530Sstevel@tonic-gate #define	NFS_TIME_T_CONVERT(systt, tt)		\
3540Sstevel@tonic-gate 	if (nfs_allow_preepoch_time) {		\
3550Sstevel@tonic-gate 		systt = (int32_t)(tt);		\
3560Sstevel@tonic-gate 	} else {				\
3570Sstevel@tonic-gate 		systt = (uint32_t)(tt);		\
3580Sstevel@tonic-gate 	}
3590Sstevel@tonic-gate 
3600Sstevel@tonic-gate /* macro to check for overflowed time attribute fields - version 3 */
3610Sstevel@tonic-gate #define	NFS3_FATTR_TIME_OK(attrs)			\
3620Sstevel@tonic-gate 	(NFS3_TIME_OK((attrs)->atime.seconds) &&	\
3630Sstevel@tonic-gate 	NFS3_TIME_OK((attrs)->mtime.seconds) &&		\
3640Sstevel@tonic-gate 	NFS3_TIME_OK((attrs)->ctime.seconds))
3650Sstevel@tonic-gate 
3660Sstevel@tonic-gate /* macro to check for overflowed time attribute fields - version 2 */
3670Sstevel@tonic-gate #define	NFS2_FATTR_TIME_OK(attrs)			\
3680Sstevel@tonic-gate 	(NFS2_TIME_OK((attrs)->na_atime.tv_sec) &&	\
3690Sstevel@tonic-gate 	NFS2_TIME_OK((attrs)->na_mtime.tv_sec) &&	\
3700Sstevel@tonic-gate 	NFS2_TIME_OK((attrs)->na_ctime.tv_sec))
3710Sstevel@tonic-gate 
3720Sstevel@tonic-gate /* Check that a size3 value is not overflowed */
3730Sstevel@tonic-gate #define	NFS3_SIZE_OK(size)	((size) <= MAXOFFSET_T)
3740Sstevel@tonic-gate 
3750Sstevel@tonic-gate #endif /* _KERNEL */
3760Sstevel@tonic-gate 
3770Sstevel@tonic-gate /*
3780Sstevel@tonic-gate  * Size of an fhandle in bytes
3790Sstevel@tonic-gate  */
3800Sstevel@tonic-gate #define	NFS_FHSIZE	32
3810Sstevel@tonic-gate 
3820Sstevel@tonic-gate struct nfs_fid {
3830Sstevel@tonic-gate 	ushort_t nf_len;
3840Sstevel@tonic-gate 	ushort_t nf_pad;
3850Sstevel@tonic-gate 	char	nf_data[NFS_FHSIZE];
3860Sstevel@tonic-gate };
3870Sstevel@tonic-gate 
3880Sstevel@tonic-gate /*
389806Sek110237  * "Legacy" filehandles use NFS_FHMAXDATA (10) byte fids. Filesystems that
390806Sek110237  * return a larger fid than NFS_FHMAXDATA, such as ZFS's .zfs snapshot
3911610Sthurlow  * directory, can use up to (((64 - 8) / 2) - 2) bytes for their fid.
3921610Sthurlow  * This currently holds for both NFSv3 and NFSv4.
3930Sstevel@tonic-gate  */
394806Sek110237 #define	NFS_FHMAXDATA		10
3951610Sthurlow #define	NFS_FH3MAXDATA		26
3961610Sthurlow #define	NFS_FH4MAXDATA		26
3970Sstevel@tonic-gate 
3980Sstevel@tonic-gate /*
3991610Sthurlow  * The original nfs file handle size for version 3 was 32 which was
4001610Sthurlow  * the same in version 2; now we're making it bigger to to deal with
4011610Sthurlow  * ZFS snapshot FIDs.
4021610Sthurlow  *
4031610Sthurlow  * If the size of fhandle3_t changes or if Version 3 uses some other
4040Sstevel@tonic-gate  * filehandle format, this constant may need to change.
4050Sstevel@tonic-gate  */
4060Sstevel@tonic-gate 
4071610Sthurlow #define	NFS3_OLDFHSIZE	32
4081610Sthurlow #define	NFS3_MAXFHSIZE	64
4090Sstevel@tonic-gate 
4100Sstevel@tonic-gate /*
411806Sek110237  * This is the actual definition of a legacy filehandle.  There is some
412806Sek110237  * dependence on this layout in NFS-related code, particularly in the
413806Sek110237  * user-level lock manager, so be careful about changing it.
414806Sek110237  *
4151610Sthurlow  * Currently only NFSv2 uses this structure.
4160Sstevel@tonic-gate  */
4170Sstevel@tonic-gate 
4181610Sthurlow typedef struct svcfh {
4190Sstevel@tonic-gate 	fsid_t	fh_fsid;			/* filesystem id */
4200Sstevel@tonic-gate 	ushort_t fh_len;			/* file number length */
4210Sstevel@tonic-gate 	char	fh_data[NFS_FHMAXDATA];		/* and data */
4220Sstevel@tonic-gate 	ushort_t fh_xlen;			/* export file number length */
4230Sstevel@tonic-gate 	char	fh_xdata[NFS_FHMAXDATA];	/* and data */
4241610Sthurlow } fhandle_t;
4250Sstevel@tonic-gate 
4260Sstevel@tonic-gate /*
4271610Sthurlow  * This is the in-memory structure for an NFSv3 extended filehandle.
428806Sek110237  */
4291610Sthurlow typedef struct {
4301610Sthurlow 	fsid_t	_fh3_fsid;			/* filesystem id */
4311610Sthurlow 	ushort_t _fh3_len;			/* file number length */
4321610Sthurlow 	char	_fh3_data[NFS_FH3MAXDATA];		/* and data */
4331610Sthurlow 	ushort_t _fh3_xlen;			/* export file number length */
4341610Sthurlow 	char	_fh3_xdata[NFS_FH3MAXDATA];	/* and data */
4351610Sthurlow } fhandle3_t;
4361610Sthurlow 
4371610Sthurlow /*
4381610Sthurlow  * This is the in-memory structure for an NFSv4 extended filehandle.
4391610Sthurlow  */
4401610Sthurlow typedef struct {
441806Sek110237 	fsid_t	fhx_fsid;			/* filesystem id */
442806Sek110237 	ushort_t fhx_len;			/* file number length */
4431610Sthurlow 	char	fhx_data[NFS_FH4MAXDATA];	/* and data */
444806Sek110237 	ushort_t fhx_xlen;			/* export file number length */
4451610Sthurlow 	char	fhx_xdata[NFS_FH4MAXDATA];	/* and data */
4461610Sthurlow } fhandle4_t;
447806Sek110237 
448806Sek110237 /*
4490Sstevel@tonic-gate  * Arguments to remote write and writecache
4500Sstevel@tonic-gate  */
4510Sstevel@tonic-gate /*
4520Sstevel@tonic-gate  * The `over the wire' representation of the first four arguments.
4530Sstevel@tonic-gate  */
4540Sstevel@tonic-gate struct otw_nfswriteargs {
4550Sstevel@tonic-gate 	fhandle_t	otw_wa_fhandle;
4560Sstevel@tonic-gate 	uint32_t	otw_wa_begoff;
4570Sstevel@tonic-gate 	uint32_t	otw_wa_offset;
4580Sstevel@tonic-gate 	uint32_t	otw_wa_totcount;
4590Sstevel@tonic-gate };
4600Sstevel@tonic-gate 
4610Sstevel@tonic-gate struct nfswriteargs {
4620Sstevel@tonic-gate 	struct otw_nfswriteargs *wa_args;	/* ptr to the otw arguments */
4630Sstevel@tonic-gate 	struct otw_nfswriteargs wa_args_buf;	/* space for otw arguments */
4640Sstevel@tonic-gate 	uint32_t	wa_count;
4650Sstevel@tonic-gate 	char		*wa_data;	/* data to write (up to NFS_MAXDATA) */
4660Sstevel@tonic-gate 	mblk_t		*wa_mblk;	/* pointer to mblks containing data */
4677387SRobert.Gordon@Sun.COM #ifdef _KERNEL
4687387SRobert.Gordon@Sun.COM 	/* rdma related info */
4697387SRobert.Gordon@Sun.COM 	struct clist	*wa_rlist;
4707387SRobert.Gordon@Sun.COM 	CONN		*wa_conn;
4717387SRobert.Gordon@Sun.COM #endif /* _KERNEL */
4720Sstevel@tonic-gate };
4730Sstevel@tonic-gate #define	wa_fhandle	wa_args->otw_wa_fhandle
4740Sstevel@tonic-gate #define	wa_begoff	wa_args->otw_wa_begoff
4750Sstevel@tonic-gate #define	wa_offset	wa_args->otw_wa_offset
4760Sstevel@tonic-gate #define	wa_totcount	wa_args->otw_wa_totcount
4770Sstevel@tonic-gate 
4780Sstevel@tonic-gate /*
4790Sstevel@tonic-gate  * NFS timeval struct using unsigned int as specified in V2 protocol.
4800Sstevel@tonic-gate  * tv_sec and tv_usec used to match existing code.
4810Sstevel@tonic-gate  */
4820Sstevel@tonic-gate struct nfs2_timeval {
4830Sstevel@tonic-gate 	uint32_t tv_sec;
4840Sstevel@tonic-gate 	uint32_t tv_usec;
4850Sstevel@tonic-gate };
4860Sstevel@tonic-gate typedef struct nfs2_timeval nfs2_timeval;
4870Sstevel@tonic-gate 
4880Sstevel@tonic-gate /*
4890Sstevel@tonic-gate  * File attributes
4900Sstevel@tonic-gate  */
4910Sstevel@tonic-gate struct nfsfattr {
4920Sstevel@tonic-gate 	enum nfsftype	na_type;	/* file type */
4930Sstevel@tonic-gate 	uint32_t	na_mode;	/* protection mode bits */
4940Sstevel@tonic-gate 	uint32_t	na_nlink;	/* # hard links */
4950Sstevel@tonic-gate 	uint32_t	na_uid;		/* owner user id */
4960Sstevel@tonic-gate 	uint32_t	na_gid;		/* owner group id */
4970Sstevel@tonic-gate 	uint32_t	na_size;	/* file size in bytes */
4985331Samw 	uint32_t	na_blocksize;	/* preferred block size */
4990Sstevel@tonic-gate 	uint32_t	na_rdev;	/* special device # */
5000Sstevel@tonic-gate 	uint32_t	na_blocks;	/* Kb of disk used by file */
5010Sstevel@tonic-gate 	uint32_t	na_fsid;	/* device # */
5020Sstevel@tonic-gate 	uint32_t	na_nodeid;	/* inode # */
5030Sstevel@tonic-gate 	struct nfs2_timeval na_atime;	/* time of last access */
5040Sstevel@tonic-gate 	struct nfs2_timeval na_mtime;	/* time of last modification */
5050Sstevel@tonic-gate 	struct nfs2_timeval na_ctime;	/* time of last change */
5060Sstevel@tonic-gate };
5070Sstevel@tonic-gate 
5080Sstevel@tonic-gate #define	n2v_type(x)	(NA_ISFIFO(x) ? VFIFO : nf_to_vt[(x)->na_type])
5090Sstevel@tonic-gate #define	n2v_rdev(x)	(NA_ISFIFO(x) ? 0 : (x)->na_rdev)
5100Sstevel@tonic-gate 
5110Sstevel@tonic-gate /*
5120Sstevel@tonic-gate  * Arguments to remote read
5130Sstevel@tonic-gate  */
5140Sstevel@tonic-gate struct nfsreadargs {
5150Sstevel@tonic-gate 	fhandle_t	ra_fhandle;	/* handle for file */
5160Sstevel@tonic-gate 	uint32_t	ra_offset;	/* byte offset in file */
5170Sstevel@tonic-gate 	uint32_t	ra_count;	/* immediate read count */
5180Sstevel@tonic-gate 	uint32_t	ra_totcount;	/* total read cnt (from this offset) */
5197387SRobert.Gordon@Sun.COM #ifdef _KERNEL
5207387SRobert.Gordon@Sun.COM 	/* used in rdma transports */
5217387SRobert.Gordon@Sun.COM 	caddr_t		ra_data;	/* destination for read data */
5227387SRobert.Gordon@Sun.COM 	struct clist	*ra_wlist;
5237387SRobert.Gordon@Sun.COM 	CONN		*ra_conn;
5247387SRobert.Gordon@Sun.COM #endif
5250Sstevel@tonic-gate };
5260Sstevel@tonic-gate 
5270Sstevel@tonic-gate /*
5280Sstevel@tonic-gate  * Status OK portion of remote read reply
5290Sstevel@tonic-gate  */
5300Sstevel@tonic-gate struct nfsrrok {
5310Sstevel@tonic-gate 	struct nfsfattr	rrok_attr;	/* attributes, need for pagin */
5320Sstevel@tonic-gate 	uint32_t	rrok_count;	/* bytes of data */
5330Sstevel@tonic-gate 	char		*rrok_data;	/* data (up to NFS_MAXDATA bytes) */
5340Sstevel@tonic-gate 	uint_t		rrok_bufsize;	/* size of kmem_alloc'd buffer */
5350Sstevel@tonic-gate 	mblk_t		*rrok_mp;	/* mblk_t contains data for reply */
5367387SRobert.Gordon@Sun.COM #ifdef _KERNEL
5377387SRobert.Gordon@Sun.COM 	uint_t		rrok_wlist_len;
5387387SRobert.Gordon@Sun.COM 	struct clist    *rrok_wlist;
5397387SRobert.Gordon@Sun.COM #endif
5400Sstevel@tonic-gate };
5410Sstevel@tonic-gate 
5420Sstevel@tonic-gate /*
5430Sstevel@tonic-gate  * Reply from remote read
5440Sstevel@tonic-gate  */
5450Sstevel@tonic-gate struct nfsrdresult {
5460Sstevel@tonic-gate 	nfsstat	rr_status;			/* status of read */
5470Sstevel@tonic-gate 	union {
5480Sstevel@tonic-gate 		struct nfsrrok	rr_ok_u;	/* attributes, need for pagin */
5490Sstevel@tonic-gate 	} rr_u;
5500Sstevel@tonic-gate };
5510Sstevel@tonic-gate #define	rr_ok		rr_u.rr_ok_u
5520Sstevel@tonic-gate #define	rr_attr		rr_u.rr_ok_u.rrok_attr
5530Sstevel@tonic-gate #define	rr_count	rr_u.rr_ok_u.rrok_count
5540Sstevel@tonic-gate #define	rr_bufsize	rr_u.rr_ok_u.rrok_bufsize
5550Sstevel@tonic-gate #define	rr_data		rr_u.rr_ok_u.rrok_data
5560Sstevel@tonic-gate #define	rr_mp		rr_u.rr_ok_u.rrok_mp
5570Sstevel@tonic-gate 
5580Sstevel@tonic-gate /*
5590Sstevel@tonic-gate  * File attributes which can be set
5600Sstevel@tonic-gate  */
5610Sstevel@tonic-gate struct nfssattr {
5620Sstevel@tonic-gate 	uint32_t	sa_mode;	/* protection mode bits */
5630Sstevel@tonic-gate 	uint32_t	sa_uid;		/* owner user id */
5640Sstevel@tonic-gate 	uint32_t	sa_gid;		/* owner group id */
5650Sstevel@tonic-gate 	uint32_t	sa_size;	/* file size in bytes */
5660Sstevel@tonic-gate 	struct nfs2_timeval sa_atime;	/* time of last access */
5670Sstevel@tonic-gate 	struct nfs2_timeval sa_mtime;	/* time of last modification */
5680Sstevel@tonic-gate };
5690Sstevel@tonic-gate 
5700Sstevel@tonic-gate 
5710Sstevel@tonic-gate /*
5720Sstevel@tonic-gate  * Reply status with file attributes
5730Sstevel@tonic-gate  */
5740Sstevel@tonic-gate struct nfsattrstat {
5750Sstevel@tonic-gate 	nfsstat	ns_status;			/* reply status */
5760Sstevel@tonic-gate 	union {
5770Sstevel@tonic-gate 		struct nfsfattr ns_attr_u;	/* NFS_OK: file attributes */
5780Sstevel@tonic-gate 	} ns_u;
5790Sstevel@tonic-gate };
5800Sstevel@tonic-gate #define	ns_attr	ns_u.ns_attr_u
5810Sstevel@tonic-gate 
5820Sstevel@tonic-gate 
5830Sstevel@tonic-gate /*
5840Sstevel@tonic-gate  * NFS_OK part of read sym link reply union
5850Sstevel@tonic-gate  */
5860Sstevel@tonic-gate struct nfssrok {
5870Sstevel@tonic-gate 	uint32_t srok_count;	/* size of string */
5880Sstevel@tonic-gate 	char	*srok_data;	/* string (up to NFS_MAXPATHLEN bytes) */
5890Sstevel@tonic-gate };
5900Sstevel@tonic-gate 
5910Sstevel@tonic-gate /*
5920Sstevel@tonic-gate  * Result of reading symbolic link
5930Sstevel@tonic-gate  */
5940Sstevel@tonic-gate struct nfsrdlnres {
5950Sstevel@tonic-gate 	nfsstat	rl_status;			/* status of symlink read */
5960Sstevel@tonic-gate 	union {
5970Sstevel@tonic-gate 		struct nfssrok	rl_srok_u;	/* name of linked to */
5980Sstevel@tonic-gate 	} rl_u;
5990Sstevel@tonic-gate };
6000Sstevel@tonic-gate #define	rl_srok		rl_u.rl_srok_u
6010Sstevel@tonic-gate #define	rl_count	rl_u.rl_srok_u.srok_count
6020Sstevel@tonic-gate #define	rl_data		rl_u.rl_srok_u.srok_data
6030Sstevel@tonic-gate 
6040Sstevel@tonic-gate 
6050Sstevel@tonic-gate /*
6060Sstevel@tonic-gate  * Arguments to readdir
6070Sstevel@tonic-gate  */
6080Sstevel@tonic-gate struct nfsrddirargs {
6090Sstevel@tonic-gate 	fhandle_t rda_fh;	/* directory handle */
6100Sstevel@tonic-gate 	uint32_t rda_offset;	/* offset in directory (opaque) */
6110Sstevel@tonic-gate 	uint32_t rda_count;	/* number of directory bytes to read */
6120Sstevel@tonic-gate };
6130Sstevel@tonic-gate 
6140Sstevel@tonic-gate /*
6150Sstevel@tonic-gate  * NFS_OK part of readdir result
6160Sstevel@tonic-gate  */
6170Sstevel@tonic-gate struct nfsrdok {
6180Sstevel@tonic-gate 	uint32_t rdok_offset;		/* next offset (opaque) */
6190Sstevel@tonic-gate 	uint32_t rdok_size;		/* size in bytes of entries */
6200Sstevel@tonic-gate 	bool_t	rdok_eof;		/* true if last entry is in result */
6210Sstevel@tonic-gate 	struct dirent64 *rdok_entries;	/* variable number of entries */
6220Sstevel@tonic-gate };
6230Sstevel@tonic-gate 
6240Sstevel@tonic-gate /*
6250Sstevel@tonic-gate  * Readdir result
6260Sstevel@tonic-gate  */
6270Sstevel@tonic-gate struct nfsrddirres {
6280Sstevel@tonic-gate 	nfsstat	rd_status;
6290Sstevel@tonic-gate 	uint_t		rd_bufsize;	/* client request size (not xdr'ed) */
6300Sstevel@tonic-gate 	union {
6310Sstevel@tonic-gate 		struct nfsrdok rd_rdok_u;
6320Sstevel@tonic-gate 	} rd_u;
6330Sstevel@tonic-gate };
6340Sstevel@tonic-gate #define	rd_rdok		rd_u.rd_rdok_u
6350Sstevel@tonic-gate #define	rd_offset	rd_u.rd_rdok_u.rdok_offset
6360Sstevel@tonic-gate #define	rd_size		rd_u.rd_rdok_u.rdok_size
6370Sstevel@tonic-gate #define	rd_eof		rd_u.rd_rdok_u.rdok_eof
6380Sstevel@tonic-gate #define	rd_entries	rd_u.rd_rdok_u.rdok_entries
6390Sstevel@tonic-gate 
6400Sstevel@tonic-gate 
6410Sstevel@tonic-gate /*
6420Sstevel@tonic-gate  * Arguments for directory operations
6430Sstevel@tonic-gate  */
6440Sstevel@tonic-gate struct nfsdiropargs {
6450Sstevel@tonic-gate 	fhandle_t	*da_fhandle;	/* pointer to directory file handle */
6460Sstevel@tonic-gate 	char		*da_name;	/* name (up to NFS_MAXNAMLEN bytes) */
6470Sstevel@tonic-gate 	fhandle_t	da_fhandle_buf;	/* directory file handle */
6480Sstevel@tonic-gate 	int		da_flags;	/* flags, see below */
6490Sstevel@tonic-gate };
6500Sstevel@tonic-gate #define	DA_FREENAME	1
6510Sstevel@tonic-gate 
6520Sstevel@tonic-gate /*
6530Sstevel@tonic-gate  * NFS_OK part of directory operation result
6540Sstevel@tonic-gate  */
6550Sstevel@tonic-gate struct  nfsdrok {
6560Sstevel@tonic-gate 	fhandle_t	drok_fhandle;	/* result file handle */
6570Sstevel@tonic-gate 	struct nfsfattr	drok_attr;	/* result file attributes */
6580Sstevel@tonic-gate };
6590Sstevel@tonic-gate 
6600Sstevel@tonic-gate /*
6610Sstevel@tonic-gate  * Results from directory operation
6620Sstevel@tonic-gate  */
6630Sstevel@tonic-gate struct  nfsdiropres {
6640Sstevel@tonic-gate 	nfsstat	dr_status;			/* result status */
6650Sstevel@tonic-gate 	union {
6660Sstevel@tonic-gate 		struct  nfsdrok	dr_drok_u;	/* NFS_OK result */
6670Sstevel@tonic-gate 	} dr_u;
6680Sstevel@tonic-gate };
6690Sstevel@tonic-gate #define	dr_drok		dr_u.dr_drok_u
6700Sstevel@tonic-gate #define	dr_fhandle	dr_u.dr_drok_u.drok_fhandle
6710Sstevel@tonic-gate #define	dr_attr		dr_u.dr_drok_u.drok_attr
6720Sstevel@tonic-gate 
6730Sstevel@tonic-gate /*
6740Sstevel@tonic-gate  * arguments to setattr
6750Sstevel@tonic-gate  */
6760Sstevel@tonic-gate struct nfssaargs {
6770Sstevel@tonic-gate 	fhandle_t	saa_fh;		/* fhandle of file to be set */
6780Sstevel@tonic-gate 	struct nfssattr	saa_sa;		/* new attributes */
6790Sstevel@tonic-gate };
6800Sstevel@tonic-gate 
6810Sstevel@tonic-gate /*
6820Sstevel@tonic-gate  * arguments to create and mkdir
6830Sstevel@tonic-gate  */
6840Sstevel@tonic-gate struct nfscreatargs {
6850Sstevel@tonic-gate 	struct nfsdiropargs	ca_da;	/* file name to create and parent dir */
6860Sstevel@tonic-gate 	struct nfssattr		*ca_sa;	/* initial attributes */
6870Sstevel@tonic-gate 	struct nfssattr		ca_sa_buf;	/* space to store attributes */
6880Sstevel@tonic-gate };
6890Sstevel@tonic-gate 
6900Sstevel@tonic-gate /*
6910Sstevel@tonic-gate  * arguments to link
6920Sstevel@tonic-gate  */
6930Sstevel@tonic-gate struct nfslinkargs {
6940Sstevel@tonic-gate 	fhandle_t		*la_from;	/* old file */
6950Sstevel@tonic-gate 	fhandle_t		la_from_buf;	/* old file */
6960Sstevel@tonic-gate 	struct nfsdiropargs	la_to;		/* new file and parent dir */
6970Sstevel@tonic-gate };
6980Sstevel@tonic-gate 
6990Sstevel@tonic-gate /*
7000Sstevel@tonic-gate  * arguments to rename
7010Sstevel@tonic-gate  */
7020Sstevel@tonic-gate struct nfsrnmargs {
7030Sstevel@tonic-gate 	struct nfsdiropargs rna_from;	/* old file and parent dir */
7040Sstevel@tonic-gate 	struct nfsdiropargs rna_to;	/* new file and parent dir */
7050Sstevel@tonic-gate };
7060Sstevel@tonic-gate 
7070Sstevel@tonic-gate /*
7080Sstevel@tonic-gate  * arguments to symlink
7090Sstevel@tonic-gate  */
7100Sstevel@tonic-gate struct nfsslargs {
7110Sstevel@tonic-gate 	struct nfsdiropargs	sla_from;	/* old file and parent dir */
7120Sstevel@tonic-gate 	char			*sla_tnm;	/* new name */
7130Sstevel@tonic-gate 	int			sla_tnm_flags;	/* flags for name */
7140Sstevel@tonic-gate 	struct nfssattr		*sla_sa;	/* attributes */
7150Sstevel@tonic-gate 	struct nfssattr		sla_sa_buf;	/* attributes buffer */
7160Sstevel@tonic-gate };
7170Sstevel@tonic-gate #define	SLA_FREETNM	1
7180Sstevel@tonic-gate 
7190Sstevel@tonic-gate /*
7200Sstevel@tonic-gate  * NFS_OK part of statfs operation
7210Sstevel@tonic-gate  */
7220Sstevel@tonic-gate struct nfsstatfsok {
7230Sstevel@tonic-gate 	uint32_t fsok_tsize;	/* preferred transfer size in bytes */
7240Sstevel@tonic-gate 	uint32_t fsok_bsize;	/* fundamental file system block size */
7250Sstevel@tonic-gate 	uint32_t fsok_blocks;	/* total blocks in file system */
7260Sstevel@tonic-gate 	uint32_t fsok_bfree;	/* free blocks in fs */
7270Sstevel@tonic-gate 	uint32_t fsok_bavail;	/* free blocks avail to non-superuser */
7280Sstevel@tonic-gate };
7290Sstevel@tonic-gate 
7300Sstevel@tonic-gate /*
7310Sstevel@tonic-gate  * Results of statfs operation
7320Sstevel@tonic-gate  */
7330Sstevel@tonic-gate struct nfsstatfs {
7340Sstevel@tonic-gate 	nfsstat	fs_status;			/* result status */
7350Sstevel@tonic-gate 	union {
7360Sstevel@tonic-gate 		struct	nfsstatfsok fs_fsok_u;	/* NFS_OK result */
7370Sstevel@tonic-gate 	} fs_u;
7380Sstevel@tonic-gate };
7390Sstevel@tonic-gate #define	fs_fsok		fs_u.fs_fsok_u
7400Sstevel@tonic-gate #define	fs_tsize	fs_u.fs_fsok_u.fsok_tsize
7410Sstevel@tonic-gate #define	fs_bsize	fs_u.fs_fsok_u.fsok_bsize
7420Sstevel@tonic-gate #define	fs_blocks	fs_u.fs_fsok_u.fsok_blocks
7430Sstevel@tonic-gate #define	fs_bfree	fs_u.fs_fsok_u.fsok_bfree
7440Sstevel@tonic-gate #define	fs_bavail	fs_u.fs_fsok_u.fsok_bavail
7450Sstevel@tonic-gate 
7460Sstevel@tonic-gate #ifdef _KERNEL
7470Sstevel@tonic-gate /*
7480Sstevel@tonic-gate  * XDR routines for handling structures defined above
7490Sstevel@tonic-gate  */
7500Sstevel@tonic-gate extern bool_t	xdr_attrstat(XDR *, struct nfsattrstat *);
7510Sstevel@tonic-gate extern bool_t	xdr_fastattrstat(XDR *, struct nfsattrstat *);
7520Sstevel@tonic-gate extern bool_t	xdr_creatargs(XDR *, struct nfscreatargs *);
7530Sstevel@tonic-gate extern bool_t	xdr_diropargs(XDR *, struct nfsdiropargs *);
7540Sstevel@tonic-gate extern bool_t	xdr_diropres(XDR *, struct nfsdiropres *);
7550Sstevel@tonic-gate extern bool_t	xdr_fastdiropres(XDR *, struct nfsdiropres *);
7560Sstevel@tonic-gate extern bool_t	xdr_drok(XDR *, struct nfsdrok *);
7570Sstevel@tonic-gate #ifdef _LITTLE_ENDIAN
7580Sstevel@tonic-gate extern bool_t	xdr_fastdrok(XDR *, struct nfsdrok *);
7590Sstevel@tonic-gate extern bool_t	xdr_fastfattr(XDR *, struct nfsfattr *);
7600Sstevel@tonic-gate #endif
7610Sstevel@tonic-gate extern bool_t	xdr_fattr(XDR *, struct nfsfattr *);
7620Sstevel@tonic-gate extern bool_t	xdr_fhandle(XDR *, fhandle_t *);
7630Sstevel@tonic-gate extern bool_t	xdr_fastfhandle(XDR *, fhandle_t **);
7640Sstevel@tonic-gate extern bool_t	xdr_linkargs(XDR *, struct nfslinkargs *);
7650Sstevel@tonic-gate extern bool_t	xdr_rddirargs(XDR *, struct nfsrddirargs *);
7660Sstevel@tonic-gate extern bool_t	xdr_putrddirres(XDR *, struct nfsrddirres *);
7670Sstevel@tonic-gate extern bool_t	xdr_getrddirres(XDR *, struct nfsrddirres *);
7680Sstevel@tonic-gate extern bool_t	xdr_rdlnres(XDR *, struct nfsrdlnres *);
7690Sstevel@tonic-gate extern bool_t	xdr_rdresult(XDR *, struct nfsrdresult *);
7700Sstevel@tonic-gate extern bool_t	xdr_readargs(XDR *, struct nfsreadargs *);
7717387SRobert.Gordon@Sun.COM extern bool_t	xdr_readlink(XDR *, fhandle_t *);
7720Sstevel@tonic-gate extern bool_t	xdr_rnmargs(XDR *, struct nfsrnmargs *);
7730Sstevel@tonic-gate extern bool_t	xdr_rrok(XDR *, struct nfsrrok *);
7740Sstevel@tonic-gate extern bool_t	xdr_saargs(XDR *, struct nfssaargs *);
7750Sstevel@tonic-gate extern bool_t	xdr_sattr(XDR *, struct nfssattr *);
7760Sstevel@tonic-gate extern bool_t	xdr_slargs(XDR *, struct nfsslargs *);
7770Sstevel@tonic-gate extern bool_t	xdr_srok(XDR *, struct nfssrok *);
7780Sstevel@tonic-gate extern bool_t	xdr_nfs2_timeval(XDR *, struct nfs2_timeval *);
7790Sstevel@tonic-gate extern bool_t	xdr_writeargs(XDR *, struct nfswriteargs *);
7800Sstevel@tonic-gate extern bool_t	xdr_fsok(XDR *, struct nfsstatfsok *);
7810Sstevel@tonic-gate #ifdef _LITTLE_ENDIAN
7820Sstevel@tonic-gate extern bool_t	xdr_fastfsok(XDR *, struct nfsstatfsok *);
7830Sstevel@tonic-gate extern bool_t	xdr_fastenum(XDR *, enum_t *);
7840Sstevel@tonic-gate #endif
7850Sstevel@tonic-gate extern bool_t	xdr_statfs(XDR *, struct nfsstatfs *);
7860Sstevel@tonic-gate extern bool_t	xdr_faststatfs(XDR *, struct nfsstatfs *);
7870Sstevel@tonic-gate #endif
7880Sstevel@tonic-gate 
7890Sstevel@tonic-gate /*
7900Sstevel@tonic-gate  * Remote file service routines
7910Sstevel@tonic-gate  */
7920Sstevel@tonic-gate #define	RFS_NULL	0
7930Sstevel@tonic-gate #define	RFS_GETATTR	1
7940Sstevel@tonic-gate #define	RFS_SETATTR	2
7950Sstevel@tonic-gate #define	RFS_ROOT	3
7960Sstevel@tonic-gate #define	RFS_LOOKUP	4
7970Sstevel@tonic-gate #define	RFS_READLINK	5
7980Sstevel@tonic-gate #define	RFS_READ	6
7990Sstevel@tonic-gate #define	RFS_WRITECACHE	7
8000Sstevel@tonic-gate #define	RFS_WRITE	8
8010Sstevel@tonic-gate #define	RFS_CREATE	9
8020Sstevel@tonic-gate #define	RFS_REMOVE	10
8030Sstevel@tonic-gate #define	RFS_RENAME	11
8040Sstevel@tonic-gate #define	RFS_LINK	12
8050Sstevel@tonic-gate #define	RFS_SYMLINK	13
8060Sstevel@tonic-gate #define	RFS_MKDIR	14
8070Sstevel@tonic-gate #define	RFS_RMDIR	15
8080Sstevel@tonic-gate #define	RFS_READDIR	16
8090Sstevel@tonic-gate #define	RFS_STATFS	17
8100Sstevel@tonic-gate #define	RFS_NPROC	18
8110Sstevel@tonic-gate 
8120Sstevel@tonic-gate #ifdef _KERNEL
8130Sstevel@tonic-gate /*
8140Sstevel@tonic-gate  * The NFS Version 2 service procedures
8150Sstevel@tonic-gate  */
8160Sstevel@tonic-gate struct exportinfo;	/* defined in nfs/export.h */
8170Sstevel@tonic-gate struct servinfo;	/* defined in nfs/nfs_clnt.h */
8180Sstevel@tonic-gate struct mntinfo;		/* defined in nfs/nfs_clnt.h */
8190Sstevel@tonic-gate 
8200Sstevel@tonic-gate extern void rfs_getattr(fhandle_t *, struct nfsattrstat *,
8210Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
8221610Sthurlow extern void *rfs_getattr_getfh(fhandle_t *);
8230Sstevel@tonic-gate extern void rfs_setattr(struct nfssaargs *, struct nfsattrstat *,
8240Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
8251610Sthurlow extern void *rfs_setattr_getfh(struct nfssaargs *);
8260Sstevel@tonic-gate extern void rfs_lookup(struct nfsdiropargs *, struct nfsdiropres *,
8270Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
8281610Sthurlow extern void *rfs_lookup_getfh(struct nfsdiropargs *);
8290Sstevel@tonic-gate extern void rfs_readlink(fhandle_t *, struct nfsrdlnres *,
8300Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
8311610Sthurlow extern void *rfs_readlink_getfh(fhandle_t *);
8320Sstevel@tonic-gate extern void rfs_rlfree(struct nfsrdlnres *);
8330Sstevel@tonic-gate extern void rfs_read(struct nfsreadargs *, struct nfsrdresult *,
8340Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
8351610Sthurlow extern void *rfs_read_getfh(struct nfsreadargs *);
8360Sstevel@tonic-gate extern void rfs_rdfree(struct nfsrdresult *);
8370Sstevel@tonic-gate extern void rfs_write_sync(struct nfswriteargs *, struct nfsattrstat *,
8380Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
8390Sstevel@tonic-gate extern void rfs_write(struct nfswriteargs *, struct nfsattrstat *,
8400Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
8411610Sthurlow extern void *rfs_write_getfh(struct nfswriteargs *);
8420Sstevel@tonic-gate extern void rfs_create(struct nfscreatargs *, struct nfsdiropres *,
8430Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
8441610Sthurlow extern void *rfs_create_getfh(struct nfscreatargs *);
8450Sstevel@tonic-gate extern void rfs_remove(struct nfsdiropargs *, enum nfsstat *,
8460Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
8471610Sthurlow extern void *rfs_remove_getfh(struct nfsdiropargs *);
8480Sstevel@tonic-gate extern void rfs_rename(struct nfsrnmargs *, enum nfsstat *,
8490Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
8501610Sthurlow extern void *rfs_rename_getfh(struct nfsrnmargs *);
8510Sstevel@tonic-gate extern void rfs_link(struct nfslinkargs *, enum nfsstat *,
8520Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
8531610Sthurlow extern void *rfs_link_getfh(struct nfslinkargs *);
8540Sstevel@tonic-gate extern void rfs_symlink(struct nfsslargs *, enum nfsstat *,
8550Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
8561610Sthurlow extern void *rfs_symlink_getfh(struct nfsslargs *);
8570Sstevel@tonic-gate extern void rfs_mkdir(struct nfscreatargs *, struct nfsdiropres *,
8580Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
8591610Sthurlow extern void *rfs_mkdir_getfh(struct nfscreatargs *);
8600Sstevel@tonic-gate extern void rfs_rmdir(struct nfsdiropargs *, enum nfsstat *,
8610Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
8621610Sthurlow extern void *rfs_rmdir_getfh(struct nfsdiropargs *);
8630Sstevel@tonic-gate extern void rfs_readdir(struct nfsrddirargs *, struct nfsrddirres *,
8640Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
8651610Sthurlow extern void *rfs_readdir_getfh(struct nfsrddirargs *);
8660Sstevel@tonic-gate extern void rfs_rddirfree(struct nfsrddirres *);
8670Sstevel@tonic-gate extern void rfs_statfs(fhandle_t *, struct nfsstatfs *,
8680Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
8691610Sthurlow extern void *rfs_statfs_getfh(fhandle_t *);
8700Sstevel@tonic-gate extern void rfs_srvrinit(void);
8710Sstevel@tonic-gate extern void rfs_srvrfini(void);
8720Sstevel@tonic-gate 
8730Sstevel@tonic-gate /*
8740Sstevel@tonic-gate  * flags to define path types during Multi Component Lookups
8750Sstevel@tonic-gate  * using the public filehandle
8760Sstevel@tonic-gate  */
8770Sstevel@tonic-gate #define	URLPATH		0x01	/* Universal Resource Locator path */
8780Sstevel@tonic-gate #define	NATIVEPATH	0x02	/* Native path, i.e., via mount protocol */
8790Sstevel@tonic-gate #define	SECURITY_QUERY	0x04	/* Security query */
8800Sstevel@tonic-gate 
88111291SRobert.Thurlow@Sun.COM /* index for svstat_ptr */
88211291SRobert.Thurlow@Sun.COM enum nfs_svccounts {NFS_CALLS, NFS_BADCALLS, NFS_REFERRALS, NFS_REFERLINKS};
8830Sstevel@tonic-gate 
8840Sstevel@tonic-gate /*	function defs for NFS kernel */
8850Sstevel@tonic-gate extern int	nfs_waitfor_purge_complete(vnode_t *);
8860Sstevel@tonic-gate extern int	nfs_validate_caches(vnode_t *, cred_t *);
8870Sstevel@tonic-gate extern void	nfs_purge_caches(vnode_t *, int, cred_t *);
8880Sstevel@tonic-gate extern void	nfs_purge_rddir_cache(vnode_t *);
8890Sstevel@tonic-gate extern void	nfs_attrcache(vnode_t *, struct nfsfattr *, hrtime_t);
8900Sstevel@tonic-gate extern int	nfs_cache_fattr(vnode_t *, struct nfsfattr *, vattr_t *,
8910Sstevel@tonic-gate 				hrtime_t, cred_t *);
8920Sstevel@tonic-gate extern void	nfs_attr_cache(vnode_t *, vattr_t *, hrtime_t, cred_t *);
8930Sstevel@tonic-gate extern void	nfs_attrcache_va(vnode_t *, struct vattr *);
8940Sstevel@tonic-gate extern int	nfs_getattr_otw(vnode_t *, struct vattr *, cred_t *);
8950Sstevel@tonic-gate extern int	nfsgetattr(vnode_t *, struct vattr *, cred_t *);
8960Sstevel@tonic-gate extern int	nattr_to_vattr(vnode_t *, struct nfsfattr *, struct vattr *);
8970Sstevel@tonic-gate extern void	nfs_async_manager(struct vfs *);
8980Sstevel@tonic-gate extern void	nfs_async_manager_stop(struct vfs *);
8990Sstevel@tonic-gate extern void	nfs_async_stop(struct vfs *);
9000Sstevel@tonic-gate extern int	nfs_async_stop_sig(struct vfs *);
9010Sstevel@tonic-gate extern int	nfs_clntinit(void);
9020Sstevel@tonic-gate extern void	nfs_clntfini(void);
9030Sstevel@tonic-gate extern int	nfstsize(void);
9040Sstevel@tonic-gate extern int	nfs_srvinit(void);
9050Sstevel@tonic-gate extern void	nfs_srvfini(void);
9060Sstevel@tonic-gate extern int	vattr_to_sattr(struct vattr *, struct nfssattr *);
9070Sstevel@tonic-gate extern void	setdiropargs(struct nfsdiropargs *, char *, vnode_t *);
9080Sstevel@tonic-gate extern int	setdirgid(vnode_t *, gid_t *, cred_t *);
9090Sstevel@tonic-gate extern int	setdirmode(vnode_t *, mode_t *, cred_t *);
9100Sstevel@tonic-gate extern int	newnum(void);
9110Sstevel@tonic-gate extern char	*newname(void);
9120Sstevel@tonic-gate extern int	nfs_subrinit(void);
9130Sstevel@tonic-gate extern void	nfs_subrfini(void);
9140Sstevel@tonic-gate extern enum nfsstat puterrno(int);
9150Sstevel@tonic-gate extern int	geterrno(enum nfsstat);
9160Sstevel@tonic-gate extern int	nfsinit(int, char *);
9170Sstevel@tonic-gate extern void	nfsfini(void);
9180Sstevel@tonic-gate extern int	nfs_vfsinit(void);
9190Sstevel@tonic-gate extern void	nfs_vfsfini(void);
9206264Srm15945 extern int	nfs_dump(vnode_t *, caddr_t, offset_t, offset_t,
9216264Srm15945     caller_context_t *);
9220Sstevel@tonic-gate extern void	nfs_perror(int error, char *fmt, ...);
9230Sstevel@tonic-gate extern void	nfs_cmn_err(int error, int level, char *fmt, ...);
9240Sstevel@tonic-gate extern int	nfs_addcllock(vnode_t *vp, struct flock64 *bfp);
9250Sstevel@tonic-gate extern void	nfs_rmcllock(vnode_t *vp, struct flock64 *bfp);
9260Sstevel@tonic-gate extern void	nfs_lockrelease(vnode_t *vp, int flag,
9270Sstevel@tonic-gate 		    offset_t offset, cred_t *credp);
9280Sstevel@tonic-gate extern int	vattr_to_nattr(struct vattr *, struct nfsfattr *);
9290Sstevel@tonic-gate extern int	mount_root(char *, char *, int, struct nfs_args *, int *);
9300Sstevel@tonic-gate extern void	nfs_lockcompletion(vnode_t *vp, int cmd);
9310Sstevel@tonic-gate extern void	nfs_add_locking_id(vnode_t *, pid_t, int, char *, int);
9320Sstevel@tonic-gate extern void	nfs3copyfh(caddr_t, vnode_t *);
9330Sstevel@tonic-gate extern void	nfscopyfh(caddr_t, vnode_t *);
9340Sstevel@tonic-gate extern int	nfs3lookup(vnode_t *, char *, vnode_t **, struct pathname *,
9350Sstevel@tonic-gate 				int, vnode_t *, cred_t *, int);
9360Sstevel@tonic-gate extern int	nfslookup(vnode_t *, char *, vnode_t **, struct pathname *,
9370Sstevel@tonic-gate 				int, vnode_t *, cred_t *, int);
9380Sstevel@tonic-gate extern void	sv_free(struct servinfo *);
9390Sstevel@tonic-gate extern int	nfsauth_access(struct exportinfo *exi, struct svc_req *req);
9400Sstevel@tonic-gate extern void	nfsauth_init();
9410Sstevel@tonic-gate extern void	nfsauth_fini();
9420Sstevel@tonic-gate extern int	nfs_setopts(vnode_t *vp, model_t model, struct nfs_args *args);
9431676Sjpk extern int	nfs_mount_label_policy(vfs_t *vfsp, struct netbuf *addr,
9441676Sjpk 		    struct knetconfig *knconf, cred_t *cr);
9452712Snn35248 extern boolean_t	nfs_has_ctty(void);
9460Sstevel@tonic-gate extern void	nfs_srv_stop_all(void);
9470Sstevel@tonic-gate extern void	nfs_srv_quiesce_all(void);
9480Sstevel@tonic-gate extern void	(*nfs_srv_quiesce_func)(void);
9492035Scalum extern int	rfs4_dss_setpaths(char *, size_t);
9502035Scalum extern int	(*nfs_srv_dss_func)(char *, size_t);
95111888SPavel.Filipensky@Sun.COM extern int	nfs_setmod_check(page_t *pp);
9520Sstevel@tonic-gate extern time_t	rfs4_lease_time;
9530Sstevel@tonic-gate extern time_t	rfs4_grace_period;
9542035Scalum extern nvlist_t	*rfs4_dss_paths, *rfs4_dss_oldpaths;
9552035Scalum 
9560Sstevel@tonic-gate 
9570Sstevel@tonic-gate extern kstat_named_t	*global_svstat_ptr[];
9580Sstevel@tonic-gate 
9590Sstevel@tonic-gate extern krwlock_t	rroklock;
9600Sstevel@tonic-gate extern vtype_t		nf_to_vt[];
9610Sstevel@tonic-gate extern kstat_named_t	*rfsproccnt_v2_ptr;
9620Sstevel@tonic-gate extern kmutex_t		nfs_minor_lock;
9630Sstevel@tonic-gate extern int		nfs_major;
9640Sstevel@tonic-gate extern int		nfs_minor;
9650Sstevel@tonic-gate extern vfsops_t		*nfs_vfsops;
9660Sstevel@tonic-gate extern struct vnodeops	*nfs_vnodeops;
9670Sstevel@tonic-gate extern const struct fs_operation_def nfs_vnodeops_template[];
9680Sstevel@tonic-gate extern int		nfsfstyp;
9690Sstevel@tonic-gate 
9700Sstevel@tonic-gate /*
9710Sstevel@tonic-gate  * Per-zone stats as consumed by nfsstat(1m)
9720Sstevel@tonic-gate  */
9730Sstevel@tonic-gate struct nfs_version_stats {
9740Sstevel@tonic-gate 	kstat_named_t	*aclreqcnt_ptr;		/* nfs_acl:0:aclreqcnt_v? */
9750Sstevel@tonic-gate 	kstat_named_t	*aclproccnt_ptr;	/* nfs_acl:0:aclproccnt_v? */
9760Sstevel@tonic-gate 	kstat_named_t	*rfsreqcnt_ptr;		/* nfs:0:rfsreqcnt_v? */
9770Sstevel@tonic-gate 	kstat_named_t	*rfsproccnt_ptr;	/* nfs:0:rfsproccnt_v? */
9780Sstevel@tonic-gate };
9790Sstevel@tonic-gate 
9800Sstevel@tonic-gate /*
9810Sstevel@tonic-gate  * A bit of asymmetry: nfs:0:nfs_client isn't part of this structure.
9820Sstevel@tonic-gate  */
9830Sstevel@tonic-gate struct nfs_stats {
9840Sstevel@tonic-gate 	kstat_named_t		*nfs_stats_svstat_ptr[NFS_VERSMAX + 1];
9850Sstevel@tonic-gate 	struct nfs_version_stats	nfs_stats_v2;
9860Sstevel@tonic-gate 	struct nfs_version_stats	nfs_stats_v3;
9870Sstevel@tonic-gate 	struct nfs_version_stats	nfs_stats_v4;
9880Sstevel@tonic-gate };
9890Sstevel@tonic-gate 
9900Sstevel@tonic-gate /*
9910Sstevel@tonic-gate  * Key used to retrieve counters.
9920Sstevel@tonic-gate  */
9930Sstevel@tonic-gate extern zone_key_t nfsstat_zone_key;
9940Sstevel@tonic-gate 
9950Sstevel@tonic-gate /*
9960Sstevel@tonic-gate  * Zone callback functions.
9970Sstevel@tonic-gate  */
9980Sstevel@tonic-gate extern void *nfsstat_zone_init(zoneid_t);
9990Sstevel@tonic-gate extern void nfsstat_zone_fini(zoneid_t, void *);
10000Sstevel@tonic-gate 
10010Sstevel@tonic-gate #endif	/* _KERNEL */
10020Sstevel@tonic-gate 
10030Sstevel@tonic-gate /*
10040Sstevel@tonic-gate  * Version 3 declarations and definitions.
10050Sstevel@tonic-gate  */
10060Sstevel@tonic-gate 
10070Sstevel@tonic-gate #define	NFS3_FHSIZE 64
10080Sstevel@tonic-gate #define	NFS3_COOKIEVERFSIZE 8
10090Sstevel@tonic-gate #define	NFS3_CREATEVERFSIZE 8
10100Sstevel@tonic-gate #define	NFS3_WRITEVERFSIZE 8
10110Sstevel@tonic-gate 
10120Sstevel@tonic-gate typedef char *filename3;
10130Sstevel@tonic-gate 
10140Sstevel@tonic-gate typedef char *nfspath3;
10150Sstevel@tonic-gate 
10160Sstevel@tonic-gate #define	nfs3nametoolong	((char *)-1)
10170Sstevel@tonic-gate 
10180Sstevel@tonic-gate typedef uint64 fileid3;
10190Sstevel@tonic-gate 
10200Sstevel@tonic-gate typedef uint64 cookie3;
10210Sstevel@tonic-gate 
10220Sstevel@tonic-gate typedef uint32 uid3;
10230Sstevel@tonic-gate 
10240Sstevel@tonic-gate typedef uint32 gid3;
10250Sstevel@tonic-gate 
10260Sstevel@tonic-gate typedef uint64 size3;
10270Sstevel@tonic-gate 
10280Sstevel@tonic-gate typedef uint64 offset3;
10290Sstevel@tonic-gate 
10300Sstevel@tonic-gate typedef uint32 mode3;
10310Sstevel@tonic-gate 
10320Sstevel@tonic-gate typedef uint32 count3;
10330Sstevel@tonic-gate 
10340Sstevel@tonic-gate /*
10350Sstevel@tonic-gate  * These three are really opaque arrays, but we treat them as
10360Sstevel@tonic-gate  * uint64 for efficiency sake
10370Sstevel@tonic-gate  */
10380Sstevel@tonic-gate typedef uint64 cookieverf3;
10390Sstevel@tonic-gate 
10400Sstevel@tonic-gate typedef uint64 createverf3;
10410Sstevel@tonic-gate 
10420Sstevel@tonic-gate typedef uint64 writeverf3;
10430Sstevel@tonic-gate 
10441610Sthurlow typedef struct nfs_fh3 {
10450Sstevel@tonic-gate 	uint_t fh3_length;
10460Sstevel@tonic-gate 	union nfs_fh3_u {
10470Sstevel@tonic-gate 		struct nfs_fh3_i {
10481610Sthurlow 			fhandle3_t fh3_i;
10490Sstevel@tonic-gate 		} nfs_fh3_i;
10500Sstevel@tonic-gate 		char data[NFS3_FHSIZE];
10510Sstevel@tonic-gate 	} fh3_u;
10521636Sthurlow 	uint_t fh3_flags;
10531610Sthurlow } nfs_fh3;
10541610Sthurlow #define	fh3_fsid	fh3_u.nfs_fh3_i.fh3_i._fh3_fsid
10551610Sthurlow #define	fh3_len		fh3_u.nfs_fh3_i.fh3_i._fh3_len
10561610Sthurlow #define	fh3_data	fh3_u.nfs_fh3_i.fh3_i._fh3_data
10571610Sthurlow #define	fh3_xlen	fh3_u.nfs_fh3_i.fh3_i._fh3_xlen
10581610Sthurlow #define	fh3_xdata	fh3_u.nfs_fh3_i.fh3_i._fh3_xdata
10591610Sthurlow #define	FH3TOFIDP(fh)	((fid_t *)&((fh)->fh3_len))
10601610Sthurlow #define	FH3TOXFIDP(fh)	((fid_t *)&((fh)->fh3_xlen))
10610Sstevel@tonic-gate 
10620Sstevel@tonic-gate /*
10631636Sthurlow  * nfs_fh3.fh3_flags values
10641636Sthurlow  */
10651636Sthurlow #define	FH_WEBNFS	0x1	/* fh is WebNFS overloaded - see makefh3_ol() */
10661636Sthurlow 
10671636Sthurlow /*
10680Sstevel@tonic-gate  * Two elements were added to the
10690Sstevel@tonic-gate  * diropargs3 structure for performance (xdr-inlining).
10700Sstevel@tonic-gate  * They are not included as part of the args
10710Sstevel@tonic-gate  * that are encoded or decoded:
10720Sstevel@tonic-gate  * dirp - ptr to the nfs_fh3
10730Sstevel@tonic-gate  * flag indicating when to free the name that was
10740Sstevel@tonic-gate  * allocated during decode.
10750Sstevel@tonic-gate  */
10760Sstevel@tonic-gate struct diropargs3 {
10770Sstevel@tonic-gate 	nfs_fh3 *dirp;
10780Sstevel@tonic-gate 	nfs_fh3 dir;
10790Sstevel@tonic-gate 	filename3 name;
10800Sstevel@tonic-gate 	int flags;
10810Sstevel@tonic-gate };
10820Sstevel@tonic-gate typedef struct diropargs3 diropargs3;
10830Sstevel@tonic-gate 
10840Sstevel@tonic-gate struct nfstime3 {
10850Sstevel@tonic-gate 	uint32 seconds;
10860Sstevel@tonic-gate 	uint32 nseconds;
10870Sstevel@tonic-gate };
10880Sstevel@tonic-gate typedef struct nfstime3 nfstime3;
10890Sstevel@tonic-gate 
10900Sstevel@tonic-gate struct specdata3 {
10910Sstevel@tonic-gate 	uint32 specdata1;
10920Sstevel@tonic-gate 	uint32 specdata2;
10930Sstevel@tonic-gate };
10940Sstevel@tonic-gate typedef struct specdata3 specdata3;
10950Sstevel@tonic-gate 
10960Sstevel@tonic-gate enum nfsstat3 {
10970Sstevel@tonic-gate 	NFS3_OK = 0,
10980Sstevel@tonic-gate 	NFS3ERR_PERM = 1,
10990Sstevel@tonic-gate 	NFS3ERR_NOENT = 2,
11000Sstevel@tonic-gate 	NFS3ERR_IO = 5,
11010Sstevel@tonic-gate 	NFS3ERR_NXIO = 6,
11020Sstevel@tonic-gate 	NFS3ERR_ACCES = 13,
11030Sstevel@tonic-gate 	NFS3ERR_EXIST = 17,
11040Sstevel@tonic-gate 	NFS3ERR_XDEV = 18,
11050Sstevel@tonic-gate 	NFS3ERR_NODEV = 19,
11060Sstevel@tonic-gate 	NFS3ERR_NOTDIR = 20,
11070Sstevel@tonic-gate 	NFS3ERR_ISDIR = 21,
11080Sstevel@tonic-gate 	NFS3ERR_INVAL = 22,
11090Sstevel@tonic-gate 	NFS3ERR_FBIG = 27,
11100Sstevel@tonic-gate 	NFS3ERR_NOSPC = 28,
11110Sstevel@tonic-gate 	NFS3ERR_ROFS = 30,
11120Sstevel@tonic-gate 	NFS3ERR_MLINK = 31,
11130Sstevel@tonic-gate 	NFS3ERR_NAMETOOLONG = 63,
11140Sstevel@tonic-gate 	NFS3ERR_NOTEMPTY = 66,
11150Sstevel@tonic-gate 	NFS3ERR_DQUOT = 69,
11160Sstevel@tonic-gate 	NFS3ERR_STALE = 70,
11170Sstevel@tonic-gate 	NFS3ERR_REMOTE = 71,
11180Sstevel@tonic-gate 	NFS3ERR_BADHANDLE = 10001,
11190Sstevel@tonic-gate 	NFS3ERR_NOT_SYNC = 10002,
11200Sstevel@tonic-gate 	NFS3ERR_BAD_COOKIE = 10003,
11210Sstevel@tonic-gate 	NFS3ERR_NOTSUPP = 10004,
11220Sstevel@tonic-gate 	NFS3ERR_TOOSMALL = 10005,
11230Sstevel@tonic-gate 	NFS3ERR_SERVERFAULT = 10006,
11240Sstevel@tonic-gate 	NFS3ERR_BADTYPE = 10007,
11250Sstevel@tonic-gate 	NFS3ERR_JUKEBOX = 10008
11260Sstevel@tonic-gate };
11270Sstevel@tonic-gate typedef enum nfsstat3 nfsstat3;
11280Sstevel@tonic-gate 
11290Sstevel@tonic-gate enum ftype3 {
11300Sstevel@tonic-gate 	NF3REG = 1,
11310Sstevel@tonic-gate 	NF3DIR = 2,
11320Sstevel@tonic-gate 	NF3BLK = 3,
11330Sstevel@tonic-gate 	NF3CHR = 4,
11340Sstevel@tonic-gate 	NF3LNK = 5,
11350Sstevel@tonic-gate 	NF3SOCK = 6,
11360Sstevel@tonic-gate 	NF3FIFO = 7
11370Sstevel@tonic-gate };
11380Sstevel@tonic-gate typedef enum ftype3 ftype3;
11390Sstevel@tonic-gate 
11400Sstevel@tonic-gate struct fattr3 {
11410Sstevel@tonic-gate 	ftype3 type;
11420Sstevel@tonic-gate 	mode3 mode;
11430Sstevel@tonic-gate 	uint32 nlink;
11440Sstevel@tonic-gate 	uid3 uid;
11450Sstevel@tonic-gate 	gid3 gid;
11460Sstevel@tonic-gate 	size3 size;
11470Sstevel@tonic-gate 	size3 used;
11480Sstevel@tonic-gate 	specdata3 rdev;
11490Sstevel@tonic-gate 	uint64 fsid;
11500Sstevel@tonic-gate 	fileid3 fileid;
11510Sstevel@tonic-gate 	nfstime3 atime;
11520Sstevel@tonic-gate 	nfstime3 mtime;
11530Sstevel@tonic-gate 	nfstime3 ctime;
11540Sstevel@tonic-gate };
11550Sstevel@tonic-gate typedef struct fattr3 fattr3;
11560Sstevel@tonic-gate 
11570Sstevel@tonic-gate #define	NFS3_SIZEOF_FATTR3	(21)
11580Sstevel@tonic-gate 
11590Sstevel@tonic-gate #ifdef _KERNEL
11600Sstevel@tonic-gate struct fattr3_res {
11610Sstevel@tonic-gate 	nfsstat3 status;
11620Sstevel@tonic-gate 	vattr_t *vap;
11630Sstevel@tonic-gate 	vnode_t *vp;
11640Sstevel@tonic-gate };
11650Sstevel@tonic-gate typedef struct fattr3_res fattr3_res;
11660Sstevel@tonic-gate #endif /* _KERNEL */
11670Sstevel@tonic-gate 
11680Sstevel@tonic-gate struct post_op_attr {
11690Sstevel@tonic-gate 	bool_t attributes;
11700Sstevel@tonic-gate 	fattr3 attr;
11710Sstevel@tonic-gate };
11720Sstevel@tonic-gate typedef struct post_op_attr post_op_attr;
11730Sstevel@tonic-gate 
11740Sstevel@tonic-gate #ifdef _KERNEL
11750Sstevel@tonic-gate struct post_op_vattr {
11760Sstevel@tonic-gate 	bool_t		attributes;
11770Sstevel@tonic-gate 	fattr3_res	fres;
11780Sstevel@tonic-gate };
11790Sstevel@tonic-gate typedef struct post_op_vattr post_op_vattr;
11800Sstevel@tonic-gate #endif /* _KERNEL */
11810Sstevel@tonic-gate 
11820Sstevel@tonic-gate struct wcc_attr {
11830Sstevel@tonic-gate 	size3 size;
11840Sstevel@tonic-gate 	nfstime3 mtime;
11850Sstevel@tonic-gate 	nfstime3 ctime;
11860Sstevel@tonic-gate };
11870Sstevel@tonic-gate typedef struct wcc_attr wcc_attr;
11880Sstevel@tonic-gate 
11890Sstevel@tonic-gate struct pre_op_attr {
11900Sstevel@tonic-gate 	bool_t attributes;
11910Sstevel@tonic-gate 	wcc_attr attr;
11920Sstevel@tonic-gate };
11930Sstevel@tonic-gate typedef struct pre_op_attr pre_op_attr;
11940Sstevel@tonic-gate 
11950Sstevel@tonic-gate struct wcc_data {
11960Sstevel@tonic-gate 	pre_op_attr before;
11970Sstevel@tonic-gate 	post_op_attr after;
11980Sstevel@tonic-gate };
11990Sstevel@tonic-gate typedef struct wcc_data wcc_data;
12000Sstevel@tonic-gate 
12010Sstevel@tonic-gate struct post_op_fh3 {
12020Sstevel@tonic-gate 	bool_t handle_follows;
12030Sstevel@tonic-gate 	nfs_fh3 handle;
12040Sstevel@tonic-gate };
12050Sstevel@tonic-gate typedef struct post_op_fh3 post_op_fh3;
12060Sstevel@tonic-gate 
12070Sstevel@tonic-gate enum time_how {
12080Sstevel@tonic-gate 	DONT_CHANGE = 0,
12090Sstevel@tonic-gate 	SET_TO_SERVER_TIME = 1,
12100Sstevel@tonic-gate 	SET_TO_CLIENT_TIME = 2
12110Sstevel@tonic-gate };
12120Sstevel@tonic-gate typedef enum time_how time_how;
12130Sstevel@tonic-gate 
12140Sstevel@tonic-gate struct set_mode3 {
12150Sstevel@tonic-gate 	bool_t set_it;
12160Sstevel@tonic-gate 	mode3 mode;
12170Sstevel@tonic-gate };
12180Sstevel@tonic-gate typedef struct set_mode3 set_mode3;
12190Sstevel@tonic-gate 
12200Sstevel@tonic-gate struct set_uid3 {
12210Sstevel@tonic-gate 	bool_t set_it;
12220Sstevel@tonic-gate 	uid3 uid;
12230Sstevel@tonic-gate };
12240Sstevel@tonic-gate typedef struct set_uid3 set_uid3;
12250Sstevel@tonic-gate 
12260Sstevel@tonic-gate struct set_gid3 {
12270Sstevel@tonic-gate 	bool_t set_it;
12280Sstevel@tonic-gate 	gid3 gid;
12290Sstevel@tonic-gate };
12300Sstevel@tonic-gate typedef struct set_gid3 set_gid3;
12310Sstevel@tonic-gate 
12320Sstevel@tonic-gate struct set_size3 {
12330Sstevel@tonic-gate 	bool_t set_it;
12340Sstevel@tonic-gate 	size3 size;
12350Sstevel@tonic-gate };
12360Sstevel@tonic-gate typedef struct set_size3 set_size3;
12370Sstevel@tonic-gate 
12380Sstevel@tonic-gate struct set_atime {
12390Sstevel@tonic-gate 	time_how set_it;
12400Sstevel@tonic-gate 	nfstime3 atime;
12410Sstevel@tonic-gate };
12420Sstevel@tonic-gate typedef struct set_atime set_atime;
12430Sstevel@tonic-gate 
12440Sstevel@tonic-gate struct set_mtime {
12450Sstevel@tonic-gate 	time_how set_it;
12460Sstevel@tonic-gate 	nfstime3 mtime;
12470Sstevel@tonic-gate };
12480Sstevel@tonic-gate typedef struct set_mtime set_mtime;
12490Sstevel@tonic-gate 
12500Sstevel@tonic-gate struct sattr3 {
12510Sstevel@tonic-gate 	set_mode3 mode;
12520Sstevel@tonic-gate 	set_uid3 uid;
12530Sstevel@tonic-gate 	set_gid3 gid;
12540Sstevel@tonic-gate 	set_size3 size;
12550Sstevel@tonic-gate 	set_atime atime;
12560Sstevel@tonic-gate 	set_mtime mtime;
12570Sstevel@tonic-gate };
12580Sstevel@tonic-gate typedef struct sattr3 sattr3;
12590Sstevel@tonic-gate 
12600Sstevel@tonic-gate /*
12610Sstevel@tonic-gate  * A couple of defines to make resok and resfail look like the
12620Sstevel@tonic-gate  * correct things in a response type independent manner.
12630Sstevel@tonic-gate  */
12640Sstevel@tonic-gate #define	resok	res_u.ok
12650Sstevel@tonic-gate #define	resfail	res_u.fail
12660Sstevel@tonic-gate 
12670Sstevel@tonic-gate struct GETATTR3args {
12680Sstevel@tonic-gate 	nfs_fh3 object;
12690Sstevel@tonic-gate };
12700Sstevel@tonic-gate typedef struct GETATTR3args GETATTR3args;
12710Sstevel@tonic-gate 
12720Sstevel@tonic-gate struct GETATTR3resok {
12730Sstevel@tonic-gate 	fattr3 obj_attributes;
12740Sstevel@tonic-gate };
12750Sstevel@tonic-gate typedef struct GETATTR3resok GETATTR3resok;
12760Sstevel@tonic-gate 
12770Sstevel@tonic-gate struct GETATTR3res {
12780Sstevel@tonic-gate 	nfsstat3 status;
12790Sstevel@tonic-gate 	union {
12800Sstevel@tonic-gate 		GETATTR3resok ok;
12810Sstevel@tonic-gate 	} res_u;
12820Sstevel@tonic-gate };
12830Sstevel@tonic-gate typedef struct GETATTR3res GETATTR3res;
12840Sstevel@tonic-gate 
12850Sstevel@tonic-gate #ifdef _KERNEL
12860Sstevel@tonic-gate struct GETATTR3vres {
12870Sstevel@tonic-gate 	nfsstat3 status;
12880Sstevel@tonic-gate 	fattr3_res fres;
12890Sstevel@tonic-gate };
12900Sstevel@tonic-gate typedef struct GETATTR3vres GETATTR3vres;
12910Sstevel@tonic-gate #endif /* _KERNEL */
12920Sstevel@tonic-gate 
12930Sstevel@tonic-gate struct sattrguard3 {
12940Sstevel@tonic-gate 	bool_t check;
12950Sstevel@tonic-gate 	nfstime3 obj_ctime;
12960Sstevel@tonic-gate };
12970Sstevel@tonic-gate typedef struct sattrguard3 sattrguard3;
12980Sstevel@tonic-gate 
12990Sstevel@tonic-gate struct SETATTR3args {
13000Sstevel@tonic-gate 	nfs_fh3 object;
13010Sstevel@tonic-gate 	sattr3 new_attributes;
13020Sstevel@tonic-gate 	sattrguard3 guard;
13030Sstevel@tonic-gate };
13040Sstevel@tonic-gate typedef struct SETATTR3args SETATTR3args;
13050Sstevel@tonic-gate 
13060Sstevel@tonic-gate struct SETATTR3resok {
13070Sstevel@tonic-gate 	wcc_data obj_wcc;
13080Sstevel@tonic-gate };
13090Sstevel@tonic-gate typedef struct SETATTR3resok SETATTR3resok;
13100Sstevel@tonic-gate 
13110Sstevel@tonic-gate struct SETATTR3resfail {
13120Sstevel@tonic-gate 	wcc_data obj_wcc;
13130Sstevel@tonic-gate };
13140Sstevel@tonic-gate typedef struct SETATTR3resfail SETATTR3resfail;
13150Sstevel@tonic-gate 
13160Sstevel@tonic-gate struct SETATTR3res {
13170Sstevel@tonic-gate 	nfsstat3 status;
13180Sstevel@tonic-gate 	union {
13190Sstevel@tonic-gate 		SETATTR3resok ok;
13200Sstevel@tonic-gate 		SETATTR3resfail fail;
13210Sstevel@tonic-gate 	} res_u;
13220Sstevel@tonic-gate };
13230Sstevel@tonic-gate typedef struct SETATTR3res SETATTR3res;
13240Sstevel@tonic-gate 
13250Sstevel@tonic-gate struct LOOKUP3args {
13260Sstevel@tonic-gate 	diropargs3 what;
13270Sstevel@tonic-gate };
13280Sstevel@tonic-gate typedef struct LOOKUP3args LOOKUP3args;
13290Sstevel@tonic-gate 
13300Sstevel@tonic-gate struct LOOKUP3resok {
13310Sstevel@tonic-gate 	nfs_fh3 object;
13320Sstevel@tonic-gate 	post_op_attr obj_attributes;
13330Sstevel@tonic-gate 	post_op_attr dir_attributes;
13340Sstevel@tonic-gate };
13350Sstevel@tonic-gate typedef struct LOOKUP3resok LOOKUP3resok;
13360Sstevel@tonic-gate 
13370Sstevel@tonic-gate struct LOOKUP3resfail {
13380Sstevel@tonic-gate 	post_op_attr dir_attributes;
13390Sstevel@tonic-gate };
13400Sstevel@tonic-gate typedef struct LOOKUP3resfail LOOKUP3resfail;
13410Sstevel@tonic-gate 
13420Sstevel@tonic-gate struct LOOKUP3res {
13430Sstevel@tonic-gate 	nfsstat3 status;
13440Sstevel@tonic-gate 	union {
13450Sstevel@tonic-gate 		LOOKUP3resok ok;
13460Sstevel@tonic-gate 		LOOKUP3resfail fail;
13470Sstevel@tonic-gate 	} res_u;
13480Sstevel@tonic-gate };
13490Sstevel@tonic-gate typedef struct LOOKUP3res LOOKUP3res;
13500Sstevel@tonic-gate 
13510Sstevel@tonic-gate #ifdef _KERNEL
13520Sstevel@tonic-gate struct LOOKUP3vres {
13530Sstevel@tonic-gate 	nfsstat3 status;
13540Sstevel@tonic-gate 	nfs_fh3 object;
13550Sstevel@tonic-gate 	post_op_vattr dir_attributes;
13560Sstevel@tonic-gate 	post_op_vattr obj_attributes;
13570Sstevel@tonic-gate };
13580Sstevel@tonic-gate typedef struct LOOKUP3vres LOOKUP3vres;
13590Sstevel@tonic-gate #endif /* _KERNEL */
13600Sstevel@tonic-gate 
13610Sstevel@tonic-gate struct ACCESS3args {
13620Sstevel@tonic-gate 	nfs_fh3 object;
13630Sstevel@tonic-gate 	uint32 access;
13640Sstevel@tonic-gate };
13650Sstevel@tonic-gate typedef struct ACCESS3args ACCESS3args;
13660Sstevel@tonic-gate #define	ACCESS3_READ 0x1
13670Sstevel@tonic-gate #define	ACCESS3_LOOKUP 0x2
13680Sstevel@tonic-gate #define	ACCESS3_MODIFY 0x4
13690Sstevel@tonic-gate #define	ACCESS3_EXTEND 0x8
13700Sstevel@tonic-gate #define	ACCESS3_DELETE 0x10
13710Sstevel@tonic-gate #define	ACCESS3_EXECUTE 0x20
13720Sstevel@tonic-gate 
13730Sstevel@tonic-gate struct ACCESS3resok {
13740Sstevel@tonic-gate 	post_op_attr obj_attributes;
13750Sstevel@tonic-gate 	uint32 access;
13760Sstevel@tonic-gate };
13770Sstevel@tonic-gate typedef struct ACCESS3resok ACCESS3resok;
13780Sstevel@tonic-gate 
13790Sstevel@tonic-gate struct ACCESS3resfail {
13800Sstevel@tonic-gate 	post_op_attr obj_attributes;
13810Sstevel@tonic-gate };
13820Sstevel@tonic-gate typedef struct ACCESS3resfail ACCESS3resfail;
13830Sstevel@tonic-gate 
13840Sstevel@tonic-gate struct ACCESS3res {
13850Sstevel@tonic-gate 	nfsstat3 status;
13860Sstevel@tonic-gate 	union {
13870Sstevel@tonic-gate 		ACCESS3resok ok;
13880Sstevel@tonic-gate 		ACCESS3resfail fail;
13890Sstevel@tonic-gate 	} res_u;
13900Sstevel@tonic-gate };
13910Sstevel@tonic-gate typedef struct ACCESS3res ACCESS3res;
13920Sstevel@tonic-gate 
13930Sstevel@tonic-gate struct READLINK3args {
13940Sstevel@tonic-gate 	nfs_fh3 symlink;
13950Sstevel@tonic-gate };
13960Sstevel@tonic-gate typedef struct READLINK3args READLINK3args;
13970Sstevel@tonic-gate 
13980Sstevel@tonic-gate struct READLINK3resok {
13990Sstevel@tonic-gate 	post_op_attr symlink_attributes;
14000Sstevel@tonic-gate 	nfspath3 data;
14010Sstevel@tonic-gate };
14020Sstevel@tonic-gate typedef struct READLINK3resok READLINK3resok;
14030Sstevel@tonic-gate 
14040Sstevel@tonic-gate struct READLINK3resfail {
14050Sstevel@tonic-gate 	post_op_attr symlink_attributes;
14060Sstevel@tonic-gate };
14070Sstevel@tonic-gate typedef struct READLINK3resfail READLINK3resfail;
14080Sstevel@tonic-gate 
14090Sstevel@tonic-gate struct READLINK3res {
14100Sstevel@tonic-gate 	nfsstat3 status;
14110Sstevel@tonic-gate 	union {
14120Sstevel@tonic-gate 		READLINK3resok ok;
14130Sstevel@tonic-gate 		READLINK3resfail fail;
14140Sstevel@tonic-gate 	} res_u;
14150Sstevel@tonic-gate };
14160Sstevel@tonic-gate typedef struct READLINK3res READLINK3res;
14170Sstevel@tonic-gate 
14180Sstevel@tonic-gate struct READ3args {
14190Sstevel@tonic-gate 	nfs_fh3 file;
14200Sstevel@tonic-gate 	offset3 offset;
14210Sstevel@tonic-gate 	count3 count;
14227387SRobert.Gordon@Sun.COM #ifdef _KERNEL
14237387SRobert.Gordon@Sun.COM 	/* for read using rdma */
14247387SRobert.Gordon@Sun.COM 	char *res_data_val_alt;
14257387SRobert.Gordon@Sun.COM 	struct uio *res_uiop;
14267387SRobert.Gordon@Sun.COM 	struct clist *wlist;
14277387SRobert.Gordon@Sun.COM 	CONN *conn;
14287387SRobert.Gordon@Sun.COM #endif
14290Sstevel@tonic-gate };
14300Sstevel@tonic-gate typedef struct READ3args READ3args;
14310Sstevel@tonic-gate 
14320Sstevel@tonic-gate struct READ3resok {
14330Sstevel@tonic-gate 	post_op_attr file_attributes;
14340Sstevel@tonic-gate 	count3 count;
14350Sstevel@tonic-gate 	bool_t eof;
14360Sstevel@tonic-gate 	struct {
14370Sstevel@tonic-gate 		uint_t data_len;
14380Sstevel@tonic-gate 		char *data_val;
14390Sstevel@tonic-gate 		mblk_t *mp;
14400Sstevel@tonic-gate 	} data;
14410Sstevel@tonic-gate 	uint_t size;
14427387SRobert.Gordon@Sun.COM #ifdef _KERNEL
14437387SRobert.Gordon@Sun.COM 	uint_t wlist_len;
14447387SRobert.Gordon@Sun.COM 	struct clist *wlist;
144511539SChunli.Zhang@Sun.COM 	frtn_t zcopy;
14467387SRobert.Gordon@Sun.COM #endif
14470Sstevel@tonic-gate };
14480Sstevel@tonic-gate typedef struct READ3resok READ3resok;
14490Sstevel@tonic-gate 
14500Sstevel@tonic-gate struct READ3resfail {
14510Sstevel@tonic-gate 	post_op_attr file_attributes;
14520Sstevel@tonic-gate };
14530Sstevel@tonic-gate typedef struct READ3resfail READ3resfail;
14540Sstevel@tonic-gate 
14550Sstevel@tonic-gate struct READ3res {
14560Sstevel@tonic-gate 	nfsstat3 status;
14570Sstevel@tonic-gate 	union {
14580Sstevel@tonic-gate 		READ3resok ok;
14590Sstevel@tonic-gate 		READ3resfail fail;
14600Sstevel@tonic-gate 	} res_u;
14610Sstevel@tonic-gate };
14620Sstevel@tonic-gate typedef struct READ3res READ3res;
14630Sstevel@tonic-gate 
14640Sstevel@tonic-gate #ifdef _KERNEL
14650Sstevel@tonic-gate /*
14660Sstevel@tonic-gate  * READ3 reply that directly decodes fattr3 directly into vattr
14670Sstevel@tonic-gate  */
14680Sstevel@tonic-gate struct READ3vres {
14690Sstevel@tonic-gate 	nfsstat3 status;
14700Sstevel@tonic-gate 	struct post_op_vattr pov;
14710Sstevel@tonic-gate 	count3 count;
14720Sstevel@tonic-gate 	bool_t eof;
14730Sstevel@tonic-gate 	struct {
14740Sstevel@tonic-gate 		uint_t data_len;
14750Sstevel@tonic-gate 		char *data_val;
14760Sstevel@tonic-gate 	} data;
14770Sstevel@tonic-gate 	uint_t size;
14787387SRobert.Gordon@Sun.COM 
14797387SRobert.Gordon@Sun.COM 	uint_t wlist_len;
14807387SRobert.Gordon@Sun.COM 	struct clist *wlist;
14810Sstevel@tonic-gate };
14820Sstevel@tonic-gate typedef struct READ3vres READ3vres;
14830Sstevel@tonic-gate #endif /* _KERNEL */
14840Sstevel@tonic-gate 
14850Sstevel@tonic-gate /*
14860Sstevel@tonic-gate  * READ3 reply that uiomoves data directly into a struct uio
14870Sstevel@tonic-gate  * ignores any attributes returned
14880Sstevel@tonic-gate  */
14890Sstevel@tonic-gate struct READ3uiores {
14900Sstevel@tonic-gate 	nfsstat3 status;
14910Sstevel@tonic-gate 	count3 count;
14920Sstevel@tonic-gate 	bool_t eof;
14930Sstevel@tonic-gate 	struct uio *uiop;
14940Sstevel@tonic-gate 	uint_t size;		/* maximum reply size */
14957387SRobert.Gordon@Sun.COM #ifdef _KERNEL
14967387SRobert.Gordon@Sun.COM 	uint_t wlist_len;
14977387SRobert.Gordon@Sun.COM 	struct clist *wlist;
14987387SRobert.Gordon@Sun.COM #endif
14990Sstevel@tonic-gate };
15000Sstevel@tonic-gate typedef struct READ3uiores READ3uiores;
15010Sstevel@tonic-gate 
15020Sstevel@tonic-gate enum stable_how {
15030Sstevel@tonic-gate 	UNSTABLE = 0,
15040Sstevel@tonic-gate 	DATA_SYNC = 1,
15050Sstevel@tonic-gate 	FILE_SYNC = 2
15060Sstevel@tonic-gate };
15070Sstevel@tonic-gate typedef enum stable_how stable_how;
15080Sstevel@tonic-gate 
15090Sstevel@tonic-gate struct WRITE3args {
15100Sstevel@tonic-gate 	nfs_fh3 file;
15110Sstevel@tonic-gate 	offset3 offset;
15120Sstevel@tonic-gate 	count3 count;
15130Sstevel@tonic-gate 	stable_how stable;
15140Sstevel@tonic-gate 	struct {
15150Sstevel@tonic-gate 		uint_t data_len;
15160Sstevel@tonic-gate 		char *data_val;
15170Sstevel@tonic-gate 	} data;
15180Sstevel@tonic-gate 	mblk_t *mblk;
15197387SRobert.Gordon@Sun.COM #ifdef _KERNEL
15207387SRobert.Gordon@Sun.COM 	struct clist *rlist;
15217387SRobert.Gordon@Sun.COM 	CONN *conn;
15227387SRobert.Gordon@Sun.COM #endif
15230Sstevel@tonic-gate };
15240Sstevel@tonic-gate typedef struct WRITE3args WRITE3args;
15250Sstevel@tonic-gate 
15260Sstevel@tonic-gate struct WRITE3resok {
15270Sstevel@tonic-gate 	wcc_data file_wcc;
15280Sstevel@tonic-gate 	count3 count;
15290Sstevel@tonic-gate 	stable_how committed;
15300Sstevel@tonic-gate 	writeverf3 verf;
15310Sstevel@tonic-gate };
15320Sstevel@tonic-gate typedef struct WRITE3resok WRITE3resok;
15330Sstevel@tonic-gate 
15340Sstevel@tonic-gate struct WRITE3resfail {
15350Sstevel@tonic-gate 	wcc_data file_wcc;
15360Sstevel@tonic-gate };
15370Sstevel@tonic-gate typedef struct WRITE3resfail WRITE3resfail;
15380Sstevel@tonic-gate 
15390Sstevel@tonic-gate struct WRITE3res {
15400Sstevel@tonic-gate 	nfsstat3 status;
15410Sstevel@tonic-gate 	union {
15420Sstevel@tonic-gate 		WRITE3resok ok;
15430Sstevel@tonic-gate 		WRITE3resfail fail;
15440Sstevel@tonic-gate 	} res_u;
15450Sstevel@tonic-gate };
15460Sstevel@tonic-gate typedef struct WRITE3res WRITE3res;
15470Sstevel@tonic-gate 
15480Sstevel@tonic-gate enum createmode3 {
15490Sstevel@tonic-gate 	UNCHECKED = 0,
15500Sstevel@tonic-gate 	GUARDED = 1,
15510Sstevel@tonic-gate 	EXCLUSIVE = 2
15520Sstevel@tonic-gate };
15530Sstevel@tonic-gate typedef enum createmode3 createmode3;
15540Sstevel@tonic-gate 
15550Sstevel@tonic-gate struct createhow3 {
15560Sstevel@tonic-gate 	createmode3 mode;
15570Sstevel@tonic-gate 	union {
15580Sstevel@tonic-gate 		sattr3 obj_attributes;
15590Sstevel@tonic-gate 		createverf3 verf;
15600Sstevel@tonic-gate 	} createhow3_u;
15610Sstevel@tonic-gate };
15620Sstevel@tonic-gate typedef struct createhow3 createhow3;
15630Sstevel@tonic-gate 
15640Sstevel@tonic-gate struct CREATE3args {
15650Sstevel@tonic-gate 	diropargs3 where;
15660Sstevel@tonic-gate 	createhow3 how;
15670Sstevel@tonic-gate };
15680Sstevel@tonic-gate typedef struct CREATE3args CREATE3args;
15690Sstevel@tonic-gate 
15700Sstevel@tonic-gate struct CREATE3resok {
15710Sstevel@tonic-gate 	post_op_fh3 obj;
15720Sstevel@tonic-gate 	post_op_attr obj_attributes;
15730Sstevel@tonic-gate 	wcc_data dir_wcc;
15740Sstevel@tonic-gate };
15750Sstevel@tonic-gate typedef struct CREATE3resok CREATE3resok;
15760Sstevel@tonic-gate 
15770Sstevel@tonic-gate struct CREATE3resfail {
15780Sstevel@tonic-gate 	wcc_data dir_wcc;
15790Sstevel@tonic-gate };
15800Sstevel@tonic-gate typedef struct CREATE3resfail CREATE3resfail;
15810Sstevel@tonic-gate 
15820Sstevel@tonic-gate struct CREATE3res {
15830Sstevel@tonic-gate 	nfsstat3 status;
15840Sstevel@tonic-gate 	union {
15850Sstevel@tonic-gate 		CREATE3resok ok;
15860Sstevel@tonic-gate 		CREATE3resfail fail;
15870Sstevel@tonic-gate 	} res_u;
15880Sstevel@tonic-gate };
15890Sstevel@tonic-gate typedef struct CREATE3res CREATE3res;
15900Sstevel@tonic-gate 
15910Sstevel@tonic-gate struct MKDIR3args {
15920Sstevel@tonic-gate 	diropargs3 where;
15930Sstevel@tonic-gate 	sattr3 attributes;
15940Sstevel@tonic-gate };
15950Sstevel@tonic-gate typedef struct MKDIR3args MKDIR3args;
15960Sstevel@tonic-gate 
15970Sstevel@tonic-gate struct MKDIR3resok {
15980Sstevel@tonic-gate 	post_op_fh3 obj;
15990Sstevel@tonic-gate 	post_op_attr obj_attributes;
16000Sstevel@tonic-gate 	wcc_data dir_wcc;
16010Sstevel@tonic-gate };
16020Sstevel@tonic-gate typedef struct MKDIR3resok MKDIR3resok;
16030Sstevel@tonic-gate 
16040Sstevel@tonic-gate struct MKDIR3resfail {
16050Sstevel@tonic-gate 	wcc_data dir_wcc;
16060Sstevel@tonic-gate };
16070Sstevel@tonic-gate typedef struct MKDIR3resfail MKDIR3resfail;
16080Sstevel@tonic-gate 
16090Sstevel@tonic-gate struct MKDIR3res {
16100Sstevel@tonic-gate 	nfsstat3 status;
16110Sstevel@tonic-gate 	union {
16120Sstevel@tonic-gate 		MKDIR3resok ok;
16130Sstevel@tonic-gate 		MKDIR3resfail fail;
16140Sstevel@tonic-gate 	} res_u;
16150Sstevel@tonic-gate };
16160Sstevel@tonic-gate typedef struct MKDIR3res MKDIR3res;
16170Sstevel@tonic-gate 
16180Sstevel@tonic-gate struct symlinkdata3 {
16190Sstevel@tonic-gate 	sattr3 symlink_attributes;
16200Sstevel@tonic-gate 	nfspath3 symlink_data;
16210Sstevel@tonic-gate };
16220Sstevel@tonic-gate typedef struct symlinkdata3 symlinkdata3;
16230Sstevel@tonic-gate 
16240Sstevel@tonic-gate struct SYMLINK3args {
16250Sstevel@tonic-gate 	diropargs3 where;
16260Sstevel@tonic-gate 	symlinkdata3 symlink;
16270Sstevel@tonic-gate };
16280Sstevel@tonic-gate typedef struct SYMLINK3args SYMLINK3args;
16290Sstevel@tonic-gate 
16300Sstevel@tonic-gate struct SYMLINK3resok {
16310Sstevel@tonic-gate 	post_op_fh3 obj;
16320Sstevel@tonic-gate 	post_op_attr obj_attributes;
16330Sstevel@tonic-gate 	wcc_data dir_wcc;
16340Sstevel@tonic-gate };
16350Sstevel@tonic-gate typedef struct SYMLINK3resok SYMLINK3resok;
16360Sstevel@tonic-gate 
16370Sstevel@tonic-gate struct SYMLINK3resfail {
16380Sstevel@tonic-gate 	wcc_data dir_wcc;
16390Sstevel@tonic-gate };
16400Sstevel@tonic-gate typedef struct SYMLINK3resfail SYMLINK3resfail;
16410Sstevel@tonic-gate 
16420Sstevel@tonic-gate struct SYMLINK3res {
16430Sstevel@tonic-gate 	nfsstat3 status;
16440Sstevel@tonic-gate 	union {
16450Sstevel@tonic-gate 		SYMLINK3resok ok;
16460Sstevel@tonic-gate 		SYMLINK3resfail fail;
16470Sstevel@tonic-gate 	} res_u;
16480Sstevel@tonic-gate };
16490Sstevel@tonic-gate typedef struct SYMLINK3res SYMLINK3res;
16500Sstevel@tonic-gate 
16510Sstevel@tonic-gate struct devicedata3 {
16520Sstevel@tonic-gate 	sattr3 dev_attributes;
16530Sstevel@tonic-gate 	specdata3 spec;
16540Sstevel@tonic-gate };
16550Sstevel@tonic-gate typedef struct devicedata3 devicedata3;
16560Sstevel@tonic-gate 
16570Sstevel@tonic-gate struct mknoddata3 {
16580Sstevel@tonic-gate 	ftype3 type;
16590Sstevel@tonic-gate 	union {
16600Sstevel@tonic-gate 		devicedata3 device;
16610Sstevel@tonic-gate 		sattr3 pipe_attributes;
16620Sstevel@tonic-gate 	} mknoddata3_u;
16630Sstevel@tonic-gate };
16640Sstevel@tonic-gate typedef struct mknoddata3 mknoddata3;
16650Sstevel@tonic-gate 
16660Sstevel@tonic-gate struct MKNOD3args {
16670Sstevel@tonic-gate 	diropargs3 where;
16680Sstevel@tonic-gate 	mknoddata3 what;
16690Sstevel@tonic-gate };
16700Sstevel@tonic-gate typedef struct MKNOD3args MKNOD3args;
16710Sstevel@tonic-gate 
16720Sstevel@tonic-gate struct MKNOD3resok {
16730Sstevel@tonic-gate 	post_op_fh3 obj;
16740Sstevel@tonic-gate 	post_op_attr obj_attributes;
16750Sstevel@tonic-gate 	wcc_data dir_wcc;
16760Sstevel@tonic-gate };
16770Sstevel@tonic-gate typedef struct MKNOD3resok MKNOD3resok;
16780Sstevel@tonic-gate 
16790Sstevel@tonic-gate struct MKNOD3resfail {
16800Sstevel@tonic-gate 	wcc_data dir_wcc;
16810Sstevel@tonic-gate };
16820Sstevel@tonic-gate typedef struct MKNOD3resfail MKNOD3resfail;
16830Sstevel@tonic-gate 
16840Sstevel@tonic-gate struct MKNOD3res {
16850Sstevel@tonic-gate 	nfsstat3 status;
16860Sstevel@tonic-gate 	union {
16870Sstevel@tonic-gate 		MKNOD3resok ok;
16880Sstevel@tonic-gate 		MKNOD3resfail fail;
16890Sstevel@tonic-gate 	} res_u;
16900Sstevel@tonic-gate };
16910Sstevel@tonic-gate typedef struct MKNOD3res MKNOD3res;
16920Sstevel@tonic-gate 
16930Sstevel@tonic-gate struct REMOVE3args {
16940Sstevel@tonic-gate 	diropargs3 object;
16950Sstevel@tonic-gate };
16960Sstevel@tonic-gate typedef struct REMOVE3args REMOVE3args;
16970Sstevel@tonic-gate 
16980Sstevel@tonic-gate struct REMOVE3resok {
16990Sstevel@tonic-gate 	wcc_data dir_wcc;
17000Sstevel@tonic-gate };
17010Sstevel@tonic-gate typedef struct REMOVE3resok REMOVE3resok;
17020Sstevel@tonic-gate 
17030Sstevel@tonic-gate struct REMOVE3resfail {
17040Sstevel@tonic-gate 	wcc_data dir_wcc;
17050Sstevel@tonic-gate };
17060Sstevel@tonic-gate typedef struct REMOVE3resfail REMOVE3resfail;
17070Sstevel@tonic-gate 
17080Sstevel@tonic-gate struct REMOVE3res {
17090Sstevel@tonic-gate 	nfsstat3 status;
17100Sstevel@tonic-gate 	union {
17110Sstevel@tonic-gate 		REMOVE3resok ok;
17120Sstevel@tonic-gate 		REMOVE3resfail fail;
17130Sstevel@tonic-gate 	} res_u;
17140Sstevel@tonic-gate };
17150Sstevel@tonic-gate typedef struct REMOVE3res REMOVE3res;
17160Sstevel@tonic-gate 
17170Sstevel@tonic-gate struct RMDIR3args {
17180Sstevel@tonic-gate 	diropargs3 object;
17190Sstevel@tonic-gate };
17200Sstevel@tonic-gate typedef struct RMDIR3args RMDIR3args;
17210Sstevel@tonic-gate 
17220Sstevel@tonic-gate struct RMDIR3resok {
17230Sstevel@tonic-gate 	wcc_data dir_wcc;
17240Sstevel@tonic-gate };
17250Sstevel@tonic-gate typedef struct RMDIR3resok RMDIR3resok;
17260Sstevel@tonic-gate 
17270Sstevel@tonic-gate struct RMDIR3resfail {
17280Sstevel@tonic-gate 	wcc_data dir_wcc;
17290Sstevel@tonic-gate };
17300Sstevel@tonic-gate typedef struct RMDIR3resfail RMDIR3resfail;
17310Sstevel@tonic-gate 
17320Sstevel@tonic-gate struct RMDIR3res {
17330Sstevel@tonic-gate 	nfsstat3 status;
17340Sstevel@tonic-gate 	union {
17350Sstevel@tonic-gate 		RMDIR3resok ok;
17360Sstevel@tonic-gate 		RMDIR3resfail fail;
17370Sstevel@tonic-gate 	} res_u;
17380Sstevel@tonic-gate };
17390Sstevel@tonic-gate typedef struct RMDIR3res RMDIR3res;
17400Sstevel@tonic-gate 
17410Sstevel@tonic-gate struct RENAME3args {
17420Sstevel@tonic-gate 	diropargs3 from;
17430Sstevel@tonic-gate 	diropargs3 to;
17440Sstevel@tonic-gate };
17450Sstevel@tonic-gate typedef struct RENAME3args RENAME3args;
17460Sstevel@tonic-gate 
17470Sstevel@tonic-gate struct RENAME3resok {
17480Sstevel@tonic-gate 	wcc_data fromdir_wcc;
17490Sstevel@tonic-gate 	wcc_data todir_wcc;
17500Sstevel@tonic-gate };
17510Sstevel@tonic-gate typedef struct RENAME3resok RENAME3resok;
17520Sstevel@tonic-gate 
17530Sstevel@tonic-gate struct RENAME3resfail {
17540Sstevel@tonic-gate 	wcc_data fromdir_wcc;
17550Sstevel@tonic-gate 	wcc_data todir_wcc;
17560Sstevel@tonic-gate };
17570Sstevel@tonic-gate typedef struct RENAME3resfail RENAME3resfail;
17580Sstevel@tonic-gate 
17590Sstevel@tonic-gate struct RENAME3res {
17600Sstevel@tonic-gate 	nfsstat3 status;
17610Sstevel@tonic-gate 	union {
17620Sstevel@tonic-gate 		RENAME3resok ok;
17630Sstevel@tonic-gate 		RENAME3resfail fail;
17640Sstevel@tonic-gate 	} res_u;
17650Sstevel@tonic-gate };
17660Sstevel@tonic-gate typedef struct RENAME3res RENAME3res;
17670Sstevel@tonic-gate 
17680Sstevel@tonic-gate struct LINK3args {
17690Sstevel@tonic-gate 	nfs_fh3 file;
17700Sstevel@tonic-gate 	diropargs3 link;
17710Sstevel@tonic-gate };
17720Sstevel@tonic-gate typedef struct LINK3args LINK3args;
17730Sstevel@tonic-gate 
17740Sstevel@tonic-gate struct LINK3resok {
17750Sstevel@tonic-gate 	post_op_attr file_attributes;
17760Sstevel@tonic-gate 	wcc_data linkdir_wcc;
17770Sstevel@tonic-gate };
17780Sstevel@tonic-gate typedef struct LINK3resok LINK3resok;
17790Sstevel@tonic-gate 
17800Sstevel@tonic-gate struct LINK3resfail {
17810Sstevel@tonic-gate 	post_op_attr file_attributes;
17820Sstevel@tonic-gate 	wcc_data linkdir_wcc;
17830Sstevel@tonic-gate };
17840Sstevel@tonic-gate typedef struct LINK3resfail LINK3resfail;
17850Sstevel@tonic-gate 
17860Sstevel@tonic-gate struct LINK3res {
17870Sstevel@tonic-gate 	nfsstat3 status;
17880Sstevel@tonic-gate 	union {
17890Sstevel@tonic-gate 		LINK3resok ok;
17900Sstevel@tonic-gate 		LINK3resfail fail;
17910Sstevel@tonic-gate 	} res_u;
17920Sstevel@tonic-gate };
17930Sstevel@tonic-gate typedef struct LINK3res LINK3res;
17940Sstevel@tonic-gate 
17950Sstevel@tonic-gate struct READDIR3args {
17960Sstevel@tonic-gate 	nfs_fh3 dir;
17970Sstevel@tonic-gate 	cookie3 cookie;
17980Sstevel@tonic-gate 	cookieverf3 cookieverf;
17990Sstevel@tonic-gate 	count3 count;
18000Sstevel@tonic-gate };
18010Sstevel@tonic-gate typedef struct READDIR3args READDIR3args;
18020Sstevel@tonic-gate 
18030Sstevel@tonic-gate struct entry3 {
18040Sstevel@tonic-gate 	fileid3 fileid;
18050Sstevel@tonic-gate 	filename3 name;
18060Sstevel@tonic-gate 	cookie3 cookie;
18070Sstevel@tonic-gate 	struct entry3 *nextentry;
18080Sstevel@tonic-gate };
18090Sstevel@tonic-gate typedef struct entry3 entry3;
18100Sstevel@tonic-gate 
18110Sstevel@tonic-gate struct dirlist3 {
18120Sstevel@tonic-gate 	entry3 *entries;
18130Sstevel@tonic-gate 	bool_t eof;
18140Sstevel@tonic-gate };
18150Sstevel@tonic-gate typedef struct dirlist3 dirlist3;
18160Sstevel@tonic-gate 
18170Sstevel@tonic-gate struct READDIR3resok {
18180Sstevel@tonic-gate 	post_op_attr dir_attributes;
18190Sstevel@tonic-gate 	cookieverf3 cookieverf;
18200Sstevel@tonic-gate 	dirlist3 reply;
18210Sstevel@tonic-gate 	uint_t size;
18220Sstevel@tonic-gate 	uint_t count;
18230Sstevel@tonic-gate 	uint_t freecount;
18240Sstevel@tonic-gate 	cookie3 cookie;
18250Sstevel@tonic-gate };
18260Sstevel@tonic-gate typedef struct READDIR3resok READDIR3resok;
18270Sstevel@tonic-gate 
18280Sstevel@tonic-gate struct READDIR3resfail {
18290Sstevel@tonic-gate 	post_op_attr dir_attributes;
18300Sstevel@tonic-gate };
18310Sstevel@tonic-gate typedef struct READDIR3resfail READDIR3resfail;
18320Sstevel@tonic-gate 
18330Sstevel@tonic-gate struct READDIR3res {
18340Sstevel@tonic-gate 	nfsstat3 status;
18350Sstevel@tonic-gate 	union {
18360Sstevel@tonic-gate 		READDIR3resok ok;
18370Sstevel@tonic-gate 		READDIR3resfail fail;
18380Sstevel@tonic-gate 	} res_u;
18390Sstevel@tonic-gate };
18400Sstevel@tonic-gate typedef struct READDIR3res READDIR3res;
18410Sstevel@tonic-gate 
18420Sstevel@tonic-gate #ifdef _KERNEL
18430Sstevel@tonic-gate struct READDIR3vres {
18440Sstevel@tonic-gate 	nfsstat3 status;
18450Sstevel@tonic-gate 	post_op_vattr dir_attributes;
18460Sstevel@tonic-gate 	cookieverf3 cookieverf;
18470Sstevel@tonic-gate 	dirent64_t *entries;			/* decoded dirent64s */
18480Sstevel@tonic-gate 	uint_t size;				/* actual size of entries */
18490Sstevel@tonic-gate 	uint_t entries_size;			/* max size of entries */
18500Sstevel@tonic-gate 	off64_t loff;				/* last offset/cookie */
18510Sstevel@tonic-gate 	bool_t eof;				/* End of directory */
18520Sstevel@tonic-gate };
18530Sstevel@tonic-gate typedef struct READDIR3vres READDIR3vres;
18540Sstevel@tonic-gate #endif /* _KERNEL */
18550Sstevel@tonic-gate 
18560Sstevel@tonic-gate struct READDIRPLUS3args {
18570Sstevel@tonic-gate 	nfs_fh3 dir;
18580Sstevel@tonic-gate 	cookie3 cookie;
18590Sstevel@tonic-gate 	cookieverf3 cookieverf;
18600Sstevel@tonic-gate 	count3 dircount;
18610Sstevel@tonic-gate 	count3 maxcount;
18620Sstevel@tonic-gate };
18630Sstevel@tonic-gate typedef struct READDIRPLUS3args READDIRPLUS3args;
18640Sstevel@tonic-gate 
18650Sstevel@tonic-gate struct entryplus3 {
18660Sstevel@tonic-gate 	fileid3 fileid;
18670Sstevel@tonic-gate 	filename3 name;
18680Sstevel@tonic-gate 	cookie3 cookie;
18690Sstevel@tonic-gate 	post_op_attr name_attributes;
18700Sstevel@tonic-gate 	post_op_fh3 name_handle;
18710Sstevel@tonic-gate 	struct entryplus3 *nextentry;
18720Sstevel@tonic-gate };
18730Sstevel@tonic-gate typedef struct entryplus3 entryplus3;
18740Sstevel@tonic-gate 
18750Sstevel@tonic-gate struct dirlistplus3 {
18760Sstevel@tonic-gate 	entryplus3 *entries;
18770Sstevel@tonic-gate 	bool_t eof;
18780Sstevel@tonic-gate };
18790Sstevel@tonic-gate typedef struct dirlistplus3 dirlistplus3;
18800Sstevel@tonic-gate 
18810Sstevel@tonic-gate struct entryplus3_info {
18820Sstevel@tonic-gate 	post_op_attr attr;
18830Sstevel@tonic-gate 	post_op_fh3 fh;
18840Sstevel@tonic-gate 	uint_t namelen;
18850Sstevel@tonic-gate };
18860Sstevel@tonic-gate typedef struct entryplus3_info entryplus3_info;
18870Sstevel@tonic-gate 
18880Sstevel@tonic-gate struct READDIRPLUS3resok {
18890Sstevel@tonic-gate 	post_op_attr dir_attributes;
18900Sstevel@tonic-gate 	cookieverf3 cookieverf;
18910Sstevel@tonic-gate 	dirlistplus3 reply;
18920Sstevel@tonic-gate 	uint_t size;
18930Sstevel@tonic-gate 	uint_t count;
18940Sstevel@tonic-gate 	uint_t maxcount;
18950Sstevel@tonic-gate 	entryplus3_info *infop;
18960Sstevel@tonic-gate };
18970Sstevel@tonic-gate typedef struct READDIRPLUS3resok READDIRPLUS3resok;
18980Sstevel@tonic-gate 
18990Sstevel@tonic-gate struct READDIRPLUS3resfail {
19000Sstevel@tonic-gate 	post_op_attr dir_attributes;
19010Sstevel@tonic-gate };
19020Sstevel@tonic-gate typedef struct READDIRPLUS3resfail READDIRPLUS3resfail;
19030Sstevel@tonic-gate 
19040Sstevel@tonic-gate struct READDIRPLUS3res {
19050Sstevel@tonic-gate 	nfsstat3 status;
19060Sstevel@tonic-gate 	union {
19070Sstevel@tonic-gate 		READDIRPLUS3resok ok;
19080Sstevel@tonic-gate 		READDIRPLUS3resfail fail;
19090Sstevel@tonic-gate 	} res_u;
19100Sstevel@tonic-gate };
19110Sstevel@tonic-gate typedef struct READDIRPLUS3res READDIRPLUS3res;
19120Sstevel@tonic-gate 
19130Sstevel@tonic-gate #ifdef _KERNEL
19140Sstevel@tonic-gate struct entryplus3_va_fh {
19150Sstevel@tonic-gate 	int va_valid;
19160Sstevel@tonic-gate 	int fh_valid;
19170Sstevel@tonic-gate 	vattr_t va;
19180Sstevel@tonic-gate 	nfs_fh3 fh;
19190Sstevel@tonic-gate 	char *d_name;		/* back pointer into entries */
19200Sstevel@tonic-gate };
19210Sstevel@tonic-gate 
19220Sstevel@tonic-gate struct READDIRPLUS3vres {
19230Sstevel@tonic-gate 	nfsstat3 status;
19240Sstevel@tonic-gate 	post_op_vattr dir_attributes;
19250Sstevel@tonic-gate 	cookieverf3 cookieverf;
19260Sstevel@tonic-gate 	dirent64_t *entries;			/* decoded dirent64s */
19270Sstevel@tonic-gate 	uint_t size;				/* actual size of entries */
19280Sstevel@tonic-gate 	uint_t entries_size;			/* max size of entries */
19290Sstevel@tonic-gate 	bool_t eof;				/* End of directory */
19300Sstevel@tonic-gate 	off64_t loff;				/* last offset/cookie */
19310Sstevel@tonic-gate 	cred_t *credentials;			/* caller's credentials */
19320Sstevel@tonic-gate 	hrtime_t time;				/* time of READDIRPLUS call */
19330Sstevel@tonic-gate };
19340Sstevel@tonic-gate typedef struct READDIRPLUS3vres READDIRPLUS3vres;
19350Sstevel@tonic-gate #endif /* _KERNEL */
19360Sstevel@tonic-gate 
19370Sstevel@tonic-gate struct FSSTAT3args {
19380Sstevel@tonic-gate 	nfs_fh3 fsroot;
19390Sstevel@tonic-gate };
19400Sstevel@tonic-gate typedef struct FSSTAT3args FSSTAT3args;
19410Sstevel@tonic-gate 
19420Sstevel@tonic-gate struct FSSTAT3resok {
19430Sstevel@tonic-gate 	post_op_attr obj_attributes;
19440Sstevel@tonic-gate 	size3 tbytes;
19450Sstevel@tonic-gate 	size3 fbytes;
19460Sstevel@tonic-gate 	size3 abytes;
19470Sstevel@tonic-gate 	size3 tfiles;
19480Sstevel@tonic-gate 	size3 ffiles;
19490Sstevel@tonic-gate 	size3 afiles;
19500Sstevel@tonic-gate 	uint32 invarsec;
19510Sstevel@tonic-gate };
19520Sstevel@tonic-gate typedef struct FSSTAT3resok FSSTAT3resok;
19530Sstevel@tonic-gate 
19540Sstevel@tonic-gate struct FSSTAT3resfail {
19550Sstevel@tonic-gate 	post_op_attr obj_attributes;
19560Sstevel@tonic-gate };
19570Sstevel@tonic-gate typedef struct FSSTAT3resfail FSSTAT3resfail;
19580Sstevel@tonic-gate 
19590Sstevel@tonic-gate struct FSSTAT3res {
19600Sstevel@tonic-gate 	nfsstat3 status;
19610Sstevel@tonic-gate 	union {
19620Sstevel@tonic-gate 		FSSTAT3resok ok;
19630Sstevel@tonic-gate 		FSSTAT3resfail fail;
19640Sstevel@tonic-gate 	} res_u;
19650Sstevel@tonic-gate };
19660Sstevel@tonic-gate typedef struct FSSTAT3res FSSTAT3res;
19670Sstevel@tonic-gate 
19680Sstevel@tonic-gate struct FSINFO3args {
19690Sstevel@tonic-gate 	nfs_fh3 fsroot;
19700Sstevel@tonic-gate };
19710Sstevel@tonic-gate typedef struct FSINFO3args FSINFO3args;
19720Sstevel@tonic-gate 
19730Sstevel@tonic-gate struct FSINFO3resok {
19740Sstevel@tonic-gate 	post_op_attr obj_attributes;
19750Sstevel@tonic-gate 	uint32 rtmax;
19760Sstevel@tonic-gate 	uint32 rtpref;
19770Sstevel@tonic-gate 	uint32 rtmult;
19780Sstevel@tonic-gate 	uint32 wtmax;
19790Sstevel@tonic-gate 	uint32 wtpref;
19800Sstevel@tonic-gate 	uint32 wtmult;
19810Sstevel@tonic-gate 	uint32 dtpref;
19820Sstevel@tonic-gate 	size3 maxfilesize;
19830Sstevel@tonic-gate 	nfstime3 time_delta;
19840Sstevel@tonic-gate 	uint32 properties;
19850Sstevel@tonic-gate };
19860Sstevel@tonic-gate typedef struct FSINFO3resok FSINFO3resok;
19870Sstevel@tonic-gate 
19880Sstevel@tonic-gate struct FSINFO3resfail {
19890Sstevel@tonic-gate 	post_op_attr obj_attributes;
19900Sstevel@tonic-gate };
19910Sstevel@tonic-gate typedef struct FSINFO3resfail FSINFO3resfail;
19920Sstevel@tonic-gate #define	FSF3_LINK 0x1
19930Sstevel@tonic-gate #define	FSF3_SYMLINK 0x2
19940Sstevel@tonic-gate #define	FSF3_HOMOGENEOUS 0x8
19950Sstevel@tonic-gate #define	FSF3_CANSETTIME 0x10
19960Sstevel@tonic-gate 
19970Sstevel@tonic-gate struct FSINFO3res {
19980Sstevel@tonic-gate 	nfsstat3 status;
19990Sstevel@tonic-gate 	union {
20000Sstevel@tonic-gate 		FSINFO3resok ok;
20010Sstevel@tonic-gate 		FSINFO3resfail fail;
20020Sstevel@tonic-gate 	} res_u;
20030Sstevel@tonic-gate };
20040Sstevel@tonic-gate typedef struct FSINFO3res FSINFO3res;
20050Sstevel@tonic-gate 
20060Sstevel@tonic-gate struct PATHCONF3args {
20070Sstevel@tonic-gate 	nfs_fh3 object;
20080Sstevel@tonic-gate };
20090Sstevel@tonic-gate typedef struct PATHCONF3args PATHCONF3args;
20100Sstevel@tonic-gate 
20110Sstevel@tonic-gate struct nfs3_pathconf_info {
20120Sstevel@tonic-gate 	uint32 link_max;
20130Sstevel@tonic-gate 	uint32 name_max;
20140Sstevel@tonic-gate 	bool_t no_trunc;
20150Sstevel@tonic-gate 	bool_t chown_restricted;
20160Sstevel@tonic-gate 	bool_t case_insensitive;
20170Sstevel@tonic-gate 	bool_t case_preserving;
20180Sstevel@tonic-gate };
20190Sstevel@tonic-gate typedef struct nfs3_pathconf_info nfs3_pathconf_info;
20200Sstevel@tonic-gate 
20210Sstevel@tonic-gate struct PATHCONF3resok {
20220Sstevel@tonic-gate 	post_op_attr obj_attributes;
20230Sstevel@tonic-gate 	nfs3_pathconf_info info;
20240Sstevel@tonic-gate };
20250Sstevel@tonic-gate typedef struct PATHCONF3resok PATHCONF3resok;
20260Sstevel@tonic-gate 
20270Sstevel@tonic-gate struct PATHCONF3resfail {
20280Sstevel@tonic-gate 	post_op_attr obj_attributes;
20290Sstevel@tonic-gate };
20300Sstevel@tonic-gate typedef struct PATHCONF3resfail PATHCONF3resfail;
20310Sstevel@tonic-gate 
20320Sstevel@tonic-gate struct PATHCONF3res {
20330Sstevel@tonic-gate 	nfsstat3 status;
20340Sstevel@tonic-gate 	union {
20350Sstevel@tonic-gate 		PATHCONF3resok ok;
20360Sstevel@tonic-gate 		PATHCONF3resfail fail;
20370Sstevel@tonic-gate 	} res_u;
20380Sstevel@tonic-gate };
20390Sstevel@tonic-gate typedef struct PATHCONF3res PATHCONF3res;
20400Sstevel@tonic-gate 
20410Sstevel@tonic-gate struct COMMIT3args {
20420Sstevel@tonic-gate 	nfs_fh3 file;
20430Sstevel@tonic-gate 	offset3 offset;
20440Sstevel@tonic-gate 	count3 count;
20450Sstevel@tonic-gate };
20460Sstevel@tonic-gate typedef struct COMMIT3args COMMIT3args;
20470Sstevel@tonic-gate 
20480Sstevel@tonic-gate struct COMMIT3resok {
20490Sstevel@tonic-gate 	wcc_data file_wcc;
20500Sstevel@tonic-gate 	writeverf3 verf;
20510Sstevel@tonic-gate };
20520Sstevel@tonic-gate typedef struct COMMIT3resok COMMIT3resok;
20530Sstevel@tonic-gate 
20540Sstevel@tonic-gate struct COMMIT3resfail {
20550Sstevel@tonic-gate 	wcc_data file_wcc;
20560Sstevel@tonic-gate };
20570Sstevel@tonic-gate typedef struct COMMIT3resfail COMMIT3resfail;
20580Sstevel@tonic-gate 
20590Sstevel@tonic-gate struct COMMIT3res {
20600Sstevel@tonic-gate 	nfsstat3 status;
20610Sstevel@tonic-gate 	union {
20620Sstevel@tonic-gate 		COMMIT3resok ok;
20630Sstevel@tonic-gate 		COMMIT3resfail fail;
20640Sstevel@tonic-gate 	} res_u;
20650Sstevel@tonic-gate };
20660Sstevel@tonic-gate typedef struct COMMIT3res COMMIT3res;
20670Sstevel@tonic-gate 
20680Sstevel@tonic-gate #define	NFS3_PROGRAM ((rpcprog_t)100003)
20690Sstevel@tonic-gate #define	NFS_V3 ((rpcvers_t)3)
20700Sstevel@tonic-gate #define	NFSPROC3_NULL ((rpcproc_t)0)
20710Sstevel@tonic-gate #define	NFSPROC3_GETATTR ((rpcproc_t)1)
20720Sstevel@tonic-gate #define	NFSPROC3_SETATTR ((rpcproc_t)2)
20730Sstevel@tonic-gate #define	NFSPROC3_LOOKUP ((rpcproc_t)3)
20740Sstevel@tonic-gate #define	NFSPROC3_ACCESS ((rpcproc_t)4)
20750Sstevel@tonic-gate #define	NFSPROC3_READLINK ((rpcproc_t)5)
20760Sstevel@tonic-gate #define	NFSPROC3_READ ((rpcproc_t)6)
20770Sstevel@tonic-gate #define	NFSPROC3_WRITE ((rpcproc_t)7)
20780Sstevel@tonic-gate #define	NFSPROC3_CREATE ((rpcproc_t)8)
20790Sstevel@tonic-gate #define	NFSPROC3_MKDIR ((rpcproc_t)9)
20800Sstevel@tonic-gate #define	NFSPROC3_SYMLINK ((rpcproc_t)10)
20810Sstevel@tonic-gate #define	NFSPROC3_MKNOD ((rpcproc_t)11)
20820Sstevel@tonic-gate #define	NFSPROC3_REMOVE ((rpcproc_t)12)
20830Sstevel@tonic-gate #define	NFSPROC3_RMDIR ((rpcproc_t)13)
20840Sstevel@tonic-gate #define	NFSPROC3_RENAME ((rpcproc_t)14)
20850Sstevel@tonic-gate #define	NFSPROC3_LINK ((rpcproc_t)15)
20860Sstevel@tonic-gate #define	NFSPROC3_READDIR ((rpcproc_t)16)
20870Sstevel@tonic-gate #define	NFSPROC3_READDIRPLUS ((rpcproc_t)17)
20880Sstevel@tonic-gate #define	NFSPROC3_FSSTAT ((rpcproc_t)18)
20890Sstevel@tonic-gate #define	NFSPROC3_FSINFO ((rpcproc_t)19)
20900Sstevel@tonic-gate #define	NFSPROC3_PATHCONF ((rpcproc_t)20)
20910Sstevel@tonic-gate #define	NFSPROC3_COMMIT ((rpcproc_t)21)
20920Sstevel@tonic-gate 
20930Sstevel@tonic-gate #ifndef _KERNEL
20940Sstevel@tonic-gate extern  void * nfsproc3_null_3();
20950Sstevel@tonic-gate extern  GETATTR3res * nfsproc3_getattr_3();
20960Sstevel@tonic-gate extern  SETATTR3res * nfsproc3_setattr_3();
20970Sstevel@tonic-gate extern  LOOKUP3res * nfsproc3_lookup_3();
20980Sstevel@tonic-gate extern  ACCESS3res * nfsproc3_access_3();
20990Sstevel@tonic-gate extern  READLINK3res * nfsproc3_readlink_3();
21000Sstevel@tonic-gate extern  READ3res * nfsproc3_read_3();
21010Sstevel@tonic-gate extern  WRITE3res * nfsproc3_write_3();
21020Sstevel@tonic-gate extern  CREATE3res * nfsproc3_create_3();
21030Sstevel@tonic-gate extern  MKDIR3res * nfsproc3_mkdir_3();
21040Sstevel@tonic-gate extern  SYMLINK3res * nfsproc3_symlink_3();
21050Sstevel@tonic-gate extern  MKNOD3res * nfsproc3_mknod_3();
21060Sstevel@tonic-gate extern  REMOVE3res * nfsproc3_remove_3();
21070Sstevel@tonic-gate extern  RMDIR3res * nfsproc3_rmdir_3();
21080Sstevel@tonic-gate extern  RENAME3res * nfsproc3_rename_3();
21090Sstevel@tonic-gate extern  LINK3res * nfsproc3_link_3();
21100Sstevel@tonic-gate extern  READDIR3res * nfsproc3_readdir_3();
21110Sstevel@tonic-gate extern  READDIRPLUS3res * nfsproc3_readdirplus_3();
21120Sstevel@tonic-gate extern  FSSTAT3res * nfsproc3_fsstat_3();
21130Sstevel@tonic-gate extern  FSINFO3res * nfsproc3_fsinfo_3();
21140Sstevel@tonic-gate extern  PATHCONF3res * nfsproc3_pathconf_3();
21150Sstevel@tonic-gate extern  COMMIT3res * nfsproc3_commit_3();
21160Sstevel@tonic-gate #endif	/* !_KERNEL */
21170Sstevel@tonic-gate 
21180Sstevel@tonic-gate #ifdef _KERNEL
21190Sstevel@tonic-gate /* the NFS Version 3 XDR functions */
21200Sstevel@tonic-gate 
21210Sstevel@tonic-gate extern bool_t xdr_nfs_fh3(XDR *, nfs_fh3 *);
21221610Sthurlow extern bool_t xdr_nfslog_nfs_fh3(XDR *, nfs_fh3 *);
21231610Sthurlow extern bool_t xdr_nfs_fh3_server(XDR *, nfs_fh3 *);
21240Sstevel@tonic-gate extern bool_t xdr_diropargs3(XDR *, diropargs3 *);
21250Sstevel@tonic-gate extern bool_t xdr_post_op_attr(XDR *, post_op_attr *);
21260Sstevel@tonic-gate extern bool_t xdr_post_op_fh3(XDR *, post_op_fh3 *);
21270Sstevel@tonic-gate extern bool_t xdr_GETATTR3res(XDR *, GETATTR3res *);
21280Sstevel@tonic-gate extern bool_t xdr_GETATTR3vres(XDR *, GETATTR3vres *);
21290Sstevel@tonic-gate extern bool_t xdr_SETATTR3args(XDR *, SETATTR3args *);
21300Sstevel@tonic-gate extern bool_t xdr_SETATTR3res(XDR *, SETATTR3res *);
21310Sstevel@tonic-gate extern bool_t xdr_LOOKUP3res(XDR *, LOOKUP3res *);
21320Sstevel@tonic-gate extern bool_t xdr_LOOKUP3vres(XDR *, LOOKUP3vres *);
21330Sstevel@tonic-gate extern bool_t xdr_ACCESS3args(XDR *, ACCESS3args *);
21340Sstevel@tonic-gate extern bool_t xdr_ACCESS3res(XDR *, ACCESS3res *);
21350Sstevel@tonic-gate extern bool_t xdr_READLINK3args(XDR *, READLINK3args *);
21360Sstevel@tonic-gate extern bool_t xdr_READLINK3res(XDR *, READLINK3res *);
21370Sstevel@tonic-gate extern bool_t xdr_READ3args(XDR *, READ3args *);
21380Sstevel@tonic-gate extern bool_t xdr_READ3res(XDR *, READ3res *);
21390Sstevel@tonic-gate extern bool_t xdr_READ3vres(XDR *, READ3vres *);
21400Sstevel@tonic-gate extern bool_t xdr_READ3uiores(XDR *, READ3uiores *);
21410Sstevel@tonic-gate extern bool_t xdr_WRITE3args(XDR *, WRITE3args *);
21420Sstevel@tonic-gate extern bool_t xdr_WRITE3res(XDR *, WRITE3res *);
21430Sstevel@tonic-gate extern bool_t xdr_CREATE3args(XDR *, CREATE3args *);
21440Sstevel@tonic-gate extern bool_t xdr_CREATE3res(XDR *, CREATE3res *);
21450Sstevel@tonic-gate extern bool_t xdr_MKDIR3args(XDR *, MKDIR3args *);
21460Sstevel@tonic-gate extern bool_t xdr_MKDIR3res(XDR *, MKDIR3res *);
21470Sstevel@tonic-gate extern bool_t xdr_SYMLINK3args(XDR *, SYMLINK3args *);
21480Sstevel@tonic-gate extern bool_t xdr_SYMLINK3res(XDR *, SYMLINK3res *);
21490Sstevel@tonic-gate extern bool_t xdr_MKNOD3args(XDR *, MKNOD3args *);
21500Sstevel@tonic-gate extern bool_t xdr_MKNOD3res(XDR *, MKNOD3res *);
21510Sstevel@tonic-gate extern bool_t xdr_REMOVE3res(XDR *, REMOVE3res *);
21520Sstevel@tonic-gate extern bool_t xdr_RMDIR3resfail(XDR *, RMDIR3resfail *);
21530Sstevel@tonic-gate extern bool_t xdr_RMDIR3res(XDR *, RMDIR3res *);
21540Sstevel@tonic-gate extern bool_t xdr_RENAME3args(XDR *, RENAME3args *);
21550Sstevel@tonic-gate extern bool_t xdr_RENAME3res(XDR *, RENAME3res *);
21560Sstevel@tonic-gate extern bool_t xdr_LINK3args(XDR *, LINK3args *);
21570Sstevel@tonic-gate extern bool_t xdr_LINK3res(XDR *, LINK3res *);
21580Sstevel@tonic-gate extern bool_t xdr_READDIR3args(XDR *, READDIR3args *);
21590Sstevel@tonic-gate extern bool_t xdr_READDIR3res(XDR *, READDIR3res *);
21600Sstevel@tonic-gate extern bool_t xdr_READDIR3vres(XDR *, READDIR3vres *);
21610Sstevel@tonic-gate extern bool_t xdr_READDIRPLUS3args(XDR *, READDIRPLUS3args *);
21620Sstevel@tonic-gate extern bool_t xdr_READDIRPLUS3res(XDR *, READDIRPLUS3res *);
21630Sstevel@tonic-gate extern bool_t xdr_READDIRPLUS3vres(XDR *, READDIRPLUS3vres *);
21640Sstevel@tonic-gate extern bool_t xdr_FSSTAT3res(XDR *, FSSTAT3res *);
21650Sstevel@tonic-gate extern bool_t xdr_FSINFO3res(XDR *, FSINFO3res *);
21660Sstevel@tonic-gate extern bool_t xdr_PATHCONF3res(XDR *, PATHCONF3res *);
21670Sstevel@tonic-gate extern bool_t xdr_COMMIT3args(XDR *, COMMIT3args *);
21680Sstevel@tonic-gate extern bool_t xdr_COMMIT3res(XDR *, COMMIT3res *);
21690Sstevel@tonic-gate extern bool_t xdr_fastnfs_fh3(XDR *, nfs_fh3 **);
21700Sstevel@tonic-gate 
21710Sstevel@tonic-gate /*
21720Sstevel@tonic-gate  * The NFS Version 3 service procedures.
21730Sstevel@tonic-gate  */
21740Sstevel@tonic-gate struct exportinfo;	/* defined in nfs/export.h */
21750Sstevel@tonic-gate struct servinfo;	/* defined in nfs/nfs_clnt.h */
21760Sstevel@tonic-gate struct mntinfo;		/* defined in nfs/nfs_clnt.h */
21770Sstevel@tonic-gate struct sec_ol;		/* defined in nfs/export.h */
21780Sstevel@tonic-gate 
21790Sstevel@tonic-gate extern void rfs3_getattr(GETATTR3args *, GETATTR3res *,
21800Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
21811610Sthurlow extern void *rfs3_getattr_getfh(GETATTR3args *);
21820Sstevel@tonic-gate extern void rfs3_setattr(SETATTR3args *, SETATTR3res *,
21830Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
21841610Sthurlow extern void *rfs3_setattr_getfh(SETATTR3args *);
21850Sstevel@tonic-gate extern void rfs3_lookup(LOOKUP3args *, LOOKUP3res *,
21860Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
21871610Sthurlow extern void *rfs3_lookup_getfh(LOOKUP3args *);
21880Sstevel@tonic-gate extern void rfs3_access(ACCESS3args *, ACCESS3res *,
21890Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
21901610Sthurlow extern void *rfs3_access_getfh(ACCESS3args *);
21910Sstevel@tonic-gate extern void rfs3_readlink(READLINK3args *, READLINK3res *,
21920Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
21931610Sthurlow extern void *rfs3_readlink_getfh(READLINK3args *);
21940Sstevel@tonic-gate extern void rfs3_readlink_free(READLINK3res *);
21950Sstevel@tonic-gate extern void rfs3_read(READ3args *, READ3res *,
21960Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
21971610Sthurlow extern void *rfs3_read_getfh(READ3args *);
21980Sstevel@tonic-gate extern void rfs3_read_free(READ3res *);
21990Sstevel@tonic-gate extern void rfs3_write(WRITE3args *, WRITE3res *,
22000Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
22011610Sthurlow extern void *rfs3_write_getfh(WRITE3args *);
22020Sstevel@tonic-gate extern void rfs3_create(CREATE3args *, CREATE3res *,
22030Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
22041610Sthurlow extern void *rfs3_create_getfh(CREATE3args *);
22050Sstevel@tonic-gate extern void rfs3_mkdir(MKDIR3args *, MKDIR3res *,
22060Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
22071610Sthurlow extern void *rfs3_mkdir_getfh(MKDIR3args *);
22080Sstevel@tonic-gate extern void rfs3_symlink(SYMLINK3args *, SYMLINK3res *,
22090Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
22101610Sthurlow extern void *rfs3_symlink_getfh(SYMLINK3args *);
22110Sstevel@tonic-gate extern void rfs3_mknod(MKNOD3args *, MKNOD3res *,
22120Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
22131610Sthurlow extern void *rfs3_mknod_getfh(MKNOD3args *);
22140Sstevel@tonic-gate extern void rfs3_remove(REMOVE3args *, REMOVE3res *,
22150Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
22161610Sthurlow extern void *rfs3_remove_getfh(REMOVE3args *);
22170Sstevel@tonic-gate extern void rfs3_rmdir(RMDIR3args *, RMDIR3res *,
22180Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
22191610Sthurlow extern void *rfs3_rmdir_getfh(RMDIR3args *);
22200Sstevel@tonic-gate extern void rfs3_rename(RENAME3args *, RENAME3res *,
22210Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
22221610Sthurlow extern void *rfs3_rename_getfh(RENAME3args *);
22230Sstevel@tonic-gate extern void rfs3_link(LINK3args *, LINK3res *,
22240Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
22251610Sthurlow extern void *rfs3_link_getfh(LINK3args *);
22260Sstevel@tonic-gate extern void rfs3_readdir(READDIR3args *, READDIR3res *,
22270Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
22281610Sthurlow extern void *rfs3_readdir_getfh(READDIR3args *);
22290Sstevel@tonic-gate extern void rfs3_readdir_free(READDIR3res *);
22300Sstevel@tonic-gate extern void rfs3_readdirplus(READDIRPLUS3args *, READDIRPLUS3res *,
22310Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
22321610Sthurlow extern void *rfs3_readdirplus_getfh(READDIRPLUS3args *);
22330Sstevel@tonic-gate extern void rfs3_readdirplus_free(READDIRPLUS3res *);
22340Sstevel@tonic-gate extern void rfs3_fsstat(FSSTAT3args *, FSSTAT3res *,
22350Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
22361610Sthurlow extern void *rfs3_fsstat_getfh(FSSTAT3args *);
22370Sstevel@tonic-gate extern void rfs3_fsinfo(FSINFO3args *, FSINFO3res *,
22380Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
22391610Sthurlow extern void *rfs3_fsinfo_getfh(FSINFO3args *);
22400Sstevel@tonic-gate extern void rfs3_pathconf(PATHCONF3args *, PATHCONF3res *,
22410Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
22421610Sthurlow extern void *rfs3_pathconf_getfh(PATHCONF3args *);
22430Sstevel@tonic-gate extern void rfs3_commit(COMMIT3args *, COMMIT3res *,
22440Sstevel@tonic-gate 			struct exportinfo *, struct svc_req *, cred_t *);
22451610Sthurlow extern void *rfs3_commit_getfh(COMMIT3args *);
22460Sstevel@tonic-gate extern void rfs3_srvrinit(void);
22470Sstevel@tonic-gate extern void rfs3_srvrfini(void);
22480Sstevel@tonic-gate 
22490Sstevel@tonic-gate extern int	nfs3_validate_caches(vnode_t *, cred_t *);
22500Sstevel@tonic-gate extern void	nfs3_cache_post_op_attr(vnode_t *, post_op_attr *, hrtime_t,
22510Sstevel@tonic-gate 			cred_t *);
22520Sstevel@tonic-gate extern void	nfs3_cache_post_op_vattr(vnode_t *, post_op_vattr *, hrtime_t,
22530Sstevel@tonic-gate 			cred_t *);
22540Sstevel@tonic-gate extern void	nfs3_cache_wcc_data(vnode_t *, wcc_data *, hrtime_t, cred_t *);
22550Sstevel@tonic-gate extern void	nfs3_attrcache(vnode_t *, fattr3 *, hrtime_t);
22560Sstevel@tonic-gate extern int	nfs3_cache_fattr3(vnode_t *, fattr3 *, vattr_t *, hrtime_t,
22570Sstevel@tonic-gate 			cred_t *);
22580Sstevel@tonic-gate extern int	nfs3_getattr_otw(vnode_t *, struct vattr *, cred_t *);
22590Sstevel@tonic-gate extern int	nfs3getattr(vnode_t *, struct vattr *, cred_t *);
22600Sstevel@tonic-gate extern int	fattr3_to_vattr(vnode_t *, fattr3 *, struct vattr *);
22610Sstevel@tonic-gate extern int	nfs3tsize(void);
22620Sstevel@tonic-gate extern uint_t	nfs3_tsize(struct knetconfig *);
22630Sstevel@tonic-gate extern uint_t	rfs3_tsize(struct svc_req *);
22640Sstevel@tonic-gate extern int	vattr_to_sattr3(struct vattr *, sattr3 *);
22650Sstevel@tonic-gate extern void	setdiropargs3(diropargs3 *, char *, vnode_t *);
22660Sstevel@tonic-gate extern enum nfsstat3 puterrno3(int);
22670Sstevel@tonic-gate extern int	geterrno3(enum nfsstat3);
22680Sstevel@tonic-gate extern int	nfs3init(int, char *);
22690Sstevel@tonic-gate extern void	nfs3fini(void);
22700Sstevel@tonic-gate extern int	nfs3_vfsinit(void);
22710Sstevel@tonic-gate extern void	nfs3_vfsfini(void);
22720Sstevel@tonic-gate extern void	vattr_to_post_op_attr(struct vattr *, post_op_attr *);
22730Sstevel@tonic-gate extern void	mblk_to_iov(mblk_t *, int, struct iovec *);
22740Sstevel@tonic-gate extern int	rfs_publicfh_mclookup(char *, vnode_t *, cred_t *,
22750Sstevel@tonic-gate 			vnode_t **, struct exportinfo **, struct sec_ol *);
22760Sstevel@tonic-gate extern int	rfs_pathname(char *, vnode_t **, vnode_t **,
22770Sstevel@tonic-gate 			vnode_t *, cred_t *, int);
22780Sstevel@tonic-gate extern vtype_t		nf3_to_vt[];
22790Sstevel@tonic-gate extern kstat_named_t	*rfsproccnt_v3_ptr;
22800Sstevel@tonic-gate extern vfsops_t		*nfs3_vfsops;
22810Sstevel@tonic-gate extern struct vnodeops	*nfs3_vnodeops;
22820Sstevel@tonic-gate extern const struct fs_operation_def nfs3_vnodeops_template[];
22830Sstevel@tonic-gate #ifdef DEBUG
22840Sstevel@tonic-gate extern int		rfs3_do_pre_op_attr;
22850Sstevel@tonic-gate extern int		rfs3_do_post_op_attr;
22860Sstevel@tonic-gate extern int		rfs3_do_post_op_fh3;
22870Sstevel@tonic-gate #endif
22880Sstevel@tonic-gate /*
22890Sstevel@tonic-gate  * Some servers do not properly update the attributes of the
22900Sstevel@tonic-gate  * directory when changes are made.  To allow interoperability
22910Sstevel@tonic-gate  * with these broken servers, the nfs_disable_rddir_cache
22920Sstevel@tonic-gate  * parameter can be used to disable readdir response caching.
22930Sstevel@tonic-gate  */
22940Sstevel@tonic-gate extern int		nfs_disable_rddir_cache;
22950Sstevel@tonic-gate 
22960Sstevel@tonic-gate /*
22970Sstevel@tonic-gate  * External functions called by the v2/v3 code into the v4 code
22980Sstevel@tonic-gate  */
22990Sstevel@tonic-gate extern void		nfs4_clnt_init(void);
23000Sstevel@tonic-gate extern void		nfs4_clnt_fini(void);
23010Sstevel@tonic-gate 
23020Sstevel@tonic-gate /*
23030Sstevel@tonic-gate  * Does NFS4 server have a vnode delegated?  TRUE if so, FALSE if not.
23040Sstevel@tonic-gate  */
23050Sstevel@tonic-gate extern bool_t rfs4_check_delegated(int mode, vnode_t *, bool_t trunc);
23060Sstevel@tonic-gate /*
23070Sstevel@tonic-gate  * VOP_GETATTR call. If a NFS4 delegation is present on the supplied vnode
23080Sstevel@tonic-gate  * call back to the delegated client to get attributes for AT_MTIME and
23090Sstevel@tonic-gate  * AT_SIZE. Invoke VOP_GETATTR to get all other attributes or all attributes
23100Sstevel@tonic-gate  * if no delegation is present.
23110Sstevel@tonic-gate  */
23120Sstevel@tonic-gate extern int rfs4_delegated_getattr(vnode_t *, vattr_t *, int, cred_t *);
23130Sstevel@tonic-gate extern void rfs4_hold_deleg_policy(void);
23140Sstevel@tonic-gate extern void rfs4_rele_deleg_policy(void);
23157067Smarks 
23167067Smarks extern int do_xattr_exists_check(vnode_t *, ulong_t *, cred_t *);
23177067Smarks 
23189871SJarrett.Lu@Sun.COM extern ts_label_t	*nfs_getflabel(vnode_t *, struct exportinfo *);
23199871SJarrett.Lu@Sun.COM extern boolean_t	do_rfs_label_check(bslabel_t *, vnode_t *, int,
23209871SJarrett.Lu@Sun.COM 			    struct exportinfo *);
232111539SChunli.Zhang@Sun.COM 
232211539SChunli.Zhang@Sun.COM /*
232311539SChunli.Zhang@Sun.COM  * Copy Reduction support.
232411539SChunli.Zhang@Sun.COM  * xuio_t wrapper with additional private data.
232511539SChunli.Zhang@Sun.COM  */
232611539SChunli.Zhang@Sun.COM 
232711539SChunli.Zhang@Sun.COM typedef struct nfs_xuio {
232811539SChunli.Zhang@Sun.COM 	xuio_t nu_uio;
232911539SChunli.Zhang@Sun.COM 	vnode_t *nu_vp;
233011539SChunli.Zhang@Sun.COM 	uint_t nu_ref;
233111539SChunli.Zhang@Sun.COM 	frtn_t nu_frtn;
233211539SChunli.Zhang@Sun.COM } nfs_xuio_t;
233311539SChunli.Zhang@Sun.COM 
233411539SChunli.Zhang@Sun.COM xuio_t *rfs_setup_xuio(vnode_t *);
233511539SChunli.Zhang@Sun.COM mblk_t *uio_to_mblk(uio_t *);
233611539SChunli.Zhang@Sun.COM void rfs_rndup_mblks(mblk_t *, uint_t, int);
233711539SChunli.Zhang@Sun.COM void rfs_free_xuio(void *);
233811539SChunli.Zhang@Sun.COM 
23390Sstevel@tonic-gate #endif	/* _KERNEL */
23400Sstevel@tonic-gate 
23410Sstevel@tonic-gate #ifdef	__cplusplus
23420Sstevel@tonic-gate }
23430Sstevel@tonic-gate #endif
23440Sstevel@tonic-gate 
23450Sstevel@tonic-gate #endif	/* _NFS_NFS_H */
2346