xref: /titanic_44/usr/src/uts/common/nfs/nfs.h (revision 5cb0d67909d9970a3e7adbea9422ca3fc88000bf)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
527242a7cSthurlow  * Common Development and Distribution License (the "License").
627242a7cSthurlow  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22dd51520eSPavan Mettu - Oracle Corporation - Menlo Park United States  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
23e36d7b11SSebastien Roy  * Copyright (c) 2013 by Delphix. All rights reserved.
24*5cb0d679SMarcel Telka  * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
287c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #ifndef	_NFS_NFS_H
317c478bd9Sstevel@tonic-gate #define	_NFS_NFS_H
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate /*	nfs.h 2.38 88/08/19 SMI 	*/
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h>
367c478bd9Sstevel@tonic-gate #include <sys/vfs.h>
377c478bd9Sstevel@tonic-gate #include <sys/stream.h>
387c478bd9Sstevel@tonic-gate #include <rpc/types.h>
397c478bd9Sstevel@tonic-gate #include <sys/types32.h>
407c478bd9Sstevel@tonic-gate #ifdef _KERNEL
410a701b1eSRobert Gordon #include <rpc/rpc_rdma.h>
4245916cd2Sjpk #include <rpc/rpc.h>
437c478bd9Sstevel@tonic-gate #include <sys/fcntl.h>
447c478bd9Sstevel@tonic-gate #include <sys/kstat.h>
457c478bd9Sstevel@tonic-gate #include <sys/dirent.h>
4645916cd2Sjpk #include <sys/zone.h>
4745916cd2Sjpk #include <sys/tsol/label.h>
48cee86682Scalum #include <sys/nvpair.h>
497c478bd9Sstevel@tonic-gate #include <nfs/mount.h>
50d67944fbSScott Rotondo #include <sys/vfs_opreg.h>
517c478bd9Sstevel@tonic-gate #endif
527c478bd9Sstevel@tonic-gate #include <vm/page.h>
537c478bd9Sstevel@tonic-gate #include <rpc/rpc_sztypes.h>
547c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h>
557c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
567c478bd9Sstevel@tonic-gate extern "C" {
577c478bd9Sstevel@tonic-gate #endif
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate /*
607c478bd9Sstevel@tonic-gate  * remote file service numbers
617c478bd9Sstevel@tonic-gate  */
627c478bd9Sstevel@tonic-gate #define	NFS_PROGRAM	((rpcprog_t)100003)
637c478bd9Sstevel@tonic-gate #define	NFS_VERSMIN	((rpcvers_t)2)
647c478bd9Sstevel@tonic-gate #define	NFS_VERSMAX	((rpcvers_t)4)
657c478bd9Sstevel@tonic-gate #define	NFS_VERSION	((rpcvers_t)2)
667c478bd9Sstevel@tonic-gate #define	NFS_PORT	2049
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate /*
697c478bd9Sstevel@tonic-gate  * Used to determine registration and service handling of versions
707c478bd9Sstevel@tonic-gate  */
717c478bd9Sstevel@tonic-gate #define	NFS_VERSMIN_DEFAULT	((rpcvers_t)2)
727c478bd9Sstevel@tonic-gate #define	NFS_VERSMAX_DEFAULT	((rpcvers_t)4)
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate extern rpcvers_t nfs_versmin;
757c478bd9Sstevel@tonic-gate extern rpcvers_t nfs_versmax;
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate /*
787c478bd9Sstevel@tonic-gate  * Default delegation setting for the server ==> "on"
797c478bd9Sstevel@tonic-gate  */
807c478bd9Sstevel@tonic-gate #define	NFS_SERVER_DELEGATION_DEFAULT	(TRUE)
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate /* Maximum size of data portion of a remote request */
837c478bd9Sstevel@tonic-gate #define	NFS_MAXDATA	8192
847c478bd9Sstevel@tonic-gate #define	NFS_MAXNAMLEN	255
857c478bd9Sstevel@tonic-gate #define	NFS_MAXPATHLEN	1024
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate /*
887c478bd9Sstevel@tonic-gate  * Rpc retransmission parameters
897c478bd9Sstevel@tonic-gate  */
907c478bd9Sstevel@tonic-gate #define	NFS_TIMEO	11	/* initial timeout for clts in 10th of a sec */
917c478bd9Sstevel@tonic-gate #define	NFS_RETRIES	5	/* times to retry request */
927c478bd9Sstevel@tonic-gate #define	NFS_COTS_TIMEO	600	/* initial timeout for cots in 10th of a sec */
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate /*
957c478bd9Sstevel@tonic-gate  * The value of UID_NOBODY/GID_NOBODY presented to the world via NFS.
967c478bd9Sstevel@tonic-gate  * UID_NOBODY/GID_NOBODY is translated to NFS_UID_NOBODY/NFS_GID_NOBODY
977c478bd9Sstevel@tonic-gate  * when being sent out over the network and NFS_UID_NOBODY/NFS_GID_NOBODY
987c478bd9Sstevel@tonic-gate  * is translated to UID_NOBODY/GID_NOBODY when received.
997c478bd9Sstevel@tonic-gate  */
1007c478bd9Sstevel@tonic-gate #define	NFS_UID_NOBODY	-2
1017c478bd9Sstevel@tonic-gate #define	NFS_GID_NOBODY	-2
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate /*
1047c478bd9Sstevel@tonic-gate  * maximum transfer size for different interfaces
1057c478bd9Sstevel@tonic-gate  */
1067c478bd9Sstevel@tonic-gate #define	ECTSIZE	2048
1077c478bd9Sstevel@tonic-gate #define	IETSIZE	8192
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate /*
1107c478bd9Sstevel@tonic-gate  * WebNFS error status
1117c478bd9Sstevel@tonic-gate  */
1127c478bd9Sstevel@tonic-gate enum wnfsstat {
1137c478bd9Sstevel@tonic-gate 	WNFSERR_CLNT_FLAVOR = 20001	/* invalid client sec flavor */
1147c478bd9Sstevel@tonic-gate };
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate /*
1177c478bd9Sstevel@tonic-gate  * Error status
1187c478bd9Sstevel@tonic-gate  * Should include all possible net errors.
1197c478bd9Sstevel@tonic-gate  * For now we just cast errno into an enum nfsstat.
1207c478bd9Sstevel@tonic-gate  */
1217c478bd9Sstevel@tonic-gate enum nfsstat {
1227c478bd9Sstevel@tonic-gate 	NFS_OK = 0,			/* no error */
1237c478bd9Sstevel@tonic-gate 	NFSERR_PERM = 1,		/* Not owner */
1247c478bd9Sstevel@tonic-gate 	NFSERR_NOENT = 2,		/* No such file or directory */
1257c478bd9Sstevel@tonic-gate 	NFSERR_IO = 5,			/* I/O error */
1267c478bd9Sstevel@tonic-gate 	NFSERR_NXIO = 6,		/* No such device or address */
1277c478bd9Sstevel@tonic-gate 	NFSERR_ACCES = 13,		/* Permission denied */
1287c478bd9Sstevel@tonic-gate 	NFSERR_EXIST = 17,		/* File exists */
1297c478bd9Sstevel@tonic-gate 	NFSERR_XDEV = 18,		/* Cross-device link */
1307c478bd9Sstevel@tonic-gate 	NFSERR_NODEV = 19,		/* No such device */
1317c478bd9Sstevel@tonic-gate 	NFSERR_NOTDIR = 20,		/* Not a directory */
1327c478bd9Sstevel@tonic-gate 	NFSERR_ISDIR = 21,		/* Is a directory */
1337c478bd9Sstevel@tonic-gate 	NFSERR_INVAL = 22,		/* Invalid argument */
1347c478bd9Sstevel@tonic-gate 	NFSERR_FBIG = 27,		/* File too large */
1357c478bd9Sstevel@tonic-gate 	NFSERR_NOSPC = 28,		/* No space left on device */
1367c478bd9Sstevel@tonic-gate 	NFSERR_ROFS = 30,		/* Read-only file system */
1377c478bd9Sstevel@tonic-gate 	NFSERR_OPNOTSUPP = 45,		/* Operation not supported */
1387c478bd9Sstevel@tonic-gate 	NFSERR_NAMETOOLONG = 63,	/* File name too long */
1397c478bd9Sstevel@tonic-gate 	NFSERR_NOTEMPTY = 66,		/* Directory not empty */
1407c478bd9Sstevel@tonic-gate 	NFSERR_DQUOT = 69,		/* Disc quota exceeded */
1417c478bd9Sstevel@tonic-gate 	NFSERR_STALE = 70,		/* Stale NFS file handle */
1427c478bd9Sstevel@tonic-gate 	NFSERR_REMOTE = 71,		/* Object is remote */
1437c478bd9Sstevel@tonic-gate 	NFSERR_WFLUSH = 99		/* write cache flushed */
1447c478bd9Sstevel@tonic-gate };
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate typedef enum nfsstat nfsstat;
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate /*
1497c478bd9Sstevel@tonic-gate  * File types
1507c478bd9Sstevel@tonic-gate  */
1517c478bd9Sstevel@tonic-gate enum nfsftype {
1527c478bd9Sstevel@tonic-gate 	NFNON,
1537c478bd9Sstevel@tonic-gate 	NFREG,		/* regular file */
1547c478bd9Sstevel@tonic-gate 	NFDIR,		/* directory */
1557c478bd9Sstevel@tonic-gate 	NFBLK,		/* block special */
1567c478bd9Sstevel@tonic-gate 	NFCHR,		/* character special */
1577c478bd9Sstevel@tonic-gate 	NFLNK,		/* symbolic link */
1587c478bd9Sstevel@tonic-gate 	NFSOC		/* socket */
1597c478bd9Sstevel@tonic-gate };
1607c478bd9Sstevel@tonic-gate 
1617c478bd9Sstevel@tonic-gate /*
1627c478bd9Sstevel@tonic-gate  * Macros for converting device numbers to and from the format
1637c478bd9Sstevel@tonic-gate  * SunOS 4.x used. SVR4 uses 14 bit majors and 18 bits minors,
1647c478bd9Sstevel@tonic-gate  * SunOS 4.x used 8 bit majors and 8 bit minors. It isn't sufficient
1657c478bd9Sstevel@tonic-gate  * to use the cmpdev() and expdev() macros because they only compress
1667c478bd9Sstevel@tonic-gate  * 7 bit (and smaller) majors. We must compress 8 bit majors too.
1677c478bd9Sstevel@tonic-gate  * If the major or minor exceeds 8 bits, then we send it out in
1687c478bd9Sstevel@tonic-gate  * full 32 bit format and hope that the peer can deal with it.
1697c478bd9Sstevel@tonic-gate  */
1707c478bd9Sstevel@tonic-gate 
1717c478bd9Sstevel@tonic-gate #define	SO4_BITSMAJOR	8	/* # of SunOS 4.x major device bits */
1727c478bd9Sstevel@tonic-gate #define	SO4_BITSMINOR	8	/* # of SunOS 4.x minor device bits */
1737c478bd9Sstevel@tonic-gate #define	SO4_MAXMAJ	0xff	/* SunOS 4.x max major value */
1747c478bd9Sstevel@tonic-gate #define	SO4_MAXMIN	0xff	/* SunOS 4.x max minor value */
1757c478bd9Sstevel@tonic-gate 
1767c478bd9Sstevel@tonic-gate /*
1777c478bd9Sstevel@tonic-gate  * Convert to over-the-wire device number format
1787c478bd9Sstevel@tonic-gate  */
1797c478bd9Sstevel@tonic-gate #define	nfsv2_cmpdev(x) \
1807c478bd9Sstevel@tonic-gate 	((uint32_t) \
1817c478bd9Sstevel@tonic-gate 	((getmajor(x) > SO4_MAXMAJ || getminor(x) > SO4_MAXMIN) ? NODEV : \
1827c478bd9Sstevel@tonic-gate 	((getmajor(x) << SO4_BITSMINOR) | (getminor(x) & SO4_MAXMIN))))
1837c478bd9Sstevel@tonic-gate 
1847c478bd9Sstevel@tonic-gate /*
1857c478bd9Sstevel@tonic-gate  * Convert from over-the-wire format to SVR4 device number format
1867c478bd9Sstevel@tonic-gate  */
1877c478bd9Sstevel@tonic-gate #define	nfsv2_expdev(x) \
1887c478bd9Sstevel@tonic-gate 	makedevice((((x) >> SO4_BITSMINOR) & SO4_MAXMAJ), (x) & SO4_MAXMIN)
1897c478bd9Sstevel@tonic-gate 
1907c478bd9Sstevel@tonic-gate /*
1917c478bd9Sstevel@tonic-gate  * Special kludge for fifos (named pipes)  [to adhere to NFS Protocol Spec]
1927c478bd9Sstevel@tonic-gate  *
1937c478bd9Sstevel@tonic-gate  * VFIFO is not in the protocol spec (VNON will be replaced by VFIFO)
1947c478bd9Sstevel@tonic-gate  * so the over-the-wire representation is VCHR with a '-1' device number.
1957c478bd9Sstevel@tonic-gate  *
1967c478bd9Sstevel@tonic-gate  * NOTE: This kludge becomes unnecessary with the Protocol Revision,
1977c478bd9Sstevel@tonic-gate  *	 but it may be necessary to support it (backwards compatibility).
1987c478bd9Sstevel@tonic-gate  */
1997c478bd9Sstevel@tonic-gate #define	NFS_FIFO_TYPE	NFCHR
2007c478bd9Sstevel@tonic-gate #define	NFS_FIFO_MODE	S_IFCHR
2017c478bd9Sstevel@tonic-gate #define	NFS_FIFO_DEV	((uint32_t)-1)
2027c478bd9Sstevel@tonic-gate 
2037c478bd9Sstevel@tonic-gate /* identify fifo in nfs attributes */
2047c478bd9Sstevel@tonic-gate #define	NA_ISFIFO(NA)	(((NA)->na_type == NFS_FIFO_TYPE) && \
2057c478bd9Sstevel@tonic-gate 			    ((NA)->na_rdev == NFS_FIFO_DEV))
2067c478bd9Sstevel@tonic-gate 
2077c478bd9Sstevel@tonic-gate /* set fifo in nfs attributes */
2087c478bd9Sstevel@tonic-gate #define	NA_SETFIFO(NA)	{ \
2097c478bd9Sstevel@tonic-gate 		(NA)->na_type = NFS_FIFO_TYPE; \
2107c478bd9Sstevel@tonic-gate 		(NA)->na_rdev = NFS_FIFO_DEV; \
2117c478bd9Sstevel@tonic-gate 		(NA)->na_mode = ((NA)->na_mode & ~S_IFMT) | NFS_FIFO_MODE; \
2127c478bd9Sstevel@tonic-gate 		}
2137c478bd9Sstevel@tonic-gate 
2147c478bd9Sstevel@tonic-gate /*
2157c478bd9Sstevel@tonic-gate  * Check for time overflow using a kernel tunable to determine whether
2167c478bd9Sstevel@tonic-gate  * we should accept or reject an unsigned 32-bit time value. Time value in NFS
2177c478bd9Sstevel@tonic-gate  * v2/3 protocol is unsigned 32 bit, but ILP32 kernel only allows 31 bits.
2187c478bd9Sstevel@tonic-gate  * In nfsv4, time value is a signed 64 bit, so needs to be checked for
2197c478bd9Sstevel@tonic-gate  * overflow as well (e.g. for setattr). So define the tunable as follows:
2207c478bd9Sstevel@tonic-gate  * nfs_allow_preepoch_time is TRUE if pre-epoch (negative) times are allowed
2217c478bd9Sstevel@tonic-gate  * and is FALSE (the default) otherwise. For nfsv2/3 this means that
2227c478bd9Sstevel@tonic-gate  * if negative times are allowed, the uint32_t time value is interpreted
2237c478bd9Sstevel@tonic-gate  * as a signed int, otherwise as a large positive number. For nfsv4,
2247c478bd9Sstevel@tonic-gate  * we use the value as is - except that if negative times are not allowed,
2257c478bd9Sstevel@tonic-gate  * we will not accept a negative value otw.
2267c478bd9Sstevel@tonic-gate  *
2277c478bd9Sstevel@tonic-gate  * So for nfsv2/3 (uint32_t):
2287c478bd9Sstevel@tonic-gate  *
2297c478bd9Sstevel@tonic-gate  * If nfs_allow_preepoch_time is
2307c478bd9Sstevel@tonic-gate  * FALSE, the maximum time value is INT32_MAX for 32-bit kernels and
2317c478bd9Sstevel@tonic-gate  * UINT32_MAX for 64-bit kernels (to allow times larger than 2038)
2327c478bd9Sstevel@tonic-gate  * and the minimum is zero. Note that in that case, a 32-bit application
2337c478bd9Sstevel@tonic-gate  * running on a 64-bit kernel will not be able to access files with
2347c478bd9Sstevel@tonic-gate  * the larger time values.
2357c478bd9Sstevel@tonic-gate  * If nfs_allow_preepoch_time is TRUE, the maximum time value is INT32_MAX
2367c478bd9Sstevel@tonic-gate  * for both kernel configurations and the minimum is INT32_MIN.
2377c478bd9Sstevel@tonic-gate  *
2387c478bd9Sstevel@tonic-gate  * And for nfsv4 (int64_t):
2397c478bd9Sstevel@tonic-gate  *
2407c478bd9Sstevel@tonic-gate  * nfsv4 allows for negative values in the protocol, and has a 64-bit
2417c478bd9Sstevel@tonic-gate  * time field, so nfs_allow_preepoch_time can be ignored.
2427c478bd9Sstevel@tonic-gate  */
2437c478bd9Sstevel@tonic-gate #ifdef _KERNEL
2447c478bd9Sstevel@tonic-gate 
2457c478bd9Sstevel@tonic-gate extern bool_t		nfs_allow_preepoch_time;
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate #ifdef _LP64
2487c478bd9Sstevel@tonic-gate 
2497c478bd9Sstevel@tonic-gate /*
2507c478bd9Sstevel@tonic-gate  * If no negative otw values are allowed, may use the full 32-bits of the
2517c478bd9Sstevel@tonic-gate  * time to represent time later than 2038, by presenting the value as an
2527c478bd9Sstevel@tonic-gate  * unsigned (but this can only be used by 64-bit apps due to cstat32
253da6c28aaSamw  * restrictions). If negative values are allowed, cannot represent times
2547c478bd9Sstevel@tonic-gate  * after 2038. Either way, all 32 bits have a valid representation.
2557c478bd9Sstevel@tonic-gate  */
2567c478bd9Sstevel@tonic-gate 
2577c478bd9Sstevel@tonic-gate /* Check if nfstime4 seconds (int64_t) can be stored in the system time */
2587c478bd9Sstevel@tonic-gate #define	NFS4_TIME_OK(tt)	TRUE
2597c478bd9Sstevel@tonic-gate 
2607c478bd9Sstevel@tonic-gate 
2617c478bd9Sstevel@tonic-gate #define	NFS3_TIME_OVERFLOW(tt)	(FALSE)
2627c478bd9Sstevel@tonic-gate #define	NFS2_TIME_OVERFLOW(tt)	(FALSE)
2637c478bd9Sstevel@tonic-gate 
2647c478bd9Sstevel@tonic-gate /*
2657c478bd9Sstevel@tonic-gate  * check if a time_t (int64_t) is ok when preepoch times are allowed -
2667c478bd9Sstevel@tonic-gate  * nfsv2/3: every 32-bit value is accepted, but can't overflow 64->32.
2677c478bd9Sstevel@tonic-gate  * nfsv4: every value is valid.
2687c478bd9Sstevel@tonic-gate  */
2697c478bd9Sstevel@tonic-gate #define	NFS_PREEPOCH_TIME_T_OK(tt)					\
2707c478bd9Sstevel@tonic-gate 	(((tt) >= (time_t)INT32_MIN) && ((tt) <= (time_t)INT32_MAX))
2717c478bd9Sstevel@tonic-gate 
2727c478bd9Sstevel@tonic-gate /*
2737c478bd9Sstevel@tonic-gate  * check if a time_t (int64_t) is ok when preepoch times are not allowed -
2747c478bd9Sstevel@tonic-gate  * nfsv2/3: every positive 32-bit value is accepted, but can't overflow 64->32.
2757c478bd9Sstevel@tonic-gate  * nfsv4: every value is valid.
2767c478bd9Sstevel@tonic-gate  */
2777c478bd9Sstevel@tonic-gate #define	NFS_NO_PREEPOCH_TIME_T_OK(tt)					\
2787c478bd9Sstevel@tonic-gate 	(((tt) >= 0) && ((tt) <= (time_t)(ulong_t)UINT32_MAX))
2797c478bd9Sstevel@tonic-gate 
2807c478bd9Sstevel@tonic-gate #else /* not _LP64 */
2817c478bd9Sstevel@tonic-gate 
2827c478bd9Sstevel@tonic-gate /*
2837c478bd9Sstevel@tonic-gate  * Cannot represent times after 2038 in a 32-bit kernel, but we may wish to
2847c478bd9Sstevel@tonic-gate  * restrict the use of negative values (which violate the protocol).
2857c478bd9Sstevel@tonic-gate  * So if negative times allowed, all uint32 time values are valid. Otherwise
2867c478bd9Sstevel@tonic-gate  * only those which are less than INT32_MAX (msb=0).
2877c478bd9Sstevel@tonic-gate  *
2887c478bd9Sstevel@tonic-gate  * NFSv4 uses int64_t for the time, so in a 32-bit kernel the nfsv4 value
2897c478bd9Sstevel@tonic-gate  * must fit in an int32_t.
2907c478bd9Sstevel@tonic-gate  */
2917c478bd9Sstevel@tonic-gate 
2927c478bd9Sstevel@tonic-gate /* Only allow signed 32-bit time values */
2937c478bd9Sstevel@tonic-gate 
2947c478bd9Sstevel@tonic-gate /* Check if an nfstime4 (int64_t) can be stored in the system time */
2957c478bd9Sstevel@tonic-gate #define	NFS4_TIME_OK(tt)						\
2967c478bd9Sstevel@tonic-gate 	(((tt) <= INT32_MAX) &&	((tt) >= INT32_MIN))
2977c478bd9Sstevel@tonic-gate 
2987c478bd9Sstevel@tonic-gate #define	NFS3_TIME_OVERFLOW(tt)	((tt) > INT32_MAX)
2997c478bd9Sstevel@tonic-gate #define	NFS2_TIME_OVERFLOW(tt)	((tt) > INT32_MAX)
3007c478bd9Sstevel@tonic-gate 
3017c478bd9Sstevel@tonic-gate /*
3027c478bd9Sstevel@tonic-gate  * check if a time_t (int32_t) is ok when preepoch times are allowed -
3037c478bd9Sstevel@tonic-gate  * every 32-bit value is accepted
3047c478bd9Sstevel@tonic-gate  */
3057c478bd9Sstevel@tonic-gate #define	NFS_PREEPOCH_TIME_T_OK(tt)	TRUE
3067c478bd9Sstevel@tonic-gate 
3077c478bd9Sstevel@tonic-gate /*
3087c478bd9Sstevel@tonic-gate  * check if a time_t (int32_t) is ok when preepoch times are not allowed -
3097c478bd9Sstevel@tonic-gate  * only positive values are accepted.
3107c478bd9Sstevel@tonic-gate  */
3117c478bd9Sstevel@tonic-gate #define	NFS_NO_PREEPOCH_TIME_T_OK(tt)	((tt) >= 0)
3127c478bd9Sstevel@tonic-gate 
3137c478bd9Sstevel@tonic-gate #endif /* _LP64 */
3147c478bd9Sstevel@tonic-gate 
3157c478bd9Sstevel@tonic-gate /* Check if an nfstime3 (uint32_t) can be stored in the system time */
3167c478bd9Sstevel@tonic-gate #define	NFS3_TIME_OK(tt)						\
3177c478bd9Sstevel@tonic-gate 	(nfs_allow_preepoch_time || (!NFS3_TIME_OVERFLOW(tt)))
3187c478bd9Sstevel@tonic-gate 
3197c478bd9Sstevel@tonic-gate /* Check if an nfs2_timeval (uint32_t) can be stored in the system time. */
3207c478bd9Sstevel@tonic-gate #define	NFS2_TIME_OK(tt)						\
3217c478bd9Sstevel@tonic-gate 	(nfs_allow_preepoch_time || (!NFS2_TIME_OVERFLOW(tt)))
3227c478bd9Sstevel@tonic-gate 
3237c478bd9Sstevel@tonic-gate /*
3247c478bd9Sstevel@tonic-gate  * Test if time_t (signed long) can be sent over the wire - for v2/3 only if:
3257c478bd9Sstevel@tonic-gate  * 1. The time value can fit in a uint32_t; and
3267c478bd9Sstevel@tonic-gate  * 2. Either the time value is positive or allow preepoch times.
3277c478bd9Sstevel@tonic-gate  * No restrictions for nfsv4.
3287c478bd9Sstevel@tonic-gate  */
3297c478bd9Sstevel@tonic-gate #define	NFS_TIME_T_OK(tt)						\
3307c478bd9Sstevel@tonic-gate 	(nfs_allow_preepoch_time ?					\
3317c478bd9Sstevel@tonic-gate 		NFS_PREEPOCH_TIME_T_OK(tt) : NFS_NO_PREEPOCH_TIME_T_OK(tt))
3327c478bd9Sstevel@tonic-gate 
3337c478bd9Sstevel@tonic-gate #define	NFS4_TIME_T_OK(tt)		TRUE
3347c478bd9Sstevel@tonic-gate 
3357c478bd9Sstevel@tonic-gate /* Test if all attr times are valid */
3367c478bd9Sstevel@tonic-gate #define	NFS_VAP_TIME_OK(vap)						\
3377c478bd9Sstevel@tonic-gate 	(nfs_allow_preepoch_time ?					\
3387c478bd9Sstevel@tonic-gate 		(NFS_PREEPOCH_TIME_T_OK((vap)->va_atime.tv_sec) &&	\
3397c478bd9Sstevel@tonic-gate 		NFS_PREEPOCH_TIME_T_OK((vap)->va_mtime.tv_sec) &&	\
3407c478bd9Sstevel@tonic-gate 		NFS_PREEPOCH_TIME_T_OK((vap)->va_ctime.tv_sec)) :	\
3417c478bd9Sstevel@tonic-gate 		(NFS_NO_PREEPOCH_TIME_T_OK((vap)->va_atime.tv_sec) &&	\
3427c478bd9Sstevel@tonic-gate 		NFS_NO_PREEPOCH_TIME_T_OK((vap)->va_mtime.tv_sec) &&	\
3437c478bd9Sstevel@tonic-gate 		NFS_NO_PREEPOCH_TIME_T_OK((vap)->va_ctime.tv_sec)))
3447c478bd9Sstevel@tonic-gate 
3457c478bd9Sstevel@tonic-gate #define	NFS4_VAP_TIME_OK(vap)			TRUE
3467c478bd9Sstevel@tonic-gate 
3477c478bd9Sstevel@tonic-gate /*
3487c478bd9Sstevel@tonic-gate  * To extend the sign or not extend the sign, that is the question.
3497c478bd9Sstevel@tonic-gate  * Note: The correct way is to code a macro:
3507c478bd9Sstevel@tonic-gate  * #define	NFS_TIME_T_CONVERT(tt)					\
3517c478bd9Sstevel@tonic-gate  *	(nfs_allow_preepoch_time ? (int32_t)(tt) : (uint32_t)(tt))
3527c478bd9Sstevel@tonic-gate  * But the 64-bit compiler does not extend the sign in that case (why?)
3537c478bd9Sstevel@tonic-gate  * so we'll do it the ugly way...
3547c478bd9Sstevel@tonic-gate  */
3557c478bd9Sstevel@tonic-gate #define	NFS_TIME_T_CONVERT(systt, tt)		\
3567c478bd9Sstevel@tonic-gate 	if (nfs_allow_preepoch_time) {		\
3577c478bd9Sstevel@tonic-gate 		systt = (int32_t)(tt);		\
3587c478bd9Sstevel@tonic-gate 	} else {				\
3597c478bd9Sstevel@tonic-gate 		systt = (uint32_t)(tt);		\
3607c478bd9Sstevel@tonic-gate 	}
3617c478bd9Sstevel@tonic-gate 
3627c478bd9Sstevel@tonic-gate /* macro to check for overflowed time attribute fields - version 3 */
3637c478bd9Sstevel@tonic-gate #define	NFS3_FATTR_TIME_OK(attrs)			\
3647c478bd9Sstevel@tonic-gate 	(NFS3_TIME_OK((attrs)->atime.seconds) &&	\
3657c478bd9Sstevel@tonic-gate 	NFS3_TIME_OK((attrs)->mtime.seconds) &&		\
3667c478bd9Sstevel@tonic-gate 	NFS3_TIME_OK((attrs)->ctime.seconds))
3677c478bd9Sstevel@tonic-gate 
3687c478bd9Sstevel@tonic-gate /* macro to check for overflowed time attribute fields - version 2 */
3697c478bd9Sstevel@tonic-gate #define	NFS2_FATTR_TIME_OK(attrs)			\
3707c478bd9Sstevel@tonic-gate 	(NFS2_TIME_OK((attrs)->na_atime.tv_sec) &&	\
3717c478bd9Sstevel@tonic-gate 	NFS2_TIME_OK((attrs)->na_mtime.tv_sec) &&	\
3727c478bd9Sstevel@tonic-gate 	NFS2_TIME_OK((attrs)->na_ctime.tv_sec))
3737c478bd9Sstevel@tonic-gate 
3747c478bd9Sstevel@tonic-gate /* Check that a size3 value is not overflowed */
3757c478bd9Sstevel@tonic-gate #define	NFS3_SIZE_OK(size)	((size) <= MAXOFFSET_T)
3767c478bd9Sstevel@tonic-gate 
3777c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
3787c478bd9Sstevel@tonic-gate 
3797c478bd9Sstevel@tonic-gate /*
3807c478bd9Sstevel@tonic-gate  * Size of an fhandle in bytes
3817c478bd9Sstevel@tonic-gate  */
3827c478bd9Sstevel@tonic-gate #define	NFS_FHSIZE	32
3837c478bd9Sstevel@tonic-gate 
3847c478bd9Sstevel@tonic-gate struct nfs_fid {
3857c478bd9Sstevel@tonic-gate 	ushort_t nf_len;
3867c478bd9Sstevel@tonic-gate 	ushort_t nf_pad;
3877c478bd9Sstevel@tonic-gate 	char	nf_data[NFS_FHSIZE];
3887c478bd9Sstevel@tonic-gate };
3897c478bd9Sstevel@tonic-gate 
3907c478bd9Sstevel@tonic-gate /*
3917c46fb7fSek110237  * "Legacy" filehandles use NFS_FHMAXDATA (10) byte fids. Filesystems that
3927c46fb7fSek110237  * return a larger fid than NFS_FHMAXDATA, such as ZFS's .zfs snapshot
39327242a7cSthurlow  * directory, can use up to (((64 - 8) / 2) - 2) bytes for their fid.
39427242a7cSthurlow  * This currently holds for both NFSv3 and NFSv4.
3957c478bd9Sstevel@tonic-gate  */
3967c46fb7fSek110237 #define	NFS_FHMAXDATA		10
39727242a7cSthurlow #define	NFS_FH3MAXDATA		26
39827242a7cSthurlow #define	NFS_FH4MAXDATA		26
3997c478bd9Sstevel@tonic-gate 
4007c478bd9Sstevel@tonic-gate /*
40127242a7cSthurlow  * The original nfs file handle size for version 3 was 32 which was
40227242a7cSthurlow  * the same in version 2; now we're making it bigger to to deal with
40327242a7cSthurlow  * ZFS snapshot FIDs.
40427242a7cSthurlow  *
40527242a7cSthurlow  * If the size of fhandle3_t changes or if Version 3 uses some other
4067c478bd9Sstevel@tonic-gate  * filehandle format, this constant may need to change.
4077c478bd9Sstevel@tonic-gate  */
4087c478bd9Sstevel@tonic-gate 
40927242a7cSthurlow #define	NFS3_OLDFHSIZE	32
41027242a7cSthurlow #define	NFS3_MAXFHSIZE	64
4117c478bd9Sstevel@tonic-gate 
4127c478bd9Sstevel@tonic-gate /*
4137c46fb7fSek110237  * This is the actual definition of a legacy filehandle.  There is some
4147c46fb7fSek110237  * dependence on this layout in NFS-related code, particularly in the
4157c46fb7fSek110237  * user-level lock manager, so be careful about changing it.
4167c46fb7fSek110237  *
41727242a7cSthurlow  * Currently only NFSv2 uses this structure.
4187c478bd9Sstevel@tonic-gate  */
4197c478bd9Sstevel@tonic-gate 
42027242a7cSthurlow typedef struct svcfh {
4217c478bd9Sstevel@tonic-gate 	fsid_t	fh_fsid;			/* filesystem id */
4227c478bd9Sstevel@tonic-gate 	ushort_t fh_len;			/* file number length */
4237c478bd9Sstevel@tonic-gate 	char	fh_data[NFS_FHMAXDATA];		/* and data */
4247c478bd9Sstevel@tonic-gate 	ushort_t fh_xlen;			/* export file number length */
4257c478bd9Sstevel@tonic-gate 	char	fh_xdata[NFS_FHMAXDATA];	/* and data */
42627242a7cSthurlow } fhandle_t;
4277c478bd9Sstevel@tonic-gate 
4287c478bd9Sstevel@tonic-gate /*
42927242a7cSthurlow  * This is the in-memory structure for an NFSv3 extended filehandle.
4307c46fb7fSek110237  */
43127242a7cSthurlow typedef struct {
43227242a7cSthurlow 	fsid_t	_fh3_fsid;			/* filesystem id */
43327242a7cSthurlow 	ushort_t _fh3_len;			/* file number length */
43427242a7cSthurlow 	char	_fh3_data[NFS_FH3MAXDATA];		/* and data */
43527242a7cSthurlow 	ushort_t _fh3_xlen;			/* export file number length */
43627242a7cSthurlow 	char	_fh3_xdata[NFS_FH3MAXDATA];	/* and data */
43727242a7cSthurlow } fhandle3_t;
43827242a7cSthurlow 
43927242a7cSthurlow /*
44027242a7cSthurlow  * This is the in-memory structure for an NFSv4 extended filehandle.
44127242a7cSthurlow  */
44227242a7cSthurlow typedef struct {
4437c46fb7fSek110237 	fsid_t	fhx_fsid;			/* filesystem id */
4447c46fb7fSek110237 	ushort_t fhx_len;			/* file number length */
44527242a7cSthurlow 	char	fhx_data[NFS_FH4MAXDATA];	/* and data */
4467c46fb7fSek110237 	ushort_t fhx_xlen;			/* export file number length */
44727242a7cSthurlow 	char	fhx_xdata[NFS_FH4MAXDATA];	/* and data */
44827242a7cSthurlow } fhandle4_t;
4497c46fb7fSek110237 
4507c46fb7fSek110237 /*
4517c478bd9Sstevel@tonic-gate  * Arguments to remote write and writecache
4527c478bd9Sstevel@tonic-gate  */
4537c478bd9Sstevel@tonic-gate /*
4547c478bd9Sstevel@tonic-gate  * The `over the wire' representation of the first four arguments.
4557c478bd9Sstevel@tonic-gate  */
4567c478bd9Sstevel@tonic-gate struct otw_nfswriteargs {
4577c478bd9Sstevel@tonic-gate 	fhandle_t	otw_wa_fhandle;
4587c478bd9Sstevel@tonic-gate 	uint32_t	otw_wa_begoff;
4597c478bd9Sstevel@tonic-gate 	uint32_t	otw_wa_offset;
4607c478bd9Sstevel@tonic-gate 	uint32_t	otw_wa_totcount;
4617c478bd9Sstevel@tonic-gate };
4627c478bd9Sstevel@tonic-gate 
4637c478bd9Sstevel@tonic-gate struct nfswriteargs {
4647c478bd9Sstevel@tonic-gate 	struct otw_nfswriteargs *wa_args;	/* ptr to the otw arguments */
4657c478bd9Sstevel@tonic-gate 	struct otw_nfswriteargs wa_args_buf;	/* space for otw arguments */
4667c478bd9Sstevel@tonic-gate 	uint32_t	wa_count;
4677c478bd9Sstevel@tonic-gate 	char		*wa_data;	/* data to write (up to NFS_MAXDATA) */
4687c478bd9Sstevel@tonic-gate 	mblk_t		*wa_mblk;	/* pointer to mblks containing data */
4690a701b1eSRobert Gordon #ifdef _KERNEL
4700a701b1eSRobert Gordon 	/* rdma related info */
4710a701b1eSRobert Gordon 	struct clist	*wa_rlist;
4720a701b1eSRobert Gordon 	CONN		*wa_conn;
4730a701b1eSRobert Gordon #endif /* _KERNEL */
4747c478bd9Sstevel@tonic-gate };
4757c478bd9Sstevel@tonic-gate #define	wa_fhandle	wa_args->otw_wa_fhandle
4767c478bd9Sstevel@tonic-gate #define	wa_begoff	wa_args->otw_wa_begoff
4777c478bd9Sstevel@tonic-gate #define	wa_offset	wa_args->otw_wa_offset
4787c478bd9Sstevel@tonic-gate #define	wa_totcount	wa_args->otw_wa_totcount
4797c478bd9Sstevel@tonic-gate 
4807c478bd9Sstevel@tonic-gate /*
4817c478bd9Sstevel@tonic-gate  * NFS timeval struct using unsigned int as specified in V2 protocol.
4827c478bd9Sstevel@tonic-gate  * tv_sec and tv_usec used to match existing code.
4837c478bd9Sstevel@tonic-gate  */
4847c478bd9Sstevel@tonic-gate struct nfs2_timeval {
4857c478bd9Sstevel@tonic-gate 	uint32_t tv_sec;
4867c478bd9Sstevel@tonic-gate 	uint32_t tv_usec;
4877c478bd9Sstevel@tonic-gate };
4887c478bd9Sstevel@tonic-gate typedef struct nfs2_timeval nfs2_timeval;
4897c478bd9Sstevel@tonic-gate 
4907c478bd9Sstevel@tonic-gate /*
4917c478bd9Sstevel@tonic-gate  * File attributes
4927c478bd9Sstevel@tonic-gate  */
4937c478bd9Sstevel@tonic-gate struct nfsfattr {
4947c478bd9Sstevel@tonic-gate 	enum nfsftype	na_type;	/* file type */
4957c478bd9Sstevel@tonic-gate 	uint32_t	na_mode;	/* protection mode bits */
4967c478bd9Sstevel@tonic-gate 	uint32_t	na_nlink;	/* # hard links */
4977c478bd9Sstevel@tonic-gate 	uint32_t	na_uid;		/* owner user id */
4987c478bd9Sstevel@tonic-gate 	uint32_t	na_gid;		/* owner group id */
4997c478bd9Sstevel@tonic-gate 	uint32_t	na_size;	/* file size in bytes */
500da6c28aaSamw 	uint32_t	na_blocksize;	/* preferred block size */
5017c478bd9Sstevel@tonic-gate 	uint32_t	na_rdev;	/* special device # */
5027c478bd9Sstevel@tonic-gate 	uint32_t	na_blocks;	/* Kb of disk used by file */
5037c478bd9Sstevel@tonic-gate 	uint32_t	na_fsid;	/* device # */
5047c478bd9Sstevel@tonic-gate 	uint32_t	na_nodeid;	/* inode # */
5057c478bd9Sstevel@tonic-gate 	struct nfs2_timeval na_atime;	/* time of last access */
5067c478bd9Sstevel@tonic-gate 	struct nfs2_timeval na_mtime;	/* time of last modification */
5077c478bd9Sstevel@tonic-gate 	struct nfs2_timeval na_ctime;	/* time of last change */
5087c478bd9Sstevel@tonic-gate };
5097c478bd9Sstevel@tonic-gate 
5107c478bd9Sstevel@tonic-gate #define	n2v_type(x)	(NA_ISFIFO(x) ? VFIFO : nf_to_vt[(x)->na_type])
5117c478bd9Sstevel@tonic-gate #define	n2v_rdev(x)	(NA_ISFIFO(x) ? 0 : (x)->na_rdev)
5127c478bd9Sstevel@tonic-gate 
5137c478bd9Sstevel@tonic-gate /*
5147c478bd9Sstevel@tonic-gate  * Arguments to remote read
5157c478bd9Sstevel@tonic-gate  */
5167c478bd9Sstevel@tonic-gate struct nfsreadargs {
5177c478bd9Sstevel@tonic-gate 	fhandle_t	ra_fhandle;	/* handle for file */
5187c478bd9Sstevel@tonic-gate 	uint32_t	ra_offset;	/* byte offset in file */
5197c478bd9Sstevel@tonic-gate 	uint32_t	ra_count;	/* immediate read count */
5207c478bd9Sstevel@tonic-gate 	uint32_t	ra_totcount;	/* total read cnt (from this offset) */
5210a701b1eSRobert Gordon #ifdef _KERNEL
5220a701b1eSRobert Gordon 	/* used in rdma transports */
5230a701b1eSRobert Gordon 	caddr_t		ra_data;	/* destination for read data */
5240a701b1eSRobert Gordon 	struct clist	*ra_wlist;
5250a701b1eSRobert Gordon 	CONN		*ra_conn;
5260a701b1eSRobert Gordon #endif
5277c478bd9Sstevel@tonic-gate };
5287c478bd9Sstevel@tonic-gate 
5297c478bd9Sstevel@tonic-gate /*
5307c478bd9Sstevel@tonic-gate  * Status OK portion of remote read reply
5317c478bd9Sstevel@tonic-gate  */
5327c478bd9Sstevel@tonic-gate struct nfsrrok {
5337c478bd9Sstevel@tonic-gate 	struct nfsfattr	rrok_attr;	/* attributes, need for pagin */
5347c478bd9Sstevel@tonic-gate 	uint32_t	rrok_count;	/* bytes of data */
5357c478bd9Sstevel@tonic-gate 	char		*rrok_data;	/* data (up to NFS_MAXDATA bytes) */
5367c478bd9Sstevel@tonic-gate 	uint_t		rrok_bufsize;	/* size of kmem_alloc'd buffer */
5377c478bd9Sstevel@tonic-gate 	mblk_t		*rrok_mp;	/* mblk_t contains data for reply */
5380a701b1eSRobert Gordon #ifdef _KERNEL
5390a701b1eSRobert Gordon 	uint_t		rrok_wlist_len;
5400a701b1eSRobert Gordon 	struct clist    *rrok_wlist;
5410a701b1eSRobert Gordon #endif
5427c478bd9Sstevel@tonic-gate };
5437c478bd9Sstevel@tonic-gate 
5447c478bd9Sstevel@tonic-gate /*
5457c478bd9Sstevel@tonic-gate  * Reply from remote read
5467c478bd9Sstevel@tonic-gate  */
5477c478bd9Sstevel@tonic-gate struct nfsrdresult {
5487c478bd9Sstevel@tonic-gate 	nfsstat	rr_status;			/* status of read */
5497c478bd9Sstevel@tonic-gate 	union {
5507c478bd9Sstevel@tonic-gate 		struct nfsrrok	rr_ok_u;	/* attributes, need for pagin */
5517c478bd9Sstevel@tonic-gate 	} rr_u;
5527c478bd9Sstevel@tonic-gate };
5537c478bd9Sstevel@tonic-gate #define	rr_ok		rr_u.rr_ok_u
5547c478bd9Sstevel@tonic-gate #define	rr_attr		rr_u.rr_ok_u.rrok_attr
5557c478bd9Sstevel@tonic-gate #define	rr_count	rr_u.rr_ok_u.rrok_count
5567c478bd9Sstevel@tonic-gate #define	rr_bufsize	rr_u.rr_ok_u.rrok_bufsize
5577c478bd9Sstevel@tonic-gate #define	rr_data		rr_u.rr_ok_u.rrok_data
5587c478bd9Sstevel@tonic-gate #define	rr_mp		rr_u.rr_ok_u.rrok_mp
5597c478bd9Sstevel@tonic-gate 
5607c478bd9Sstevel@tonic-gate /*
5617c478bd9Sstevel@tonic-gate  * File attributes which can be set
5627c478bd9Sstevel@tonic-gate  */
5637c478bd9Sstevel@tonic-gate struct nfssattr {
5647c478bd9Sstevel@tonic-gate 	uint32_t	sa_mode;	/* protection mode bits */
5657c478bd9Sstevel@tonic-gate 	uint32_t	sa_uid;		/* owner user id */
5667c478bd9Sstevel@tonic-gate 	uint32_t	sa_gid;		/* owner group id */
5677c478bd9Sstevel@tonic-gate 	uint32_t	sa_size;	/* file size in bytes */
5687c478bd9Sstevel@tonic-gate 	struct nfs2_timeval sa_atime;	/* time of last access */
5697c478bd9Sstevel@tonic-gate 	struct nfs2_timeval sa_mtime;	/* time of last modification */
5707c478bd9Sstevel@tonic-gate };
5717c478bd9Sstevel@tonic-gate 
5727c478bd9Sstevel@tonic-gate 
5737c478bd9Sstevel@tonic-gate /*
5747c478bd9Sstevel@tonic-gate  * Reply status with file attributes
5757c478bd9Sstevel@tonic-gate  */
5767c478bd9Sstevel@tonic-gate struct nfsattrstat {
5777c478bd9Sstevel@tonic-gate 	nfsstat	ns_status;			/* reply status */
5787c478bd9Sstevel@tonic-gate 	union {
5797c478bd9Sstevel@tonic-gate 		struct nfsfattr ns_attr_u;	/* NFS_OK: file attributes */
5807c478bd9Sstevel@tonic-gate 	} ns_u;
5817c478bd9Sstevel@tonic-gate };
5827c478bd9Sstevel@tonic-gate #define	ns_attr	ns_u.ns_attr_u
5837c478bd9Sstevel@tonic-gate 
5847c478bd9Sstevel@tonic-gate 
5857c478bd9Sstevel@tonic-gate /*
5867c478bd9Sstevel@tonic-gate  * NFS_OK part of read sym link reply union
5877c478bd9Sstevel@tonic-gate  */
5887c478bd9Sstevel@tonic-gate struct nfssrok {
5897c478bd9Sstevel@tonic-gate 	uint32_t srok_count;	/* size of string */
5907c478bd9Sstevel@tonic-gate 	char	*srok_data;	/* string (up to NFS_MAXPATHLEN bytes) */
5917c478bd9Sstevel@tonic-gate };
5927c478bd9Sstevel@tonic-gate 
5937c478bd9Sstevel@tonic-gate /*
5947c478bd9Sstevel@tonic-gate  * Result of reading symbolic link
5957c478bd9Sstevel@tonic-gate  */
5967c478bd9Sstevel@tonic-gate struct nfsrdlnres {
5977c478bd9Sstevel@tonic-gate 	nfsstat	rl_status;			/* status of symlink read */
5987c478bd9Sstevel@tonic-gate 	union {
5997c478bd9Sstevel@tonic-gate 		struct nfssrok	rl_srok_u;	/* name of linked to */
6007c478bd9Sstevel@tonic-gate 	} rl_u;
6017c478bd9Sstevel@tonic-gate };
6027c478bd9Sstevel@tonic-gate #define	rl_srok		rl_u.rl_srok_u
6037c478bd9Sstevel@tonic-gate #define	rl_count	rl_u.rl_srok_u.srok_count
6047c478bd9Sstevel@tonic-gate #define	rl_data		rl_u.rl_srok_u.srok_data
6057c478bd9Sstevel@tonic-gate 
6067c478bd9Sstevel@tonic-gate 
6077c478bd9Sstevel@tonic-gate /*
6087c478bd9Sstevel@tonic-gate  * Arguments to readdir
6097c478bd9Sstevel@tonic-gate  */
6107c478bd9Sstevel@tonic-gate struct nfsrddirargs {
6117c478bd9Sstevel@tonic-gate 	fhandle_t rda_fh;	/* directory handle */
6127c478bd9Sstevel@tonic-gate 	uint32_t rda_offset;	/* offset in directory (opaque) */
6137c478bd9Sstevel@tonic-gate 	uint32_t rda_count;	/* number of directory bytes to read */
6147c478bd9Sstevel@tonic-gate };
6157c478bd9Sstevel@tonic-gate 
6167c478bd9Sstevel@tonic-gate /*
6177c478bd9Sstevel@tonic-gate  * NFS_OK part of readdir result
6187c478bd9Sstevel@tonic-gate  */
6197c478bd9Sstevel@tonic-gate struct nfsrdok {
6207c478bd9Sstevel@tonic-gate 	uint32_t rdok_offset;		/* next offset (opaque) */
6217c478bd9Sstevel@tonic-gate 	uint32_t rdok_size;		/* size in bytes of entries */
6227c478bd9Sstevel@tonic-gate 	bool_t	rdok_eof;		/* true if last entry is in result */
6237c478bd9Sstevel@tonic-gate 	struct dirent64 *rdok_entries;	/* variable number of entries */
6247c478bd9Sstevel@tonic-gate };
6257c478bd9Sstevel@tonic-gate 
6267c478bd9Sstevel@tonic-gate /*
6277c478bd9Sstevel@tonic-gate  * Readdir result
6287c478bd9Sstevel@tonic-gate  */
6297c478bd9Sstevel@tonic-gate struct nfsrddirres {
6307c478bd9Sstevel@tonic-gate 	nfsstat	rd_status;
6317c478bd9Sstevel@tonic-gate 	uint_t		rd_bufsize;	/* client request size (not xdr'ed) */
6327c478bd9Sstevel@tonic-gate 	union {
6337c478bd9Sstevel@tonic-gate 		struct nfsrdok rd_rdok_u;
6347c478bd9Sstevel@tonic-gate 	} rd_u;
6357c478bd9Sstevel@tonic-gate };
6367c478bd9Sstevel@tonic-gate #define	rd_rdok		rd_u.rd_rdok_u
6377c478bd9Sstevel@tonic-gate #define	rd_offset	rd_u.rd_rdok_u.rdok_offset
6387c478bd9Sstevel@tonic-gate #define	rd_size		rd_u.rd_rdok_u.rdok_size
6397c478bd9Sstevel@tonic-gate #define	rd_eof		rd_u.rd_rdok_u.rdok_eof
6407c478bd9Sstevel@tonic-gate #define	rd_entries	rd_u.rd_rdok_u.rdok_entries
6417c478bd9Sstevel@tonic-gate 
6427c478bd9Sstevel@tonic-gate 
6437c478bd9Sstevel@tonic-gate /*
6447c478bd9Sstevel@tonic-gate  * Arguments for directory operations
6457c478bd9Sstevel@tonic-gate  */
6467c478bd9Sstevel@tonic-gate struct nfsdiropargs {
6477c478bd9Sstevel@tonic-gate 	fhandle_t	*da_fhandle;	/* pointer to directory file handle */
6487c478bd9Sstevel@tonic-gate 	char		*da_name;	/* name (up to NFS_MAXNAMLEN bytes) */
6497c478bd9Sstevel@tonic-gate 	fhandle_t	da_fhandle_buf;	/* directory file handle */
6507c478bd9Sstevel@tonic-gate 	int		da_flags;	/* flags, see below */
6517c478bd9Sstevel@tonic-gate };
6527c478bd9Sstevel@tonic-gate #define	DA_FREENAME	1
6537c478bd9Sstevel@tonic-gate 
6547c478bd9Sstevel@tonic-gate /*
6557c478bd9Sstevel@tonic-gate  * NFS_OK part of directory operation result
6567c478bd9Sstevel@tonic-gate  */
6577c478bd9Sstevel@tonic-gate struct  nfsdrok {
6587c478bd9Sstevel@tonic-gate 	fhandle_t	drok_fhandle;	/* result file handle */
6597c478bd9Sstevel@tonic-gate 	struct nfsfattr	drok_attr;	/* result file attributes */
6607c478bd9Sstevel@tonic-gate };
6617c478bd9Sstevel@tonic-gate 
6627c478bd9Sstevel@tonic-gate /*
6637c478bd9Sstevel@tonic-gate  * Results from directory operation
6647c478bd9Sstevel@tonic-gate  */
6657c478bd9Sstevel@tonic-gate struct  nfsdiropres {
6667c478bd9Sstevel@tonic-gate 	nfsstat	dr_status;			/* result status */
6677c478bd9Sstevel@tonic-gate 	union {
6687c478bd9Sstevel@tonic-gate 		struct  nfsdrok	dr_drok_u;	/* NFS_OK result */
6697c478bd9Sstevel@tonic-gate 	} dr_u;
6707c478bd9Sstevel@tonic-gate };
6717c478bd9Sstevel@tonic-gate #define	dr_drok		dr_u.dr_drok_u
6727c478bd9Sstevel@tonic-gate #define	dr_fhandle	dr_u.dr_drok_u.drok_fhandle
6737c478bd9Sstevel@tonic-gate #define	dr_attr		dr_u.dr_drok_u.drok_attr
6747c478bd9Sstevel@tonic-gate 
6757c478bd9Sstevel@tonic-gate /*
6767c478bd9Sstevel@tonic-gate  * arguments to setattr
6777c478bd9Sstevel@tonic-gate  */
6787c478bd9Sstevel@tonic-gate struct nfssaargs {
6797c478bd9Sstevel@tonic-gate 	fhandle_t	saa_fh;		/* fhandle of file to be set */
6807c478bd9Sstevel@tonic-gate 	struct nfssattr	saa_sa;		/* new attributes */
6817c478bd9Sstevel@tonic-gate };
6827c478bd9Sstevel@tonic-gate 
6837c478bd9Sstevel@tonic-gate /*
6847c478bd9Sstevel@tonic-gate  * arguments to create and mkdir
6857c478bd9Sstevel@tonic-gate  */
6867c478bd9Sstevel@tonic-gate struct nfscreatargs {
6877c478bd9Sstevel@tonic-gate 	struct nfsdiropargs	ca_da;	/* file name to create and parent dir */
6887c478bd9Sstevel@tonic-gate 	struct nfssattr		*ca_sa;	/* initial attributes */
6897c478bd9Sstevel@tonic-gate 	struct nfssattr		ca_sa_buf;	/* space to store attributes */
6907c478bd9Sstevel@tonic-gate };
6917c478bd9Sstevel@tonic-gate 
6927c478bd9Sstevel@tonic-gate /*
6937c478bd9Sstevel@tonic-gate  * arguments to link
6947c478bd9Sstevel@tonic-gate  */
6957c478bd9Sstevel@tonic-gate struct nfslinkargs {
6967c478bd9Sstevel@tonic-gate 	fhandle_t		*la_from;	/* old file */
6977c478bd9Sstevel@tonic-gate 	fhandle_t		la_from_buf;	/* old file */
6987c478bd9Sstevel@tonic-gate 	struct nfsdiropargs	la_to;		/* new file and parent dir */
6997c478bd9Sstevel@tonic-gate };
7007c478bd9Sstevel@tonic-gate 
7017c478bd9Sstevel@tonic-gate /*
7027c478bd9Sstevel@tonic-gate  * arguments to rename
7037c478bd9Sstevel@tonic-gate  */
7047c478bd9Sstevel@tonic-gate struct nfsrnmargs {
7057c478bd9Sstevel@tonic-gate 	struct nfsdiropargs rna_from;	/* old file and parent dir */
7067c478bd9Sstevel@tonic-gate 	struct nfsdiropargs rna_to;	/* new file and parent dir */
7077c478bd9Sstevel@tonic-gate };
7087c478bd9Sstevel@tonic-gate 
7097c478bd9Sstevel@tonic-gate /*
7107c478bd9Sstevel@tonic-gate  * arguments to symlink
7117c478bd9Sstevel@tonic-gate  */
7127c478bd9Sstevel@tonic-gate struct nfsslargs {
7137c478bd9Sstevel@tonic-gate 	struct nfsdiropargs	sla_from;	/* old file and parent dir */
7147c478bd9Sstevel@tonic-gate 	char			*sla_tnm;	/* new name */
7157c478bd9Sstevel@tonic-gate 	int			sla_tnm_flags;	/* flags for name */
7167c478bd9Sstevel@tonic-gate 	struct nfssattr		*sla_sa;	/* attributes */
7177c478bd9Sstevel@tonic-gate 	struct nfssattr		sla_sa_buf;	/* attributes buffer */
7187c478bd9Sstevel@tonic-gate };
7197c478bd9Sstevel@tonic-gate #define	SLA_FREETNM	1
7207c478bd9Sstevel@tonic-gate 
7217c478bd9Sstevel@tonic-gate /*
7227c478bd9Sstevel@tonic-gate  * NFS_OK part of statfs operation
7237c478bd9Sstevel@tonic-gate  */
7247c478bd9Sstevel@tonic-gate struct nfsstatfsok {
7257c478bd9Sstevel@tonic-gate 	uint32_t fsok_tsize;	/* preferred transfer size in bytes */
7267c478bd9Sstevel@tonic-gate 	uint32_t fsok_bsize;	/* fundamental file system block size */
7277c478bd9Sstevel@tonic-gate 	uint32_t fsok_blocks;	/* total blocks in file system */
7287c478bd9Sstevel@tonic-gate 	uint32_t fsok_bfree;	/* free blocks in fs */
7297c478bd9Sstevel@tonic-gate 	uint32_t fsok_bavail;	/* free blocks avail to non-superuser */
7307c478bd9Sstevel@tonic-gate };
7317c478bd9Sstevel@tonic-gate 
7327c478bd9Sstevel@tonic-gate /*
7337c478bd9Sstevel@tonic-gate  * Results of statfs operation
7347c478bd9Sstevel@tonic-gate  */
7357c478bd9Sstevel@tonic-gate struct nfsstatfs {
7367c478bd9Sstevel@tonic-gate 	nfsstat	fs_status;			/* result status */
7377c478bd9Sstevel@tonic-gate 	union {
7387c478bd9Sstevel@tonic-gate 		struct	nfsstatfsok fs_fsok_u;	/* NFS_OK result */
7397c478bd9Sstevel@tonic-gate 	} fs_u;
7407c478bd9Sstevel@tonic-gate };
7417c478bd9Sstevel@tonic-gate #define	fs_fsok		fs_u.fs_fsok_u
7427c478bd9Sstevel@tonic-gate #define	fs_tsize	fs_u.fs_fsok_u.fsok_tsize
7437c478bd9Sstevel@tonic-gate #define	fs_bsize	fs_u.fs_fsok_u.fsok_bsize
7447c478bd9Sstevel@tonic-gate #define	fs_blocks	fs_u.fs_fsok_u.fsok_blocks
7457c478bd9Sstevel@tonic-gate #define	fs_bfree	fs_u.fs_fsok_u.fsok_bfree
7467c478bd9Sstevel@tonic-gate #define	fs_bavail	fs_u.fs_fsok_u.fsok_bavail
7477c478bd9Sstevel@tonic-gate 
7487c478bd9Sstevel@tonic-gate #ifdef _KERNEL
7497c478bd9Sstevel@tonic-gate /*
7507c478bd9Sstevel@tonic-gate  * XDR routines for handling structures defined above
7517c478bd9Sstevel@tonic-gate  */
752*5cb0d679SMarcel Telka extern bool_t	xdr_attrstat(XDR *, struct nfsattrstat *);
753*5cb0d679SMarcel Telka extern bool_t	xdr_fastattrstat(XDR *, struct nfsattrstat *);
754*5cb0d679SMarcel Telka extern bool_t	xdr_creatargs(XDR *, struct nfscreatargs *);
755*5cb0d679SMarcel Telka extern bool_t	xdr_diropargs(XDR *, struct nfsdiropargs *);
756*5cb0d679SMarcel Telka extern bool_t	xdr_diropres(XDR *, struct nfsdiropres *);
757*5cb0d679SMarcel Telka extern bool_t	xdr_fastdiropres(XDR *, struct nfsdiropres *);
758*5cb0d679SMarcel Telka extern bool_t	xdr_drok(XDR *, struct nfsdrok *);
7597c478bd9Sstevel@tonic-gate #ifdef _LITTLE_ENDIAN
760*5cb0d679SMarcel Telka extern bool_t	xdr_fastdrok(XDR *, struct nfsdrok *);
761*5cb0d679SMarcel Telka extern bool_t	xdr_fastfattr(XDR *, struct nfsfattr *);
7627c478bd9Sstevel@tonic-gate #endif
763*5cb0d679SMarcel Telka extern bool_t	xdr_fattr(XDR *, struct nfsfattr *);
764*5cb0d679SMarcel Telka extern bool_t	xdr_fhandle(XDR *, fhandle_t *);
765*5cb0d679SMarcel Telka extern bool_t	xdr_fastfhandle(XDR *, fhandle_t **);
766*5cb0d679SMarcel Telka extern bool_t	xdr_linkargs(XDR *, struct nfslinkargs *);
767*5cb0d679SMarcel Telka extern bool_t	xdr_rddirargs(XDR *, struct nfsrddirargs *);
768*5cb0d679SMarcel Telka extern bool_t	xdr_putrddirres(XDR *, struct nfsrddirres *);
769*5cb0d679SMarcel Telka extern bool_t	xdr_getrddirres(XDR *, struct nfsrddirres *);
770*5cb0d679SMarcel Telka extern bool_t	xdr_rdlnres(XDR *, struct nfsrdlnres *);
771*5cb0d679SMarcel Telka extern bool_t	xdr_rdresult(XDR *, struct nfsrdresult *);
772*5cb0d679SMarcel Telka extern bool_t	xdr_readargs(XDR *, struct nfsreadargs *);
773*5cb0d679SMarcel Telka extern bool_t	xdr_readlink(XDR *, fhandle_t *);
774*5cb0d679SMarcel Telka extern bool_t	xdr_rnmargs(XDR *, struct nfsrnmargs *);
775*5cb0d679SMarcel Telka extern bool_t	xdr_rrok(XDR *, struct nfsrrok *);
776*5cb0d679SMarcel Telka extern bool_t	xdr_saargs(XDR *, struct nfssaargs *);
777*5cb0d679SMarcel Telka extern bool_t	xdr_sattr(XDR *, struct nfssattr *);
778*5cb0d679SMarcel Telka extern bool_t	xdr_slargs(XDR *, struct nfsslargs *);
779*5cb0d679SMarcel Telka extern bool_t	xdr_srok(XDR *, struct nfssrok *);
780*5cb0d679SMarcel Telka extern bool_t	xdr_nfs2_timeval(XDR *, struct nfs2_timeval *);
781*5cb0d679SMarcel Telka extern bool_t	xdr_writeargs(XDR *, struct nfswriteargs *);
782*5cb0d679SMarcel Telka extern bool_t	xdr_fsok(XDR *, struct nfsstatfsok *);
7837c478bd9Sstevel@tonic-gate #ifdef _LITTLE_ENDIAN
784*5cb0d679SMarcel Telka extern bool_t	xdr_fastfsok(XDR *, struct nfsstatfsok *);
785*5cb0d679SMarcel Telka extern bool_t	xdr_fastenum(XDR *, enum_t *);
7867c478bd9Sstevel@tonic-gate #endif
787*5cb0d679SMarcel Telka extern bool_t	xdr_statfs(XDR *, struct nfsstatfs *);
788*5cb0d679SMarcel Telka extern bool_t	xdr_faststatfs(XDR *, struct nfsstatfs *);
7897c478bd9Sstevel@tonic-gate #endif
7907c478bd9Sstevel@tonic-gate 
7917c478bd9Sstevel@tonic-gate /*
7927c478bd9Sstevel@tonic-gate  * Remote file service routines
7937c478bd9Sstevel@tonic-gate  */
7947c478bd9Sstevel@tonic-gate #define	RFS_NULL	0
7957c478bd9Sstevel@tonic-gate #define	RFS_GETATTR	1
7967c478bd9Sstevel@tonic-gate #define	RFS_SETATTR	2
7977c478bd9Sstevel@tonic-gate #define	RFS_ROOT	3
7987c478bd9Sstevel@tonic-gate #define	RFS_LOOKUP	4
7997c478bd9Sstevel@tonic-gate #define	RFS_READLINK	5
8007c478bd9Sstevel@tonic-gate #define	RFS_READ	6
8017c478bd9Sstevel@tonic-gate #define	RFS_WRITECACHE	7
8027c478bd9Sstevel@tonic-gate #define	RFS_WRITE	8
8037c478bd9Sstevel@tonic-gate #define	RFS_CREATE	9
8047c478bd9Sstevel@tonic-gate #define	RFS_REMOVE	10
8057c478bd9Sstevel@tonic-gate #define	RFS_RENAME	11
8067c478bd9Sstevel@tonic-gate #define	RFS_LINK	12
8077c478bd9Sstevel@tonic-gate #define	RFS_SYMLINK	13
8087c478bd9Sstevel@tonic-gate #define	RFS_MKDIR	14
8097c478bd9Sstevel@tonic-gate #define	RFS_RMDIR	15
8107c478bd9Sstevel@tonic-gate #define	RFS_READDIR	16
8117c478bd9Sstevel@tonic-gate #define	RFS_STATFS	17
8127c478bd9Sstevel@tonic-gate #define	RFS_NPROC	18
8137c478bd9Sstevel@tonic-gate 
8147c478bd9Sstevel@tonic-gate #ifdef _KERNEL
8157c478bd9Sstevel@tonic-gate /*
8167c478bd9Sstevel@tonic-gate  * The NFS Version 2 service procedures
8177c478bd9Sstevel@tonic-gate  */
8187c478bd9Sstevel@tonic-gate struct exportinfo;	/* defined in nfs/export.h */
8197c478bd9Sstevel@tonic-gate struct servinfo;	/* defined in nfs/nfs_clnt.h */
8207c478bd9Sstevel@tonic-gate struct mntinfo;		/* defined in nfs/nfs_clnt.h */
8217c478bd9Sstevel@tonic-gate 
822*5cb0d679SMarcel Telka extern void	rfs_getattr(fhandle_t *, struct nfsattrstat *,
823*5cb0d679SMarcel Telka     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
824*5cb0d679SMarcel Telka extern void	*rfs_getattr_getfh(fhandle_t *);
825*5cb0d679SMarcel Telka extern void	rfs_setattr(struct nfssaargs *, struct nfsattrstat *,
826*5cb0d679SMarcel Telka     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
827*5cb0d679SMarcel Telka extern void	*rfs_setattr_getfh(struct nfssaargs *);
828*5cb0d679SMarcel Telka extern void	rfs_lookup(struct nfsdiropargs *, struct nfsdiropres *,
829*5cb0d679SMarcel Telka     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
830*5cb0d679SMarcel Telka extern void	*rfs_lookup_getfh(struct nfsdiropargs *);
831*5cb0d679SMarcel Telka extern void	rfs_readlink(fhandle_t *, struct nfsrdlnres *,
832*5cb0d679SMarcel Telka     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
833*5cb0d679SMarcel Telka extern void	*rfs_readlink_getfh(fhandle_t *);
834*5cb0d679SMarcel Telka extern void	rfs_rlfree(struct nfsrdlnres *);
835*5cb0d679SMarcel Telka extern void	rfs_read(struct nfsreadargs *, struct nfsrdresult *,
836*5cb0d679SMarcel Telka     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
837*5cb0d679SMarcel Telka extern void	*rfs_read_getfh(struct nfsreadargs *);
838*5cb0d679SMarcel Telka extern void	rfs_rdfree(struct nfsrdresult *);
839*5cb0d679SMarcel Telka extern void	rfs_write_sync(struct nfswriteargs *, struct nfsattrstat *,
840*5cb0d679SMarcel Telka     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
841*5cb0d679SMarcel Telka extern void	rfs_write(struct nfswriteargs *, struct nfsattrstat *,
842*5cb0d679SMarcel Telka     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
843*5cb0d679SMarcel Telka extern void	*rfs_write_getfh(struct nfswriteargs *);
844*5cb0d679SMarcel Telka extern void	rfs_create(struct nfscreatargs *, struct nfsdiropres *,
845*5cb0d679SMarcel Telka     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
846*5cb0d679SMarcel Telka extern void	*rfs_create_getfh(struct nfscreatargs *);
847*5cb0d679SMarcel Telka extern void	rfs_remove(struct nfsdiropargs *, enum nfsstat *,
848*5cb0d679SMarcel Telka     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
849*5cb0d679SMarcel Telka extern void	*rfs_remove_getfh(struct nfsdiropargs *);
850*5cb0d679SMarcel Telka extern void	rfs_rename(struct nfsrnmargs *, enum nfsstat *,
851*5cb0d679SMarcel Telka     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
852*5cb0d679SMarcel Telka extern void	*rfs_rename_getfh(struct nfsrnmargs *);
853*5cb0d679SMarcel Telka extern void	rfs_link(struct nfslinkargs *, enum nfsstat *,
854*5cb0d679SMarcel Telka     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
855*5cb0d679SMarcel Telka extern void	*rfs_link_getfh(struct nfslinkargs *);
856*5cb0d679SMarcel Telka extern void	rfs_symlink(struct nfsslargs *, enum nfsstat *,
857*5cb0d679SMarcel Telka     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
858*5cb0d679SMarcel Telka extern void	*rfs_symlink_getfh(struct nfsslargs *);
859*5cb0d679SMarcel Telka extern void	rfs_mkdir(struct nfscreatargs *, struct nfsdiropres *,
860*5cb0d679SMarcel Telka     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
861*5cb0d679SMarcel Telka extern void	*rfs_mkdir_getfh(struct nfscreatargs *);
862*5cb0d679SMarcel Telka extern void	rfs_rmdir(struct nfsdiropargs *, enum nfsstat *,
863*5cb0d679SMarcel Telka     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
864*5cb0d679SMarcel Telka extern void	*rfs_rmdir_getfh(struct nfsdiropargs *);
865*5cb0d679SMarcel Telka extern void	rfs_readdir(struct nfsrddirargs *, struct nfsrddirres *,
866*5cb0d679SMarcel Telka     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
867*5cb0d679SMarcel Telka extern void	*rfs_readdir_getfh(struct nfsrddirargs *);
868*5cb0d679SMarcel Telka extern void	rfs_rddirfree(struct nfsrddirres *);
869*5cb0d679SMarcel Telka extern void	rfs_statfs(fhandle_t *, struct nfsstatfs *, struct exportinfo *,
870*5cb0d679SMarcel Telka     struct svc_req *, cred_t *, bool_t);
871*5cb0d679SMarcel Telka extern void	*rfs_statfs_getfh(fhandle_t *);
872*5cb0d679SMarcel Telka extern void	rfs_srvrinit(void);
873*5cb0d679SMarcel Telka extern void	rfs_srvrfini(void);
8747c478bd9Sstevel@tonic-gate 
8757c478bd9Sstevel@tonic-gate /*
8767c478bd9Sstevel@tonic-gate  * flags to define path types during Multi Component Lookups
8777c478bd9Sstevel@tonic-gate  * using the public filehandle
8787c478bd9Sstevel@tonic-gate  */
8797c478bd9Sstevel@tonic-gate #define	URLPATH		0x01	/* Universal Resource Locator path */
8807c478bd9Sstevel@tonic-gate #define	NATIVEPATH	0x02	/* Native path, i.e., via mount protocol */
8817c478bd9Sstevel@tonic-gate #define	SECURITY_QUERY	0x04	/* Security query */
8827c478bd9Sstevel@tonic-gate 
8832f172c55SRobert Thurlow /* index for svstat_ptr */
8842f172c55SRobert Thurlow enum nfs_svccounts {NFS_CALLS, NFS_BADCALLS, NFS_REFERRALS, NFS_REFERLINKS};
8857c478bd9Sstevel@tonic-gate 
8867c478bd9Sstevel@tonic-gate /*	function defs for NFS kernel */
887*5cb0d679SMarcel Telka extern int	nfs_waitfor_purge_complete(vnode_t *);
888*5cb0d679SMarcel Telka extern int	nfs_validate_caches(vnode_t *, cred_t *);
889*5cb0d679SMarcel Telka extern void	nfs_purge_caches(vnode_t *, int, cred_t *);
890*5cb0d679SMarcel Telka extern void	nfs_purge_rddir_cache(vnode_t *);
891*5cb0d679SMarcel Telka extern void	nfs_attrcache(vnode_t *, struct nfsfattr *, hrtime_t);
892*5cb0d679SMarcel Telka extern int	nfs_cache_fattr(vnode_t *, struct nfsfattr *, vattr_t *,
893*5cb0d679SMarcel Telka     hrtime_t, cred_t *);
894*5cb0d679SMarcel Telka extern void	nfs_attr_cache(vnode_t *, vattr_t *, hrtime_t, cred_t *);
895*5cb0d679SMarcel Telka extern void	nfs_attrcache_va(vnode_t *, struct vattr *);
896*5cb0d679SMarcel Telka extern int	nfs_getattr_otw(vnode_t *, struct vattr *, cred_t *);
897*5cb0d679SMarcel Telka extern int	nfsgetattr(vnode_t *, struct vattr *, cred_t *);
898*5cb0d679SMarcel Telka extern int	nattr_to_vattr(vnode_t *, struct nfsfattr *, struct vattr *);
899*5cb0d679SMarcel Telka extern void	nfs_async_manager(struct vfs *);
900*5cb0d679SMarcel Telka extern void	nfs_async_manager_stop(struct vfs *);
901*5cb0d679SMarcel Telka extern void	nfs_async_stop(struct vfs *);
902*5cb0d679SMarcel Telka extern int	nfs_async_stop_sig(struct vfs *);
903*5cb0d679SMarcel Telka extern int	nfs_clntinit(void);
904*5cb0d679SMarcel Telka extern void	nfs_clntfini(void);
905*5cb0d679SMarcel Telka extern int	nfstsize(void);
906*5cb0d679SMarcel Telka extern int	nfs_srvinit(void);
907*5cb0d679SMarcel Telka extern void	nfs_srvfini(void);
908*5cb0d679SMarcel Telka extern int	vattr_to_sattr(struct vattr *, struct nfssattr *);
909*5cb0d679SMarcel Telka extern void	setdiropargs(struct nfsdiropargs *, char *, vnode_t *);
910*5cb0d679SMarcel Telka extern int	setdirgid(vnode_t *, gid_t *, cred_t *);
911*5cb0d679SMarcel Telka extern int	setdirmode(vnode_t *, mode_t *, cred_t *);
912*5cb0d679SMarcel Telka extern int	newnum(void);
913*5cb0d679SMarcel Telka extern char	*newname(void);
914*5cb0d679SMarcel Telka extern int	nfs_subrinit(void);
915*5cb0d679SMarcel Telka extern void	nfs_subrfini(void);
916*5cb0d679SMarcel Telka extern enum nfsstat puterrno(int);
917*5cb0d679SMarcel Telka extern int	geterrno(enum nfsstat);
918*5cb0d679SMarcel Telka extern int	nfsinit(int, char *);
919*5cb0d679SMarcel Telka extern void	nfsfini(void);
920*5cb0d679SMarcel Telka extern int	nfs_vfsinit(void);
921*5cb0d679SMarcel Telka extern void	nfs_vfsfini(void);
922*5cb0d679SMarcel Telka extern int	nfs_dump(vnode_t *, caddr_t, offset_t, offset_t,
923*5cb0d679SMarcel Telka     caller_context_t *);
924*5cb0d679SMarcel Telka extern void	nfs_perror(int, char *, ...);
925*5cb0d679SMarcel Telka extern void	nfs_cmn_err(int, int, char *, ...);
926*5cb0d679SMarcel Telka extern int	nfs_addcllock(vnode_t *, struct flock64 *);
927*5cb0d679SMarcel Telka extern void	nfs_rmcllock(vnode_t *, struct flock64 *);
928*5cb0d679SMarcel Telka extern void	nfs_lockrelease(vnode_t *, int, offset_t, cred_t *);
929*5cb0d679SMarcel Telka extern int	vattr_to_nattr(struct vattr *, struct nfsfattr *);
930*5cb0d679SMarcel Telka extern int	mount_root(char *, char *, int, struct nfs_args *, int *);
931*5cb0d679SMarcel Telka extern void	nfs_lockcompletion(vnode_t *, int);
932*5cb0d679SMarcel Telka extern void	nfs_add_locking_id(vnode_t *, pid_t, int, char *, int);
933*5cb0d679SMarcel Telka extern void	nfs3copyfh(caddr_t, vnode_t *);
934*5cb0d679SMarcel Telka extern void	nfscopyfh(caddr_t, vnode_t *);
935*5cb0d679SMarcel Telka extern int	nfs3lookup(vnode_t *, char *, vnode_t **, struct pathname *,
936*5cb0d679SMarcel Telka     int, vnode_t *, cred_t *, int);
937*5cb0d679SMarcel Telka extern int	nfslookup(vnode_t *, char *, vnode_t **, struct pathname *, int,
938e36d7b11SSebastien Roy     vnode_t *, cred_t *, int);
939*5cb0d679SMarcel Telka extern void	sv_free(struct servinfo *);
940*5cb0d679SMarcel Telka extern int	nfsauth_access(struct exportinfo *, struct svc_req *, cred_t *,
941*5cb0d679SMarcel Telka     uid_t *, gid_t *);
942*5cb0d679SMarcel Telka extern void	nfsauth_init(void);
943*5cb0d679SMarcel Telka extern void	nfsauth_fini(void);
944*5cb0d679SMarcel Telka extern int	nfs_setopts(vnode_t *, model_t, struct nfs_args *);
945*5cb0d679SMarcel Telka extern int	nfs_mount_label_policy(vfs_t *, struct netbuf *,
946*5cb0d679SMarcel Telka     struct knetconfig *, cred_t *);
947*5cb0d679SMarcel Telka extern boolean_t nfs_has_ctty(void);
948*5cb0d679SMarcel Telka extern void	nfs_srv_stop_all(void);
949*5cb0d679SMarcel Telka extern void	nfs_srv_quiesce_all(void);
950*5cb0d679SMarcel Telka extern int	rfs4_dss_setpaths(char *, size_t);
951*5cb0d679SMarcel Telka extern int	nfs_setmod_check(page_t *);
952e36d7b11SSebastien Roy 
9537c478bd9Sstevel@tonic-gate extern time_t	rfs4_lease_time;
9547c478bd9Sstevel@tonic-gate extern time_t	rfs4_grace_period;
955cee86682Scalum extern nvlist_t	*rfs4_dss_paths, *rfs4_dss_oldpaths;
956cee86682Scalum 
9577c478bd9Sstevel@tonic-gate extern kstat_named_t	*global_svstat_ptr[];
9587c478bd9Sstevel@tonic-gate 
9597c478bd9Sstevel@tonic-gate extern krwlock_t	rroklock;
9607c478bd9Sstevel@tonic-gate extern vtype_t		nf_to_vt[];
9617c478bd9Sstevel@tonic-gate extern kstat_named_t	*rfsproccnt_v2_ptr;
9627c478bd9Sstevel@tonic-gate extern kmutex_t		nfs_minor_lock;
9637c478bd9Sstevel@tonic-gate extern int		nfs_major;
9647c478bd9Sstevel@tonic-gate extern int		nfs_minor;
9657c478bd9Sstevel@tonic-gate extern vfsops_t		*nfs_vfsops;
9667c478bd9Sstevel@tonic-gate extern struct vnodeops	*nfs_vnodeops;
9677c478bd9Sstevel@tonic-gate extern const struct fs_operation_def nfs_vnodeops_template[];
9687c478bd9Sstevel@tonic-gate extern int		nfsfstyp;
969e36d7b11SSebastien Roy extern void		(*nfs_srv_quiesce_func)(void);
970e36d7b11SSebastien Roy extern int		(*nfs_srv_dss_func)(char *, size_t);
9717c478bd9Sstevel@tonic-gate 
9727c478bd9Sstevel@tonic-gate /*
9737c478bd9Sstevel@tonic-gate  * Per-zone stats as consumed by nfsstat(1m)
9747c478bd9Sstevel@tonic-gate  */
9757c478bd9Sstevel@tonic-gate struct nfs_version_stats {
9767c478bd9Sstevel@tonic-gate 	kstat_named_t	*aclreqcnt_ptr;		/* nfs_acl:0:aclreqcnt_v? */
9777c478bd9Sstevel@tonic-gate 	kstat_named_t	*aclproccnt_ptr;	/* nfs_acl:0:aclproccnt_v? */
9787c478bd9Sstevel@tonic-gate 	kstat_named_t	*rfsreqcnt_ptr;		/* nfs:0:rfsreqcnt_v? */
9797c478bd9Sstevel@tonic-gate 	kstat_named_t	*rfsproccnt_ptr;	/* nfs:0:rfsproccnt_v? */
9807c478bd9Sstevel@tonic-gate };
9817c478bd9Sstevel@tonic-gate 
9827c478bd9Sstevel@tonic-gate /*
9837c478bd9Sstevel@tonic-gate  * A bit of asymmetry: nfs:0:nfs_client isn't part of this structure.
9847c478bd9Sstevel@tonic-gate  */
9857c478bd9Sstevel@tonic-gate struct nfs_stats {
9867c478bd9Sstevel@tonic-gate 	kstat_named_t		*nfs_stats_svstat_ptr[NFS_VERSMAX + 1];
9877c478bd9Sstevel@tonic-gate 	struct nfs_version_stats	nfs_stats_v2;
9887c478bd9Sstevel@tonic-gate 	struct nfs_version_stats	nfs_stats_v3;
9897c478bd9Sstevel@tonic-gate 	struct nfs_version_stats	nfs_stats_v4;
9907c478bd9Sstevel@tonic-gate };
9917c478bd9Sstevel@tonic-gate 
9927c478bd9Sstevel@tonic-gate /*
9937c478bd9Sstevel@tonic-gate  * Key used to retrieve counters.
9947c478bd9Sstevel@tonic-gate  */
9957c478bd9Sstevel@tonic-gate extern zone_key_t nfsstat_zone_key;
9967c478bd9Sstevel@tonic-gate 
9977c478bd9Sstevel@tonic-gate /*
9987c478bd9Sstevel@tonic-gate  * Zone callback functions.
9997c478bd9Sstevel@tonic-gate  */
1000*5cb0d679SMarcel Telka extern void	*nfsstat_zone_init(zoneid_t);
1001*5cb0d679SMarcel Telka extern void	nfsstat_zone_fini(zoneid_t, void *);
10027c478bd9Sstevel@tonic-gate 
10037c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
10047c478bd9Sstevel@tonic-gate 
10057c478bd9Sstevel@tonic-gate /*
10067c478bd9Sstevel@tonic-gate  * Version 3 declarations and definitions.
10077c478bd9Sstevel@tonic-gate  */
10087c478bd9Sstevel@tonic-gate 
10097c478bd9Sstevel@tonic-gate #define	NFS3_FHSIZE 64
10107c478bd9Sstevel@tonic-gate #define	NFS3_COOKIEVERFSIZE 8
10117c478bd9Sstevel@tonic-gate #define	NFS3_CREATEVERFSIZE 8
10127c478bd9Sstevel@tonic-gate #define	NFS3_WRITEVERFSIZE 8
10137c478bd9Sstevel@tonic-gate 
10147c478bd9Sstevel@tonic-gate typedef char *filename3;
10157c478bd9Sstevel@tonic-gate 
10167c478bd9Sstevel@tonic-gate typedef char *nfspath3;
10177c478bd9Sstevel@tonic-gate 
10187c478bd9Sstevel@tonic-gate #define	nfs3nametoolong	((char *)-1)
10197c478bd9Sstevel@tonic-gate 
10207c478bd9Sstevel@tonic-gate typedef uint64 fileid3;
10217c478bd9Sstevel@tonic-gate 
10227c478bd9Sstevel@tonic-gate typedef uint64 cookie3;
10237c478bd9Sstevel@tonic-gate 
10247c478bd9Sstevel@tonic-gate typedef uint32 uid3;
10257c478bd9Sstevel@tonic-gate 
10267c478bd9Sstevel@tonic-gate typedef uint32 gid3;
10277c478bd9Sstevel@tonic-gate 
10287c478bd9Sstevel@tonic-gate typedef uint64 size3;
10297c478bd9Sstevel@tonic-gate 
10307c478bd9Sstevel@tonic-gate typedef uint64 offset3;
10317c478bd9Sstevel@tonic-gate 
10327c478bd9Sstevel@tonic-gate typedef uint32 mode3;
10337c478bd9Sstevel@tonic-gate 
10347c478bd9Sstevel@tonic-gate typedef uint32 count3;
10357c478bd9Sstevel@tonic-gate 
10367c478bd9Sstevel@tonic-gate /*
10377c478bd9Sstevel@tonic-gate  * These three are really opaque arrays, but we treat them as
10387c478bd9Sstevel@tonic-gate  * uint64 for efficiency sake
10397c478bd9Sstevel@tonic-gate  */
10407c478bd9Sstevel@tonic-gate typedef uint64 cookieverf3;
10417c478bd9Sstevel@tonic-gate 
10427c478bd9Sstevel@tonic-gate typedef uint64 createverf3;
10437c478bd9Sstevel@tonic-gate 
10447c478bd9Sstevel@tonic-gate typedef uint64 writeverf3;
10457c478bd9Sstevel@tonic-gate 
104627242a7cSthurlow typedef struct nfs_fh3 {
10477c478bd9Sstevel@tonic-gate 	uint_t fh3_length;
10487c478bd9Sstevel@tonic-gate 	union nfs_fh3_u {
10497c478bd9Sstevel@tonic-gate 		struct nfs_fh3_i {
105027242a7cSthurlow 			fhandle3_t fh3_i;
10517c478bd9Sstevel@tonic-gate 		} nfs_fh3_i;
10527c478bd9Sstevel@tonic-gate 		char data[NFS3_FHSIZE];
10537c478bd9Sstevel@tonic-gate 	} fh3_u;
10546a8ebdc3Sthurlow 	uint_t fh3_flags;
105527242a7cSthurlow } nfs_fh3;
105627242a7cSthurlow #define	fh3_fsid	fh3_u.nfs_fh3_i.fh3_i._fh3_fsid
105727242a7cSthurlow #define	fh3_len		fh3_u.nfs_fh3_i.fh3_i._fh3_len
105827242a7cSthurlow #define	fh3_data	fh3_u.nfs_fh3_i.fh3_i._fh3_data
105927242a7cSthurlow #define	fh3_xlen	fh3_u.nfs_fh3_i.fh3_i._fh3_xlen
106027242a7cSthurlow #define	fh3_xdata	fh3_u.nfs_fh3_i.fh3_i._fh3_xdata
106127242a7cSthurlow #define	FH3TOFIDP(fh)	((fid_t *)&((fh)->fh3_len))
106227242a7cSthurlow #define	FH3TOXFIDP(fh)	((fid_t *)&((fh)->fh3_xlen))
10637c478bd9Sstevel@tonic-gate 
10647c478bd9Sstevel@tonic-gate /*
10656a8ebdc3Sthurlow  * nfs_fh3.fh3_flags values
10666a8ebdc3Sthurlow  */
10676a8ebdc3Sthurlow #define	FH_WEBNFS	0x1	/* fh is WebNFS overloaded - see makefh3_ol() */
10686a8ebdc3Sthurlow 
10696a8ebdc3Sthurlow /*
10707c478bd9Sstevel@tonic-gate  * Two elements were added to the
10717c478bd9Sstevel@tonic-gate  * diropargs3 structure for performance (xdr-inlining).
10727c478bd9Sstevel@tonic-gate  * They are not included as part of the args
10737c478bd9Sstevel@tonic-gate  * that are encoded or decoded:
10747c478bd9Sstevel@tonic-gate  * dirp - ptr to the nfs_fh3
10757c478bd9Sstevel@tonic-gate  * flag indicating when to free the name that was
10767c478bd9Sstevel@tonic-gate  * allocated during decode.
10777c478bd9Sstevel@tonic-gate  */
10787c478bd9Sstevel@tonic-gate struct diropargs3 {
10797c478bd9Sstevel@tonic-gate 	nfs_fh3 *dirp;
10807c478bd9Sstevel@tonic-gate 	nfs_fh3 dir;
10817c478bd9Sstevel@tonic-gate 	filename3 name;
10827c478bd9Sstevel@tonic-gate 	int flags;
10837c478bd9Sstevel@tonic-gate };
10847c478bd9Sstevel@tonic-gate typedef struct diropargs3 diropargs3;
10857c478bd9Sstevel@tonic-gate 
10867c478bd9Sstevel@tonic-gate struct nfstime3 {
10877c478bd9Sstevel@tonic-gate 	uint32 seconds;
10887c478bd9Sstevel@tonic-gate 	uint32 nseconds;
10897c478bd9Sstevel@tonic-gate };
10907c478bd9Sstevel@tonic-gate typedef struct nfstime3 nfstime3;
10917c478bd9Sstevel@tonic-gate 
10927c478bd9Sstevel@tonic-gate struct specdata3 {
10937c478bd9Sstevel@tonic-gate 	uint32 specdata1;
10947c478bd9Sstevel@tonic-gate 	uint32 specdata2;
10957c478bd9Sstevel@tonic-gate };
10967c478bd9Sstevel@tonic-gate typedef struct specdata3 specdata3;
10977c478bd9Sstevel@tonic-gate 
10987c478bd9Sstevel@tonic-gate enum nfsstat3 {
10997c478bd9Sstevel@tonic-gate 	NFS3_OK = 0,
11007c478bd9Sstevel@tonic-gate 	NFS3ERR_PERM = 1,
11017c478bd9Sstevel@tonic-gate 	NFS3ERR_NOENT = 2,
11027c478bd9Sstevel@tonic-gate 	NFS3ERR_IO = 5,
11037c478bd9Sstevel@tonic-gate 	NFS3ERR_NXIO = 6,
11047c478bd9Sstevel@tonic-gate 	NFS3ERR_ACCES = 13,
11057c478bd9Sstevel@tonic-gate 	NFS3ERR_EXIST = 17,
11067c478bd9Sstevel@tonic-gate 	NFS3ERR_XDEV = 18,
11077c478bd9Sstevel@tonic-gate 	NFS3ERR_NODEV = 19,
11087c478bd9Sstevel@tonic-gate 	NFS3ERR_NOTDIR = 20,
11097c478bd9Sstevel@tonic-gate 	NFS3ERR_ISDIR = 21,
11107c478bd9Sstevel@tonic-gate 	NFS3ERR_INVAL = 22,
11117c478bd9Sstevel@tonic-gate 	NFS3ERR_FBIG = 27,
11127c478bd9Sstevel@tonic-gate 	NFS3ERR_NOSPC = 28,
11137c478bd9Sstevel@tonic-gate 	NFS3ERR_ROFS = 30,
11147c478bd9Sstevel@tonic-gate 	NFS3ERR_MLINK = 31,
11157c478bd9Sstevel@tonic-gate 	NFS3ERR_NAMETOOLONG = 63,
11167c478bd9Sstevel@tonic-gate 	NFS3ERR_NOTEMPTY = 66,
11177c478bd9Sstevel@tonic-gate 	NFS3ERR_DQUOT = 69,
11187c478bd9Sstevel@tonic-gate 	NFS3ERR_STALE = 70,
11197c478bd9Sstevel@tonic-gate 	NFS3ERR_REMOTE = 71,
11207c478bd9Sstevel@tonic-gate 	NFS3ERR_BADHANDLE = 10001,
11217c478bd9Sstevel@tonic-gate 	NFS3ERR_NOT_SYNC = 10002,
11227c478bd9Sstevel@tonic-gate 	NFS3ERR_BAD_COOKIE = 10003,
11237c478bd9Sstevel@tonic-gate 	NFS3ERR_NOTSUPP = 10004,
11247c478bd9Sstevel@tonic-gate 	NFS3ERR_TOOSMALL = 10005,
11257c478bd9Sstevel@tonic-gate 	NFS3ERR_SERVERFAULT = 10006,
11267c478bd9Sstevel@tonic-gate 	NFS3ERR_BADTYPE = 10007,
11277c478bd9Sstevel@tonic-gate 	NFS3ERR_JUKEBOX = 10008
11287c478bd9Sstevel@tonic-gate };
11297c478bd9Sstevel@tonic-gate typedef enum nfsstat3 nfsstat3;
11307c478bd9Sstevel@tonic-gate 
11317c478bd9Sstevel@tonic-gate enum ftype3 {
11327c478bd9Sstevel@tonic-gate 	NF3REG = 1,
11337c478bd9Sstevel@tonic-gate 	NF3DIR = 2,
11347c478bd9Sstevel@tonic-gate 	NF3BLK = 3,
11357c478bd9Sstevel@tonic-gate 	NF3CHR = 4,
11367c478bd9Sstevel@tonic-gate 	NF3LNK = 5,
11377c478bd9Sstevel@tonic-gate 	NF3SOCK = 6,
11387c478bd9Sstevel@tonic-gate 	NF3FIFO = 7
11397c478bd9Sstevel@tonic-gate };
11407c478bd9Sstevel@tonic-gate typedef enum ftype3 ftype3;
11417c478bd9Sstevel@tonic-gate 
11427c478bd9Sstevel@tonic-gate struct fattr3 {
11437c478bd9Sstevel@tonic-gate 	ftype3 type;
11447c478bd9Sstevel@tonic-gate 	mode3 mode;
11457c478bd9Sstevel@tonic-gate 	uint32 nlink;
11467c478bd9Sstevel@tonic-gate 	uid3 uid;
11477c478bd9Sstevel@tonic-gate 	gid3 gid;
11487c478bd9Sstevel@tonic-gate 	size3 size;
11497c478bd9Sstevel@tonic-gate 	size3 used;
11507c478bd9Sstevel@tonic-gate 	specdata3 rdev;
11517c478bd9Sstevel@tonic-gate 	uint64 fsid;
11527c478bd9Sstevel@tonic-gate 	fileid3 fileid;
11537c478bd9Sstevel@tonic-gate 	nfstime3 atime;
11547c478bd9Sstevel@tonic-gate 	nfstime3 mtime;
11557c478bd9Sstevel@tonic-gate 	nfstime3 ctime;
11567c478bd9Sstevel@tonic-gate };
11577c478bd9Sstevel@tonic-gate typedef struct fattr3 fattr3;
11587c478bd9Sstevel@tonic-gate 
11597c478bd9Sstevel@tonic-gate #define	NFS3_SIZEOF_FATTR3	(21)
11607c478bd9Sstevel@tonic-gate 
11617c478bd9Sstevel@tonic-gate #ifdef _KERNEL
11627c478bd9Sstevel@tonic-gate struct fattr3_res {
11637c478bd9Sstevel@tonic-gate 	nfsstat3 status;
11647c478bd9Sstevel@tonic-gate 	vattr_t *vap;
11657c478bd9Sstevel@tonic-gate 	vnode_t *vp;
11667c478bd9Sstevel@tonic-gate };
11677c478bd9Sstevel@tonic-gate typedef struct fattr3_res fattr3_res;
11687c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
11697c478bd9Sstevel@tonic-gate 
11707c478bd9Sstevel@tonic-gate struct post_op_attr {
11717c478bd9Sstevel@tonic-gate 	bool_t attributes;
11727c478bd9Sstevel@tonic-gate 	fattr3 attr;
11737c478bd9Sstevel@tonic-gate };
11747c478bd9Sstevel@tonic-gate typedef struct post_op_attr post_op_attr;
11757c478bd9Sstevel@tonic-gate 
11767c478bd9Sstevel@tonic-gate #ifdef _KERNEL
11777c478bd9Sstevel@tonic-gate struct post_op_vattr {
11787c478bd9Sstevel@tonic-gate 	bool_t		attributes;
11797c478bd9Sstevel@tonic-gate 	fattr3_res	fres;
11807c478bd9Sstevel@tonic-gate };
11817c478bd9Sstevel@tonic-gate typedef struct post_op_vattr post_op_vattr;
11827c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
11837c478bd9Sstevel@tonic-gate 
11847c478bd9Sstevel@tonic-gate struct wcc_attr {
11857c478bd9Sstevel@tonic-gate 	size3 size;
11867c478bd9Sstevel@tonic-gate 	nfstime3 mtime;
11877c478bd9Sstevel@tonic-gate 	nfstime3 ctime;
11887c478bd9Sstevel@tonic-gate };
11897c478bd9Sstevel@tonic-gate typedef struct wcc_attr wcc_attr;
11907c478bd9Sstevel@tonic-gate 
11917c478bd9Sstevel@tonic-gate struct pre_op_attr {
11927c478bd9Sstevel@tonic-gate 	bool_t attributes;
11937c478bd9Sstevel@tonic-gate 	wcc_attr attr;
11947c478bd9Sstevel@tonic-gate };
11957c478bd9Sstevel@tonic-gate typedef struct pre_op_attr pre_op_attr;
11967c478bd9Sstevel@tonic-gate 
11977c478bd9Sstevel@tonic-gate struct wcc_data {
11987c478bd9Sstevel@tonic-gate 	pre_op_attr before;
11997c478bd9Sstevel@tonic-gate 	post_op_attr after;
12007c478bd9Sstevel@tonic-gate };
12017c478bd9Sstevel@tonic-gate typedef struct wcc_data wcc_data;
12027c478bd9Sstevel@tonic-gate 
12037c478bd9Sstevel@tonic-gate struct post_op_fh3 {
12047c478bd9Sstevel@tonic-gate 	bool_t handle_follows;
12057c478bd9Sstevel@tonic-gate 	nfs_fh3 handle;
12067c478bd9Sstevel@tonic-gate };
12077c478bd9Sstevel@tonic-gate typedef struct post_op_fh3 post_op_fh3;
12087c478bd9Sstevel@tonic-gate 
12097c478bd9Sstevel@tonic-gate enum time_how {
12107c478bd9Sstevel@tonic-gate 	DONT_CHANGE = 0,
12117c478bd9Sstevel@tonic-gate 	SET_TO_SERVER_TIME = 1,
12127c478bd9Sstevel@tonic-gate 	SET_TO_CLIENT_TIME = 2
12137c478bd9Sstevel@tonic-gate };
12147c478bd9Sstevel@tonic-gate typedef enum time_how time_how;
12157c478bd9Sstevel@tonic-gate 
12167c478bd9Sstevel@tonic-gate struct set_mode3 {
12177c478bd9Sstevel@tonic-gate 	bool_t set_it;
12187c478bd9Sstevel@tonic-gate 	mode3 mode;
12197c478bd9Sstevel@tonic-gate };
12207c478bd9Sstevel@tonic-gate typedef struct set_mode3 set_mode3;
12217c478bd9Sstevel@tonic-gate 
12227c478bd9Sstevel@tonic-gate struct set_uid3 {
12237c478bd9Sstevel@tonic-gate 	bool_t set_it;
12247c478bd9Sstevel@tonic-gate 	uid3 uid;
12257c478bd9Sstevel@tonic-gate };
12267c478bd9Sstevel@tonic-gate typedef struct set_uid3 set_uid3;
12277c478bd9Sstevel@tonic-gate 
12287c478bd9Sstevel@tonic-gate struct set_gid3 {
12297c478bd9Sstevel@tonic-gate 	bool_t set_it;
12307c478bd9Sstevel@tonic-gate 	gid3 gid;
12317c478bd9Sstevel@tonic-gate };
12327c478bd9Sstevel@tonic-gate typedef struct set_gid3 set_gid3;
12337c478bd9Sstevel@tonic-gate 
12347c478bd9Sstevel@tonic-gate struct set_size3 {
12357c478bd9Sstevel@tonic-gate 	bool_t set_it;
12367c478bd9Sstevel@tonic-gate 	size3 size;
12377c478bd9Sstevel@tonic-gate };
12387c478bd9Sstevel@tonic-gate typedef struct set_size3 set_size3;
12397c478bd9Sstevel@tonic-gate 
12407c478bd9Sstevel@tonic-gate struct set_atime {
12417c478bd9Sstevel@tonic-gate 	time_how set_it;
12427c478bd9Sstevel@tonic-gate 	nfstime3 atime;
12437c478bd9Sstevel@tonic-gate };
12447c478bd9Sstevel@tonic-gate typedef struct set_atime set_atime;
12457c478bd9Sstevel@tonic-gate 
12467c478bd9Sstevel@tonic-gate struct set_mtime {
12477c478bd9Sstevel@tonic-gate 	time_how set_it;
12487c478bd9Sstevel@tonic-gate 	nfstime3 mtime;
12497c478bd9Sstevel@tonic-gate };
12507c478bd9Sstevel@tonic-gate typedef struct set_mtime set_mtime;
12517c478bd9Sstevel@tonic-gate 
12527c478bd9Sstevel@tonic-gate struct sattr3 {
12537c478bd9Sstevel@tonic-gate 	set_mode3 mode;
12547c478bd9Sstevel@tonic-gate 	set_uid3 uid;
12557c478bd9Sstevel@tonic-gate 	set_gid3 gid;
12567c478bd9Sstevel@tonic-gate 	set_size3 size;
12577c478bd9Sstevel@tonic-gate 	set_atime atime;
12587c478bd9Sstevel@tonic-gate 	set_mtime mtime;
12597c478bd9Sstevel@tonic-gate };
12607c478bd9Sstevel@tonic-gate typedef struct sattr3 sattr3;
12617c478bd9Sstevel@tonic-gate 
12627c478bd9Sstevel@tonic-gate /*
12637c478bd9Sstevel@tonic-gate  * A couple of defines to make resok and resfail look like the
12647c478bd9Sstevel@tonic-gate  * correct things in a response type independent manner.
12657c478bd9Sstevel@tonic-gate  */
12667c478bd9Sstevel@tonic-gate #define	resok	res_u.ok
12677c478bd9Sstevel@tonic-gate #define	resfail	res_u.fail
12687c478bd9Sstevel@tonic-gate 
12697c478bd9Sstevel@tonic-gate struct GETATTR3args {
12707c478bd9Sstevel@tonic-gate 	nfs_fh3 object;
12717c478bd9Sstevel@tonic-gate };
12727c478bd9Sstevel@tonic-gate typedef struct GETATTR3args GETATTR3args;
12737c478bd9Sstevel@tonic-gate 
12747c478bd9Sstevel@tonic-gate struct GETATTR3resok {
12757c478bd9Sstevel@tonic-gate 	fattr3 obj_attributes;
12767c478bd9Sstevel@tonic-gate };
12777c478bd9Sstevel@tonic-gate typedef struct GETATTR3resok GETATTR3resok;
12787c478bd9Sstevel@tonic-gate 
12797c478bd9Sstevel@tonic-gate struct GETATTR3res {
12807c478bd9Sstevel@tonic-gate 	nfsstat3 status;
12817c478bd9Sstevel@tonic-gate 	union {
12827c478bd9Sstevel@tonic-gate 		GETATTR3resok ok;
12837c478bd9Sstevel@tonic-gate 	} res_u;
12847c478bd9Sstevel@tonic-gate };
12857c478bd9Sstevel@tonic-gate typedef struct GETATTR3res GETATTR3res;
12867c478bd9Sstevel@tonic-gate 
12877c478bd9Sstevel@tonic-gate #ifdef _KERNEL
12887c478bd9Sstevel@tonic-gate struct GETATTR3vres {
12897c478bd9Sstevel@tonic-gate 	nfsstat3 status;
12907c478bd9Sstevel@tonic-gate 	fattr3_res fres;
12917c478bd9Sstevel@tonic-gate };
12927c478bd9Sstevel@tonic-gate typedef struct GETATTR3vres GETATTR3vres;
12937c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
12947c478bd9Sstevel@tonic-gate 
12957c478bd9Sstevel@tonic-gate struct sattrguard3 {
12967c478bd9Sstevel@tonic-gate 	bool_t check;
12977c478bd9Sstevel@tonic-gate 	nfstime3 obj_ctime;
12987c478bd9Sstevel@tonic-gate };
12997c478bd9Sstevel@tonic-gate typedef struct sattrguard3 sattrguard3;
13007c478bd9Sstevel@tonic-gate 
13017c478bd9Sstevel@tonic-gate struct SETATTR3args {
13027c478bd9Sstevel@tonic-gate 	nfs_fh3 object;
13037c478bd9Sstevel@tonic-gate 	sattr3 new_attributes;
13047c478bd9Sstevel@tonic-gate 	sattrguard3 guard;
13057c478bd9Sstevel@tonic-gate };
13067c478bd9Sstevel@tonic-gate typedef struct SETATTR3args SETATTR3args;
13077c478bd9Sstevel@tonic-gate 
13087c478bd9Sstevel@tonic-gate struct SETATTR3resok {
13097c478bd9Sstevel@tonic-gate 	wcc_data obj_wcc;
13107c478bd9Sstevel@tonic-gate };
13117c478bd9Sstevel@tonic-gate typedef struct SETATTR3resok SETATTR3resok;
13127c478bd9Sstevel@tonic-gate 
13137c478bd9Sstevel@tonic-gate struct SETATTR3resfail {
13147c478bd9Sstevel@tonic-gate 	wcc_data obj_wcc;
13157c478bd9Sstevel@tonic-gate };
13167c478bd9Sstevel@tonic-gate typedef struct SETATTR3resfail SETATTR3resfail;
13177c478bd9Sstevel@tonic-gate 
13187c478bd9Sstevel@tonic-gate struct SETATTR3res {
13197c478bd9Sstevel@tonic-gate 	nfsstat3 status;
13207c478bd9Sstevel@tonic-gate 	union {
13217c478bd9Sstevel@tonic-gate 		SETATTR3resok ok;
13227c478bd9Sstevel@tonic-gate 		SETATTR3resfail fail;
13237c478bd9Sstevel@tonic-gate 	} res_u;
13247c478bd9Sstevel@tonic-gate };
13257c478bd9Sstevel@tonic-gate typedef struct SETATTR3res SETATTR3res;
13267c478bd9Sstevel@tonic-gate 
13277c478bd9Sstevel@tonic-gate struct LOOKUP3args {
13287c478bd9Sstevel@tonic-gate 	diropargs3 what;
13297c478bd9Sstevel@tonic-gate };
13307c478bd9Sstevel@tonic-gate typedef struct LOOKUP3args LOOKUP3args;
13317c478bd9Sstevel@tonic-gate 
13327c478bd9Sstevel@tonic-gate struct LOOKUP3resok {
13337c478bd9Sstevel@tonic-gate 	nfs_fh3 object;
13347c478bd9Sstevel@tonic-gate 	post_op_attr obj_attributes;
13357c478bd9Sstevel@tonic-gate 	post_op_attr dir_attributes;
13367c478bd9Sstevel@tonic-gate };
13377c478bd9Sstevel@tonic-gate typedef struct LOOKUP3resok LOOKUP3resok;
13387c478bd9Sstevel@tonic-gate 
13397c478bd9Sstevel@tonic-gate struct LOOKUP3resfail {
13407c478bd9Sstevel@tonic-gate 	post_op_attr dir_attributes;
13417c478bd9Sstevel@tonic-gate };
13427c478bd9Sstevel@tonic-gate typedef struct LOOKUP3resfail LOOKUP3resfail;
13437c478bd9Sstevel@tonic-gate 
13447c478bd9Sstevel@tonic-gate struct LOOKUP3res {
13457c478bd9Sstevel@tonic-gate 	nfsstat3 status;
13467c478bd9Sstevel@tonic-gate 	union {
13477c478bd9Sstevel@tonic-gate 		LOOKUP3resok ok;
13487c478bd9Sstevel@tonic-gate 		LOOKUP3resfail fail;
13497c478bd9Sstevel@tonic-gate 	} res_u;
13507c478bd9Sstevel@tonic-gate };
13517c478bd9Sstevel@tonic-gate typedef struct LOOKUP3res LOOKUP3res;
13527c478bd9Sstevel@tonic-gate 
13537c478bd9Sstevel@tonic-gate #ifdef _KERNEL
13547c478bd9Sstevel@tonic-gate struct LOOKUP3vres {
13557c478bd9Sstevel@tonic-gate 	nfsstat3 status;
13567c478bd9Sstevel@tonic-gate 	nfs_fh3 object;
13577c478bd9Sstevel@tonic-gate 	post_op_vattr dir_attributes;
13587c478bd9Sstevel@tonic-gate 	post_op_vattr obj_attributes;
13597c478bd9Sstevel@tonic-gate };
13607c478bd9Sstevel@tonic-gate typedef struct LOOKUP3vres LOOKUP3vres;
13617c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
13627c478bd9Sstevel@tonic-gate 
13637c478bd9Sstevel@tonic-gate struct ACCESS3args {
13647c478bd9Sstevel@tonic-gate 	nfs_fh3 object;
13657c478bd9Sstevel@tonic-gate 	uint32 access;
13667c478bd9Sstevel@tonic-gate };
13677c478bd9Sstevel@tonic-gate typedef struct ACCESS3args ACCESS3args;
13687c478bd9Sstevel@tonic-gate #define	ACCESS3_READ 0x1
13697c478bd9Sstevel@tonic-gate #define	ACCESS3_LOOKUP 0x2
13707c478bd9Sstevel@tonic-gate #define	ACCESS3_MODIFY 0x4
13717c478bd9Sstevel@tonic-gate #define	ACCESS3_EXTEND 0x8
13727c478bd9Sstevel@tonic-gate #define	ACCESS3_DELETE 0x10
13737c478bd9Sstevel@tonic-gate #define	ACCESS3_EXECUTE 0x20
13747c478bd9Sstevel@tonic-gate 
13757c478bd9Sstevel@tonic-gate struct ACCESS3resok {
13767c478bd9Sstevel@tonic-gate 	post_op_attr obj_attributes;
13777c478bd9Sstevel@tonic-gate 	uint32 access;
13787c478bd9Sstevel@tonic-gate };
13797c478bd9Sstevel@tonic-gate typedef struct ACCESS3resok ACCESS3resok;
13807c478bd9Sstevel@tonic-gate 
13817c478bd9Sstevel@tonic-gate struct ACCESS3resfail {
13827c478bd9Sstevel@tonic-gate 	post_op_attr obj_attributes;
13837c478bd9Sstevel@tonic-gate };
13847c478bd9Sstevel@tonic-gate typedef struct ACCESS3resfail ACCESS3resfail;
13857c478bd9Sstevel@tonic-gate 
13867c478bd9Sstevel@tonic-gate struct ACCESS3res {
13877c478bd9Sstevel@tonic-gate 	nfsstat3 status;
13887c478bd9Sstevel@tonic-gate 	union {
13897c478bd9Sstevel@tonic-gate 		ACCESS3resok ok;
13907c478bd9Sstevel@tonic-gate 		ACCESS3resfail fail;
13917c478bd9Sstevel@tonic-gate 	} res_u;
13927c478bd9Sstevel@tonic-gate };
13937c478bd9Sstevel@tonic-gate typedef struct ACCESS3res ACCESS3res;
13947c478bd9Sstevel@tonic-gate 
13957c478bd9Sstevel@tonic-gate struct READLINK3args {
13967c478bd9Sstevel@tonic-gate 	nfs_fh3 symlink;
13977c478bd9Sstevel@tonic-gate };
13987c478bd9Sstevel@tonic-gate typedef struct READLINK3args READLINK3args;
13997c478bd9Sstevel@tonic-gate 
14007c478bd9Sstevel@tonic-gate struct READLINK3resok {
14017c478bd9Sstevel@tonic-gate 	post_op_attr symlink_attributes;
14027c478bd9Sstevel@tonic-gate 	nfspath3 data;
14037c478bd9Sstevel@tonic-gate };
14047c478bd9Sstevel@tonic-gate typedef struct READLINK3resok READLINK3resok;
14057c478bd9Sstevel@tonic-gate 
14067c478bd9Sstevel@tonic-gate struct READLINK3resfail {
14077c478bd9Sstevel@tonic-gate 	post_op_attr symlink_attributes;
14087c478bd9Sstevel@tonic-gate };
14097c478bd9Sstevel@tonic-gate typedef struct READLINK3resfail READLINK3resfail;
14107c478bd9Sstevel@tonic-gate 
14117c478bd9Sstevel@tonic-gate struct READLINK3res {
14127c478bd9Sstevel@tonic-gate 	nfsstat3 status;
14137c478bd9Sstevel@tonic-gate 	union {
14147c478bd9Sstevel@tonic-gate 		READLINK3resok ok;
14157c478bd9Sstevel@tonic-gate 		READLINK3resfail fail;
14167c478bd9Sstevel@tonic-gate 	} res_u;
14177c478bd9Sstevel@tonic-gate };
14187c478bd9Sstevel@tonic-gate typedef struct READLINK3res READLINK3res;
14197c478bd9Sstevel@tonic-gate 
14207c478bd9Sstevel@tonic-gate struct READ3args {
14217c478bd9Sstevel@tonic-gate 	nfs_fh3 file;
14227c478bd9Sstevel@tonic-gate 	offset3 offset;
14237c478bd9Sstevel@tonic-gate 	count3 count;
14240a701b1eSRobert Gordon #ifdef _KERNEL
14250a701b1eSRobert Gordon 	/* for read using rdma */
14260a701b1eSRobert Gordon 	char *res_data_val_alt;
14270a701b1eSRobert Gordon 	struct uio *res_uiop;
14280a701b1eSRobert Gordon 	struct clist *wlist;
14290a701b1eSRobert Gordon 	CONN *conn;
14300a701b1eSRobert Gordon #endif
14317c478bd9Sstevel@tonic-gate };
14327c478bd9Sstevel@tonic-gate typedef struct READ3args READ3args;
14337c478bd9Sstevel@tonic-gate 
14347c478bd9Sstevel@tonic-gate struct READ3resok {
14357c478bd9Sstevel@tonic-gate 	post_op_attr file_attributes;
14367c478bd9Sstevel@tonic-gate 	count3 count;
14377c478bd9Sstevel@tonic-gate 	bool_t eof;
14387c478bd9Sstevel@tonic-gate 	struct {
14397c478bd9Sstevel@tonic-gate 		uint_t data_len;
14407c478bd9Sstevel@tonic-gate 		char *data_val;
14417c478bd9Sstevel@tonic-gate 		mblk_t *mp;
14427c478bd9Sstevel@tonic-gate 	} data;
14437c478bd9Sstevel@tonic-gate 	uint_t size;
14440a701b1eSRobert Gordon #ifdef _KERNEL
14450a701b1eSRobert Gordon 	uint_t wlist_len;
14460a701b1eSRobert Gordon 	struct clist *wlist;
1447c242f9a0Schunli zhang - Sun Microsystems - Irvine United States 	frtn_t zcopy;
14480a701b1eSRobert Gordon #endif
14497c478bd9Sstevel@tonic-gate };
14507c478bd9Sstevel@tonic-gate typedef struct READ3resok READ3resok;
14517c478bd9Sstevel@tonic-gate 
14527c478bd9Sstevel@tonic-gate struct READ3resfail {
14537c478bd9Sstevel@tonic-gate 	post_op_attr file_attributes;
14547c478bd9Sstevel@tonic-gate };
14557c478bd9Sstevel@tonic-gate typedef struct READ3resfail READ3resfail;
14567c478bd9Sstevel@tonic-gate 
14577c478bd9Sstevel@tonic-gate struct READ3res {
14587c478bd9Sstevel@tonic-gate 	nfsstat3 status;
14597c478bd9Sstevel@tonic-gate 	union {
14607c478bd9Sstevel@tonic-gate 		READ3resok ok;
14617c478bd9Sstevel@tonic-gate 		READ3resfail fail;
14627c478bd9Sstevel@tonic-gate 	} res_u;
14637c478bd9Sstevel@tonic-gate };
14647c478bd9Sstevel@tonic-gate typedef struct READ3res READ3res;
14657c478bd9Sstevel@tonic-gate 
14667c478bd9Sstevel@tonic-gate #ifdef _KERNEL
14677c478bd9Sstevel@tonic-gate /*
14687c478bd9Sstevel@tonic-gate  * READ3 reply that directly decodes fattr3 directly into vattr
14697c478bd9Sstevel@tonic-gate  */
14707c478bd9Sstevel@tonic-gate struct READ3vres {
14717c478bd9Sstevel@tonic-gate 	nfsstat3 status;
14727c478bd9Sstevel@tonic-gate 	struct post_op_vattr pov;
14737c478bd9Sstevel@tonic-gate 	count3 count;
14747c478bd9Sstevel@tonic-gate 	bool_t eof;
14757c478bd9Sstevel@tonic-gate 	struct {
14767c478bd9Sstevel@tonic-gate 		uint_t data_len;
14777c478bd9Sstevel@tonic-gate 		char *data_val;
14787c478bd9Sstevel@tonic-gate 	} data;
14797c478bd9Sstevel@tonic-gate 	uint_t size;
14800a701b1eSRobert Gordon 
14810a701b1eSRobert Gordon 	uint_t wlist_len;
14820a701b1eSRobert Gordon 	struct clist *wlist;
14837c478bd9Sstevel@tonic-gate };
14847c478bd9Sstevel@tonic-gate typedef struct READ3vres READ3vres;
14857c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
14867c478bd9Sstevel@tonic-gate 
14877c478bd9Sstevel@tonic-gate /*
14887c478bd9Sstevel@tonic-gate  * READ3 reply that uiomoves data directly into a struct uio
14897c478bd9Sstevel@tonic-gate  * ignores any attributes returned
14907c478bd9Sstevel@tonic-gate  */
14917c478bd9Sstevel@tonic-gate struct READ3uiores {
14927c478bd9Sstevel@tonic-gate 	nfsstat3 status;
14937c478bd9Sstevel@tonic-gate 	count3 count;
14947c478bd9Sstevel@tonic-gate 	bool_t eof;
14957c478bd9Sstevel@tonic-gate 	struct uio *uiop;
14967c478bd9Sstevel@tonic-gate 	uint_t size;		/* maximum reply size */
14970a701b1eSRobert Gordon #ifdef _KERNEL
14980a701b1eSRobert Gordon 	uint_t wlist_len;
14990a701b1eSRobert Gordon 	struct clist *wlist;
15000a701b1eSRobert Gordon #endif
15017c478bd9Sstevel@tonic-gate };
15027c478bd9Sstevel@tonic-gate typedef struct READ3uiores READ3uiores;
15037c478bd9Sstevel@tonic-gate 
15047c478bd9Sstevel@tonic-gate enum stable_how {
15057c478bd9Sstevel@tonic-gate 	UNSTABLE = 0,
15067c478bd9Sstevel@tonic-gate 	DATA_SYNC = 1,
15077c478bd9Sstevel@tonic-gate 	FILE_SYNC = 2
15087c478bd9Sstevel@tonic-gate };
15097c478bd9Sstevel@tonic-gate typedef enum stable_how stable_how;
15107c478bd9Sstevel@tonic-gate 
15117c478bd9Sstevel@tonic-gate struct WRITE3args {
15127c478bd9Sstevel@tonic-gate 	nfs_fh3 file;
15137c478bd9Sstevel@tonic-gate 	offset3 offset;
15147c478bd9Sstevel@tonic-gate 	count3 count;
15157c478bd9Sstevel@tonic-gate 	stable_how stable;
15167c478bd9Sstevel@tonic-gate 	struct {
15177c478bd9Sstevel@tonic-gate 		uint_t data_len;
15187c478bd9Sstevel@tonic-gate 		char *data_val;
15197c478bd9Sstevel@tonic-gate 	} data;
15207c478bd9Sstevel@tonic-gate 	mblk_t *mblk;
15210a701b1eSRobert Gordon #ifdef _KERNEL
15220a701b1eSRobert Gordon 	struct clist *rlist;
15230a701b1eSRobert Gordon 	CONN *conn;
15240a701b1eSRobert Gordon #endif
15257c478bd9Sstevel@tonic-gate };
15267c478bd9Sstevel@tonic-gate typedef struct WRITE3args WRITE3args;
15277c478bd9Sstevel@tonic-gate 
15287c478bd9Sstevel@tonic-gate struct WRITE3resok {
15297c478bd9Sstevel@tonic-gate 	wcc_data file_wcc;
15307c478bd9Sstevel@tonic-gate 	count3 count;
15317c478bd9Sstevel@tonic-gate 	stable_how committed;
15327c478bd9Sstevel@tonic-gate 	writeverf3 verf;
15337c478bd9Sstevel@tonic-gate };
15347c478bd9Sstevel@tonic-gate typedef struct WRITE3resok WRITE3resok;
15357c478bd9Sstevel@tonic-gate 
15367c478bd9Sstevel@tonic-gate struct WRITE3resfail {
15377c478bd9Sstevel@tonic-gate 	wcc_data file_wcc;
15387c478bd9Sstevel@tonic-gate };
15397c478bd9Sstevel@tonic-gate typedef struct WRITE3resfail WRITE3resfail;
15407c478bd9Sstevel@tonic-gate 
15417c478bd9Sstevel@tonic-gate struct WRITE3res {
15427c478bd9Sstevel@tonic-gate 	nfsstat3 status;
15437c478bd9Sstevel@tonic-gate 	union {
15447c478bd9Sstevel@tonic-gate 		WRITE3resok ok;
15457c478bd9Sstevel@tonic-gate 		WRITE3resfail fail;
15467c478bd9Sstevel@tonic-gate 	} res_u;
15477c478bd9Sstevel@tonic-gate };
15487c478bd9Sstevel@tonic-gate typedef struct WRITE3res WRITE3res;
15497c478bd9Sstevel@tonic-gate 
15507c478bd9Sstevel@tonic-gate enum createmode3 {
15517c478bd9Sstevel@tonic-gate 	UNCHECKED = 0,
15527c478bd9Sstevel@tonic-gate 	GUARDED = 1,
15537c478bd9Sstevel@tonic-gate 	EXCLUSIVE = 2
15547c478bd9Sstevel@tonic-gate };
15557c478bd9Sstevel@tonic-gate typedef enum createmode3 createmode3;
15567c478bd9Sstevel@tonic-gate 
15577c478bd9Sstevel@tonic-gate struct createhow3 {
15587c478bd9Sstevel@tonic-gate 	createmode3 mode;
15597c478bd9Sstevel@tonic-gate 	union {
15607c478bd9Sstevel@tonic-gate 		sattr3 obj_attributes;
15617c478bd9Sstevel@tonic-gate 		createverf3 verf;
15627c478bd9Sstevel@tonic-gate 	} createhow3_u;
15637c478bd9Sstevel@tonic-gate };
15647c478bd9Sstevel@tonic-gate typedef struct createhow3 createhow3;
15657c478bd9Sstevel@tonic-gate 
15667c478bd9Sstevel@tonic-gate struct CREATE3args {
15677c478bd9Sstevel@tonic-gate 	diropargs3 where;
15687c478bd9Sstevel@tonic-gate 	createhow3 how;
15697c478bd9Sstevel@tonic-gate };
15707c478bd9Sstevel@tonic-gate typedef struct CREATE3args CREATE3args;
15717c478bd9Sstevel@tonic-gate 
15727c478bd9Sstevel@tonic-gate struct CREATE3resok {
15737c478bd9Sstevel@tonic-gate 	post_op_fh3 obj;
15747c478bd9Sstevel@tonic-gate 	post_op_attr obj_attributes;
15757c478bd9Sstevel@tonic-gate 	wcc_data dir_wcc;
15767c478bd9Sstevel@tonic-gate };
15777c478bd9Sstevel@tonic-gate typedef struct CREATE3resok CREATE3resok;
15787c478bd9Sstevel@tonic-gate 
15797c478bd9Sstevel@tonic-gate struct CREATE3resfail {
15807c478bd9Sstevel@tonic-gate 	wcc_data dir_wcc;
15817c478bd9Sstevel@tonic-gate };
15827c478bd9Sstevel@tonic-gate typedef struct CREATE3resfail CREATE3resfail;
15837c478bd9Sstevel@tonic-gate 
15847c478bd9Sstevel@tonic-gate struct CREATE3res {
15857c478bd9Sstevel@tonic-gate 	nfsstat3 status;
15867c478bd9Sstevel@tonic-gate 	union {
15877c478bd9Sstevel@tonic-gate 		CREATE3resok ok;
15887c478bd9Sstevel@tonic-gate 		CREATE3resfail fail;
15897c478bd9Sstevel@tonic-gate 	} res_u;
15907c478bd9Sstevel@tonic-gate };
15917c478bd9Sstevel@tonic-gate typedef struct CREATE3res CREATE3res;
15927c478bd9Sstevel@tonic-gate 
15937c478bd9Sstevel@tonic-gate struct MKDIR3args {
15947c478bd9Sstevel@tonic-gate 	diropargs3 where;
15957c478bd9Sstevel@tonic-gate 	sattr3 attributes;
15967c478bd9Sstevel@tonic-gate };
15977c478bd9Sstevel@tonic-gate typedef struct MKDIR3args MKDIR3args;
15987c478bd9Sstevel@tonic-gate 
15997c478bd9Sstevel@tonic-gate struct MKDIR3resok {
16007c478bd9Sstevel@tonic-gate 	post_op_fh3 obj;
16017c478bd9Sstevel@tonic-gate 	post_op_attr obj_attributes;
16027c478bd9Sstevel@tonic-gate 	wcc_data dir_wcc;
16037c478bd9Sstevel@tonic-gate };
16047c478bd9Sstevel@tonic-gate typedef struct MKDIR3resok MKDIR3resok;
16057c478bd9Sstevel@tonic-gate 
16067c478bd9Sstevel@tonic-gate struct MKDIR3resfail {
16077c478bd9Sstevel@tonic-gate 	wcc_data dir_wcc;
16087c478bd9Sstevel@tonic-gate };
16097c478bd9Sstevel@tonic-gate typedef struct MKDIR3resfail MKDIR3resfail;
16107c478bd9Sstevel@tonic-gate 
16117c478bd9Sstevel@tonic-gate struct MKDIR3res {
16127c478bd9Sstevel@tonic-gate 	nfsstat3 status;
16137c478bd9Sstevel@tonic-gate 	union {
16147c478bd9Sstevel@tonic-gate 		MKDIR3resok ok;
16157c478bd9Sstevel@tonic-gate 		MKDIR3resfail fail;
16167c478bd9Sstevel@tonic-gate 	} res_u;
16177c478bd9Sstevel@tonic-gate };
16187c478bd9Sstevel@tonic-gate typedef struct MKDIR3res MKDIR3res;
16197c478bd9Sstevel@tonic-gate 
16207c478bd9Sstevel@tonic-gate struct symlinkdata3 {
16217c478bd9Sstevel@tonic-gate 	sattr3 symlink_attributes;
16227c478bd9Sstevel@tonic-gate 	nfspath3 symlink_data;
16237c478bd9Sstevel@tonic-gate };
16247c478bd9Sstevel@tonic-gate typedef struct symlinkdata3 symlinkdata3;
16257c478bd9Sstevel@tonic-gate 
16267c478bd9Sstevel@tonic-gate struct SYMLINK3args {
16277c478bd9Sstevel@tonic-gate 	diropargs3 where;
16287c478bd9Sstevel@tonic-gate 	symlinkdata3 symlink;
16297c478bd9Sstevel@tonic-gate };
16307c478bd9Sstevel@tonic-gate typedef struct SYMLINK3args SYMLINK3args;
16317c478bd9Sstevel@tonic-gate 
16327c478bd9Sstevel@tonic-gate struct SYMLINK3resok {
16337c478bd9Sstevel@tonic-gate 	post_op_fh3 obj;
16347c478bd9Sstevel@tonic-gate 	post_op_attr obj_attributes;
16357c478bd9Sstevel@tonic-gate 	wcc_data dir_wcc;
16367c478bd9Sstevel@tonic-gate };
16377c478bd9Sstevel@tonic-gate typedef struct SYMLINK3resok SYMLINK3resok;
16387c478bd9Sstevel@tonic-gate 
16397c478bd9Sstevel@tonic-gate struct SYMLINK3resfail {
16407c478bd9Sstevel@tonic-gate 	wcc_data dir_wcc;
16417c478bd9Sstevel@tonic-gate };
16427c478bd9Sstevel@tonic-gate typedef struct SYMLINK3resfail SYMLINK3resfail;
16437c478bd9Sstevel@tonic-gate 
16447c478bd9Sstevel@tonic-gate struct SYMLINK3res {
16457c478bd9Sstevel@tonic-gate 	nfsstat3 status;
16467c478bd9Sstevel@tonic-gate 	union {
16477c478bd9Sstevel@tonic-gate 		SYMLINK3resok ok;
16487c478bd9Sstevel@tonic-gate 		SYMLINK3resfail fail;
16497c478bd9Sstevel@tonic-gate 	} res_u;
16507c478bd9Sstevel@tonic-gate };
16517c478bd9Sstevel@tonic-gate typedef struct SYMLINK3res SYMLINK3res;
16527c478bd9Sstevel@tonic-gate 
16537c478bd9Sstevel@tonic-gate struct devicedata3 {
16547c478bd9Sstevel@tonic-gate 	sattr3 dev_attributes;
16557c478bd9Sstevel@tonic-gate 	specdata3 spec;
16567c478bd9Sstevel@tonic-gate };
16577c478bd9Sstevel@tonic-gate typedef struct devicedata3 devicedata3;
16587c478bd9Sstevel@tonic-gate 
16597c478bd9Sstevel@tonic-gate struct mknoddata3 {
16607c478bd9Sstevel@tonic-gate 	ftype3 type;
16617c478bd9Sstevel@tonic-gate 	union {
16627c478bd9Sstevel@tonic-gate 		devicedata3 device;
16637c478bd9Sstevel@tonic-gate 		sattr3 pipe_attributes;
16647c478bd9Sstevel@tonic-gate 	} mknoddata3_u;
16657c478bd9Sstevel@tonic-gate };
16667c478bd9Sstevel@tonic-gate typedef struct mknoddata3 mknoddata3;
16677c478bd9Sstevel@tonic-gate 
16687c478bd9Sstevel@tonic-gate struct MKNOD3args {
16697c478bd9Sstevel@tonic-gate 	diropargs3 where;
16707c478bd9Sstevel@tonic-gate 	mknoddata3 what;
16717c478bd9Sstevel@tonic-gate };
16727c478bd9Sstevel@tonic-gate typedef struct MKNOD3args MKNOD3args;
16737c478bd9Sstevel@tonic-gate 
16747c478bd9Sstevel@tonic-gate struct MKNOD3resok {
16757c478bd9Sstevel@tonic-gate 	post_op_fh3 obj;
16767c478bd9Sstevel@tonic-gate 	post_op_attr obj_attributes;
16777c478bd9Sstevel@tonic-gate 	wcc_data dir_wcc;
16787c478bd9Sstevel@tonic-gate };
16797c478bd9Sstevel@tonic-gate typedef struct MKNOD3resok MKNOD3resok;
16807c478bd9Sstevel@tonic-gate 
16817c478bd9Sstevel@tonic-gate struct MKNOD3resfail {
16827c478bd9Sstevel@tonic-gate 	wcc_data dir_wcc;
16837c478bd9Sstevel@tonic-gate };
16847c478bd9Sstevel@tonic-gate typedef struct MKNOD3resfail MKNOD3resfail;
16857c478bd9Sstevel@tonic-gate 
16867c478bd9Sstevel@tonic-gate struct MKNOD3res {
16877c478bd9Sstevel@tonic-gate 	nfsstat3 status;
16887c478bd9Sstevel@tonic-gate 	union {
16897c478bd9Sstevel@tonic-gate 		MKNOD3resok ok;
16907c478bd9Sstevel@tonic-gate 		MKNOD3resfail fail;
16917c478bd9Sstevel@tonic-gate 	} res_u;
16927c478bd9Sstevel@tonic-gate };
16937c478bd9Sstevel@tonic-gate typedef struct MKNOD3res MKNOD3res;
16947c478bd9Sstevel@tonic-gate 
16957c478bd9Sstevel@tonic-gate struct REMOVE3args {
16967c478bd9Sstevel@tonic-gate 	diropargs3 object;
16977c478bd9Sstevel@tonic-gate };
16987c478bd9Sstevel@tonic-gate typedef struct REMOVE3args REMOVE3args;
16997c478bd9Sstevel@tonic-gate 
17007c478bd9Sstevel@tonic-gate struct REMOVE3resok {
17017c478bd9Sstevel@tonic-gate 	wcc_data dir_wcc;
17027c478bd9Sstevel@tonic-gate };
17037c478bd9Sstevel@tonic-gate typedef struct REMOVE3resok REMOVE3resok;
17047c478bd9Sstevel@tonic-gate 
17057c478bd9Sstevel@tonic-gate struct REMOVE3resfail {
17067c478bd9Sstevel@tonic-gate 	wcc_data dir_wcc;
17077c478bd9Sstevel@tonic-gate };
17087c478bd9Sstevel@tonic-gate typedef struct REMOVE3resfail REMOVE3resfail;
17097c478bd9Sstevel@tonic-gate 
17107c478bd9Sstevel@tonic-gate struct REMOVE3res {
17117c478bd9Sstevel@tonic-gate 	nfsstat3 status;
17127c478bd9Sstevel@tonic-gate 	union {
17137c478bd9Sstevel@tonic-gate 		REMOVE3resok ok;
17147c478bd9Sstevel@tonic-gate 		REMOVE3resfail fail;
17157c478bd9Sstevel@tonic-gate 	} res_u;
17167c478bd9Sstevel@tonic-gate };
17177c478bd9Sstevel@tonic-gate typedef struct REMOVE3res REMOVE3res;
17187c478bd9Sstevel@tonic-gate 
17197c478bd9Sstevel@tonic-gate struct RMDIR3args {
17207c478bd9Sstevel@tonic-gate 	diropargs3 object;
17217c478bd9Sstevel@tonic-gate };
17227c478bd9Sstevel@tonic-gate typedef struct RMDIR3args RMDIR3args;
17237c478bd9Sstevel@tonic-gate 
17247c478bd9Sstevel@tonic-gate struct RMDIR3resok {
17257c478bd9Sstevel@tonic-gate 	wcc_data dir_wcc;
17267c478bd9Sstevel@tonic-gate };
17277c478bd9Sstevel@tonic-gate typedef struct RMDIR3resok RMDIR3resok;
17287c478bd9Sstevel@tonic-gate 
17297c478bd9Sstevel@tonic-gate struct RMDIR3resfail {
17307c478bd9Sstevel@tonic-gate 	wcc_data dir_wcc;
17317c478bd9Sstevel@tonic-gate };
17327c478bd9Sstevel@tonic-gate typedef struct RMDIR3resfail RMDIR3resfail;
17337c478bd9Sstevel@tonic-gate 
17347c478bd9Sstevel@tonic-gate struct RMDIR3res {
17357c478bd9Sstevel@tonic-gate 	nfsstat3 status;
17367c478bd9Sstevel@tonic-gate 	union {
17377c478bd9Sstevel@tonic-gate 		RMDIR3resok ok;
17387c478bd9Sstevel@tonic-gate 		RMDIR3resfail fail;
17397c478bd9Sstevel@tonic-gate 	} res_u;
17407c478bd9Sstevel@tonic-gate };
17417c478bd9Sstevel@tonic-gate typedef struct RMDIR3res RMDIR3res;
17427c478bd9Sstevel@tonic-gate 
17437c478bd9Sstevel@tonic-gate struct RENAME3args {
17447c478bd9Sstevel@tonic-gate 	diropargs3 from;
17457c478bd9Sstevel@tonic-gate 	diropargs3 to;
17467c478bd9Sstevel@tonic-gate };
17477c478bd9Sstevel@tonic-gate typedef struct RENAME3args RENAME3args;
17487c478bd9Sstevel@tonic-gate 
17497c478bd9Sstevel@tonic-gate struct RENAME3resok {
17507c478bd9Sstevel@tonic-gate 	wcc_data fromdir_wcc;
17517c478bd9Sstevel@tonic-gate 	wcc_data todir_wcc;
17527c478bd9Sstevel@tonic-gate };
17537c478bd9Sstevel@tonic-gate typedef struct RENAME3resok RENAME3resok;
17547c478bd9Sstevel@tonic-gate 
17557c478bd9Sstevel@tonic-gate struct RENAME3resfail {
17567c478bd9Sstevel@tonic-gate 	wcc_data fromdir_wcc;
17577c478bd9Sstevel@tonic-gate 	wcc_data todir_wcc;
17587c478bd9Sstevel@tonic-gate };
17597c478bd9Sstevel@tonic-gate typedef struct RENAME3resfail RENAME3resfail;
17607c478bd9Sstevel@tonic-gate 
17617c478bd9Sstevel@tonic-gate struct RENAME3res {
17627c478bd9Sstevel@tonic-gate 	nfsstat3 status;
17637c478bd9Sstevel@tonic-gate 	union {
17647c478bd9Sstevel@tonic-gate 		RENAME3resok ok;
17657c478bd9Sstevel@tonic-gate 		RENAME3resfail fail;
17667c478bd9Sstevel@tonic-gate 	} res_u;
17677c478bd9Sstevel@tonic-gate };
17687c478bd9Sstevel@tonic-gate typedef struct RENAME3res RENAME3res;
17697c478bd9Sstevel@tonic-gate 
17707c478bd9Sstevel@tonic-gate struct LINK3args {
17717c478bd9Sstevel@tonic-gate 	nfs_fh3 file;
17727c478bd9Sstevel@tonic-gate 	diropargs3 link;
17737c478bd9Sstevel@tonic-gate };
17747c478bd9Sstevel@tonic-gate typedef struct LINK3args LINK3args;
17757c478bd9Sstevel@tonic-gate 
17767c478bd9Sstevel@tonic-gate struct LINK3resok {
17777c478bd9Sstevel@tonic-gate 	post_op_attr file_attributes;
17787c478bd9Sstevel@tonic-gate 	wcc_data linkdir_wcc;
17797c478bd9Sstevel@tonic-gate };
17807c478bd9Sstevel@tonic-gate typedef struct LINK3resok LINK3resok;
17817c478bd9Sstevel@tonic-gate 
17827c478bd9Sstevel@tonic-gate struct LINK3resfail {
17837c478bd9Sstevel@tonic-gate 	post_op_attr file_attributes;
17847c478bd9Sstevel@tonic-gate 	wcc_data linkdir_wcc;
17857c478bd9Sstevel@tonic-gate };
17867c478bd9Sstevel@tonic-gate typedef struct LINK3resfail LINK3resfail;
17877c478bd9Sstevel@tonic-gate 
17887c478bd9Sstevel@tonic-gate struct LINK3res {
17897c478bd9Sstevel@tonic-gate 	nfsstat3 status;
17907c478bd9Sstevel@tonic-gate 	union {
17917c478bd9Sstevel@tonic-gate 		LINK3resok ok;
17927c478bd9Sstevel@tonic-gate 		LINK3resfail fail;
17937c478bd9Sstevel@tonic-gate 	} res_u;
17947c478bd9Sstevel@tonic-gate };
17957c478bd9Sstevel@tonic-gate typedef struct LINK3res LINK3res;
17967c478bd9Sstevel@tonic-gate 
17977c478bd9Sstevel@tonic-gate struct READDIR3args {
17987c478bd9Sstevel@tonic-gate 	nfs_fh3 dir;
17997c478bd9Sstevel@tonic-gate 	cookie3 cookie;
18007c478bd9Sstevel@tonic-gate 	cookieverf3 cookieverf;
18017c478bd9Sstevel@tonic-gate 	count3 count;
18027c478bd9Sstevel@tonic-gate };
18037c478bd9Sstevel@tonic-gate typedef struct READDIR3args READDIR3args;
18047c478bd9Sstevel@tonic-gate 
18057c478bd9Sstevel@tonic-gate struct entry3 {
18067c478bd9Sstevel@tonic-gate 	fileid3 fileid;
18077c478bd9Sstevel@tonic-gate 	filename3 name;
18087c478bd9Sstevel@tonic-gate 	cookie3 cookie;
18097c478bd9Sstevel@tonic-gate 	struct entry3 *nextentry;
18107c478bd9Sstevel@tonic-gate };
18117c478bd9Sstevel@tonic-gate typedef struct entry3 entry3;
18127c478bd9Sstevel@tonic-gate 
18137c478bd9Sstevel@tonic-gate struct dirlist3 {
18147c478bd9Sstevel@tonic-gate 	entry3 *entries;
18157c478bd9Sstevel@tonic-gate 	bool_t eof;
18167c478bd9Sstevel@tonic-gate };
18177c478bd9Sstevel@tonic-gate typedef struct dirlist3 dirlist3;
18187c478bd9Sstevel@tonic-gate 
18197c478bd9Sstevel@tonic-gate struct READDIR3resok {
18207c478bd9Sstevel@tonic-gate 	post_op_attr dir_attributes;
18217c478bd9Sstevel@tonic-gate 	cookieverf3 cookieverf;
18227c478bd9Sstevel@tonic-gate 	dirlist3 reply;
18237c478bd9Sstevel@tonic-gate 	uint_t size;
18247c478bd9Sstevel@tonic-gate 	uint_t count;
18257c478bd9Sstevel@tonic-gate 	uint_t freecount;
18267c478bd9Sstevel@tonic-gate 	cookie3 cookie;
18277c478bd9Sstevel@tonic-gate };
18287c478bd9Sstevel@tonic-gate typedef struct READDIR3resok READDIR3resok;
18297c478bd9Sstevel@tonic-gate 
18307c478bd9Sstevel@tonic-gate struct READDIR3resfail {
18317c478bd9Sstevel@tonic-gate 	post_op_attr dir_attributes;
18327c478bd9Sstevel@tonic-gate };
18337c478bd9Sstevel@tonic-gate typedef struct READDIR3resfail READDIR3resfail;
18347c478bd9Sstevel@tonic-gate 
18357c478bd9Sstevel@tonic-gate struct READDIR3res {
18367c478bd9Sstevel@tonic-gate 	nfsstat3 status;
18377c478bd9Sstevel@tonic-gate 	union {
18387c478bd9Sstevel@tonic-gate 		READDIR3resok ok;
18397c478bd9Sstevel@tonic-gate 		READDIR3resfail fail;
18407c478bd9Sstevel@tonic-gate 	} res_u;
18417c478bd9Sstevel@tonic-gate };
18427c478bd9Sstevel@tonic-gate typedef struct READDIR3res READDIR3res;
18437c478bd9Sstevel@tonic-gate 
18447c478bd9Sstevel@tonic-gate #ifdef _KERNEL
18457c478bd9Sstevel@tonic-gate struct READDIR3vres {
18467c478bd9Sstevel@tonic-gate 	nfsstat3 status;
18477c478bd9Sstevel@tonic-gate 	post_op_vattr dir_attributes;
18487c478bd9Sstevel@tonic-gate 	cookieverf3 cookieverf;
18497c478bd9Sstevel@tonic-gate 	dirent64_t *entries;			/* decoded dirent64s */
18507c478bd9Sstevel@tonic-gate 	uint_t size;				/* actual size of entries */
18517c478bd9Sstevel@tonic-gate 	uint_t entries_size;			/* max size of entries */
18527c478bd9Sstevel@tonic-gate 	off64_t loff;				/* last offset/cookie */
18537c478bd9Sstevel@tonic-gate 	bool_t eof;				/* End of directory */
18547c478bd9Sstevel@tonic-gate };
18557c478bd9Sstevel@tonic-gate typedef struct READDIR3vres READDIR3vres;
18567c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
18577c478bd9Sstevel@tonic-gate 
18587c478bd9Sstevel@tonic-gate struct READDIRPLUS3args {
18597c478bd9Sstevel@tonic-gate 	nfs_fh3 dir;
18607c478bd9Sstevel@tonic-gate 	cookie3 cookie;
18617c478bd9Sstevel@tonic-gate 	cookieverf3 cookieverf;
18627c478bd9Sstevel@tonic-gate 	count3 dircount;
18637c478bd9Sstevel@tonic-gate 	count3 maxcount;
18647c478bd9Sstevel@tonic-gate };
18657c478bd9Sstevel@tonic-gate typedef struct READDIRPLUS3args READDIRPLUS3args;
18667c478bd9Sstevel@tonic-gate 
18677c478bd9Sstevel@tonic-gate struct entryplus3 {
18687c478bd9Sstevel@tonic-gate 	fileid3 fileid;
18697c478bd9Sstevel@tonic-gate 	filename3 name;
18707c478bd9Sstevel@tonic-gate 	cookie3 cookie;
18717c478bd9Sstevel@tonic-gate 	post_op_attr name_attributes;
18727c478bd9Sstevel@tonic-gate 	post_op_fh3 name_handle;
18737c478bd9Sstevel@tonic-gate 	struct entryplus3 *nextentry;
18747c478bd9Sstevel@tonic-gate };
18757c478bd9Sstevel@tonic-gate typedef struct entryplus3 entryplus3;
18767c478bd9Sstevel@tonic-gate 
18777c478bd9Sstevel@tonic-gate struct dirlistplus3 {
18787c478bd9Sstevel@tonic-gate 	entryplus3 *entries;
18797c478bd9Sstevel@tonic-gate 	bool_t eof;
18807c478bd9Sstevel@tonic-gate };
18817c478bd9Sstevel@tonic-gate typedef struct dirlistplus3 dirlistplus3;
18827c478bd9Sstevel@tonic-gate 
18837c478bd9Sstevel@tonic-gate struct entryplus3_info {
18847c478bd9Sstevel@tonic-gate 	post_op_attr attr;
18857c478bd9Sstevel@tonic-gate 	post_op_fh3 fh;
18867c478bd9Sstevel@tonic-gate 	uint_t namelen;
18877c478bd9Sstevel@tonic-gate };
18887c478bd9Sstevel@tonic-gate typedef struct entryplus3_info entryplus3_info;
18897c478bd9Sstevel@tonic-gate 
18907c478bd9Sstevel@tonic-gate struct READDIRPLUS3resok {
18917c478bd9Sstevel@tonic-gate 	post_op_attr dir_attributes;
18927c478bd9Sstevel@tonic-gate 	cookieverf3 cookieverf;
18937c478bd9Sstevel@tonic-gate 	dirlistplus3 reply;
18947c478bd9Sstevel@tonic-gate 	uint_t size;
18957c478bd9Sstevel@tonic-gate 	uint_t count;
18967c478bd9Sstevel@tonic-gate 	uint_t maxcount;
18977c478bd9Sstevel@tonic-gate 	entryplus3_info *infop;
18987c478bd9Sstevel@tonic-gate };
18997c478bd9Sstevel@tonic-gate typedef struct READDIRPLUS3resok READDIRPLUS3resok;
19007c478bd9Sstevel@tonic-gate 
19017c478bd9Sstevel@tonic-gate struct READDIRPLUS3resfail {
19027c478bd9Sstevel@tonic-gate 	post_op_attr dir_attributes;
19037c478bd9Sstevel@tonic-gate };
19047c478bd9Sstevel@tonic-gate typedef struct READDIRPLUS3resfail READDIRPLUS3resfail;
19057c478bd9Sstevel@tonic-gate 
19067c478bd9Sstevel@tonic-gate struct READDIRPLUS3res {
19077c478bd9Sstevel@tonic-gate 	nfsstat3 status;
19087c478bd9Sstevel@tonic-gate 	union {
19097c478bd9Sstevel@tonic-gate 		READDIRPLUS3resok ok;
19107c478bd9Sstevel@tonic-gate 		READDIRPLUS3resfail fail;
19117c478bd9Sstevel@tonic-gate 	} res_u;
19127c478bd9Sstevel@tonic-gate };
19137c478bd9Sstevel@tonic-gate typedef struct READDIRPLUS3res READDIRPLUS3res;
19147c478bd9Sstevel@tonic-gate 
19157c478bd9Sstevel@tonic-gate #ifdef _KERNEL
19167c478bd9Sstevel@tonic-gate struct entryplus3_va_fh {
19177c478bd9Sstevel@tonic-gate 	int va_valid;
19187c478bd9Sstevel@tonic-gate 	int fh_valid;
19197c478bd9Sstevel@tonic-gate 	vattr_t va;
19207c478bd9Sstevel@tonic-gate 	nfs_fh3 fh;
19217c478bd9Sstevel@tonic-gate 	char *d_name;		/* back pointer into entries */
19227c478bd9Sstevel@tonic-gate };
19237c478bd9Sstevel@tonic-gate 
19247c478bd9Sstevel@tonic-gate struct READDIRPLUS3vres {
19257c478bd9Sstevel@tonic-gate 	nfsstat3 status;
19267c478bd9Sstevel@tonic-gate 	post_op_vattr dir_attributes;
19277c478bd9Sstevel@tonic-gate 	cookieverf3 cookieverf;
19287c478bd9Sstevel@tonic-gate 	dirent64_t *entries;			/* decoded dirent64s */
19297c478bd9Sstevel@tonic-gate 	uint_t size;				/* actual size of entries */
19307c478bd9Sstevel@tonic-gate 	uint_t entries_size;			/* max size of entries */
19317c478bd9Sstevel@tonic-gate 	bool_t eof;				/* End of directory */
19327c478bd9Sstevel@tonic-gate 	off64_t loff;				/* last offset/cookie */
19337c478bd9Sstevel@tonic-gate 	cred_t *credentials;			/* caller's credentials */
19347c478bd9Sstevel@tonic-gate 	hrtime_t time;				/* time of READDIRPLUS call */
19357c478bd9Sstevel@tonic-gate };
19367c478bd9Sstevel@tonic-gate typedef struct READDIRPLUS3vres READDIRPLUS3vres;
19377c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
19387c478bd9Sstevel@tonic-gate 
19397c478bd9Sstevel@tonic-gate struct FSSTAT3args {
19407c478bd9Sstevel@tonic-gate 	nfs_fh3 fsroot;
19417c478bd9Sstevel@tonic-gate };
19427c478bd9Sstevel@tonic-gate typedef struct FSSTAT3args FSSTAT3args;
19437c478bd9Sstevel@tonic-gate 
19447c478bd9Sstevel@tonic-gate struct FSSTAT3resok {
19457c478bd9Sstevel@tonic-gate 	post_op_attr obj_attributes;
19467c478bd9Sstevel@tonic-gate 	size3 tbytes;
19477c478bd9Sstevel@tonic-gate 	size3 fbytes;
19487c478bd9Sstevel@tonic-gate 	size3 abytes;
19497c478bd9Sstevel@tonic-gate 	size3 tfiles;
19507c478bd9Sstevel@tonic-gate 	size3 ffiles;
19517c478bd9Sstevel@tonic-gate 	size3 afiles;
19527c478bd9Sstevel@tonic-gate 	uint32 invarsec;
19537c478bd9Sstevel@tonic-gate };
19547c478bd9Sstevel@tonic-gate typedef struct FSSTAT3resok FSSTAT3resok;
19557c478bd9Sstevel@tonic-gate 
19567c478bd9Sstevel@tonic-gate struct FSSTAT3resfail {
19577c478bd9Sstevel@tonic-gate 	post_op_attr obj_attributes;
19587c478bd9Sstevel@tonic-gate };
19597c478bd9Sstevel@tonic-gate typedef struct FSSTAT3resfail FSSTAT3resfail;
19607c478bd9Sstevel@tonic-gate 
19617c478bd9Sstevel@tonic-gate struct FSSTAT3res {
19627c478bd9Sstevel@tonic-gate 	nfsstat3 status;
19637c478bd9Sstevel@tonic-gate 	union {
19647c478bd9Sstevel@tonic-gate 		FSSTAT3resok ok;
19657c478bd9Sstevel@tonic-gate 		FSSTAT3resfail fail;
19667c478bd9Sstevel@tonic-gate 	} res_u;
19677c478bd9Sstevel@tonic-gate };
19687c478bd9Sstevel@tonic-gate typedef struct FSSTAT3res FSSTAT3res;
19697c478bd9Sstevel@tonic-gate 
19707c478bd9Sstevel@tonic-gate struct FSINFO3args {
19717c478bd9Sstevel@tonic-gate 	nfs_fh3 fsroot;
19727c478bd9Sstevel@tonic-gate };
19737c478bd9Sstevel@tonic-gate typedef struct FSINFO3args FSINFO3args;
19747c478bd9Sstevel@tonic-gate 
19757c478bd9Sstevel@tonic-gate struct FSINFO3resok {
19767c478bd9Sstevel@tonic-gate 	post_op_attr obj_attributes;
19777c478bd9Sstevel@tonic-gate 	uint32 rtmax;
19787c478bd9Sstevel@tonic-gate 	uint32 rtpref;
19797c478bd9Sstevel@tonic-gate 	uint32 rtmult;
19807c478bd9Sstevel@tonic-gate 	uint32 wtmax;
19817c478bd9Sstevel@tonic-gate 	uint32 wtpref;
19827c478bd9Sstevel@tonic-gate 	uint32 wtmult;
19837c478bd9Sstevel@tonic-gate 	uint32 dtpref;
19847c478bd9Sstevel@tonic-gate 	size3 maxfilesize;
19857c478bd9Sstevel@tonic-gate 	nfstime3 time_delta;
19867c478bd9Sstevel@tonic-gate 	uint32 properties;
19877c478bd9Sstevel@tonic-gate };
19887c478bd9Sstevel@tonic-gate typedef struct FSINFO3resok FSINFO3resok;
19897c478bd9Sstevel@tonic-gate 
19907c478bd9Sstevel@tonic-gate struct FSINFO3resfail {
19917c478bd9Sstevel@tonic-gate 	post_op_attr obj_attributes;
19927c478bd9Sstevel@tonic-gate };
19937c478bd9Sstevel@tonic-gate typedef struct FSINFO3resfail FSINFO3resfail;
19947c478bd9Sstevel@tonic-gate #define	FSF3_LINK 0x1
19957c478bd9Sstevel@tonic-gate #define	FSF3_SYMLINK 0x2
19967c478bd9Sstevel@tonic-gate #define	FSF3_HOMOGENEOUS 0x8
19977c478bd9Sstevel@tonic-gate #define	FSF3_CANSETTIME 0x10
19987c478bd9Sstevel@tonic-gate 
19997c478bd9Sstevel@tonic-gate struct FSINFO3res {
20007c478bd9Sstevel@tonic-gate 	nfsstat3 status;
20017c478bd9Sstevel@tonic-gate 	union {
20027c478bd9Sstevel@tonic-gate 		FSINFO3resok ok;
20037c478bd9Sstevel@tonic-gate 		FSINFO3resfail fail;
20047c478bd9Sstevel@tonic-gate 	} res_u;
20057c478bd9Sstevel@tonic-gate };
20067c478bd9Sstevel@tonic-gate typedef struct FSINFO3res FSINFO3res;
20077c478bd9Sstevel@tonic-gate 
20087c478bd9Sstevel@tonic-gate struct PATHCONF3args {
20097c478bd9Sstevel@tonic-gate 	nfs_fh3 object;
20107c478bd9Sstevel@tonic-gate };
20117c478bd9Sstevel@tonic-gate typedef struct PATHCONF3args PATHCONF3args;
20127c478bd9Sstevel@tonic-gate 
20137c478bd9Sstevel@tonic-gate struct nfs3_pathconf_info {
20147c478bd9Sstevel@tonic-gate 	uint32 link_max;
20157c478bd9Sstevel@tonic-gate 	uint32 name_max;
20167c478bd9Sstevel@tonic-gate 	bool_t no_trunc;
20177c478bd9Sstevel@tonic-gate 	bool_t chown_restricted;
20187c478bd9Sstevel@tonic-gate 	bool_t case_insensitive;
20197c478bd9Sstevel@tonic-gate 	bool_t case_preserving;
20207c478bd9Sstevel@tonic-gate };
20217c478bd9Sstevel@tonic-gate typedef struct nfs3_pathconf_info nfs3_pathconf_info;
20227c478bd9Sstevel@tonic-gate 
20237c478bd9Sstevel@tonic-gate struct PATHCONF3resok {
20247c478bd9Sstevel@tonic-gate 	post_op_attr obj_attributes;
20257c478bd9Sstevel@tonic-gate 	nfs3_pathconf_info info;
20267c478bd9Sstevel@tonic-gate };
20277c478bd9Sstevel@tonic-gate typedef struct PATHCONF3resok PATHCONF3resok;
20287c478bd9Sstevel@tonic-gate 
20297c478bd9Sstevel@tonic-gate struct PATHCONF3resfail {
20307c478bd9Sstevel@tonic-gate 	post_op_attr obj_attributes;
20317c478bd9Sstevel@tonic-gate };
20327c478bd9Sstevel@tonic-gate typedef struct PATHCONF3resfail PATHCONF3resfail;
20337c478bd9Sstevel@tonic-gate 
20347c478bd9Sstevel@tonic-gate struct PATHCONF3res {
20357c478bd9Sstevel@tonic-gate 	nfsstat3 status;
20367c478bd9Sstevel@tonic-gate 	union {
20377c478bd9Sstevel@tonic-gate 		PATHCONF3resok ok;
20387c478bd9Sstevel@tonic-gate 		PATHCONF3resfail fail;
20397c478bd9Sstevel@tonic-gate 	} res_u;
20407c478bd9Sstevel@tonic-gate };
20417c478bd9Sstevel@tonic-gate typedef struct PATHCONF3res PATHCONF3res;
20427c478bd9Sstevel@tonic-gate 
20437c478bd9Sstevel@tonic-gate struct COMMIT3args {
20447c478bd9Sstevel@tonic-gate 	nfs_fh3 file;
20457c478bd9Sstevel@tonic-gate 	offset3 offset;
20467c478bd9Sstevel@tonic-gate 	count3 count;
20477c478bd9Sstevel@tonic-gate };
20487c478bd9Sstevel@tonic-gate typedef struct COMMIT3args COMMIT3args;
20497c478bd9Sstevel@tonic-gate 
20507c478bd9Sstevel@tonic-gate struct COMMIT3resok {
20517c478bd9Sstevel@tonic-gate 	wcc_data file_wcc;
20527c478bd9Sstevel@tonic-gate 	writeverf3 verf;
20537c478bd9Sstevel@tonic-gate };
20547c478bd9Sstevel@tonic-gate typedef struct COMMIT3resok COMMIT3resok;
20557c478bd9Sstevel@tonic-gate 
20567c478bd9Sstevel@tonic-gate struct COMMIT3resfail {
20577c478bd9Sstevel@tonic-gate 	wcc_data file_wcc;
20587c478bd9Sstevel@tonic-gate };
20597c478bd9Sstevel@tonic-gate typedef struct COMMIT3resfail COMMIT3resfail;
20607c478bd9Sstevel@tonic-gate 
20617c478bd9Sstevel@tonic-gate struct COMMIT3res {
20627c478bd9Sstevel@tonic-gate 	nfsstat3 status;
20637c478bd9Sstevel@tonic-gate 	union {
20647c478bd9Sstevel@tonic-gate 		COMMIT3resok ok;
20657c478bd9Sstevel@tonic-gate 		COMMIT3resfail fail;
20667c478bd9Sstevel@tonic-gate 	} res_u;
20677c478bd9Sstevel@tonic-gate };
20687c478bd9Sstevel@tonic-gate typedef struct COMMIT3res COMMIT3res;
20697c478bd9Sstevel@tonic-gate 
20707c478bd9Sstevel@tonic-gate #define	NFS3_PROGRAM ((rpcprog_t)100003)
20717c478bd9Sstevel@tonic-gate #define	NFS_V3 ((rpcvers_t)3)
20727c478bd9Sstevel@tonic-gate #define	NFSPROC3_NULL ((rpcproc_t)0)
20737c478bd9Sstevel@tonic-gate #define	NFSPROC3_GETATTR ((rpcproc_t)1)
20747c478bd9Sstevel@tonic-gate #define	NFSPROC3_SETATTR ((rpcproc_t)2)
20757c478bd9Sstevel@tonic-gate #define	NFSPROC3_LOOKUP ((rpcproc_t)3)
20767c478bd9Sstevel@tonic-gate #define	NFSPROC3_ACCESS ((rpcproc_t)4)
20777c478bd9Sstevel@tonic-gate #define	NFSPROC3_READLINK ((rpcproc_t)5)
20787c478bd9Sstevel@tonic-gate #define	NFSPROC3_READ ((rpcproc_t)6)
20797c478bd9Sstevel@tonic-gate #define	NFSPROC3_WRITE ((rpcproc_t)7)
20807c478bd9Sstevel@tonic-gate #define	NFSPROC3_CREATE ((rpcproc_t)8)
20817c478bd9Sstevel@tonic-gate #define	NFSPROC3_MKDIR ((rpcproc_t)9)
20827c478bd9Sstevel@tonic-gate #define	NFSPROC3_SYMLINK ((rpcproc_t)10)
20837c478bd9Sstevel@tonic-gate #define	NFSPROC3_MKNOD ((rpcproc_t)11)
20847c478bd9Sstevel@tonic-gate #define	NFSPROC3_REMOVE ((rpcproc_t)12)
20857c478bd9Sstevel@tonic-gate #define	NFSPROC3_RMDIR ((rpcproc_t)13)
20867c478bd9Sstevel@tonic-gate #define	NFSPROC3_RENAME ((rpcproc_t)14)
20877c478bd9Sstevel@tonic-gate #define	NFSPROC3_LINK ((rpcproc_t)15)
20887c478bd9Sstevel@tonic-gate #define	NFSPROC3_READDIR ((rpcproc_t)16)
20897c478bd9Sstevel@tonic-gate #define	NFSPROC3_READDIRPLUS ((rpcproc_t)17)
20907c478bd9Sstevel@tonic-gate #define	NFSPROC3_FSSTAT ((rpcproc_t)18)
20917c478bd9Sstevel@tonic-gate #define	NFSPROC3_FSINFO ((rpcproc_t)19)
20927c478bd9Sstevel@tonic-gate #define	NFSPROC3_PATHCONF ((rpcproc_t)20)
20937c478bd9Sstevel@tonic-gate #define	NFSPROC3_COMMIT ((rpcproc_t)21)
20947c478bd9Sstevel@tonic-gate 
20957c478bd9Sstevel@tonic-gate #ifndef _KERNEL
2096*5cb0d679SMarcel Telka extern void		*nfsproc3_null_3();
2097*5cb0d679SMarcel Telka extern GETATTR3res	*nfsproc3_getattr_3();
2098*5cb0d679SMarcel Telka extern SETATTR3res	*nfsproc3_setattr_3();
2099*5cb0d679SMarcel Telka extern LOOKUP3res	*nfsproc3_lookup_3();
2100*5cb0d679SMarcel Telka extern ACCESS3res	*nfsproc3_access_3();
2101*5cb0d679SMarcel Telka extern READLINK3res	*nfsproc3_readlink_3();
2102*5cb0d679SMarcel Telka extern READ3res	*nfsproc3_read_3();
2103*5cb0d679SMarcel Telka extern WRITE3res	*nfsproc3_write_3();
2104*5cb0d679SMarcel Telka extern CREATE3res	*nfsproc3_create_3();
2105*5cb0d679SMarcel Telka extern MKDIR3res	*nfsproc3_mkdir_3();
2106*5cb0d679SMarcel Telka extern SYMLINK3res	*nfsproc3_symlink_3();
2107*5cb0d679SMarcel Telka extern MKNOD3res	*nfsproc3_mknod_3();
2108*5cb0d679SMarcel Telka extern REMOVE3res	*nfsproc3_remove_3();
2109*5cb0d679SMarcel Telka extern RMDIR3res	*nfsproc3_rmdir_3();
2110*5cb0d679SMarcel Telka extern RENAME3res	*nfsproc3_rename_3();
2111*5cb0d679SMarcel Telka extern LINK3res	*nfsproc3_link_3();
2112*5cb0d679SMarcel Telka extern READDIR3res	*nfsproc3_readdir_3();
2113*5cb0d679SMarcel Telka extern READDIRPLUS3res	*nfsproc3_readdirplus_3();
2114*5cb0d679SMarcel Telka extern FSSTAT3res	*nfsproc3_fsstat_3();
2115*5cb0d679SMarcel Telka extern FSINFO3res	*nfsproc3_fsinfo_3();
2116*5cb0d679SMarcel Telka extern PATHCONF3res	*nfsproc3_pathconf_3();
2117*5cb0d679SMarcel Telka extern COMMIT3res	*nfsproc3_commit_3();
21187c478bd9Sstevel@tonic-gate #endif	/* !_KERNEL */
21197c478bd9Sstevel@tonic-gate 
21207c478bd9Sstevel@tonic-gate #ifdef _KERNEL
21217c478bd9Sstevel@tonic-gate /* the NFS Version 3 XDR functions */
21227c478bd9Sstevel@tonic-gate 
2123*5cb0d679SMarcel Telka extern bool_t xdr_nfs_fh3(XDR *, nfs_fh3 *);
2124*5cb0d679SMarcel Telka extern bool_t xdr_nfslog_nfs_fh3(XDR *, nfs_fh3 *);
2125*5cb0d679SMarcel Telka extern bool_t xdr_nfs_fh3_server(XDR *, nfs_fh3 *);
2126*5cb0d679SMarcel Telka extern bool_t xdr_diropargs3(XDR *, diropargs3 *);
2127*5cb0d679SMarcel Telka extern bool_t xdr_post_op_attr(XDR *, post_op_attr *);
2128*5cb0d679SMarcel Telka extern bool_t xdr_post_op_fh3(XDR *, post_op_fh3 *);
2129*5cb0d679SMarcel Telka extern bool_t xdr_GETATTR3res(XDR *, GETATTR3res *);
2130*5cb0d679SMarcel Telka extern bool_t xdr_GETATTR3vres(XDR *, GETATTR3vres *);
2131*5cb0d679SMarcel Telka extern bool_t xdr_SETATTR3args(XDR *, SETATTR3args *);
2132*5cb0d679SMarcel Telka extern bool_t xdr_SETATTR3res(XDR *, SETATTR3res *);
2133*5cb0d679SMarcel Telka extern bool_t xdr_LOOKUP3res(XDR *, LOOKUP3res *);
2134*5cb0d679SMarcel Telka extern bool_t xdr_LOOKUP3vres(XDR *, LOOKUP3vres *);
2135*5cb0d679SMarcel Telka extern bool_t xdr_ACCESS3args(XDR *, ACCESS3args *);
2136*5cb0d679SMarcel Telka extern bool_t xdr_ACCESS3res(XDR *, ACCESS3res *);
2137*5cb0d679SMarcel Telka extern bool_t xdr_READLINK3args(XDR *, READLINK3args *);
2138*5cb0d679SMarcel Telka extern bool_t xdr_READLINK3res(XDR *, READLINK3res *);
2139*5cb0d679SMarcel Telka extern bool_t xdr_READ3args(XDR *, READ3args *);
2140*5cb0d679SMarcel Telka extern bool_t xdr_READ3res(XDR *, READ3res *);
2141*5cb0d679SMarcel Telka extern bool_t xdr_READ3vres(XDR *, READ3vres *);
2142*5cb0d679SMarcel Telka extern bool_t xdr_READ3uiores(XDR *, READ3uiores *);
2143*5cb0d679SMarcel Telka extern bool_t xdr_WRITE3args(XDR *, WRITE3args *);
2144*5cb0d679SMarcel Telka extern bool_t xdr_WRITE3res(XDR *, WRITE3res *);
2145*5cb0d679SMarcel Telka extern bool_t xdr_CREATE3args(XDR *, CREATE3args *);
2146*5cb0d679SMarcel Telka extern bool_t xdr_CREATE3res(XDR *, CREATE3res *);
2147*5cb0d679SMarcel Telka extern bool_t xdr_MKDIR3args(XDR *, MKDIR3args *);
2148*5cb0d679SMarcel Telka extern bool_t xdr_MKDIR3res(XDR *, MKDIR3res *);
2149*5cb0d679SMarcel Telka extern bool_t xdr_SYMLINK3args(XDR *, SYMLINK3args *);
2150*5cb0d679SMarcel Telka extern bool_t xdr_SYMLINK3res(XDR *, SYMLINK3res *);
2151*5cb0d679SMarcel Telka extern bool_t xdr_MKNOD3args(XDR *, MKNOD3args *);
2152*5cb0d679SMarcel Telka extern bool_t xdr_MKNOD3res(XDR *, MKNOD3res *);
2153*5cb0d679SMarcel Telka extern bool_t xdr_REMOVE3res(XDR *, REMOVE3res *);
2154*5cb0d679SMarcel Telka extern bool_t xdr_RMDIR3resfail(XDR *, RMDIR3resfail *);
2155*5cb0d679SMarcel Telka extern bool_t xdr_RMDIR3res(XDR *, RMDIR3res *);
2156*5cb0d679SMarcel Telka extern bool_t xdr_RENAME3args(XDR *, RENAME3args *);
2157*5cb0d679SMarcel Telka extern bool_t xdr_RENAME3res(XDR *, RENAME3res *);
2158*5cb0d679SMarcel Telka extern bool_t xdr_LINK3args(XDR *, LINK3args *);
2159*5cb0d679SMarcel Telka extern bool_t xdr_LINK3res(XDR *, LINK3res *);
2160*5cb0d679SMarcel Telka extern bool_t xdr_READDIR3args(XDR *, READDIR3args *);
2161*5cb0d679SMarcel Telka extern bool_t xdr_READDIR3res(XDR *, READDIR3res *);
2162*5cb0d679SMarcel Telka extern bool_t xdr_READDIR3vres(XDR *, READDIR3vres *);
2163*5cb0d679SMarcel Telka extern bool_t xdr_READDIRPLUS3args(XDR *, READDIRPLUS3args *);
2164*5cb0d679SMarcel Telka extern bool_t xdr_READDIRPLUS3res(XDR *, READDIRPLUS3res *);
2165*5cb0d679SMarcel Telka extern bool_t xdr_READDIRPLUS3vres(XDR *, READDIRPLUS3vres *);
2166*5cb0d679SMarcel Telka extern bool_t xdr_FSSTAT3res(XDR *, FSSTAT3res *);
2167*5cb0d679SMarcel Telka extern bool_t xdr_FSINFO3res(XDR *, FSINFO3res *);
2168*5cb0d679SMarcel Telka extern bool_t xdr_PATHCONF3res(XDR *, PATHCONF3res *);
2169*5cb0d679SMarcel Telka extern bool_t xdr_COMMIT3args(XDR *, COMMIT3args *);
2170*5cb0d679SMarcel Telka extern bool_t xdr_COMMIT3res(XDR *, COMMIT3res *);
2171*5cb0d679SMarcel Telka extern bool_t xdr_fastnfs_fh3(XDR *, nfs_fh3 **);
21727c478bd9Sstevel@tonic-gate 
21737c478bd9Sstevel@tonic-gate /*
21747c478bd9Sstevel@tonic-gate  * The NFS Version 3 service procedures.
21757c478bd9Sstevel@tonic-gate  */
21767c478bd9Sstevel@tonic-gate struct exportinfo;	/* defined in nfs/export.h */
21777c478bd9Sstevel@tonic-gate struct servinfo;	/* defined in nfs/nfs_clnt.h */
21787c478bd9Sstevel@tonic-gate struct mntinfo;		/* defined in nfs/nfs_clnt.h */
21797c478bd9Sstevel@tonic-gate struct sec_ol;		/* defined in nfs/export.h */
21807c478bd9Sstevel@tonic-gate 
2181*5cb0d679SMarcel Telka extern void	rfs3_getattr(GETATTR3args *, GETATTR3res *, struct exportinfo *,
2182*5cb0d679SMarcel Telka     struct svc_req *, cred_t *, bool_t);
2183*5cb0d679SMarcel Telka extern void	*rfs3_getattr_getfh(GETATTR3args *);
2184*5cb0d679SMarcel Telka extern void	rfs3_setattr(SETATTR3args *, SETATTR3res *, struct exportinfo *,
2185*5cb0d679SMarcel Telka     struct svc_req *, cred_t *, bool_t);
2186*5cb0d679SMarcel Telka extern void	*rfs3_setattr_getfh(SETATTR3args *);
2187*5cb0d679SMarcel Telka extern void	rfs3_lookup(LOOKUP3args *, LOOKUP3res *, struct exportinfo *,
2188*5cb0d679SMarcel Telka     struct svc_req *, cred_t *, bool_t);
2189*5cb0d679SMarcel Telka extern void	*rfs3_lookup_getfh(LOOKUP3args *);
2190*5cb0d679SMarcel Telka extern void	rfs3_access(ACCESS3args *, ACCESS3res *, struct exportinfo *,
2191*5cb0d679SMarcel Telka     struct svc_req *, cred_t *, bool_t);
2192*5cb0d679SMarcel Telka extern void	*rfs3_access_getfh(ACCESS3args *);
2193*5cb0d679SMarcel Telka extern void	rfs3_readlink(READLINK3args *, READLINK3res *,
2194*5cb0d679SMarcel Telka     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
2195*5cb0d679SMarcel Telka extern void	*rfs3_readlink_getfh(READLINK3args *);
2196*5cb0d679SMarcel Telka extern void	rfs3_readlink_free(READLINK3res *);
2197*5cb0d679SMarcel Telka extern void	rfs3_read(READ3args *, READ3res *, struct exportinfo *,
2198*5cb0d679SMarcel Telka     struct svc_req *, cred_t *, bool_t);
2199*5cb0d679SMarcel Telka extern void	*rfs3_read_getfh(READ3args *);
2200*5cb0d679SMarcel Telka extern void	rfs3_read_free(READ3res *);
2201*5cb0d679SMarcel Telka extern void	rfs3_write(WRITE3args *, WRITE3res *, struct exportinfo *,
2202*5cb0d679SMarcel Telka     struct svc_req *, cred_t *, bool_t);
2203*5cb0d679SMarcel Telka extern void	*rfs3_write_getfh(WRITE3args *);
2204*5cb0d679SMarcel Telka extern void	rfs3_create(CREATE3args *, CREATE3res *, struct exportinfo *,
2205*5cb0d679SMarcel Telka     struct svc_req *, cred_t *, bool_t);
2206*5cb0d679SMarcel Telka extern void	*rfs3_create_getfh(CREATE3args *);
2207*5cb0d679SMarcel Telka extern void	rfs3_mkdir(MKDIR3args *, MKDIR3res *, struct exportinfo *,
2208*5cb0d679SMarcel Telka     struct svc_req *, cred_t *, bool_t);
2209*5cb0d679SMarcel Telka extern void	*rfs3_mkdir_getfh(MKDIR3args *);
2210*5cb0d679SMarcel Telka extern void	rfs3_symlink(SYMLINK3args *, SYMLINK3res *, struct exportinfo *,
2211*5cb0d679SMarcel Telka     struct svc_req *, cred_t *, bool_t);
2212*5cb0d679SMarcel Telka extern void	*rfs3_symlink_getfh(SYMLINK3args *);
2213*5cb0d679SMarcel Telka extern void	rfs3_mknod(MKNOD3args *, MKNOD3res *, struct exportinfo *,
2214*5cb0d679SMarcel Telka     struct svc_req *, cred_t *, bool_t);
2215*5cb0d679SMarcel Telka extern void	*rfs3_mknod_getfh(MKNOD3args *);
2216*5cb0d679SMarcel Telka extern void	rfs3_remove(REMOVE3args *, REMOVE3res *, struct exportinfo *,
2217*5cb0d679SMarcel Telka     struct svc_req *, cred_t *, bool_t);
2218*5cb0d679SMarcel Telka extern void	*rfs3_remove_getfh(REMOVE3args *);
2219*5cb0d679SMarcel Telka extern void	rfs3_rmdir(RMDIR3args *, RMDIR3res *, struct exportinfo *,
2220*5cb0d679SMarcel Telka     struct svc_req *, cred_t *, bool_t);
2221*5cb0d679SMarcel Telka extern void	*rfs3_rmdir_getfh(RMDIR3args *);
2222*5cb0d679SMarcel Telka extern void	rfs3_rename(RENAME3args *, RENAME3res *, struct exportinfo *,
2223*5cb0d679SMarcel Telka     struct svc_req *, cred_t *, bool_t);
2224*5cb0d679SMarcel Telka extern void	*rfs3_rename_getfh(RENAME3args *);
2225*5cb0d679SMarcel Telka extern void	rfs3_link(LINK3args *, LINK3res *, struct exportinfo *,
2226*5cb0d679SMarcel Telka     struct svc_req *, cred_t *, bool_t);
2227*5cb0d679SMarcel Telka extern void	*rfs3_link_getfh(LINK3args *);
2228*5cb0d679SMarcel Telka extern void	rfs3_readdir(READDIR3args *, READDIR3res *, struct exportinfo *,
2229*5cb0d679SMarcel Telka     struct svc_req *, cred_t *, bool_t);
2230*5cb0d679SMarcel Telka extern void	*rfs3_readdir_getfh(READDIR3args *);
2231*5cb0d679SMarcel Telka extern void	rfs3_readdir_free(READDIR3res *);
2232*5cb0d679SMarcel Telka extern void	rfs3_readdirplus(READDIRPLUS3args *, READDIRPLUS3res *,
2233*5cb0d679SMarcel Telka     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
2234*5cb0d679SMarcel Telka extern void	*rfs3_readdirplus_getfh(READDIRPLUS3args *);
2235*5cb0d679SMarcel Telka extern void	rfs3_readdirplus_free(READDIRPLUS3res *);
2236*5cb0d679SMarcel Telka extern void	rfs3_fsstat(FSSTAT3args *, FSSTAT3res *, struct exportinfo *,
2237*5cb0d679SMarcel Telka     struct svc_req *, cred_t *, bool_t);
2238*5cb0d679SMarcel Telka extern void	*rfs3_fsstat_getfh(FSSTAT3args *);
2239*5cb0d679SMarcel Telka extern void	rfs3_fsinfo(FSINFO3args *, FSINFO3res *, struct exportinfo *,
2240*5cb0d679SMarcel Telka     struct svc_req *, cred_t *, bool_t);
2241*5cb0d679SMarcel Telka extern void	*rfs3_fsinfo_getfh(FSINFO3args *);
2242*5cb0d679SMarcel Telka extern void	rfs3_pathconf(PATHCONF3args *, PATHCONF3res *,
2243*5cb0d679SMarcel Telka     struct exportinfo *, struct svc_req *, cred_t *, bool_t);
2244*5cb0d679SMarcel Telka extern void	*rfs3_pathconf_getfh(PATHCONF3args *);
2245*5cb0d679SMarcel Telka extern void	rfs3_commit(COMMIT3args *, COMMIT3res *, struct exportinfo *,
2246*5cb0d679SMarcel Telka     struct svc_req *, cred_t *, bool_t);
2247*5cb0d679SMarcel Telka extern void	*rfs3_commit_getfh(COMMIT3args *);
2248*5cb0d679SMarcel Telka extern void	rfs3_srvrinit(void);
2249*5cb0d679SMarcel Telka extern void	rfs3_srvrfini(void);
22507c478bd9Sstevel@tonic-gate 
2251*5cb0d679SMarcel Telka extern int	nfs3_validate_caches(vnode_t *, cred_t *);
2252*5cb0d679SMarcel Telka extern void	nfs3_cache_post_op_attr(vnode_t *, post_op_attr *, hrtime_t,
22537c478bd9Sstevel@tonic-gate     cred_t *);
2254*5cb0d679SMarcel Telka extern void	nfs3_cache_post_op_vattr(vnode_t *, post_op_vattr *, hrtime_t,
2255*5cb0d679SMarcel Telka     cred_t *);
2256*5cb0d679SMarcel Telka extern void	nfs3_cache_wcc_data(vnode_t *, wcc_data *, hrtime_t, cred_t *);
2257*5cb0d679SMarcel Telka extern void	nfs3_attrcache(vnode_t *, fattr3 *, hrtime_t);
2258*5cb0d679SMarcel Telka extern int	nfs3_cache_fattr3(vnode_t *, fattr3 *, vattr_t *, hrtime_t,
2259*5cb0d679SMarcel Telka     cred_t *);
2260*5cb0d679SMarcel Telka extern int	nfs3_getattr_otw(vnode_t *, struct vattr *, cred_t *);
2261*5cb0d679SMarcel Telka extern int	nfs3getattr(vnode_t *, struct vattr *, cred_t *);
2262*5cb0d679SMarcel Telka extern int	fattr3_to_vattr(vnode_t *, fattr3 *, struct vattr *);
2263*5cb0d679SMarcel Telka extern int	nfs3tsize(void);
2264*5cb0d679SMarcel Telka extern uint_t	nfs3_tsize(struct knetconfig *);
2265*5cb0d679SMarcel Telka extern uint_t	rfs3_tsize(struct svc_req *);
2266*5cb0d679SMarcel Telka extern int	vattr_to_sattr3(struct vattr *, sattr3 *);
2267*5cb0d679SMarcel Telka extern void	setdiropargs3(diropargs3 *, char *, vnode_t *);
2268*5cb0d679SMarcel Telka extern enum nfsstat3 puterrno3(int);
2269*5cb0d679SMarcel Telka extern int	geterrno3(enum nfsstat3);
2270*5cb0d679SMarcel Telka extern int	nfs3init(int, char *);
2271*5cb0d679SMarcel Telka extern void	nfs3fini(void);
2272*5cb0d679SMarcel Telka extern int	nfs3_vfsinit(void);
2273*5cb0d679SMarcel Telka extern void	nfs3_vfsfini(void);
2274*5cb0d679SMarcel Telka extern void	vattr_to_post_op_attr(struct vattr *, post_op_attr *);
2275*5cb0d679SMarcel Telka extern void	mblk_to_iov(mblk_t *, int, struct iovec *);
2276*5cb0d679SMarcel Telka extern int	rfs_publicfh_mclookup(char *, vnode_t *, cred_t *, vnode_t **,
2277e36d7b11SSebastien Roy     struct exportinfo **, struct sec_ol *);
2278*5cb0d679SMarcel Telka extern int	rfs_pathname(char *, vnode_t **, vnode_t **, vnode_t *,
2279*5cb0d679SMarcel Telka     cred_t *, int);
2280e36d7b11SSebastien Roy 
22817c478bd9Sstevel@tonic-gate extern vtype_t		nf3_to_vt[];
22827c478bd9Sstevel@tonic-gate extern kstat_named_t	*rfsproccnt_v3_ptr;
22837c478bd9Sstevel@tonic-gate extern vfsops_t		*nfs3_vfsops;
22847c478bd9Sstevel@tonic-gate extern struct vnodeops	*nfs3_vnodeops;
22857c478bd9Sstevel@tonic-gate extern const struct fs_operation_def nfs3_vnodeops_template[];
228627246829SVitaliy Gusev 
22877c478bd9Sstevel@tonic-gate /*
22887c478bd9Sstevel@tonic-gate  * Some servers do not properly update the attributes of the
22897c478bd9Sstevel@tonic-gate  * directory when changes are made.  To allow interoperability
22907c478bd9Sstevel@tonic-gate  * with these broken servers, the nfs_disable_rddir_cache
22917c478bd9Sstevel@tonic-gate  * parameter can be used to disable readdir response caching.
22927c478bd9Sstevel@tonic-gate  */
22937c478bd9Sstevel@tonic-gate extern int		nfs_disable_rddir_cache;
22947c478bd9Sstevel@tonic-gate 
22957c478bd9Sstevel@tonic-gate /*
22967c478bd9Sstevel@tonic-gate  * External functions called by the v2/v3 code into the v4 code
22977c478bd9Sstevel@tonic-gate  */
2298*5cb0d679SMarcel Telka extern void	nfs4_clnt_init(void);
2299*5cb0d679SMarcel Telka extern void	nfs4_clnt_fini(void);
23007c478bd9Sstevel@tonic-gate 
23017c478bd9Sstevel@tonic-gate /*
23027c478bd9Sstevel@tonic-gate  * Does NFS4 server have a vnode delegated?  TRUE if so, FALSE if not.
23037c478bd9Sstevel@tonic-gate  */
2304*5cb0d679SMarcel Telka extern bool_t	rfs4_check_delegated(int mode, vnode_t *, bool_t trunc);
23057c478bd9Sstevel@tonic-gate /*
23067c478bd9Sstevel@tonic-gate  * VOP_GETATTR call. If a NFS4 delegation is present on the supplied vnode
23077c478bd9Sstevel@tonic-gate  * call back to the delegated client to get attributes for AT_MTIME and
23087c478bd9Sstevel@tonic-gate  * AT_SIZE. Invoke VOP_GETATTR to get all other attributes or all attributes
23097c478bd9Sstevel@tonic-gate  * if no delegation is present.
23107c478bd9Sstevel@tonic-gate  */
2311*5cb0d679SMarcel Telka extern int	rfs4_delegated_getattr(vnode_t *, vattr_t *, int, cred_t *);
2312*5cb0d679SMarcel Telka extern void	rfs4_hold_deleg_policy(void);
2313*5cb0d679SMarcel Telka extern void	rfs4_rele_deleg_policy(void);
231493aeed83Smarks 
2315*5cb0d679SMarcel Telka extern int	do_xattr_exists_check(vnode_t *, ulong_t *, cred_t *);
231693aeed83Smarks 
2317*5cb0d679SMarcel Telka extern ts_label_t *nfs_getflabel(vnode_t *, struct exportinfo *);
2318*5cb0d679SMarcel Telka extern boolean_t do_rfs_label_check(bslabel_t *, vnode_t *, int,
2319*5cb0d679SMarcel Telka     struct exportinfo *);
2320c242f9a0Schunli zhang - Sun Microsystems - Irvine United States 
2321c242f9a0Schunli zhang - Sun Microsystems - Irvine United States /*
2322c242f9a0Schunli zhang - Sun Microsystems - Irvine United States  * Copy Reduction support.
2323c242f9a0Schunli zhang - Sun Microsystems - Irvine United States  * xuio_t wrapper with additional private data.
2324c242f9a0Schunli zhang - Sun Microsystems - Irvine United States  */
2325c242f9a0Schunli zhang - Sun Microsystems - Irvine United States 
2326c242f9a0Schunli zhang - Sun Microsystems - Irvine United States typedef struct nfs_xuio {
2327c242f9a0Schunli zhang - Sun Microsystems - Irvine United States 	xuio_t nu_uio;
2328c242f9a0Schunli zhang - Sun Microsystems - Irvine United States 	vnode_t *nu_vp;
2329c242f9a0Schunli zhang - Sun Microsystems - Irvine United States 	uint_t nu_ref;
2330c242f9a0Schunli zhang - Sun Microsystems - Irvine United States 	frtn_t nu_frtn;
2331c242f9a0Schunli zhang - Sun Microsystems - Irvine United States } nfs_xuio_t;
2332c242f9a0Schunli zhang - Sun Microsystems - Irvine United States 
2333*5cb0d679SMarcel Telka extern xuio_t	*rfs_setup_xuio(vnode_t *);
2334*5cb0d679SMarcel Telka extern mblk_t	*uio_to_mblk(uio_t *);
2335*5cb0d679SMarcel Telka extern mblk_t	*rfs_read_alloc(uint_t, struct iovec **, int *);
2336*5cb0d679SMarcel Telka extern void	rfs_rndup_mblks(mblk_t *, uint_t, int);
2337*5cb0d679SMarcel Telka extern void	rfs_free_xuio(void *);
2338c242f9a0Schunli zhang - Sun Microsystems - Irvine United States 
23397c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
23407c478bd9Sstevel@tonic-gate 
23417c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
23427c478bd9Sstevel@tonic-gate }
23437c478bd9Sstevel@tonic-gate #endif
23447c478bd9Sstevel@tonic-gate 
23457c478bd9Sstevel@tonic-gate #endif	/* _NFS_NFS_H */
2346