Home | History | Annotate | Line # | Download | only in common
nfs.h revision 1.2
      1  1.2  pgoyette /*	$NetBSD: nfs.h,v 1.2 2016/12/13 22:52:46 pgoyette Exp $	*/
      2  1.1  dholland /*-
      3  1.1  dholland  * Copyright (c) 1989, 1993
      4  1.1  dholland  *	The Regents of the University of California.  All rights reserved.
      5  1.1  dholland  *
      6  1.1  dholland  * This code is derived from software contributed to Berkeley by
      7  1.1  dholland  * Rick Macklem at The University of Guelph.
      8  1.1  dholland  *
      9  1.1  dholland  * Redistribution and use in source and binary forms, with or without
     10  1.1  dholland  * modification, are permitted provided that the following conditions
     11  1.1  dholland  * are met:
     12  1.1  dholland  * 1. Redistributions of source code must retain the above copyright
     13  1.1  dholland  *    notice, this list of conditions and the following disclaimer.
     14  1.1  dholland  * 2. Redistributions in binary form must reproduce the above copyright
     15  1.1  dholland  *    notice, this list of conditions and the following disclaimer in the
     16  1.1  dholland  *    documentation and/or other materials provided with the distribution.
     17  1.1  dholland  * 4. Neither the name of the University nor the names of its contributors
     18  1.1  dholland  *    may be used to endorse or promote products derived from this software
     19  1.1  dholland  *    without specific prior written permission.
     20  1.1  dholland  *
     21  1.1  dholland  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     22  1.1  dholland  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     23  1.1  dholland  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24  1.1  dholland  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     25  1.1  dholland  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     26  1.1  dholland  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     27  1.1  dholland  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     28  1.1  dholland  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     29  1.1  dholland  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     30  1.1  dholland  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     31  1.1  dholland  * SUCH DAMAGE.
     32  1.1  dholland  *
     33  1.2  pgoyette  * FreeBSD: head/sys/fs/nfs/nfs.h 291527 2015-11-30 21:54:27Z rmacklem
     34  1.2  pgoyette  * $NetBSD: nfs.h,v 1.2 2016/12/13 22:52:46 pgoyette Exp $
     35  1.1  dholland  */
     36  1.1  dholland 
     37  1.1  dholland #ifndef _NFS_NFS_H_
     38  1.1  dholland #define	_NFS_NFS_H_
     39  1.1  dholland /*
     40  1.1  dholland  * Tunable constants for nfs
     41  1.1  dholland  */
     42  1.1  dholland 
     43  1.1  dholland #define	NFS_MAXIOVEC	34
     44  1.1  dholland #define	NFS_TICKINTVL	500		/* Desired time for a tick (msec) */
     45  1.1  dholland #define	NFS_HZ		(hz / nfscl_ticks) /* Ticks/sec */
     46  1.1  dholland #define	NFS_TIMEO	(1 * NFS_HZ)	/* Default timeout = 1 second */
     47  1.1  dholland #define	NFS_MINTIMEO	(1 * NFS_HZ)	/* Min timeout to use */
     48  1.1  dholland #define	NFS_MAXTIMEO	(60 * NFS_HZ)	/* Max timeout to backoff to */
     49  1.1  dholland #define	NFS_TCPTIMEO	300		/* TCP timeout */
     50  1.1  dholland #define	NFS_MAXRCVTIMEO	60		/* 1 minute in seconds */
     51  1.1  dholland #define	NFS_MINIDEMTIMEO (5 * NFS_HZ)	/* Min timeout for non-idempotent ops*/
     52  1.1  dholland #define	NFS_MAXREXMIT	100		/* Stop counting after this many */
     53  1.1  dholland #define	NFSV4_CALLBACKTIMEO (2 * NFS_HZ) /* Timeout in ticks */
     54  1.1  dholland #define	NFSV4_CALLBACKRETRY 5		/* Number of retries before failure */
     55  1.2  pgoyette #define	NFSV4_SLOTS	64		/* Number of slots, fore channel */
     56  1.2  pgoyette #define	NFSV4_CBSLOTS	8		/* Number of slots, back channel */
     57  1.1  dholland #define	NFSV4_CBRETRYCNT 4		/* # of CBRecall retries upon err */
     58  1.1  dholland #define	NFSV4_UPCALLTIMEO (15 * NFS_HZ)	/* Timeout in ticks for upcalls */
     59  1.1  dholland 					/* to gssd or nfsuserd */
     60  1.1  dholland #define	NFSV4_UPCALLRETRY 4		/* Number of retries before failure */
     61  1.1  dholland #define	NFS_MAXWINDOW	1024		/* Max number of outstanding requests */
     62  1.1  dholland #define	NFS_RETRANS	10		/* Num of retrans for soft mounts */
     63  1.1  dholland #define	NFS_RETRANS_TCP	2		/* Num of retrans for TCP soft mounts */
     64  1.1  dholland #define	NFS_MAXGRPS	16		/* Max. size of groups list */
     65  1.1  dholland #define	NFS_TRYLATERDEL	15		/* Maximum delay timeout (sec) */
     66  1.1  dholland #ifndef NFS_REMOVETIMEO
     67  1.1  dholland #define	NFS_REMOVETIMEO 15  /* # sec to wait for delegret in local syscall */
     68  1.1  dholland #endif
     69  1.1  dholland #ifndef NFS_MINATTRTIMO
     70  1.1  dholland #define	NFS_MINATTRTIMO 5		/* Attribute cache timeout in sec */
     71  1.1  dholland #endif
     72  1.1  dholland #ifndef NFS_MAXATTRTIMO
     73  1.1  dholland #define	NFS_MAXATTRTIMO 60
     74  1.1  dholland #endif
     75  1.2  pgoyette #if 0	/* Defined in NetBSD in machine/param.h */
     76  1.1  dholland #define	NFS_WSIZE	8192		/* Def. write data size <= 8192 */
     77  1.1  dholland #define	NFS_RSIZE	8192		/* Def. read data size <= 8192 */
     78  1.2  pgoyette #endif
     79  1.1  dholland #define	NFS_READDIRSIZE	8192		/* Def. readdir size */
     80  1.1  dholland #define	NFS_DEFRAHEAD	1		/* Def. read ahead # blocks */
     81  1.1  dholland #define	NFS_MAXRAHEAD	16		/* Max. read ahead # blocks */
     82  1.1  dholland #define	NFS_MAXASYNCDAEMON 	64	/* Max. number async_daemons runnable */
     83  1.1  dholland #define	NFS_MAXUIDHASH	64		/* Max. # of hashed uid entries/mp */
     84  1.1  dholland #ifndef	NFSRV_LEASE
     85  1.1  dholland #define	NFSRV_LEASE		120	/* Lease time in seconds for V4 */
     86  1.1  dholland #endif					/* assigned to nfsrv_lease */
     87  1.1  dholland #ifndef NFSRV_STALELEASE
     88  1.1  dholland #define	NFSRV_STALELEASE	(5 * nfsrv_lease)
     89  1.1  dholland #endif
     90  1.1  dholland #ifndef NFSRV_MOULDYLEASE
     91  1.1  dholland #define	NFSRV_MOULDYLEASE	604800	/* One week (in sec) */
     92  1.1  dholland #endif
     93  1.1  dholland #ifndef NFSCLIENTHASHSIZE
     94  1.1  dholland #define	NFSCLIENTHASHSIZE	20	/* Size of server client hash table */
     95  1.1  dholland #endif
     96  1.1  dholland #ifndef NFSLOCKHASHSIZE
     97  1.1  dholland #define	NFSLOCKHASHSIZE		20	/* Size of server nfslock hash table */
     98  1.1  dholland #endif
     99  1.2  pgoyette #ifndef NFSSESSIONHASHSIZE
    100  1.2  pgoyette #define	NFSSESSIONHASHSIZE	20	/* Size of server session hash table */
    101  1.2  pgoyette #endif
    102  1.1  dholland #define	NFSSTATEHASHSIZE	10	/* Size of server stateid hash table */
    103  1.1  dholland #ifndef	NFSCLDELEGHIGHWATER
    104  1.1  dholland #define	NFSCLDELEGHIGHWATER	10000	/* limit for client delegations */
    105  1.1  dholland #endif
    106  1.1  dholland #ifndef	NFSCLLAYOUTHIGHWATER
    107  1.1  dholland #define	NFSCLLAYOUTHIGHWATER	10000	/* limit for client pNFS layouts */
    108  1.1  dholland #endif
    109  1.1  dholland #ifndef NFSNOOPEN			/* Inactive open owner (sec) */
    110  1.1  dholland #define	NFSNOOPEN		120
    111  1.1  dholland #endif
    112  1.1  dholland #define	NFSRV_LEASEDELTA	15	/* # of seconds to delay beyond lease */
    113  1.1  dholland #define	NFS_IDMAXSIZE		4	/* max sizeof (in_addr_t) */
    114  1.1  dholland #ifndef NFSRVCACHE_UDPTIMEOUT
    115  1.1  dholland #define	NFSRVCACHE_UDPTIMEOUT	30	/* # of sec to hold cached rpcs(udp) */
    116  1.1  dholland #endif
    117  1.1  dholland #ifndef NFSRVCACHE_UDPHIGHWATER
    118  1.1  dholland #define	NFSRVCACHE_UDPHIGHWATER	500	/* Max # of udp cache entries */
    119  1.1  dholland #endif
    120  1.1  dholland #ifndef NFSRVCACHE_TCPTIMEOUT
    121  1.1  dholland #define	NFSRVCACHE_TCPTIMEOUT	(3600*12) /*#of sec to hold cached rpcs(tcp) */
    122  1.1  dholland #endif
    123  1.1  dholland #ifndef	NFSRVCACHE_FLOODLEVEL
    124  1.1  dholland #define	NFSRVCACHE_FLOODLEVEL	16384	/* Very high water mark for cache */
    125  1.1  dholland #endif
    126  1.1  dholland #ifndef	NFSRV_CLIENTHIGHWATER
    127  1.1  dholland #define	NFSRV_CLIENTHIGHWATER	1000
    128  1.1  dholland #endif
    129  1.1  dholland #ifndef	NFSRV_MAXDUMPLIST
    130  1.1  dholland #define	NFSRV_MAXDUMPLIST	10000
    131  1.1  dholland #endif
    132  1.1  dholland #ifndef NFS_ACCESSCACHESIZE
    133  1.1  dholland #define	NFS_ACCESSCACHESIZE	8
    134  1.1  dholland #endif
    135  1.1  dholland #define	NFSV4_CBPORT	7745		/* Callback port for testing */
    136  1.1  dholland 
    137  1.1  dholland /*
    138  1.1  dholland  * This macro defines the high water mark for issuing V4 delegations.
    139  1.2  pgoyette  * (It is currently set at a conservative 20% of nfsrv_v4statelimit. This
    140  1.1  dholland  *  may want to increase when clients can make more effective use of
    141  1.1  dholland  *  delegations.)
    142  1.1  dholland  */
    143  1.2  pgoyette #define	NFSRV_V4DELEGLIMIT(c) (((c) * 5) > nfsrv_v4statelimit)
    144  1.1  dholland 
    145  1.1  dholland #define	NFS_READDIRBLKSIZ	DIRBLKSIZ	/* Minimal nm_readdirsize */
    146  1.1  dholland 
    147  1.1  dholland /*
    148  1.1  dholland  * Oddballs
    149  1.1  dholland  */
    150  1.1  dholland #define	NFS_CMPFH(n, f, s) 						\
    151  1.2  pgoyette     ((n)->n_fhp->nfh_len == (s) && !NFSBCMP((n)->n_fhp->nfh_fh, (void *)(f), (s)))
    152  1.1  dholland #define	NFSRV_CMPFH(nf, ns, f, s) 					\
    153  1.2  pgoyette 	((ns) == (s) && !NFSBCMP((void *)(nf), (void *)(f), (s)))
    154  1.1  dholland #define	NFS_CMPTIME(t1, t2) 						\
    155  1.1  dholland 	((t1).tv_sec == (t2).tv_sec && (t1).tv_nsec == (t2).tv_nsec)
    156  1.1  dholland #define	NFS_SETTIME(t) do { 						\
    157  1.1  dholland 	(t).tv_sec = time.tv_sec; (t).tv_nsec = 1000 * time.tv_usec; } while (0)
    158  1.1  dholland #define	NFS_SRVMAXDATA(n) 						\
    159  1.1  dholland 		(((n)->nd_flag & (ND_NFSV3 | ND_NFSV4)) ? 		\
    160  1.2  pgoyette 		 NFS_SRVMAXIO : NFS_V2MAXDATA)
    161  1.1  dholland #define	NFS64BITSSET	0xffffffffffffffffull
    162  1.1  dholland #define	NFS64BITSMINUS1	0xfffffffffffffffeull
    163  1.1  dholland 
    164  1.1  dholland /*
    165  1.1  dholland  * Structures for the nfssvc(2) syscall. Not that anyone but nfsd, mount_nfs
    166  1.1  dholland  * and nfsloaduser should ever try and use it.
    167  1.1  dholland  */
    168  1.1  dholland struct nfsd_addsock_args {
    169  1.1  dholland 	int	sock;		/* Socket to serve */
    170  1.2  pgoyette 	char	*name;		/* Client addr for connection based sockets */
    171  1.1  dholland 	int	namelen;	/* Length of name */
    172  1.1  dholland };
    173  1.1  dholland 
    174  1.1  dholland /*
    175  1.1  dholland  * nfsd argument for new krpc.
    176  1.1  dholland  */
    177  1.1  dholland struct nfsd_nfsd_args {
    178  1.1  dholland 	const char *principal;	/* GSS-API service principal name */
    179  1.1  dholland 	int	minthreads;	/* minimum service thread count */
    180  1.1  dholland 	int	maxthreads;	/* maximum service thread count */
    181  1.1  dholland };
    182  1.1  dholland 
    183  1.1  dholland /*
    184  1.1  dholland  * Arguments for use by the callback daemon.
    185  1.1  dholland  */
    186  1.1  dholland struct nfsd_nfscbd_args {
    187  1.1  dholland 	const char *principal;	/* GSS-API service principal name */
    188  1.1  dholland };
    189  1.1  dholland 
    190  1.1  dholland struct nfscbd_args {
    191  1.1  dholland 	int	sock;		/* Socket to serve */
    192  1.2  pgoyette 	char	*name;		/* Client addr for connection based sockets */
    193  1.1  dholland 	int	namelen;	/* Length of name */
    194  1.1  dholland 	u_short	port;		/* Port# for callbacks */
    195  1.1  dholland };
    196  1.1  dholland 
    197  1.1  dholland struct nfsd_idargs {
    198  1.1  dholland 	int		nid_flag;	/* Flags (see below) */
    199  1.1  dholland 	uid_t		nid_uid;	/* user/group id */
    200  1.1  dholland 	gid_t		nid_gid;
    201  1.1  dholland 	int		nid_usermax;	/* Upper bound on user name cache */
    202  1.1  dholland 	int		nid_usertimeout;/* User name timeout (minutes) */
    203  1.1  dholland 	u_char		*nid_name;	/* Name */
    204  1.1  dholland 	int		nid_namelen;	/* and its length */
    205  1.2  pgoyette 	gid_t		*nid_grps;	/* and the list */
    206  1.2  pgoyette 	int		nid_ngroup;	/* Size of groups list */
    207  1.2  pgoyette };
    208  1.2  pgoyette 
    209  1.2  pgoyette struct nfsd_oidargs {
    210  1.2  pgoyette 	int		nid_flag;	/* Flags (see below) */
    211  1.2  pgoyette 	uid_t		nid_uid;	/* user/group id */
    212  1.2  pgoyette 	gid_t		nid_gid;
    213  1.2  pgoyette 	int		nid_usermax;	/* Upper bound on user name cache */
    214  1.2  pgoyette 	int		nid_usertimeout;/* User name timeout (minutes) */
    215  1.2  pgoyette 	u_char		*nid_name;	/* Name */
    216  1.2  pgoyette 	int		nid_namelen;	/* and its length */
    217  1.1  dholland };
    218  1.1  dholland 
    219  1.1  dholland struct nfsd_clid {
    220  1.1  dholland 	int		nclid_idlen;	/* Length of client id */
    221  1.1  dholland 	u_char		nclid_id[NFSV4_OPAQUELIMIT]; /* and name */
    222  1.1  dholland };
    223  1.1  dholland 
    224  1.1  dholland struct nfsd_dumplist {
    225  1.1  dholland 	int		ndl_size;	/* Number of elements */
    226  1.1  dholland 	void		*ndl_list;	/* and the list of elements */
    227  1.1  dholland };
    228  1.1  dholland 
    229  1.1  dholland struct nfsd_dumpclients {
    230  1.1  dholland 	u_int32_t	ndcl_flags;		/* LCL_xxx flags */
    231  1.1  dholland 	u_int32_t	ndcl_nopenowners;	/* Number of openowners */
    232  1.1  dholland 	u_int32_t	ndcl_nopens;		/* and opens */
    233  1.1  dholland 	u_int32_t	ndcl_nlockowners;	/* and of lockowners */
    234  1.1  dholland 	u_int32_t	ndcl_nlocks;		/* and of locks */
    235  1.1  dholland 	u_int32_t	ndcl_ndelegs;		/* and of delegations */
    236  1.1  dholland 	u_int32_t	ndcl_nolddelegs;	/* and old delegations */
    237  1.1  dholland 	sa_family_t	ndcl_addrfam;		/* Callback address */
    238  1.1  dholland 	union {
    239  1.1  dholland 		struct in_addr sin_addr;
    240  1.1  dholland 		struct in6_addr sin6_addr;
    241  1.1  dholland 	} ndcl_cbaddr;
    242  1.1  dholland 	struct nfsd_clid ndcl_clid;	/* and client id */
    243  1.1  dholland };
    244  1.1  dholland 
    245  1.1  dholland struct nfsd_dumplocklist {
    246  1.1  dholland 	char		*ndllck_fname;	/* File Name */
    247  1.1  dholland 	int		ndllck_size;	/* Number of elements */
    248  1.1  dholland 	void		*ndllck_list;	/* and the list of elements */
    249  1.1  dholland };
    250  1.1  dholland 
    251  1.1  dholland struct nfsd_dumplocks {
    252  1.1  dholland 	u_int32_t	ndlck_flags;		/* state flags NFSLCK_xxx */
    253  1.1  dholland 	nfsv4stateid_t	ndlck_stateid;		/* stateid */
    254  1.1  dholland 	u_int64_t	ndlck_first;		/* lock byte range */
    255  1.1  dholland 	u_int64_t	ndlck_end;
    256  1.1  dholland 	struct nfsd_clid ndlck_owner;		/* Owner of open/lock */
    257  1.1  dholland 	sa_family_t	ndlck_addrfam;		/* Callback address */
    258  1.1  dholland 	union {
    259  1.1  dholland 		struct in_addr sin_addr;
    260  1.1  dholland 		struct in6_addr sin6_addr;
    261  1.1  dholland 	} ndlck_cbaddr;
    262  1.1  dholland 	struct nfsd_clid ndlck_clid;	/* and client id */
    263  1.1  dholland };
    264  1.1  dholland 
    265  1.1  dholland /*
    266  1.1  dholland  * Structure for referral information.
    267  1.1  dholland  */
    268  1.1  dholland struct nfsreferral {
    269  1.1  dholland 	u_char		*nfr_srvlist;	/* List of servers */
    270  1.1  dholland 	int		nfr_srvcnt;	/* number of servers */
    271  1.1  dholland 	vnode_t		nfr_vp;	/* vnode for referral */
    272  1.1  dholland 	u_int32_t	nfr_dfileno;	/* assigned dir inode# */
    273  1.1  dholland };
    274  1.1  dholland 
    275  1.1  dholland /*
    276  1.1  dholland  * Flags for lc_flags and opsflags for nfsrv_getclient().
    277  1.1  dholland  */
    278  1.1  dholland #define	LCL_NEEDSCONFIRM	0x00000001
    279  1.1  dholland #define	LCL_DONTCLEAN		0x00000002
    280  1.1  dholland #define	LCL_WAKEUPWANTED	0x00000004
    281  1.1  dholland #define	LCL_TCPCALLBACK		0x00000008
    282  1.1  dholland #define	LCL_CALLBACKSON		0x00000010
    283  1.1  dholland #define	LCL_INDEXNOTOK		0x00000020
    284  1.1  dholland #define	LCL_STAMPEDSTABLE	0x00000040
    285  1.1  dholland #define	LCL_EXPIREIT		0x00000080
    286  1.1  dholland #define	LCL_CBDOWN		0x00000100
    287  1.1  dholland #define	LCL_KERBV		0x00000400
    288  1.1  dholland #define	LCL_NAME		0x00000800
    289  1.1  dholland #define	LCL_NEEDSCBNULL		0x00001000
    290  1.1  dholland #define	LCL_GSSINTEGRITY	0x00002000
    291  1.1  dholland #define	LCL_GSSPRIVACY		0x00004000
    292  1.1  dholland #define	LCL_ADMINREVOKED	0x00008000
    293  1.2  pgoyette #define	LCL_RECLAIMCOMPLETE	0x00010000
    294  1.2  pgoyette #define	LCL_NFSV41		0x00020000
    295  1.1  dholland 
    296  1.1  dholland #define	LCL_GSS		LCL_KERBV	/* Or of all mechs */
    297  1.1  dholland 
    298  1.1  dholland /*
    299  1.1  dholland  * Bits for flags in nfslock and nfsstate.
    300  1.1  dholland  * The access, deny, NFSLCK_READ and NFSLCK_WRITE bits must be defined as
    301  1.1  dholland  * below, in the correct order, so the shifts work for tests.
    302  1.1  dholland  */
    303  1.1  dholland #define	NFSLCK_READACCESS	0x00000001
    304  1.1  dholland #define	NFSLCK_WRITEACCESS	0x00000002
    305  1.1  dholland #define	NFSLCK_ACCESSBITS	(NFSLCK_READACCESS | NFSLCK_WRITEACCESS)
    306  1.1  dholland #define	NFSLCK_SHIFT		2
    307  1.1  dholland #define	NFSLCK_READDENY		0x00000004
    308  1.1  dholland #define	NFSLCK_WRITEDENY	0x00000008
    309  1.1  dholland #define	NFSLCK_DENYBITS		(NFSLCK_READDENY | NFSLCK_WRITEDENY)
    310  1.1  dholland #define	NFSLCK_SHAREBITS 						\
    311  1.1  dholland     (NFSLCK_READACCESS|NFSLCK_WRITEACCESS|NFSLCK_READDENY|NFSLCK_WRITEDENY)
    312  1.1  dholland #define	NFSLCK_LOCKSHIFT	4
    313  1.1  dholland #define	NFSLCK_READ		0x00000010
    314  1.1  dholland #define	NFSLCK_WRITE		0x00000020
    315  1.1  dholland #define	NFSLCK_BLOCKING		0x00000040
    316  1.1  dholland #define	NFSLCK_RECLAIM		0x00000080
    317  1.1  dholland #define	NFSLCK_OPENTOLOCK	0x00000100
    318  1.1  dholland #define	NFSLCK_TEST		0x00000200
    319  1.1  dholland #define	NFSLCK_LOCK		0x00000400
    320  1.1  dholland #define	NFSLCK_UNLOCK		0x00000800
    321  1.1  dholland #define	NFSLCK_OPEN		0x00001000
    322  1.1  dholland #define	NFSLCK_CLOSE		0x00002000
    323  1.1  dholland #define	NFSLCK_CHECK		0x00004000
    324  1.1  dholland #define	NFSLCK_RELEASE		0x00008000
    325  1.1  dholland #define	NFSLCK_NEEDSCONFIRM	0x00010000
    326  1.1  dholland #define	NFSLCK_CONFIRM		0x00020000
    327  1.1  dholland #define	NFSLCK_DOWNGRADE	0x00040000
    328  1.1  dholland #define	NFSLCK_DELEGREAD	0x00080000
    329  1.1  dholland #define	NFSLCK_DELEGWRITE	0x00100000
    330  1.1  dholland #define	NFSLCK_DELEGCUR		0x00200000
    331  1.1  dholland #define	NFSLCK_DELEGPREV	0x00400000
    332  1.1  dholland #define	NFSLCK_OLDDELEG		0x00800000
    333  1.1  dholland #define	NFSLCK_DELEGRECALL	0x01000000
    334  1.1  dholland #define	NFSLCK_SETATTR		0x02000000
    335  1.1  dholland #define	NFSLCK_DELEGPURGE	0x04000000
    336  1.1  dholland #define	NFSLCK_DELEGRETURN	0x08000000
    337  1.2  pgoyette #define	NFSLCK_WANTWDELEG	0x10000000
    338  1.2  pgoyette #define	NFSLCK_WANTRDELEG	0x20000000
    339  1.2  pgoyette #define	NFSLCK_WANTNODELEG	0x40000000
    340  1.2  pgoyette #define	NFSLCK_WANTBITS							\
    341  1.2  pgoyette     (NFSLCK_WANTWDELEG | NFSLCK_WANTRDELEG | NFSLCK_WANTNODELEG)
    342  1.1  dholland 
    343  1.1  dholland /* And bits for nid_flag */
    344  1.1  dholland #define	NFSID_INITIALIZE	0x0001
    345  1.1  dholland #define	NFSID_ADDUID		0x0002
    346  1.1  dholland #define	NFSID_DELUID		0x0004
    347  1.1  dholland #define	NFSID_ADDUSERNAME	0x0008
    348  1.1  dholland #define	NFSID_DELUSERNAME	0x0010
    349  1.1  dholland #define	NFSID_ADDGID		0x0020
    350  1.1  dholland #define	NFSID_DELGID		0x0040
    351  1.1  dholland #define	NFSID_ADDGROUPNAME	0x0080
    352  1.1  dholland #define	NFSID_DELGROUPNAME	0x0100
    353  1.1  dholland 
    354  1.1  dholland /*
    355  1.1  dholland  * fs.nfs sysctl(3) identifiers
    356  1.1  dholland  */
    357  1.1  dholland #define	NFS_NFSSTATS	1		/* struct: struct nfsstats */
    358  1.1  dholland 
    359  1.1  dholland /*
    360  1.1  dholland  * Here is the definition of the attribute bits array and macros that
    361  1.1  dholland  * manipulate it.
    362  1.1  dholland  * THE MACROS MUST BE MANUALLY MODIFIED IF NFSATTRBIT_MAXWORDS CHANGES!!
    363  1.1  dholland  * It is (NFSATTRBIT_MAX + 31) / 32.
    364  1.1  dholland  */
    365  1.2  pgoyette #define	NFSATTRBIT_MAXWORDS	3
    366  1.1  dholland 
    367  1.1  dholland typedef struct {
    368  1.1  dholland 	u_int32_t bits[NFSATTRBIT_MAXWORDS];
    369  1.1  dholland } nfsattrbit_t;
    370  1.1  dholland 
    371  1.2  pgoyette #define	NFSZERO_ATTRBIT(b) do {						\
    372  1.2  pgoyette 	(b)->bits[0] = 0;						\
    373  1.2  pgoyette 	(b)->bits[1] = 0;						\
    374  1.2  pgoyette 	(b)->bits[2] = 0;						\
    375  1.2  pgoyette } while (0)
    376  1.2  pgoyette 
    377  1.2  pgoyette #define	NFSSET_ATTRBIT(t, f) do {					\
    378  1.2  pgoyette 	(t)->bits[0] = (f)->bits[0];			 		\
    379  1.2  pgoyette 	(t)->bits[1] = (f)->bits[1];					\
    380  1.2  pgoyette 	(t)->bits[2] = (f)->bits[2];					\
    381  1.2  pgoyette } while (0)
    382  1.2  pgoyette 
    383  1.1  dholland #define	NFSSETSUPP_ATTRBIT(b) do { 					\
    384  1.1  dholland 	(b)->bits[0] = NFSATTRBIT_SUPP0; 				\
    385  1.2  pgoyette 	(b)->bits[1] = (NFSATTRBIT_SUPP1 | NFSATTRBIT_SUPPSETONLY);	\
    386  1.2  pgoyette 	(b)->bits[2] = NFSATTRBIT_SUPP2;				\
    387  1.2  pgoyette } while (0)
    388  1.2  pgoyette 
    389  1.1  dholland #define	NFSISSET_ATTRBIT(b, p)	((b)->bits[(p) / 32] & (1 << ((p) % 32)))
    390  1.1  dholland #define	NFSSETBIT_ATTRBIT(b, p)	((b)->bits[(p) / 32] |= (1 << ((p) % 32)))
    391  1.1  dholland #define	NFSCLRBIT_ATTRBIT(b, p)	((b)->bits[(p) / 32] &= ~(1 << ((p) % 32)))
    392  1.2  pgoyette 
    393  1.1  dholland #define	NFSCLRALL_ATTRBIT(b, a)	do { 					\
    394  1.2  pgoyette 	(b)->bits[0] &= ~((a)->bits[0]);	 			\
    395  1.2  pgoyette 	(b)->bits[1] &= ~((a)->bits[1]);	 			\
    396  1.2  pgoyette 	(b)->bits[2] &= ~((a)->bits[2]);				\
    397  1.2  pgoyette } while (0)
    398  1.2  pgoyette 
    399  1.1  dholland #define	NFSCLRNOT_ATTRBIT(b, a)	do { 					\
    400  1.2  pgoyette 	(b)->bits[0] &= ((a)->bits[0]);		 			\
    401  1.2  pgoyette 	(b)->bits[1] &= ((a)->bits[1]);		 			\
    402  1.2  pgoyette 	(b)->bits[2] &= ((a)->bits[2]);		 			\
    403  1.2  pgoyette } while (0)
    404  1.2  pgoyette 
    405  1.1  dholland #define	NFSCLRNOTFILLABLE_ATTRBIT(b) do { 				\
    406  1.2  pgoyette 	(b)->bits[0] &= NFSATTRBIT_SUPP0;	 			\
    407  1.2  pgoyette 	(b)->bits[1] &= NFSATTRBIT_SUPP1;				\
    408  1.2  pgoyette 	(b)->bits[2] &= NFSATTRBIT_SUPP2;				\
    409  1.2  pgoyette } while (0)
    410  1.2  pgoyette 
    411  1.1  dholland #define	NFSCLRNOTSETABLE_ATTRBIT(b) do { 				\
    412  1.2  pgoyette 	(b)->bits[0] &= NFSATTRBIT_SETABLE0;	 			\
    413  1.2  pgoyette 	(b)->bits[1] &= NFSATTRBIT_SETABLE1;				\
    414  1.2  pgoyette 	(b)->bits[2] &= NFSATTRBIT_SETABLE2;				\
    415  1.2  pgoyette } while (0)
    416  1.2  pgoyette 
    417  1.2  pgoyette #define	NFSNONZERO_ATTRBIT(b)	((b)->bits[0] || (b)->bits[1] || (b)->bits[2])
    418  1.2  pgoyette #define	NFSEQUAL_ATTRBIT(b, p)	((b)->bits[0] == (p)->bits[0] &&	\
    419  1.2  pgoyette 	(b)->bits[1] == (p)->bits[1] && (b)->bits[2] == (p)->bits[2])
    420  1.2  pgoyette 
    421  1.1  dholland #define	NFSGETATTR_ATTRBIT(b) do { 					\
    422  1.2  pgoyette 	(b)->bits[0] = NFSATTRBIT_GETATTR0;	 			\
    423  1.2  pgoyette 	(b)->bits[1] = NFSATTRBIT_GETATTR1;				\
    424  1.2  pgoyette 	(b)->bits[2] = NFSATTRBIT_GETATTR2;				\
    425  1.2  pgoyette } while (0)
    426  1.2  pgoyette 
    427  1.1  dholland #define	NFSWCCATTR_ATTRBIT(b) do { 					\
    428  1.2  pgoyette 	(b)->bits[0] = NFSATTRBIT_WCCATTR0;	 			\
    429  1.2  pgoyette 	(b)->bits[1] = NFSATTRBIT_WCCATTR1;				\
    430  1.2  pgoyette 	(b)->bits[2] = NFSATTRBIT_WCCATTR2;				\
    431  1.2  pgoyette } while (0)
    432  1.2  pgoyette 
    433  1.1  dholland #define	NFSWRITEGETATTR_ATTRBIT(b) do { 				\
    434  1.2  pgoyette 	(b)->bits[0] = NFSATTRBIT_WRITEGETATTR0;			\
    435  1.2  pgoyette 	(b)->bits[1] = NFSATTRBIT_WRITEGETATTR1;			\
    436  1.2  pgoyette 	(b)->bits[2] = NFSATTRBIT_WRITEGETATTR2;			\
    437  1.2  pgoyette } while (0)
    438  1.2  pgoyette 
    439  1.1  dholland #define	NFSCBGETATTR_ATTRBIT(b, c) do { 				\
    440  1.2  pgoyette 	(c)->bits[0] = ((b)->bits[0] & NFSATTRBIT_CBGETATTR0);		\
    441  1.2  pgoyette 	(c)->bits[1] = ((b)->bits[1] & NFSATTRBIT_CBGETATTR1);		\
    442  1.2  pgoyette 	(c)->bits[2] = ((b)->bits[2] & NFSATTRBIT_CBGETATTR2);		\
    443  1.2  pgoyette } while (0)
    444  1.2  pgoyette 
    445  1.1  dholland #define	NFSPATHCONF_GETATTRBIT(b) do { 					\
    446  1.2  pgoyette 	(b)->bits[0] = NFSGETATTRBIT_PATHCONF0;		 		\
    447  1.2  pgoyette 	(b)->bits[1] = NFSGETATTRBIT_PATHCONF1;				\
    448  1.2  pgoyette 	(b)->bits[2] = NFSGETATTRBIT_PATHCONF2;				\
    449  1.2  pgoyette } while (0)
    450  1.2  pgoyette 
    451  1.1  dholland #define	NFSSTATFS_GETATTRBIT(b)	do { 					\
    452  1.2  pgoyette 	(b)->bits[0] = NFSGETATTRBIT_STATFS0;	 			\
    453  1.2  pgoyette 	(b)->bits[1] = NFSGETATTRBIT_STATFS1;				\
    454  1.2  pgoyette 	(b)->bits[2] = NFSGETATTRBIT_STATFS2;				\
    455  1.2  pgoyette } while (0)
    456  1.2  pgoyette 
    457  1.1  dholland #define	NFSISSETSTATFS_ATTRBIT(b) 					\
    458  1.1  dholland 		(((b)->bits[0] & NFSATTRBIT_STATFS0) || 		\
    459  1.2  pgoyette 		 ((b)->bits[1] & NFSATTRBIT_STATFS1) ||			\
    460  1.2  pgoyette 		 ((b)->bits[2] & NFSATTRBIT_STATFS2))
    461  1.2  pgoyette 
    462  1.1  dholland #define	NFSCLRSTATFS_ATTRBIT(b)	do { 					\
    463  1.2  pgoyette 	(b)->bits[0] &= ~NFSATTRBIT_STATFS0;	 			\
    464  1.2  pgoyette 	(b)->bits[1] &= ~NFSATTRBIT_STATFS1;				\
    465  1.2  pgoyette 	(b)->bits[2] &= ~NFSATTRBIT_STATFS2;				\
    466  1.2  pgoyette } while (0)
    467  1.2  pgoyette 
    468  1.1  dholland #define	NFSREADDIRPLUS_ATTRBIT(b) do { 					\
    469  1.2  pgoyette 	(b)->bits[0] = NFSATTRBIT_READDIRPLUS0;		 		\
    470  1.2  pgoyette 	(b)->bits[1] = NFSATTRBIT_READDIRPLUS1;				\
    471  1.2  pgoyette 	(b)->bits[2] = NFSATTRBIT_READDIRPLUS2;				\
    472  1.2  pgoyette } while (0)
    473  1.2  pgoyette 
    474  1.1  dholland #define	NFSREFERRAL_ATTRBIT(b) do { 					\
    475  1.2  pgoyette 	(b)->bits[0] = NFSATTRBIT_REFERRAL0;		 		\
    476  1.2  pgoyette 	(b)->bits[1] = NFSATTRBIT_REFERRAL1;				\
    477  1.2  pgoyette 	(b)->bits[2] = NFSATTRBIT_REFERRAL2;				\
    478  1.2  pgoyette } while (0)
    479  1.1  dholland 
    480  1.1  dholland /*
    481  1.1  dholland  * Store uid, gid creds that were used when the stateid was acquired.
    482  1.1  dholland  * The RPC layer allows NFS_MAXGRPS + 1 groups to go out on the wire,
    483  1.1  dholland  * so that's how many gets stored here.
    484  1.1  dholland  */
    485  1.1  dholland struct nfscred {
    486  1.1  dholland 	uid_t 		nfsc_uid;
    487  1.1  dholland 	gid_t		nfsc_groups[NFS_MAXGRPS + 1];
    488  1.1  dholland 	int		nfsc_ngroups;
    489  1.1  dholland };
    490  1.1  dholland 
    491  1.1  dholland /*
    492  1.1  dholland  * Constants that define the file handle for the V4 root directory.
    493  1.1  dholland  * (The FSID must never be used by other file systems that are exported.)
    494  1.1  dholland  */
    495  1.1  dholland #define	NFSV4ROOT_FSID0		((int32_t) -1)
    496  1.1  dholland #define	NFSV4ROOT_FSID1		((int32_t) -1)
    497  1.1  dholland #define	NFSV4ROOT_REFERRAL	((int32_t) -2)
    498  1.1  dholland #define	NFSV4ROOT_INO		2	/* It's traditional */
    499  1.1  dholland #define	NFSV4ROOT_GEN		1
    500  1.1  dholland 
    501  1.1  dholland /*
    502  1.1  dholland  * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts.
    503  1.1  dholland  * What should be in this set is open to debate, but I believe that since
    504  1.1  dholland  * I/O system calls on ufs are never interrupted by signals the set should
    505  1.1  dholland  * be minimal. My reasoning is that many current programs that use signals
    506  1.1  dholland  * such as SIGALRM will not expect file I/O system calls to be interrupted
    507  1.1  dholland  * by them and break.
    508  1.1  dholland  */
    509  1.1  dholland #if defined(_KERNEL) || defined(KERNEL)
    510  1.1  dholland 
    511  1.1  dholland struct uio; struct buf; struct vattr; struct nameidata;	/* XXX */
    512  1.1  dholland 
    513  1.1  dholland /*
    514  1.1  dholland  * Socket errors ignored for connectionless sockets?
    515  1.1  dholland  * For now, ignore them all
    516  1.1  dholland  */
    517  1.1  dholland #define	NFSIGNORE_SOERROR(s, e) 					\
    518  1.1  dholland 		((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \
    519  1.1  dholland 		((s) & PR_CONNREQUIRED) == 0)
    520  1.1  dholland 
    521  1.1  dholland 
    522  1.1  dholland /*
    523  1.1  dholland  * This structure holds socket information for a connection. Used by the
    524  1.1  dholland  * client and the server for callbacks.
    525  1.1  dholland  */
    526  1.1  dholland struct nfssockreq {
    527  1.1  dholland 	NFSSOCKADDR_T	nr_nam;
    528  1.1  dholland 	int		nr_sotype;
    529  1.1  dholland 	int		nr_soproto;
    530  1.1  dholland 	int		nr_soflags;
    531  1.1  dholland 	struct ucred	*nr_cred;
    532  1.1  dholland 	int		nr_lock;
    533  1.1  dholland 	NFSMUTEX_T	nr_mtx;
    534  1.1  dholland 	u_int32_t	nr_prog;
    535  1.1  dholland 	u_int32_t	nr_vers;
    536  1.1  dholland 	struct __rpc_client *nr_client;
    537  1.1  dholland 	AUTH		*nr_auth;
    538  1.1  dholland };
    539  1.1  dholland 
    540  1.1  dholland /*
    541  1.1  dholland  * And associated nr_lock bits.
    542  1.1  dholland  */
    543  1.1  dholland #define	NFSR_SNDLOCK		0x01
    544  1.1  dholland #define	NFSR_WANTSND		0x02
    545  1.1  dholland #define	NFSR_RCVLOCK		0x04
    546  1.1  dholland #define	NFSR_WANTRCV		0x08
    547  1.1  dholland #define	NFSR_RESERVEDPORT	0x10
    548  1.1  dholland #define	NFSR_LOCALHOST		0x20
    549  1.1  dholland 
    550  1.1  dholland /*
    551  1.1  dholland  * Queue head for nfsreq's
    552  1.1  dholland  */
    553  1.1  dholland TAILQ_HEAD(nfsreqhead, nfsreq);
    554  1.1  dholland 
    555  1.1  dholland /* This is the only nfsreq R_xxx flag still used. */
    556  1.1  dholland #define	R_DONTRECOVER	0x00000100	/* don't initiate recovery when this
    557  1.1  dholland 					   rpc gets a stale state reply */
    558  1.1  dholland 
    559  1.1  dholland /*
    560  1.1  dholland  * Network address hash list element
    561  1.1  dholland  */
    562  1.1  dholland union nethostaddr {
    563  1.1  dholland 	struct in_addr	had_inet;
    564  1.1  dholland 	struct in6_addr had_inet6;
    565  1.1  dholland };
    566  1.1  dholland 
    567  1.1  dholland /*
    568  1.1  dholland  * Structure of list of mechanisms.
    569  1.1  dholland  */
    570  1.1  dholland struct nfsgss_mechlist {
    571  1.1  dholland 	int	len;
    572  1.1  dholland 	const u_char	*str;
    573  1.1  dholland 	int	totlen;
    574  1.1  dholland };
    575  1.1  dholland #define	KERBV_MECH	0	/* position in list */
    576  1.1  dholland 
    577  1.1  dholland /*
    578  1.1  dholland  * This structure is used by the server for describing each request.
    579  1.1  dholland  */
    580  1.1  dholland struct nfsrv_descript {
    581  1.1  dholland 	mbuf_t			nd_mrep;	/* Request mbuf list */
    582  1.1  dholland 	mbuf_t			nd_md;		/* Current dissect mbuf */
    583  1.1  dholland 	mbuf_t			nd_mreq;	/* Reply mbuf list */
    584  1.1  dholland 	mbuf_t			nd_mb;		/* Current build mbuf */
    585  1.1  dholland 	NFSSOCKADDR_T		nd_nam;		/* and socket addr */
    586  1.1  dholland 	NFSSOCKADDR_T		nd_nam2;	/* return socket addr */
    587  1.2  pgoyette 	char			*nd_dpos;	/* Current dissect pos */
    588  1.2  pgoyette 	char			*nd_bpos;	/* Current build pos */
    589  1.1  dholland 	u_int16_t		nd_procnum;	/* RPC # */
    590  1.1  dholland 	u_int32_t		nd_flag;	/* nd_flag */
    591  1.1  dholland 	u_int32_t		nd_repstat;	/* Reply status */
    592  1.1  dholland 	int			*nd_errp;	/* Pointer to ret status */
    593  1.1  dholland 	u_int32_t		nd_retxid;	/* Reply xid */
    594  1.1  dholland 	struct nfsrvcache	*nd_rp;		/* Assoc. cache entry */
    595  1.1  dholland 	fhandle_t		nd_fh;		/* File handle */
    596  1.1  dholland 	struct ucred		*nd_cred;	/* Credentials */
    597  1.1  dholland 	uid_t			nd_saveduid;	/* Saved uid */
    598  1.1  dholland 	u_int64_t		nd_sockref;	/* Rcv socket ref# */
    599  1.1  dholland 	u_int64_t		nd_compref;	/* Compound RPC ref# */
    600  1.1  dholland 	time_t			nd_tcpconntime;	/* Time TCP connection est. */
    601  1.1  dholland 	nfsquad_t		nd_clientid;	/* Implied clientid */
    602  1.1  dholland 	int			nd_gssnamelen;	/* principal name length */
    603  1.1  dholland 	char			*nd_gssname;	/* principal name */
    604  1.1  dholland 	uint32_t		*nd_slotseq;	/* ptr to slot seq# in req */
    605  1.2  pgoyette 	uint8_t			nd_sessionid[NFSX_V4SESSIONID];	/* Session id */
    606  1.2  pgoyette 	uint32_t		nd_slotid;	/* Slotid for this RPC */
    607  1.2  pgoyette 	SVCXPRT			*nd_xprt;	/* Server RPC handle */
    608  1.1  dholland };
    609  1.1  dholland 
    610  1.1  dholland #define	nd_princlen	nd_gssnamelen
    611  1.1  dholland #define	nd_principal	nd_gssname
    612  1.1  dholland 
    613  1.1  dholland /* Bits for "nd_flag" */
    614  1.1  dholland #define	ND_DONTSAVEREPLY 	0x00000001
    615  1.1  dholland #define	ND_SAVEREPLY		0x00000002
    616  1.1  dholland #define	ND_NFSV2		0x00000004
    617  1.1  dholland #define	ND_NFSV3		0x00000008
    618  1.1  dholland #define	ND_NFSV4		0x00000010
    619  1.1  dholland #define	ND_KERBV		0x00000020
    620  1.1  dholland #define	ND_GSSINTEGRITY		0x00000040
    621  1.1  dholland #define	ND_GSSPRIVACY		0x00000080
    622  1.1  dholland #define	ND_WINDOWVERF		0x00000100
    623  1.1  dholland #define	ND_GSSINITREPLY		0x00000200
    624  1.1  dholland #define	ND_STREAMSOCK		0x00000400
    625  1.1  dholland #define	ND_PUBLOOKUP		0x00000800
    626  1.1  dholland #define	ND_USEGSSNAME		0x00001000
    627  1.1  dholland #define	ND_SAMETCPCONN		0x00002000
    628  1.1  dholland #define	ND_IMPLIEDCLID		0x00004000
    629  1.1  dholland #define	ND_NOMOREDATA		0x00008000
    630  1.1  dholland #define	ND_V4WCCATTR		0x00010000
    631  1.1  dholland #define	ND_NFSCB		0x00020000
    632  1.1  dholland #define	ND_AUTHNONE		0x00040000
    633  1.1  dholland #define	ND_EXAUTHSYS		0x00080000
    634  1.1  dholland #define	ND_EXGSS		0x00100000
    635  1.1  dholland #define	ND_EXGSSINTEGRITY	0x00200000
    636  1.1  dholland #define	ND_EXGSSPRIVACY		0x00400000
    637  1.1  dholland #define	ND_INCRSEQID		0x00800000
    638  1.1  dholland #define	ND_NFSCL		0x01000000
    639  1.1  dholland #define	ND_NFSV41		0x02000000
    640  1.1  dholland #define	ND_HASSEQUENCE		0x04000000
    641  1.2  pgoyette #define	ND_CACHETHIS		0x08000000
    642  1.2  pgoyette #define	ND_LASTOP		0x10000000
    643  1.1  dholland 
    644  1.1  dholland /*
    645  1.1  dholland  * ND_GSS should be the "or" of all GSS type authentications.
    646  1.1  dholland  */
    647  1.1  dholland #define	ND_GSS		(ND_KERBV)
    648  1.1  dholland 
    649  1.1  dholland struct nfsv4_opflag {
    650  1.1  dholland 	int	retfh;
    651  1.1  dholland 	int	needscfh;
    652  1.1  dholland 	int	savereply;
    653  1.1  dholland 	int	modifyfs;
    654  1.1  dholland 	int	lktype;
    655  1.1  dholland 	int	needsseq;
    656  1.1  dholland };
    657  1.1  dholland 
    658  1.1  dholland /*
    659  1.1  dholland  * Flags used to indicate what to do w.r.t. seqid checking.
    660  1.1  dholland  */
    661  1.1  dholland #define	NFSRVSEQID_FIRST	0x01
    662  1.1  dholland #define	NFSRVSEQID_LAST		0x02
    663  1.1  dholland #define	NFSRVSEQID_OPEN		0x04
    664  1.1  dholland 
    665  1.1  dholland /*
    666  1.1  dholland  * assign a doubly linked list to a new head
    667  1.1  dholland  * and prepend one list into another.
    668  1.1  dholland  */
    669  1.1  dholland #define	LIST_NEWHEAD(nhead, ohead, field) do { 				\
    670  1.1  dholland 	if (((nhead)->lh_first = (ohead)->lh_first) != NULL) 		\
    671  1.1  dholland 		(ohead)->lh_first->field.le_prev = &(nhead)->lh_first; 	\
    672  1.1  dholland 	(ohead)->lh_first = NULL; 					\
    673  1.1  dholland     } while (0)
    674  1.1  dholland 
    675  1.1  dholland #define	LIST_PREPEND(head, phead, lelm, field) do {			\
    676  1.1  dholland 	if ((head)->lh_first != NULL) {					\
    677  1.1  dholland 		(lelm)->field.le_next = (head)->lh_first;		\
    678  1.1  dholland 		(lelm)->field.le_next->field.le_prev =			\
    679  1.1  dholland 		    &(lelm)->field.le_next;				\
    680  1.1  dholland 	}								\
    681  1.1  dholland 	(head)->lh_first = (phead)->lh_first;				\
    682  1.1  dholland 	(head)->lh_first->field.le_prev = &(head)->lh_first;		\
    683  1.1  dholland     } while (0)
    684  1.1  dholland 
    685  1.1  dholland /*
    686  1.1  dholland  * File handle structure for client. Malloc'd to the correct length with
    687  1.1  dholland  * malloc type M_NFSFH.
    688  1.1  dholland  */
    689  1.1  dholland struct nfsfh {
    690  1.1  dholland 	u_int16_t	nfh_len;	/* Length of file handle */
    691  1.1  dholland 	u_int8_t	nfh_fh[1];	/* and the file handle */
    692  1.1  dholland };
    693  1.1  dholland 
    694  1.1  dholland /*
    695  1.1  dholland  * File handle structure for server. The NFSRV_MAXFH constant is
    696  1.1  dholland  * set in nfsdport.h. I use a 32bit length, so that alignment is
    697  1.1  dholland  * preserved.
    698  1.1  dholland  */
    699  1.1  dholland struct nfsrvfh {
    700  1.1  dholland 	u_int32_t	nfsrvfh_len;
    701  1.1  dholland 	u_int8_t	nfsrvfh_data[NFSRV_MAXFH];
    702  1.1  dholland };
    703  1.1  dholland 
    704  1.1  dholland /*
    705  1.1  dholland  * This structure is used for sleep locks on the NFSv4 nfsd threads and
    706  1.1  dholland  * NFSv4 client data structures.
    707  1.1  dholland  */
    708  1.1  dholland struct nfsv4lock {
    709  1.1  dholland 	u_int32_t	nfslock_usecnt;
    710  1.1  dholland 	u_int8_t	nfslock_lock;
    711  1.1  dholland };
    712  1.1  dholland #define	NFSV4LOCK_LOCK		0x01
    713  1.1  dholland #define	NFSV4LOCK_LOCKWANTED	0x02
    714  1.1  dholland #define	NFSV4LOCK_WANTED	0x04
    715  1.1  dholland 
    716  1.1  dholland /*
    717  1.1  dholland  * Values for the override argument for nfsvno_accchk().
    718  1.1  dholland  */
    719  1.1  dholland #define	NFSACCCHK_NOOVERRIDE		0
    720  1.1  dholland #define	NFSACCCHK_ALLOWROOT		1
    721  1.1  dholland #define	NFSACCCHK_ALLOWOWNER		2
    722  1.1  dholland 
    723  1.1  dholland /*
    724  1.1  dholland  * and values for the vpislocked argument for nfsvno_accchk().
    725  1.1  dholland  */
    726  1.1  dholland #define	NFSACCCHK_VPNOTLOCKED		0
    727  1.1  dholland #define	NFSACCCHK_VPISLOCKED		1
    728  1.1  dholland 
    729  1.1  dholland /*
    730  1.1  dholland  * Slot for the NFSv4.1 Sequence Op.
    731  1.1  dholland  */
    732  1.1  dholland struct nfsslot {
    733  1.1  dholland 	int		nfssl_inprog;
    734  1.1  dholland 	uint32_t	nfssl_seq;
    735  1.1  dholland 	struct mbuf	*nfssl_reply;
    736  1.1  dholland };
    737  1.1  dholland 
    738  1.1  dholland #endif	/* _KERNEL */
    739  1.1  dholland 
    740  1.1  dholland #endif	/* _NFS_NFS_H */
    741