nfs.h revision 194541
1191783Srmacklem/*- 2191783Srmacklem * Copyright (c) 1989, 1993 3191783Srmacklem * The Regents of the University of California. All rights reserved. 4191783Srmacklem * 5191783Srmacklem * This code is derived from software contributed to Berkeley by 6191783Srmacklem * Rick Macklem at The University of Guelph. 7191783Srmacklem * 8191783Srmacklem * Redistribution and use in source and binary forms, with or without 9191783Srmacklem * modification, are permitted provided that the following conditions 10191783Srmacklem * are met: 11191783Srmacklem * 1. Redistributions of source code must retain the above copyright 12191783Srmacklem * notice, this list of conditions and the following disclaimer. 13191783Srmacklem * 2. Redistributions in binary form must reproduce the above copyright 14191783Srmacklem * notice, this list of conditions and the following disclaimer in the 15191783Srmacklem * documentation and/or other materials provided with the distribution. 16191783Srmacklem * 4. Neither the name of the University nor the names of its contributors 17191783Srmacklem * may be used to endorse or promote products derived from this software 18191783Srmacklem * without specific prior written permission. 19191783Srmacklem * 20191783Srmacklem * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21191783Srmacklem * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22191783Srmacklem * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23191783Srmacklem * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24191783Srmacklem * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25191783Srmacklem * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26191783Srmacklem * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27191783Srmacklem * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28191783Srmacklem * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29191783Srmacklem * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30191783Srmacklem * SUCH DAMAGE. 31191783Srmacklem * 32191783Srmacklem * $FreeBSD: head/sys/fs/nfs/nfs.h 194541 2009-06-20 17:11:07Z rmacklem $ 33191783Srmacklem */ 34191783Srmacklem 35191783Srmacklem#ifndef _NFS_NFS_H_ 36191783Srmacklem#define _NFS_NFS_H_ 37191783Srmacklem/* 38191783Srmacklem * Tunable constants for nfs 39191783Srmacklem */ 40191783Srmacklem 41191783Srmacklem#define NFS_MAXIOVEC 34 42191783Srmacklem#define NFS_TICKINTVL 10 /* Desired time for a tick (msec) */ 43191783Srmacklem#define NFS_HZ (hz / nfscl_ticks) /* Ticks/sec */ 44191783Srmacklem#define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */ 45191783Srmacklem#define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */ 46191783Srmacklem#define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */ 47191783Srmacklem#define NFS_TCPTIMEO 300 /* TCP timeout */ 48191783Srmacklem#define NFS_MAXRCVTIMEO 60 /* 1 minute in seconds */ 49191783Srmacklem#define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/ 50191783Srmacklem#define NFS_MAXREXMIT 100 /* Stop counting after this many */ 51191783Srmacklem#define NFSV4_CALLBACKTIMEO (2 * NFS_HZ) /* Timeout in ticks */ 52191783Srmacklem#define NFSV4_CALLBACKRETRY 5 /* Number of retries before failure */ 53191783Srmacklem#define NFSV4_CBRETRYCNT 4 /* # of CBRecall retries upon err */ 54191783Srmacklem#define NFSV4_UPCALLTIMEO (15 * NFS_HZ) /* Timeout in ticks for upcalls */ 55191783Srmacklem /* to gssd or nfsuserd */ 56191783Srmacklem#define NFSV4_UPCALLRETRY 4 /* Number of retries before failure */ 57191783Srmacklem#define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */ 58191783Srmacklem#define NFS_RETRANS 10 /* Num of retrans for soft mounts */ 59191783Srmacklem#define NFS_MAXGRPS 16 /* Max. size of groups list */ 60191783Srmacklem#define NFS_TRYLATERDEL 15 /* Maximum delay timeout (sec) */ 61191783Srmacklem#ifndef NFS_REMOVETIMEO 62191783Srmacklem#define NFS_REMOVETIMEO 15 /* # sec to wait for delegret in local syscall */ 63191783Srmacklem#endif 64191783Srmacklem#ifndef NFS_MINATTRTIMO 65191783Srmacklem#define NFS_MINATTRTIMO 5 /* Attribute cache timeout in sec */ 66191783Srmacklem#endif 67191783Srmacklem#ifndef NFS_MAXATTRTIMO 68191783Srmacklem#define NFS_MAXATTRTIMO 60 69191783Srmacklem#endif 70191783Srmacklem#define NFS_WSIZE 8192 /* Def. write data size <= 8192 */ 71191783Srmacklem#define NFS_RSIZE 8192 /* Def. read data size <= 8192 */ 72191783Srmacklem#define NFS_READDIRSIZE 8192 /* Def. readdir size */ 73191783Srmacklem#define NFS_DEFRAHEAD 0 /* Def. read ahead # blocks */ 74191783Srmacklem#define NFS_MAXRAHEAD 32 /* Max. read ahead # blocks */ 75191783Srmacklem#define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */ 76191783Srmacklem#ifndef NFSRV_LEASE 77191783Srmacklem#define NFSRV_LEASE 120 /* Lease time in seconds for V4 */ 78191783Srmacklem#endif /* assigned to nfsrv_lease */ 79191783Srmacklem#ifndef NFSRV_STALELEASE 80191783Srmacklem#define NFSRV_STALELEASE (5 * nfsrv_lease) 81191783Srmacklem#endif 82191783Srmacklem#ifndef NFSRV_MOULDYLEASE 83191783Srmacklem#define NFSRV_MOULDYLEASE 604800 /* One week (in sec) */ 84191783Srmacklem#endif 85191783Srmacklem#ifndef NFSCLIENTHASHSIZE 86191783Srmacklem#define NFSCLIENTHASHSIZE 20 /* Size of server client hash table */ 87191783Srmacklem#endif 88191783Srmacklem#ifndef NFSLOCKHASHSIZE 89191783Srmacklem#define NFSLOCKHASHSIZE 20 /* Size of server nfslock hash table */ 90191783Srmacklem#endif 91191783Srmacklem#define NFSSTATEHASHSIZE 10 /* Size of server stateid hash table */ 92191783Srmacklem#ifndef NFSUSERHASHSIZE 93191783Srmacklem#define NFSUSERHASHSIZE 30 /* Size of user id hash table */ 94191783Srmacklem#endif 95191783Srmacklem#ifndef NFSGROUPHASHSIZE 96191783Srmacklem#define NFSGROUPHASHSIZE 5 /* Size of group id hash table */ 97191783Srmacklem#endif 98191783Srmacklem#ifndef NFSCLDELEGHIGHWATER 99191783Srmacklem#define NFSCLDELEGHIGHWATER 10000 /* limit for client delegations */ 100191783Srmacklem#endif 101191783Srmacklem#ifndef NFSNOOPEN /* Inactive open owner (sec) */ 102191783Srmacklem#define NFSNOOPEN 120 103191783Srmacklem#endif 104191783Srmacklem#define NFSRV_LEASEDELTA 15 /* # of seconds to delay beyond lease */ 105191783Srmacklem#define NFS_IDMAXSIZE 4 /* max sizeof (in_addr_t) */ 106191783Srmacklem#ifndef NFSRVCACHE_UDPTIMEOUT 107191783Srmacklem#define NFSRVCACHE_UDPTIMEOUT 30 /* # of sec to hold cached rpcs(udp) */ 108191783Srmacklem#endif 109191783Srmacklem#ifndef NFSRVCACHE_UDPHIGHWATER 110191783Srmacklem#define NFSRVCACHE_UDPHIGHWATER 500 /* Max # of udp cache entries */ 111191783Srmacklem#endif 112191783Srmacklem#ifndef NFSRVCACHE_TCPTIMEOUT 113191783Srmacklem#define NFSRVCACHE_TCPTIMEOUT (3600*12) /*#of sec to hold cached rpcs(tcp) */ 114191783Srmacklem#endif 115191783Srmacklem#ifndef NFSRVCACHE_FLOODLEVEL 116191783Srmacklem#define NFSRVCACHE_FLOODLEVEL 16384 /* Very high water mark for cache */ 117191783Srmacklem#endif 118191783Srmacklem#ifndef NFSRV_CLIENTHIGHWATER 119191783Srmacklem#define NFSRV_CLIENTHIGHWATER 1000 120191783Srmacklem#endif 121191783Srmacklem#ifndef NFSRV_MAXDUMPLIST 122191783Srmacklem#define NFSRV_MAXDUMPLIST 10000 123191783Srmacklem#endif 124191783Srmacklem#ifndef NFS_ACCESSCACHESIZE 125191783Srmacklem#define NFS_ACCESSCACHESIZE 8 126191783Srmacklem#endif 127191783Srmacklem#define NFSV4_CBPORT 7745 /* Callback port for testing */ 128191783Srmacklem 129191783Srmacklem/* 130191783Srmacklem * This macro defines the high water mark for issuing V4 delegations. 131191783Srmacklem * (It is currently set at a conservative 20% of NFSRV_V4STATELIMIT. This 132191783Srmacklem * may want to increase when clients can make more effective use of 133191783Srmacklem * delegations.) 134191783Srmacklem */ 135191783Srmacklem#define NFSRV_V4DELEGLIMIT(c) (((c) * 5) > NFSRV_V4STATELIMIT) 136191783Srmacklem 137191783Srmacklem#define NFS_READDIRBLKSIZ DIRBLKSIZ /* Minimal nm_readdirsize */ 138191783Srmacklem 139191783Srmacklem/* 140191783Srmacklem * Oddballs 141191783Srmacklem */ 142191783Srmacklem#define NFS_CMPFH(n, f, s) \ 143191783Srmacklem ((n)->n_fhp->nfh_len == (s) && !NFSBCMP((n)->n_fhp->nfh_fh, (caddr_t)(f), (s))) 144191783Srmacklem#define NFSRV_CMPFH(nf, ns, f, s) \ 145191783Srmacklem ((ns) == (s) && !NFSBCMP((caddr_t)(nf), (caddr_t)(f), (s))) 146191783Srmacklem#define NFS_CMPTIME(t1, t2) \ 147191783Srmacklem ((t1).tv_sec == (t2).tv_sec && (t1).tv_nsec == (t2).tv_nsec) 148191783Srmacklem#define NFS_SETTIME(t) do { \ 149191783Srmacklem (t).tv_sec = time.tv_sec; (t).tv_nsec = 1000 * time.tv_usec; } while (0) 150191783Srmacklem#define NFS_SRVMAXDATA(n) \ 151191783Srmacklem (((n)->nd_flag & (ND_NFSV3 | ND_NFSV4)) ? \ 152191783Srmacklem NFS_MAXDATA : NFS_V2MAXDATA) 153191783Srmacklem#define NFS64BITSSET 0xffffffffffffffffull 154191783Srmacklem#define NFS64BITSMINUS1 0xfffffffffffffffeull 155191783Srmacklem 156191783Srmacklem/* 157191783Srmacklem * Structures for the nfssvc(2) syscall. Not that anyone but nfsd, mount_nfs 158191783Srmacklem * and nfsloaduser should ever try and use it. 159191783Srmacklem */ 160192000Srmacklemstruct nfsd_addsock_args { 161191783Srmacklem int sock; /* Socket to serve */ 162191783Srmacklem caddr_t name; /* Client addr for connection based sockets */ 163191783Srmacklem int namelen; /* Length of name */ 164191783Srmacklem}; 165191783Srmacklem 166191783Srmacklem/* 167191783Srmacklem * nfsd argument for new krpc. 168191783Srmacklem */ 169191783Srmacklemstruct nfsd_nfsd_args { 170191783Srmacklem const char *principal; /* GSS-API service principal name */ 171191783Srmacklem int minthreads; /* minimum service thread count */ 172191783Srmacklem int maxthreads; /* maximum service thread count */ 173191783Srmacklem}; 174191783Srmacklem 175191783Srmacklem/* 176191783Srmacklem * Arguments for use by the callback daemon. 177191783Srmacklem */ 178191783Srmacklemstruct nfsd_nfscbd_args { 179191783Srmacklem const char *principal; /* GSS-API service principal name */ 180191783Srmacklem}; 181191783Srmacklem 182191783Srmacklemstruct nfscbd_args { 183191783Srmacklem int sock; /* Socket to serve */ 184191783Srmacklem caddr_t name; /* Client addr for connection based sockets */ 185191783Srmacklem int namelen; /* Length of name */ 186191783Srmacklem u_short port; /* Port# for callbacks */ 187191783Srmacklem}; 188191783Srmacklem 189191783Srmacklemstruct nfsd_idargs { 190191783Srmacklem int nid_flag; /* Flags (see below) */ 191191783Srmacklem uid_t nid_uid; /* user/group id */ 192191783Srmacklem gid_t nid_gid; 193191783Srmacklem int nid_usermax; /* Upper bound on user name cache */ 194191783Srmacklem int nid_usertimeout;/* User name timeout (minutes) */ 195191783Srmacklem u_char *nid_name; /* Name */ 196191783Srmacklem int nid_namelen; /* and its length */ 197191783Srmacklem}; 198191783Srmacklem 199191783Srmacklemstruct nfsd_clid { 200191783Srmacklem int nclid_idlen; /* Length of client id */ 201191783Srmacklem u_char nclid_id[NFSV4_OPAQUELIMIT]; /* and name */ 202191783Srmacklem}; 203191783Srmacklem 204191783Srmacklemstruct nfsd_dumplist { 205191783Srmacklem int ndl_size; /* Number of elements */ 206191783Srmacklem void *ndl_list; /* and the list of elements */ 207191783Srmacklem}; 208191783Srmacklem 209191783Srmacklemstruct nfsd_dumpclients { 210191783Srmacklem u_int32_t ndcl_flags; /* LCL_xxx flags */ 211191783Srmacklem u_int32_t ndcl_nopenowners; /* Number of openowners */ 212191783Srmacklem u_int32_t ndcl_nopens; /* and opens */ 213191783Srmacklem u_int32_t ndcl_nlockowners; /* and of lockowners */ 214191783Srmacklem u_int32_t ndcl_nlocks; /* and of locks */ 215191783Srmacklem u_int32_t ndcl_ndelegs; /* and of delegations */ 216191783Srmacklem u_int32_t ndcl_nolddelegs; /* and old delegations */ 217191783Srmacklem sa_family_t ndcl_addrfam; /* Callback address */ 218191783Srmacklem union { 219191783Srmacklem struct in_addr sin_addr; 220191783Srmacklem struct in6_addr sin6_addr; 221191783Srmacklem } ndcl_cbaddr; 222191783Srmacklem struct nfsd_clid ndcl_clid; /* and client id */ 223191783Srmacklem}; 224191783Srmacklem 225191783Srmacklemstruct nfsd_dumplocklist { 226191783Srmacklem char *ndllck_fname; /* File Name */ 227191783Srmacklem int ndllck_size; /* Number of elements */ 228191783Srmacklem void *ndllck_list; /* and the list of elements */ 229191783Srmacklem}; 230191783Srmacklem 231191783Srmacklemstruct nfsd_dumplocks { 232191783Srmacklem u_int32_t ndlck_flags; /* state flags NFSLCK_xxx */ 233191783Srmacklem nfsv4stateid_t ndlck_stateid; /* stateid */ 234191783Srmacklem u_int64_t ndlck_first; /* lock byte range */ 235191783Srmacklem u_int64_t ndlck_end; 236191783Srmacklem struct nfsd_clid ndlck_owner; /* Owner of open/lock */ 237191783Srmacklem sa_family_t ndlck_addrfam; /* Callback address */ 238191783Srmacklem union { 239191783Srmacklem struct in_addr sin_addr; 240191783Srmacklem struct in6_addr sin6_addr; 241191783Srmacklem } ndlck_cbaddr; 242191783Srmacklem struct nfsd_clid ndlck_clid; /* and client id */ 243191783Srmacklem}; 244191783Srmacklem 245191783Srmacklem/* 246191783Srmacklem * Structure for referral information. 247191783Srmacklem */ 248191783Srmacklemstruct nfsreferral { 249191783Srmacklem u_char *nfr_srvlist; /* List of servers */ 250191783Srmacklem int nfr_srvcnt; /* number of servers */ 251191783Srmacklem vnode_t nfr_vp; /* vnode for referral */ 252191783Srmacklem u_int32_t nfr_dfileno; /* assigned dir inode# */ 253191783Srmacklem}; 254191783Srmacklem 255191783Srmacklem/* 256191783Srmacklem * Flags for lc_flags and opsflags for nfsrv_getclient(). 257191783Srmacklem */ 258191783Srmacklem#define LCL_NEEDSCONFIRM 0x00000001 259191783Srmacklem#define LCL_DONTCLEAN 0x00000002 260191783Srmacklem#define LCL_WAKEUPWANTED 0x00000004 261191783Srmacklem#define LCL_TCPCALLBACK 0x00000008 262191783Srmacklem#define LCL_CALLBACKSON 0x00000010 263191783Srmacklem#define LCL_INDEXNOTOK 0x00000020 264191783Srmacklem#define LCL_STAMPEDSTABLE 0x00000040 265191783Srmacklem#define LCL_EXPIREIT 0x00000080 266191783Srmacklem#define LCL_CBDOWN 0x00000100 267191783Srmacklem#define LCL_KERBV 0x00000400 268191783Srmacklem#define LCL_NAME 0x00000800 269191783Srmacklem#define LCL_NEEDSCBNULL 0x00001000 270191783Srmacklem#define LCL_GSSINTEGRITY 0x00002000 271191783Srmacklem#define LCL_GSSPRIVACY 0x00004000 272191783Srmacklem#define LCL_ADMINREVOKED 0x00008000 273191783Srmacklem 274191783Srmacklem#define LCL_GSS LCL_KERBV /* Or of all mechs */ 275191783Srmacklem 276191783Srmacklem/* 277191783Srmacklem * Bits for flags in nfslock and nfsstate. 278191783Srmacklem * The access, deny, NFSLCK_READ and NFSLCK_WRITE bits must be defined as 279191783Srmacklem * below, in the correct order, so the shifts work for tests. 280191783Srmacklem */ 281191783Srmacklem#define NFSLCK_READACCESS 0x00000001 282191783Srmacklem#define NFSLCK_WRITEACCESS 0x00000002 283191783Srmacklem#define NFSLCK_ACCESSBITS (NFSLCK_READACCESS | NFSLCK_WRITEACCESS) 284191783Srmacklem#define NFSLCK_SHIFT 2 285191783Srmacklem#define NFSLCK_READDENY 0x00000004 286191783Srmacklem#define NFSLCK_WRITEDENY 0x00000008 287191783Srmacklem#define NFSLCK_DENYBITS (NFSLCK_READDENY | NFSLCK_WRITEDENY) 288191783Srmacklem#define NFSLCK_SHAREBITS \ 289191783Srmacklem (NFSLCK_READACCESS|NFSLCK_WRITEACCESS|NFSLCK_READDENY|NFSLCK_WRITEDENY) 290191783Srmacklem#define NFSLCK_LOCKSHIFT 4 291191783Srmacklem#define NFSLCK_READ 0x00000010 292191783Srmacklem#define NFSLCK_WRITE 0x00000020 293191783Srmacklem#define NFSLCK_BLOCKING 0x00000040 294191783Srmacklem#define NFSLCK_RECLAIM 0x00000080 295191783Srmacklem#define NFSLCK_OPENTOLOCK 0x00000100 296191783Srmacklem#define NFSLCK_TEST 0x00000200 297191783Srmacklem#define NFSLCK_LOCK 0x00000400 298191783Srmacklem#define NFSLCK_UNLOCK 0x00000800 299191783Srmacklem#define NFSLCK_OPEN 0x00001000 300191783Srmacklem#define NFSLCK_CLOSE 0x00002000 301191783Srmacklem#define NFSLCK_CHECK 0x00004000 302191783Srmacklem#define NFSLCK_RELEASE 0x00008000 303191783Srmacklem#define NFSLCK_NEEDSCONFIRM 0x00010000 304191783Srmacklem#define NFSLCK_CONFIRM 0x00020000 305191783Srmacklem#define NFSLCK_DOWNGRADE 0x00040000 306191783Srmacklem#define NFSLCK_DELEGREAD 0x00080000 307191783Srmacklem#define NFSLCK_DELEGWRITE 0x00100000 308191783Srmacklem#define NFSLCK_DELEGCUR 0x00200000 309191783Srmacklem#define NFSLCK_DELEGPREV 0x00400000 310191783Srmacklem#define NFSLCK_OLDDELEG 0x00800000 311191783Srmacklem#define NFSLCK_DELEGRECALL 0x01000000 312191783Srmacklem#define NFSLCK_SETATTR 0x02000000 313191783Srmacklem#define NFSLCK_DELEGPURGE 0x04000000 314191783Srmacklem#define NFSLCK_DELEGRETURN 0x08000000 315191783Srmacklem 316191783Srmacklem/* And bits for nid_flag */ 317191783Srmacklem#define NFSID_INITIALIZE 0x0001 318191783Srmacklem#define NFSID_ADDUID 0x0002 319191783Srmacklem#define NFSID_DELUID 0x0004 320191783Srmacklem#define NFSID_ADDUSERNAME 0x0008 321191783Srmacklem#define NFSID_DELUSERNAME 0x0010 322191783Srmacklem#define NFSID_ADDGID 0x0020 323191783Srmacklem#define NFSID_DELGID 0x0040 324191783Srmacklem#define NFSID_ADDGROUPNAME 0x0080 325191783Srmacklem#define NFSID_DELGROUPNAME 0x0100 326191783Srmacklem 327191783Srmacklem/* 328191783Srmacklem * fs.nfs sysctl(3) identifiers 329191783Srmacklem */ 330191783Srmacklem#define NFS_NFSSTATS 1 /* struct: struct nfsstats */ 331191783Srmacklem 332191783Srmacklem#define FS_NFS_NAMES { \ 333191783Srmacklem { 0, 0 }, \ 334191783Srmacklem { "nfsstats", CTLTYPE_STRUCT }, \ 335191783Srmacklem} 336191783Srmacklem 337191783Srmacklem/* 338191783Srmacklem * Here is the definition of the attribute bits array and macros that 339191783Srmacklem * manipulate it. 340191783Srmacklem * THE MACROS MUST BE MANUALLY MODIFIED IF NFSATTRBIT_MAXWORDS CHANGES!! 341191783Srmacklem * It is (NFSATTRBIT_MAX + 31) / 32. 342191783Srmacklem */ 343191783Srmacklem#define NFSATTRBIT_MAXWORDS 2 344191783Srmacklem 345191783Srmacklemtypedef struct { 346191783Srmacklem u_int32_t bits[NFSATTRBIT_MAXWORDS]; 347191783Srmacklem} nfsattrbit_t; 348191783Srmacklem 349191783Srmacklem#define NFSZERO_ATTRBIT(b) do { (b)->bits[0] = 0; (b)->bits[1] = 0; } while (0) 350191783Srmacklem#define NFSSET_ATTRBIT(t, f) do { (t)->bits[0] = (f)->bits[0]; \ 351191783Srmacklem (t)->bits[1] = (f)->bits[1]; } while (0) 352191783Srmacklem#define NFSSETSUPP_ATTRBIT(b) do { \ 353191783Srmacklem (b)->bits[0] = NFSATTRBIT_SUPP0; \ 354191783Srmacklem (b)->bits[1] = (NFSATTRBIT_SUPP1 | NFSATTRBIT_SUPPSETONLY); } while (0) 355191783Srmacklem#define NFSISSET_ATTRBIT(b, p) ((b)->bits[(p) / 32] & (1 << ((p) % 32))) 356191783Srmacklem#define NFSSETBIT_ATTRBIT(b, p) ((b)->bits[(p) / 32] |= (1 << ((p) % 32))) 357191783Srmacklem#define NFSCLRBIT_ATTRBIT(b, p) ((b)->bits[(p) / 32] &= ~(1 << ((p) % 32))) 358191783Srmacklem#define NFSCLRALL_ATTRBIT(b, a) do { \ 359191783Srmacklem (b)->bits[0] &= ~((a)->bits[0]); \ 360191783Srmacklem (b)->bits[1] &= ~((a)->bits[1]); \ 361191783Srmacklem } while (0) 362191783Srmacklem#define NFSCLRNOT_ATTRBIT(b, a) do { \ 363191783Srmacklem (b)->bits[0] &= ((a)->bits[0]); \ 364191783Srmacklem (b)->bits[1] &= ((a)->bits[1]); \ 365191783Srmacklem } while (0) 366191783Srmacklem#define NFSCLRNOTFILLABLE_ATTRBIT(b) do { \ 367191783Srmacklem (b)->bits[0] &= NFSATTRBIT_SUPP0; \ 368191783Srmacklem (b)->bits[1] &= NFSATTRBIT_SUPP1; } while (0) 369191783Srmacklem#define NFSCLRNOTSETABLE_ATTRBIT(b) do { \ 370191783Srmacklem (b)->bits[0] &= NFSATTRBIT_SETABLE0; \ 371191783Srmacklem (b)->bits[1] &= NFSATTRBIT_SETABLE1; } while (0) 372191783Srmacklem#define NFSNONZERO_ATTRBIT(b) ((b)->bits[0] || (b)->bits[1]) 373191783Srmacklem#define NFSEQUAL_ATTRBIT(b, p) \ 374191783Srmacklem ((b)->bits[0] == (p)->bits[0] && (b)->bits[1] == (p)->bits[1]) 375191783Srmacklem#define NFSGETATTR_ATTRBIT(b) do { \ 376191783Srmacklem (b)->bits[0] = NFSATTRBIT_GETATTR0; \ 377191783Srmacklem (b)->bits[1] = NFSATTRBIT_GETATTR1; } while (0) 378191783Srmacklem#define NFSWCCATTR_ATTRBIT(b) do { \ 379191783Srmacklem (b)->bits[0] = NFSATTRBIT_WCCATTR0; \ 380191783Srmacklem (b)->bits[1] = NFSATTRBIT_WCCATTR1; } while (0) 381191783Srmacklem#define NFSWRITEGETATTR_ATTRBIT(b) do { \ 382191783Srmacklem (b)->bits[0] = NFSATTRBIT_WRITEGETATTR0; \ 383191783Srmacklem (b)->bits[1] = NFSATTRBIT_WRITEGETATTR1; } while (0) 384191783Srmacklem#define NFSCBGETATTR_ATTRBIT(b, c) do { \ 385191783Srmacklem (c)->bits[0] = ((b)->bits[0] & NFSATTRBIT_CBGETATTR0); \ 386191783Srmacklem (c)->bits[1] = ((b)->bits[1] & NFSATTRBIT_CBGETATTR1); } while (0) 387191783Srmacklem#define NFSPATHCONF_GETATTRBIT(b) do { \ 388191783Srmacklem (b)->bits[0] = NFSGETATTRBIT_PATHCONF0; \ 389191783Srmacklem (b)->bits[1] = NFSGETATTRBIT_PATHCONF1; } while (0) 390191783Srmacklem#define NFSSTATFS_GETATTRBIT(b) do { \ 391191783Srmacklem (b)->bits[0] = NFSGETATTRBIT_STATFS0; \ 392191783Srmacklem (b)->bits[1] = NFSGETATTRBIT_STATFS1; } while (0) 393191783Srmacklem#define NFSISSETSTATFS_ATTRBIT(b) \ 394191783Srmacklem (((b)->bits[0] & NFSATTRBIT_STATFS0) || \ 395191783Srmacklem ((b)->bits[1] & NFSATTRBIT_STATFS1)) 396191783Srmacklem#define NFSCLRSTATFS_ATTRBIT(b) do { \ 397191783Srmacklem (b)->bits[0] &= ~NFSATTRBIT_STATFS0; \ 398191783Srmacklem (b)->bits[1] &= ~NFSATTRBIT_STATFS1; } while (0) 399191783Srmacklem#define NFSREADDIRPLUS_ATTRBIT(b) do { \ 400191783Srmacklem (b)->bits[0] = NFSATTRBIT_READDIRPLUS0; \ 401191783Srmacklem (b)->bits[1] = NFSATTRBIT_READDIRPLUS1; } while (0) 402191783Srmacklem#define NFSREFERRAL_ATTRBIT(b) do { \ 403191783Srmacklem (b)->bits[0] = NFSATTRBIT_REFERRAL0; \ 404191783Srmacklem (b)->bits[1] = NFSATTRBIT_REFERRAL1; } while (0) 405191783Srmacklem 406191783Srmacklem/* 407194523Srmacklem * Store uid, gid creds that were used when the stateid was acquired. 408194541Srmacklem * The RPC layer allows NFS_MAXGRPS + 1 groups to go out on the wire, 409194523Srmacklem * so that's how many gets stored here. 410191783Srmacklem */ 411191783Srmacklemstruct nfscred { 412191783Srmacklem uid_t nfsc_uid; 413194541Srmacklem gid_t nfsc_groups[NFS_MAXGRPS + 1]; 414191783Srmacklem int nfsc_ngroups; 415191783Srmacklem}; 416191783Srmacklem 417191783Srmacklem/* 418191783Srmacklem * Constants that define the file handle for the V4 root directory. 419191783Srmacklem * (The FSID must never be used by other file systems that are exported.) 420191783Srmacklem */ 421191783Srmacklem#define NFSV4ROOT_FSID0 ((int32_t) -1) 422191783Srmacklem#define NFSV4ROOT_FSID1 ((int32_t) -1) 423191783Srmacklem#define NFSV4ROOT_REFERRAL ((int32_t) -2) 424191783Srmacklem#define NFSV4ROOT_INO 2 /* It's traditional */ 425191783Srmacklem#define NFSV4ROOT_GEN 1 426191783Srmacklem 427191783Srmacklem/* 428191783Srmacklem * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts. 429191783Srmacklem * What should be in this set is open to debate, but I believe that since 430191783Srmacklem * I/O system calls on ufs are never interrupted by signals the set should 431191783Srmacklem * be minimal. My reasoning is that many current programs that use signals 432191783Srmacklem * such as SIGALRM will not expect file I/O system calls to be interrupted 433191783Srmacklem * by them and break. 434191783Srmacklem */ 435191783Srmacklem#if defined(_KERNEL) || defined(KERNEL) 436191783Srmacklem 437191783Srmacklemstruct uio; struct buf; struct vattr; struct nameidata; /* XXX */ 438191783Srmacklem 439191783Srmacklem/* 440191783Srmacklem * Socket errors ignored for connectionless sockets? 441191783Srmacklem * For now, ignore them all 442191783Srmacklem */ 443191783Srmacklem#define NFSIGNORE_SOERROR(s, e) \ 444191783Srmacklem ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \ 445191783Srmacklem ((s) & PR_CONNREQUIRED) == 0) 446191783Srmacklem 447191783Srmacklem 448191783Srmacklem/* 449191783Srmacklem * This structure holds socket information for a connection. Used by the 450191783Srmacklem * client and the server for callbacks. 451191783Srmacklem */ 452191783Srmacklemstruct nfssockreq { 453191783Srmacklem NFSSOCKADDR_T nr_nam; 454191783Srmacklem int nr_sotype; 455191783Srmacklem int nr_soproto; 456191783Srmacklem int nr_soflags; 457191783Srmacklem struct ucred *nr_cred; 458191783Srmacklem int nr_lock; 459191783Srmacklem NFSMUTEX_T nr_mtx; 460191783Srmacklem u_int32_t nr_prog; 461191783Srmacklem u_int32_t nr_vers; 462191783Srmacklem struct __rpc_client *nr_client; 463191783Srmacklem}; 464191783Srmacklem 465191783Srmacklem/* 466191783Srmacklem * And associated nr_lock bits. 467191783Srmacklem */ 468191783Srmacklem#define NFSR_SNDLOCK 0x01 469191783Srmacklem#define NFSR_WANTSND 0x02 470191783Srmacklem#define NFSR_RCVLOCK 0x04 471191783Srmacklem#define NFSR_WANTRCV 0x08 472191783Srmacklem#define NFSR_RESERVEDPORT 0x10 473191783Srmacklem#define NFSR_LOCALHOST 0x20 474191783Srmacklem 475191783Srmacklem/* 476191783Srmacklem * Queue head for nfsreq's 477191783Srmacklem */ 478191783SrmacklemTAILQ_HEAD(nfsreqhead, nfsreq); 479191783Srmacklem 480192581Srmacklem/* This is the only nfsreq R_xxx flag still used. */ 481191783Srmacklem#define R_DONTRECOVER 0x00000100 /* don't initiate recovery when this 482191783Srmacklem rpc gets a stale state reply */ 483191783Srmacklem 484191783Srmacklem/* 485191783Srmacklem * Network address hash list element 486191783Srmacklem */ 487191783Srmacklemunion nethostaddr { 488191783Srmacklem struct in_addr had_inet; 489191783Srmacklem struct in6_addr had_inet6; 490191783Srmacklem}; 491191783Srmacklem 492191783Srmacklem/* 493191783Srmacklem * Structure of list of mechanisms. 494191783Srmacklem */ 495191783Srmacklemstruct nfsgss_mechlist { 496191783Srmacklem int len; 497191783Srmacklem const u_char *str; 498191783Srmacklem int totlen; 499191783Srmacklem}; 500191783Srmacklem#define KERBV_MECH 0 /* position in list */ 501191783Srmacklem 502191783Srmacklem/* 503191783Srmacklem * This structure is used by the server for describing each request. 504191783Srmacklem */ 505191783Srmacklemstruct nfsrv_descript { 506191783Srmacklem mbuf_t nd_mrep; /* Request mbuf list */ 507191783Srmacklem mbuf_t nd_md; /* Current dissect mbuf */ 508191783Srmacklem mbuf_t nd_mreq; /* Reply mbuf list */ 509191783Srmacklem mbuf_t nd_mb; /* Current build mbuf */ 510191783Srmacklem NFSSOCKADDR_T nd_nam; /* and socket addr */ 511191783Srmacklem NFSSOCKADDR_T nd_nam2; /* return socket addr */ 512191783Srmacklem caddr_t nd_dpos; /* Current dissect pos */ 513191783Srmacklem caddr_t nd_bpos; /* Current build pos */ 514191783Srmacklem u_int16_t nd_procnum; /* RPC # */ 515191783Srmacklem u_int32_t nd_flag; /* nd_flag */ 516191783Srmacklem u_int32_t nd_repstat; /* Reply status */ 517191783Srmacklem int *nd_errp; /* Pointer to ret status */ 518191783Srmacklem u_int32_t nd_retxid; /* Reply xid */ 519191783Srmacklem struct nfsrvcache *nd_rp; /* Assoc. cache entry */ 520191783Srmacklem struct timeval nd_starttime; /* Time RPC initiated */ 521191783Srmacklem fhandle_t nd_fh; /* File handle */ 522191783Srmacklem struct ucred *nd_cred; /* Credentials */ 523191783Srmacklem uid_t nd_saveduid; /* Saved uid */ 524191783Srmacklem u_int64_t nd_sockref; /* Rcv socket ref# */ 525191783Srmacklem u_int64_t nd_compref; /* Compound RPC ref# */ 526191783Srmacklem time_t nd_tcpconntime; /* Time TCP connection est. */ 527191783Srmacklem nfsquad_t nd_clientid; /* Implied clientid */ 528191783Srmacklem int nd_gssnamelen; /* principal name length */ 529191783Srmacklem char *nd_gssname; /* principal name */ 530191783Srmacklem}; 531191783Srmacklem 532191783Srmacklem#define nd_princlen nd_gssnamelen 533191783Srmacklem#define nd_principal nd_gssname 534191783Srmacklem 535191783Srmacklem/* Bits for "nd_flag" */ 536191783Srmacklem#define ND_DONTSAVEREPLY 0x00000001 537191783Srmacklem#define ND_SAVEREPLY 0x00000002 538191783Srmacklem#define ND_NFSV2 0x00000004 539191783Srmacklem#define ND_NFSV3 0x00000008 540191783Srmacklem#define ND_NFSV4 0x00000010 541191783Srmacklem#define ND_KERBV 0x00000020 542191783Srmacklem#define ND_GSSINTEGRITY 0x00000040 543191783Srmacklem#define ND_GSSPRIVACY 0x00000080 544191783Srmacklem#define ND_WINDOWVERF 0x00000100 545191783Srmacklem#define ND_GSSINITREPLY 0x00000200 546191783Srmacklem#define ND_STREAMSOCK 0x00000400 547191783Srmacklem#define ND_PUBLOOKUP 0x00000800 548191783Srmacklem#define ND_USEGSSNAME 0x00001000 549191783Srmacklem#define ND_SAMETCPCONN 0x00002000 550191783Srmacklem#define ND_IMPLIEDCLID 0x00004000 551191783Srmacklem#define ND_NOMOREDATA 0x00008000 552191783Srmacklem#define ND_V4WCCATTR 0x00010000 553191783Srmacklem#define ND_NFSCB 0x00020000 554191783Srmacklem#define ND_AUTHNONE 0x00040000 555192121Srmacklem#define ND_EXAUTHSYS 0x00080000 556192121Srmacklem#define ND_EXGSS 0x00100000 557192121Srmacklem#define ND_EXGSSINTEGRITY 0x00200000 558192121Srmacklem#define ND_EXGSSPRIVACY 0x00400000 559192121Srmacklem#define ND_INCRSEQID 0x00800000 560191783Srmacklem 561191783Srmacklem/* 562191783Srmacklem * ND_GSS should be the "or" of all GSS type authentications. 563191783Srmacklem */ 564191783Srmacklem#define ND_GSS (ND_KERBV) 565191783Srmacklem 566191783Srmacklemstruct nfsv4_opflag { 567191783Srmacklem int retfh; 568191783Srmacklem int needscfh; 569191783Srmacklem int savereply; 570191783Srmacklem int modifyfs; 571191783Srmacklem}; 572191783Srmacklem 573191783Srmacklem/* 574191783Srmacklem * Flags used to indicate what to do w.r.t. seqid checking. 575191783Srmacklem */ 576191783Srmacklem#define NFSRVSEQID_FIRST 0x01 577191783Srmacklem#define NFSRVSEQID_LAST 0x02 578191783Srmacklem#define NFSRVSEQID_OPEN 0x04 579191783Srmacklem 580191783Srmacklem/* 581191783Srmacklem * assign a doubly linked list to a new head 582191783Srmacklem * and prepend one list into another. 583191783Srmacklem */ 584191783Srmacklem#define LIST_NEWHEAD(nhead, ohead, field) do { \ 585191783Srmacklem if (((nhead)->lh_first = (ohead)->lh_first) != NULL) \ 586191783Srmacklem (ohead)->lh_first->field.le_prev = &(nhead)->lh_first; \ 587191783Srmacklem (ohead)->lh_first = NULL; \ 588191783Srmacklem } while (0) 589191783Srmacklem 590191783Srmacklem#define LIST_PREPEND(head, phead, lelm, field) do { \ 591191783Srmacklem if ((head)->lh_first != NULL) { \ 592191783Srmacklem (lelm)->field.le_next = (head)->lh_first; \ 593191783Srmacklem (lelm)->field.le_next->field.le_prev = \ 594191783Srmacklem &(lelm)->field.le_next; \ 595191783Srmacklem } \ 596191783Srmacklem (head)->lh_first = (phead)->lh_first; \ 597191783Srmacklem (head)->lh_first->field.le_prev = &(head)->lh_first; \ 598191783Srmacklem } while (0) 599191783Srmacklem 600191783Srmacklem/* 601191783Srmacklem * File handle structure for client. Malloc'd to the correct length with 602191783Srmacklem * malloc type M_NFSFH. 603191783Srmacklem */ 604191783Srmacklemstruct nfsfh { 605191783Srmacklem u_int16_t nfh_len; /* Length of file handle */ 606191783Srmacklem u_int8_t nfh_fh[1]; /* and the file handle */ 607191783Srmacklem}; 608191783Srmacklem 609191783Srmacklem/* 610191783Srmacklem * File handle structure for server. The NFSRV_MAXFH constant is 611191783Srmacklem * set in nfsdport.h. I use a 32bit length, so that alignment is 612191783Srmacklem * preserved. 613191783Srmacklem */ 614191783Srmacklemstruct nfsrvfh { 615191783Srmacklem u_int32_t nfsrvfh_len; 616191783Srmacklem u_int8_t nfsrvfh_data[NFSRV_MAXFH]; 617191783Srmacklem}; 618191783Srmacklem 619191783Srmacklem/* 620191783Srmacklem * This structure is used for sleep locks on the NFSv4 nfsd threads and 621191783Srmacklem * NFSv4 client data structures. 622191783Srmacklem */ 623191783Srmacklemstruct nfsv4lock { 624191783Srmacklem u_int32_t nfslock_usecnt; 625191783Srmacklem u_int8_t nfslock_lock; 626191783Srmacklem}; 627191783Srmacklem#define NFSV4LOCK_LOCK 0x01 628191783Srmacklem#define NFSV4LOCK_LOCKWANTED 0x02 629191783Srmacklem#define NFSV4LOCK_WANTED 0x04 630191783Srmacklem 631191783Srmacklem/* 632191783Srmacklem * Values for the override argument for nfsvno_accchk(). 633191783Srmacklem */ 634191783Srmacklem#define NFSACCCHK_NOOVERRIDE 0 635191783Srmacklem#define NFSACCCHK_ALLOWROOT 1 636191783Srmacklem#define NFSACCCHK_ALLOWOWNER 2 637191783Srmacklem 638191783Srmacklem/* 639191783Srmacklem * and values for the vpislocked argument for nfsvno_accchk(). 640191783Srmacklem */ 641191783Srmacklem#define NFSACCCHK_VPNOTLOCKED 0 642191783Srmacklem#define NFSACCCHK_VPISLOCKED 1 643191783Srmacklem 644191783Srmacklem#endif /* _KERNEL */ 645191783Srmacklem 646191783Srmacklem#endif /* _NFS_NFS_H */ 647