1 /* 2 * Copyright (c) 2000-2018 Apple Inc. All rights reserved. 3 * 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. The rights granted to you under the License 10 * may not be used to create, or enable the creation or redistribution of, 11 * unlawful or unlicensed copies of an Apple operating system, or to 12 * circumvent, violate, or enable the circumvention or violation of, any 13 * terms of an Apple operating system software license agreement. 14 * 15 * Please obtain a copy of the License at 16 * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 * 18 * The Original Code and all software distributed under the License are 19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 * Please see the License for the specific language governing rights and 24 * limitations under the License. 25 * 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 */ 28 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ 29 /* 30 * Copyright (c) 1989, 1993, 1995 31 * The Regents of the University of California. All rights reserved. 32 * 33 * This code is derived from software contributed to Berkeley by 34 * Rick Macklem at The University of Guelph. 35 * 36 * Redistribution and use in source and binary forms, with or without 37 * modification, are permitted provided that the following conditions 38 * are met: 39 * 1. Redistributions of source code must retain the above copyright 40 * notice, this list of conditions and the following disclaimer. 41 * 2. Redistributions in binary form must reproduce the above copyright 42 * notice, this list of conditions and the following disclaimer in the 43 * documentation and/or other materials provided with the distribution. 44 * 3. All advertising materials mentioning features or use of this software 45 * must display the following acknowledgement: 46 * This product includes software developed by the University of 47 * California, Berkeley and its contributors. 48 * 4. Neither the name of the University nor the names of its contributors 49 * may be used to endorse or promote products derived from this software 50 * without specific prior written permission. 51 * 52 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 53 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 54 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 55 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 56 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 57 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 58 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 59 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 60 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 61 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 62 * SUCH DAMAGE. 63 * 64 * @(#)nfs.h 8.4 (Berkeley) 5/1/95 65 * FreeBSD-Id: nfs.h,v 1.32 1997/10/12 20:25:38 phk Exp $ 66 */ 67 68 #ifndef _NFS_NFS_H_ 69 #define _NFS_NFS_H_ 70 71 #include <sys/appleapiopts.h> 72 #include <sys/cdefs.h> 73 #include <sys/socket.h> 74 #include <sys/mount.h> 75 76 #ifdef KERNEL 77 #include <sys/vnode.h> 78 #include <sys/user.h> 79 #include <net/radix.h> 80 #include <kern/locks.h> 81 #include <kern/lock_group.h> 82 #endif 83 84 #include <nfs/rpcv2.h> 85 #include <nfs/nfsproto.h> 86 87 #ifdef __APPLE_API_PRIVATE 88 /* 89 * Tunable constants for nfs 90 */ 91 92 #define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */ 93 #define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */ 94 extern int nfs_ticks; 95 #define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */ 96 #define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */ 97 #define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */ 98 #define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/ 99 #define NFS_MAXREXMIT 100 /* Stop counting after this many */ 100 #define NFS_RETRANS 10 /* Num of retrans for soft mounts */ 101 #define NFS_TRYLATERDEL 4 /* Initial try later delay (sec) */ 102 #define NFS_MAXGRPS 16U /* Max. size of groups list */ 103 #define NFS_MINATTRTIMO 5 /* Attribute cache timeout in sec */ 104 #define NFS_MAXATTRTIMO 60 105 #define NFS_MINDIRATTRTIMO 5 /* directory attribute cache timeout in sec */ 106 #define NFS_MAXDIRATTRTIMO 60 107 #define NFS_MAXPORT 0xffff 108 #define NFS_IOSIZE (1024 * 1024) /* suggested I/O size */ 109 #define NFS_RWSIZE 32768 /* Def. read/write data size <= 32K */ 110 #define NFS_WSIZE NFS_RWSIZE /* Def. write data size <= 32K */ 111 #define NFS_RSIZE NFS_RWSIZE /* Def. read data size <= 32K */ 112 #define NFS_DGRAM_WSIZE 8192 /* UDP Def. write data size <= 8K */ 113 #define NFS_DGRAM_RSIZE 8192 /* UDP Def. read data size <= 8K */ 114 #define NFS_READDIRSIZE 32768 /* Def. readdir size */ 115 #define NFS_DEFRAHEAD 16 /* Def. read ahead # blocks */ 116 #define NFS_MAXRAHEAD 128 /* Max. read ahead # blocks */ 117 #define NFS_DEFMAXASYNCWRITES 128 /* Def. max # concurrent async write RPCs */ 118 #define NFS_DEFASYNCTHREAD 16 /* Def. # nfsiod threads */ 119 #define NFS_MAXASYNCTHREAD 64 /* max # nfsiod threads */ 120 #define NFS_ASYNCTHREADMAXIDLE 60 /* Seconds before idle nfsiods are reaped */ 121 #define NFS_DEFSTATFSRATELIMIT 10 /* Def. max # statfs RPCs per second */ 122 #define NFS_REQUESTDELAY 10 /* ms interval to check request queue */ 123 #define NFSRV_MAXWGATHERDELAY 100 /* Max. write gather delay (msec) */ 124 #ifndef NFSRV_WGATHERDELAY 125 #define NFSRV_WGATHERDELAY 1 /* Default write gather delay (msec) */ 126 #endif 127 #define NFS_DIRBLKSIZ 4096 /* size of NFS directory buffers */ 128 #if defined(KERNEL) && !defined(DIRBLKSIZ) 129 #define DIRBLKSIZ 512 /* XXX we used to use ufs's DIRBLKSIZ */ 130 /* can't be larger than NFS_FABLKSIZE */ 131 #endif 132 133 /* default values for unresponsive mount timeouts */ 134 #define NFS_TPRINTF_INITIAL_DELAY 5 135 #define NFS_TPRINTF_DELAY 30 136 137 /* NFS client mount timeouts */ 138 #define NFS_MOUNT_TIMEOUT 30 139 #define NFS_MOUNT_QUICK_TIMEOUT 8 140 141 /* 142 * Oddballs 143 */ 144 #define NFS_CMPFH(n, f, s) \ 145 ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s))) 146 #define NFSRV_NDMAXDATA(n) \ 147 (((n)->nd_vers == NFS_VER3) ? (((n)->nd_nam2) ? \ 148 NFS_MAXDGRAMDATA : NFSRV_MAXDATA) : NFS_V2MAXDATA) 149 #define NFS_PORT_INVALID(port) \ 150 (((port) > NFS_MAXPORT) || ((port) < 0)) 151 152 /* 153 * The IO_METASYNC flag should be implemented for local file systems. 154 * (Until then, it is nothin at all.) 155 */ 156 #ifndef IO_METASYNC 157 #define IO_METASYNC 0 158 #endif 159 160 /* 161 * Expected allocation sizes for major data structures. If the actual size 162 * of the structure exceeds these sizes, then malloc() will be allocating 163 * almost twice the memory required. This is used in nfs_init() to warn 164 * the sysadmin that the size of a structure should be reduced. 165 * (These sizes are always a power of 2. If the kernel malloc() changes 166 * to one that does not allocate space in powers of 2 size, then this all 167 * becomes bunk!). 168 * Note that some of these structures come out of their own nfs zones. 169 */ 170 #define NFS_NODEALLOC 1024 171 #define NFS_MNTALLOC 1024 172 #define NFS_SVCALLOC 512 173 174 #define NFS_ARGSVERSION_XDR 88 /* NFS mount args are in XDR format */ 175 176 #define NFS_XDRARGS_VERSION_0 0 177 #define NFS_MATTR_BITMAP_LEN 1 /* length of mount attributes bitmap */ 178 #define NFS_MFLAG_BITMAP_LEN 1 /* length of mount flags bitmap */ 179 180 /* NFS mount attributes */ 181 #define NFS_MATTR_FLAGS 0 /* mount flags (NFS_MATTR_*) */ 182 #define NFS_MATTR_NFS_VERSION 1 /* NFS protocol version */ 183 #define NFS_MATTR_NFS_MINOR_VERSION 2 /* NFS protocol minor version */ 184 #define NFS_MATTR_READ_SIZE 3 /* READ RPC size */ 185 #define NFS_MATTR_WRITE_SIZE 4 /* WRITE RPC size */ 186 #define NFS_MATTR_READDIR_SIZE 5 /* READDIR RPC size */ 187 #define NFS_MATTR_READAHEAD 6 /* block readahead count */ 188 #define NFS_MATTR_ATTRCACHE_REG_MIN 7 /* minimum attribute cache time */ 189 #define NFS_MATTR_ATTRCACHE_REG_MAX 8 /* maximum attribute cache time */ 190 #define NFS_MATTR_ATTRCACHE_DIR_MIN 9 /* minimum attribute cache time for dirs */ 191 #define NFS_MATTR_ATTRCACHE_DIR_MAX 10 /* maximum attribute cache time for dirs */ 192 #define NFS_MATTR_LOCK_MODE 11 /* advisory file locking mode (NFS_LOCK_MODE_*) */ 193 #define NFS_MATTR_SECURITY 12 /* RPC security flavors to use */ 194 #define NFS_MATTR_MAX_GROUP_LIST 13 /* max # of RPC AUTH_SYS groups */ 195 #define NFS_MATTR_SOCKET_TYPE 14 /* socket transport type as a netid-like string */ 196 #define NFS_MATTR_NFS_PORT 15 /* port # to use for NFS protocol */ 197 #define NFS_MATTR_MOUNT_PORT 16 /* port # to use for MOUNT protocol */ 198 #define NFS_MATTR_REQUEST_TIMEOUT 17 /* initial RPC request timeout value */ 199 #define NFS_MATTR_SOFT_RETRY_COUNT 18 /* max RPC retransmissions for soft mounts */ 200 #define NFS_MATTR_DEAD_TIMEOUT 19 /* how long until unresponsive mount is considered dead */ 201 #define NFS_MATTR_FH 20 /* file handle for mount directory */ 202 #define NFS_MATTR_FS_LOCATIONS 21 /* list of locations for the file system */ 203 #define NFS_MATTR_MNTFLAGS 22 /* VFS mount flags (MNT_*) */ 204 #define NFS_MATTR_MNTFROM 23 /* fixed string to use for "f_mntfromname" */ 205 #define NFS_MATTR_REALM 24 /* Realm to authenticate with */ 206 #define NFS_MATTR_PRINCIPAL 25 /* GSS principal to authenticate with */ 207 #define NFS_MATTR_SVCPRINCIPAL 26 /* GSS principal to authenticate to, the server principal */ 208 #define NFS_MATTR_NFS_VERSION_RANGE 27 /* Packed version range to try */ 209 #define NFS_MATTR_KERB_ETYPE 28 /* Enctype to use for kerberos mounts */ 210 #define NFS_MATTR_LOCAL_NFS_PORT 29 /* Unix domain socket for NFS protocol */ 211 #define NFS_MATTR_LOCAL_MOUNT_PORT 30 /* Unix domain socket for MOUNT protocol */ 212 #define NFS_MATTR_SET_MOUNT_OWNER 31 /* Set owner of mount point */ 213 214 /* NFS mount flags */ 215 #define NFS_MFLAG_SOFT 0 /* soft mount (requests fail if unresponsive) */ 216 #define NFS_MFLAG_INTR 1 /* allow operations to be interrupted */ 217 #define NFS_MFLAG_RESVPORT 2 /* use a reserved port */ 218 #define NFS_MFLAG_NOCONNECT 3 /* don't connect the socket (UDP) */ 219 #define NFS_MFLAG_DUMBTIMER 4 /* don't estimate RTT dynamically */ 220 #define NFS_MFLAG_CALLUMNT 5 /* call MOUNTPROC_UMNT on unmount */ 221 #define NFS_MFLAG_RDIRPLUS 6 /* request additional info when reading directories */ 222 #define NFS_MFLAG_NONEGNAMECACHE 7 /* don't do negative name caching */ 223 #define NFS_MFLAG_MUTEJUKEBOX 8 /* don't treat jukebox errors as unresponsive */ 224 #define NFS_MFLAG_EPHEMERAL 9 /* ephemeral (mirror) mount */ 225 #define NFS_MFLAG_NOCALLBACK 10 /* don't provide callback RPC service */ 226 #define NFS_MFLAG_NAMEDATTR 11 /* don't use named attributes */ 227 #define NFS_MFLAG_NOACL 12 /* don't support ACLs */ 228 #define NFS_MFLAG_ACLONLY 13 /* only support ACLs - not mode */ 229 #define NFS_MFLAG_NFC 14 /* send NFC strings */ 230 #define NFS_MFLAG_NOQUOTA 15 /* don't support QUOTA requests */ 231 #define NFS_MFLAG_MNTUDP 16 /* MOUNT protocol should use UDP */ 232 #define NFS_MFLAG_MNTQUICK 17 /* use short timeouts while mounting */ 233 /* 18 reserved */ 234 #define NFS_MFLAG_NOOPAQUE_AUTH 19 /* don't make the mount AUTH_OPAQUE. Used by V3 */ 235 236 /* Macros for packing and unpacking packed versions */ 237 #define PVER2MAJOR(M) ((uint32_t)(((M) >> 16) & 0xffff)) 238 #define PVER2MINOR(m) ((uint32_t)((m) & 0xffff)) 239 #define VER2PVER(M, m) ((uint32_t)((M) << 16) | ((m) & 0xffff)) 240 241 /* NFS advisory file locking modes */ 242 #define NFS_LOCK_MODE_ENABLED 0 /* advisory file locking enabled */ 243 #define NFS_LOCK_MODE_DISABLED 1 /* do not support advisory file locking */ 244 #define NFS_LOCK_MODE_LOCAL 2 /* perform advisory file locking locally */ 245 246 #define NFS_STRLEN_INT(str) \ 247 (int)strnlen(str, INT_MAX) 248 #define NFS_UIO_ADDIOV(a_uio, a_baseaddr, a_length) \ 249 assert(a_length <= UINT32_MAX); uio_addiov(a_uio, a_baseaddr, (uint32_t)(a_length)); 250 #define NFS_BZERO(off, bytes) \ 251 do { \ 252 uint32_t bytes32 = bytes > UINT32_MAX ? UINT32_MAX : (uint32_t)(bytes); \ 253 bzero(off, bytes32); \ 254 if (bytes > UINT32_MAX) { \ 255 bzero(off + bytes32, (uint32_t)(bytes - UINT32_MAX)); \ 256 } \ 257 } while(0); 258 #define NFS_ZFREE(zone, ptr) \ 259 do { \ 260 if ((ptr)) { \ 261 zfree((zone), (ptr)); \ 262 (ptr) = NULL; \ 263 } \ 264 } while (0); \ 265 266 /* Supported encryption types for kerberos session keys */ 267 typedef enum nfs_supported_kerberos_etypes { 268 NFS_DES3_CBC_SHA1_KD = 16, 269 NFS_AES128_CTS_HMAC_SHA1_96 = 17, 270 NFS_AES256_CTS_HMAC_SHA1_96 = 18 271 } nfs_supported_kerberos_etypes; 272 273 /* Structure to hold an array of kerberos enctypes to allow on a mount */ 274 #define NFS_MAX_ETYPES 3 275 struct nfs_etype { 276 uint32_t count; 277 uint32_t selected; /* index in etypes that is being used. Set to count if nothing has been selected */ 278 nfs_supported_kerberos_etypes etypes[NFS_MAX_ETYPES]; 279 }; 280 281 /* 282 * Old-style arguments to mount NFS 283 */ 284 #define NFS_ARGSVERSION 6 /* change when nfs_args changes */ 285 struct nfs_args { 286 int version; /* args structure version number */ 287 #ifdef KERNEL 288 user32_addr_t addr; /* file server address */ 289 #else 290 struct sockaddr *addr; /* file server address */ 291 #endif 292 uint8_t addrlen; /* length of address */ 293 int sotype; /* Socket type */ 294 int proto; /* and Protocol */ 295 #ifdef KERNEL 296 user32_addr_t fh; /* File handle to be mounted */ 297 #else 298 u_char *fh; /* File handle to be mounted */ 299 #endif 300 int fhsize; /* Size, in bytes, of fh */ 301 int flags; /* flags */ 302 int wsize; /* write size in bytes */ 303 int rsize; /* read size in bytes */ 304 int readdirsize; /* readdir size in bytes */ 305 int timeo; /* initial timeout in .1 secs */ 306 int retrans; /* times to retry send */ 307 int maxgrouplist; /* Max. size of group list */ 308 int readahead; /* # of blocks to readahead */ 309 int leaseterm; /* obsolete: Term (sec) of lease */ 310 int deadthresh; /* obsolete: Retrans threshold */ 311 #ifdef KERNEL 312 user32_addr_t hostname; /* server's name */ 313 #else 314 char *hostname; /* server's name */ 315 #endif 316 /* NFS_ARGSVERSION 3 ends here */ 317 int acregmin; /* reg file min attr cache timeout */ 318 int acregmax; /* reg file max attr cache timeout */ 319 int acdirmin; /* dir min attr cache timeout */ 320 int acdirmax; /* dir max attr cache timeout */ 321 /* NFS_ARGSVERSION 4 ends here */ 322 uint32_t auth; /* security mechanism flavor */ 323 /* NFS_ARGSVERSION 5 ends here */ 324 uint32_t deadtimeout; /* secs until unresponsive mount considered dead */ 325 }; 326 327 /* incremental size additions in each version of nfs_args */ 328 #define NFS_ARGSVERSION4_INCSIZE (4 * sizeof(int)) 329 #define NFS_ARGSVERSION5_INCSIZE (sizeof(uint32_t)) 330 #define NFS_ARGSVERSION6_INCSIZE (sizeof(uint32_t)) 331 332 #ifdef KERNEL 333 /* LP64 version of nfs_args. all pointers and longs 334 * grow when we're dealing with a 64-bit process. 335 * WARNING - keep in sync with nfs_args 336 */ 337 struct user_nfs_args { 338 int version; /* args structure version number */ 339 user_addr_t addr __attribute((aligned(8))); /* file server address */ 340 uint8_t addrlen; /* length of address */ 341 int sotype; /* Socket type */ 342 int proto; /* and Protocol */ 343 user_addr_t fh __attribute((aligned(8))); /* File handle to be mounted */ 344 int fhsize; /* Size, in bytes, of fh */ 345 int flags; /* flags */ 346 int wsize; /* write size in bytes */ 347 int rsize; /* read size in bytes */ 348 int readdirsize; /* readdir size in bytes */ 349 int timeo; /* initial timeout in .1 secs */ 350 int retrans; /* times to retry send */ 351 int maxgrouplist; /* Max. size of group list */ 352 int readahead; /* # of blocks to readahead */ 353 int leaseterm; /* obsolete: Term (sec) of lease */ 354 int deadthresh; /* obsolete: Retrans threshold */ 355 user_addr_t hostname __attribute((aligned(8))); /* server's name */ 356 /* NFS_ARGSVERSION 3 ends here */ 357 int acregmin; /* reg file min attr cache timeout */ 358 int acregmax; /* reg file max attr cache timeout */ 359 int acdirmin; /* dir min attr cache timeout */ 360 int acdirmax; /* dir max attr cache timeout */ 361 /* NFS_ARGSVERSION 4 ends here */ 362 uint32_t auth; /* security mechanism flavor */ 363 /* NFS_ARGSVERSION 5 ends here */ 364 uint32_t deadtimeout; /* secs until unresponsive mount considered dead */ 365 }; 366 #endif // KERNEL 367 368 /* 369 * Old-style NFS mount option flags 370 */ 371 #define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */ 372 #define NFSMNT_WSIZE 0x00000002 /* set write size */ 373 #define NFSMNT_RSIZE 0x00000004 /* set read size */ 374 #define NFSMNT_TIMEO 0x00000008 /* set initial timeout */ 375 #define NFSMNT_RETRANS 0x00000010 /* set number of request retries */ 376 #define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */ 377 #define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */ 378 #define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */ 379 #define NFSMNT_NONEGNAMECACHE 0x00000100 /* Don't do negative name caching */ 380 #define NFSMNT_NFSV3 0x00000200 /* Use NFS Version 3 protocol */ 381 #define NFSMNT_NFSV4 0x00000400 /* Use NFS Version 4 protocol */ 382 #define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */ 383 #define NFSMNT_DEADTIMEOUT 0x00001000 /* unmount after a period of unresponsiveness */ 384 #define NFSMNT_READAHEAD 0x00002000 /* set read ahead */ 385 #define NFSMNT_CALLUMNT 0x00004000 /* call MOUNTPROC_UMNT on unmount */ 386 #define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */ 387 #define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */ 388 #define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */ 389 #define NFSMNT_NOLOCKS 0x00040000 /* don't support file locking */ 390 #define NFSMNT_LOCALLOCKS 0x00080000 /* do file locking locally on client */ 391 #define NFSMNT_ACREGMIN 0x00100000 /* reg min attr cache timeout */ 392 #define NFSMNT_ACREGMAX 0x00200000 /* reg max attr cache timeout */ 393 #define NFSMNT_ACDIRMIN 0x00400000 /* dir min attr cache timeout */ 394 #define NFSMNT_ACDIRMAX 0x00800000 /* dir max attr cache timeout */ 395 #define NFSMNT_SECFLAVOR 0x01000000 /* Use security flavor */ 396 #define NFSMNT_SECSYSOK 0x02000000 /* Server can support auth sys */ 397 #define NFSMNT_MUTEJUKEBOX 0x04000000 /* don't treat jukebox errors as unresponsive */ 398 #define NFSMNT_NOQUOTA 0x08000000 /* don't support QUOTA requests */ 399 400 401 /* 402 * fs.nfs sysctl(3) NFS_MOUNTINFO defines 403 */ 404 #define NFS_MOUNT_INFO_VERSION 0 /* nfsstat mount information version */ 405 #define NFS_MIATTR_BITMAP_LEN 1 /* length of mount info attributes bitmap */ 406 #define NFS_MIFLAG_BITMAP_LEN 1 /* length of mount info flags bitmap */ 407 408 /* NFS mount info attributes */ 409 #define NFS_MIATTR_FLAGS 0 /* mount info flags bitmap (MIFLAG_*) */ 410 #define NFS_MIATTR_ORIG_ARGS 1 /* original mount args passed into mount call */ 411 #define NFS_MIATTR_CUR_ARGS 2 /* current mount args values */ 412 #define NFS_MIATTR_CUR_LOC_INDEX 3 /* current fs location index */ 413 414 /* NFS mount info flags */ 415 #define NFS_MIFLAG_DEAD 0 /* mount is dead */ 416 #define NFS_MIFLAG_NOTRESP 1 /* server is unresponsive */ 417 #define NFS_MIFLAG_RECOVERY 2 /* mount in recovery */ 418 419 420 /* 421 * Structures for the nfssvc(2) syscall. Not that anyone but nfsd 422 * should ever try and use it. 423 */ 424 struct nfsd_args { 425 int sock; /* Socket to serve */ 426 #ifdef KERNEL 427 user32_addr_t name; /* Client addr for connection based sockets */ 428 #else 429 caddr_t name; /* Client addr for connection based sockets */ 430 #endif 431 int namelen; /* Length of name */ 432 }; 433 434 #ifdef KERNEL 435 /* LP64 version of nfsd_args. all pointers and longs 436 * grow when we're dealing with a 64-bit process. 437 * WARNING - keep in sync with nfsd_args 438 */ 439 struct user_nfsd_args { 440 int sock; /* Socket to serve */ 441 user_addr_t name __attribute((aligned(8))); /* Client addr for connection based sockets */ 442 int namelen; /* Length of name */ 443 }; 444 445 #endif // KERNEL 446 447 /* 448 * NFS Server File Handle structures 449 */ 450 451 /* NFS export handle identifies which NFS export */ 452 #define NFS_FH_VERSION 0x4e580000 /* 'NX00' */ 453 struct nfs_exphandle { 454 uint32_t nxh_version; /* data structure version */ 455 uint32_t nxh_fsid; /* File System Export ID */ 456 uint32_t nxh_expid; /* Export ID */ 457 uint16_t nxh_flags; /* export handle flags */ 458 uint8_t nxh_reserved; /* future use */ 459 uint32_t nxh_fidlen; /* length of File ID */ 460 }; 461 462 /* nxh_flags */ 463 #define NXHF_INVALIDFH 0x0001 /* file handle is invalid */ 464 465 #define NFS_MAX_FID_SIZE (NFS_MAX_FH_SIZE - sizeof(struct nfs_exphandle)) 466 #define NFSV4_MAX_FID_SIZE (NFSV4_MAX_FH_SIZE - sizeof(struct nfs_exphandle)) 467 #define NFSV3_MAX_FID_SIZE (NFSV3_MAX_FH_SIZE - sizeof(struct nfs_exphandle)) 468 #define NFSV2_MAX_FID_SIZE (NFSV2_MAX_FH_SIZE - sizeof(struct nfs_exphandle)) 469 470 /* NFS server internal view of fhandle_t */ 471 /* The first sizeof(fhandle_t) bytes must match what goes into fhandle_t. */ 472 /* (fhp is used to allow use of an external buffer) */ 473 struct nfs_filehandle { 474 uint32_t nfh_len; /* total length of file handle */ 475 struct nfs_exphandle nfh_xh; /* export handle */ 476 unsigned char nfh_fid[NFS_MAX_FID_SIZE]; /* File ID */ 477 unsigned char *nfh_fhp; /* pointer to file handle */ 478 }; 479 480 /* 481 * NFS export data structures 482 */ 483 484 /* Structure to hold an array of security flavors */ 485 #define NX_MAX_SEC_FLAVORS 5 486 struct nfs_sec { 487 int count; 488 uint32_t flavors[NX_MAX_SEC_FLAVORS]; 489 }; 490 491 struct nfs_export_net_args { 492 uint32_t nxna_flags; /* export flags */ 493 struct xucred nxna_cred; /* mapped credential for root/all user */ 494 struct sockaddr_storage nxna_addr; /* net address to which exported */ 495 struct sockaddr_storage nxna_mask; /* mask for net address */ 496 struct nfs_sec nxna_sec; /* security mechanism flavors */ 497 }; 498 499 struct nfs_export_args { 500 uint32_t nxa_fsid; /* export FS ID */ 501 uint32_t nxa_expid; /* export ID */ 502 #ifdef KERNEL 503 user32_addr_t nxa_fspath; /* export FS path */ 504 user32_addr_t nxa_exppath; /* export sub-path */ 505 #else 506 char *nxa_fspath; /* export FS path */ 507 char *nxa_exppath; /* export sub-path */ 508 #endif 509 uint32_t nxa_flags; /* export arg flags */ 510 uint32_t nxa_netcount; /* #entries in ex_nets array */ 511 #ifdef KERNEL 512 user32_addr_t nxa_nets; /* array of net args */ 513 #else 514 struct nfs_export_net_args *nxa_nets; /* array of net args */ 515 #endif 516 }; 517 518 #ifdef KERNEL 519 /* LP64 version of export_args */ 520 521 struct user_nfs_export_args { 522 uint32_t nxa_fsid; /* export FS ID */ 523 uint32_t nxa_expid; /* export ID */ 524 user_addr_t nxa_fspath; /* export FS path */ 525 user_addr_t nxa_exppath; /* export sub-path */ 526 uint32_t nxa_flags; /* export arg flags */ 527 uint32_t nxa_netcount; /* #entries in ex_nets array */ 528 user_addr_t nxa_nets; /* array of net args */ 529 }; 530 531 #endif /* KERNEL */ 532 533 /* nfs export arg flags */ 534 #define NXA_DELETE 0x0001 /* delete the specified export(s) */ 535 #define NXA_ADD 0x0002 /* add the specified export(s) */ 536 #define NXA_REPLACE 0x0003 /* delete and add the specified export(s) */ 537 #define NXA_DELETE_ALL 0x0004 /* delete all exports */ 538 #define NXA_OFFLINE 0x0008 /* export is offline */ 539 #define NXA_CHECK 0x0010 /* check if exportable */ 540 541 /* export option flags */ 542 #define NX_READONLY 0x0001 /* exported read-only */ 543 #define NX_DEFAULTEXPORT 0x0002 /* exported to the world */ 544 #define NX_MAPROOT 0x0004 /* map root access to anon credential */ 545 #define NX_MAPALL 0x0008 /* map all access to anon credential */ 546 #define NX_32BITCLIENTS 0x0020 /* restrict directory cookies to 32 bits */ 547 #define NX_OFFLINE 0x0040 /* export is offline */ 548 #define NX_MANGLEDNAMES 0x0080 /* export will return mangled names for names > 255 bytes */ 549 550 /* 551 * fs.nfs sysctl(3) export stats record structures 552 */ 553 #define NFS_EXPORT_STAT_REC_VERSION 1 /* export stat record version */ 554 #define NFS_USER_STAT_REC_VERSION 1 /* active user list record version */ 555 556 /* descriptor describing following records */ 557 struct nfs_export_stat_desc { 558 uint32_t rec_vers; /* version of export stat records */ 559 uint64_t rec_count; /* total record count */ 560 }__attribute__((__packed__)); 561 562 /* export stat record containing path and stat counters */ 563 struct nfs_export_stat_rec { 564 char path[RPCMNT_PATHLEN + 1]; 565 uint64_t ops; /* Count of NFS Requests received for this export */ 566 uint64_t bytes_read; /* Count of bytes read from this export */ 567 uint64_t bytes_written; /* Count of bytes written to this export */ 568 }__attribute__((__packed__)); 569 570 /* Active user list stat buffer descriptor */ 571 struct nfs_user_stat_desc { 572 uint32_t rec_vers; /* version of active user stat records */ 573 uint32_t rec_count; /* total record count */ 574 }__attribute__((__packed__)); 575 576 /* Active user list user stat record format */ 577 struct nfs_user_stat_user_rec { 578 u_char rec_type; 579 uid_t uid; 580 struct sockaddr_storage sock; 581 uint64_t ops; 582 uint64_t bytes_read; 583 uint64_t bytes_written; 584 time_t tm_start; 585 time_t tm_last; 586 }__attribute__((__packed__)); 587 588 /* Active user list path record format */ 589 struct nfs_user_stat_path_rec { 590 u_char rec_type; 591 char path[RPCMNT_PATHLEN + 1]; 592 }__attribute__((__packed__)); 593 594 /* Defines for rec_type field of 595 * nfs_user_stat_rec & nfs_user_stat_rec 596 * data structures 597 */ 598 #define NFS_USER_STAT_USER_REC 0 599 #define NFS_USER_STAT_PATH_REC 1 600 601 602 #ifdef KERNEL 603 struct nfs_exportfs; 604 605 struct nfs_export_options { 606 uint32_t nxo_flags; /* export options */ 607 kauth_cred_t nxo_cred; /* mapped credential */ 608 struct nfs_sec nxo_sec; /* security mechanism flavors */ 609 }; 610 611 /* Network address lookup element and individual export options */ 612 struct nfs_netopt { 613 struct radix_node no_rnodes[2]; /* radix tree glue */ 614 struct nfs_export_options no_opt; /* export options */ 615 struct sockaddr *no_addr; /* net address to which exported */ 616 struct sockaddr *no_mask; /* mask for net address */ 617 }; 618 619 /* statistic counters for each exported directory 620 * 621 * Since 64-bit atomic operations are not available on 32-bit platforms, 622 * 64-bit counters are implemented using 32-bit integers and 32-bit 623 * atomic operations 624 */ 625 typedef struct nfsstatcount64 { 626 uint32_t hi; 627 uint32_t lo; 628 } nfsstatcount64; 629 630 struct nfs_export_stat_counters { 631 struct nfsstatcount64 ops; /* Count of NFS Requests received for this export */ 632 struct nfsstatcount64 bytes_read; /* Count of bytes read from this export */ 633 struct nfsstatcount64 bytes_written; /* Count of bytes written to his export */ 634 }; 635 636 /* Macro for updating nfs export stat counters */ 637 #define NFSStatAdd64(PTR, VAL) \ 638 do { \ 639 uint32_t NFSSA_OldValue = \ 640 OSAddAtomic((VAL), &(PTR)->lo); \ 641 if ((NFSSA_OldValue + (VAL)) < NFSSA_OldValue) \ 642 OSAddAtomic(1, &(PTR)->hi); \ 643 } while (0) 644 645 /* Some defines for dealing with active user list stats */ 646 #define NFSRV_USER_STAT_DEF_MAX_NODES 1024 /* default active user list size limit */ 647 #define NFSRV_USER_STAT_DEF_IDLE_SEC 7200 /* default idle seconds (node no longer considered active) */ 648 649 /* active user list globals */ 650 extern uint32_t nfsrv_user_stat_enabled; /* enable/disable active user list */ 651 extern uint32_t nfsrv_user_stat_node_count; /* current count of user stat nodes */ 652 extern uint32_t nfsrv_user_stat_max_idle_sec; /* idle seconds (node no longer considered active) */ 653 extern uint32_t nfsrv_user_stat_max_nodes; /* active user list size limit */ 654 extern lck_grp_t nfsrv_active_user_mutex_group; 655 656 /* An active user node represented in the kernel */ 657 struct nfs_user_stat_node { 658 TAILQ_ENTRY(nfs_user_stat_node) lru_link; 659 LIST_ENTRY(nfs_user_stat_node) hash_link; 660 uid_t uid; 661 struct sockaddr_storage sock; 662 uint64_t ops; 663 uint64_t bytes_read; 664 uint64_t bytes_written; 665 time_t tm_start; 666 time_t tm_last; 667 }; 668 669 /* Hash table for active user nodes */ 670 #define NFS_USER_STAT_HASH_SIZE 16 /* MUST be a power of 2 */ 671 #define NFS_USER_STAT_HASH(userhashtbl, uid) \ 672 &((userhashtbl)[(uid) & (NFS_USER_STAT_HASH_SIZE - 1)]) 673 674 TAILQ_HEAD(nfs_user_stat_lru_head, nfs_user_stat_node); 675 LIST_HEAD(nfs_user_stat_hashtbl_head, nfs_user_stat_node); 676 677 /* Active user list data structure */ 678 /* One per exported directory */ 679 struct nfs_active_user_list { 680 struct nfs_user_stat_lru_head user_lru; 681 struct nfs_user_stat_hashtbl_head user_hashtbl[NFS_USER_STAT_HASH_SIZE]; 682 uint32_t node_count; 683 lck_mtx_t user_mutex; 684 }; 685 686 687 /* Network export information */ 688 /* one of these for each exported directory */ 689 struct nfs_export { 690 LIST_ENTRY(nfs_export) nx_next; /* FS export list */ 691 LIST_ENTRY(nfs_export) nx_hash; /* export hash chain */ 692 struct nfs_export *nx_parent; /* parent export */ 693 uint32_t nx_id; /* export ID */ 694 uint32_t nx_flags; /* export flags */ 695 struct nfs_exportfs *nx_fs; /* exported file system */ 696 char *nx_path; /* exported file system sub-path */ 697 struct nfs_filehandle nx_fh; /* export root file handle */ 698 struct nfs_export_options nx_defopt; /* default options */ 699 uint32_t nx_expcnt; /* # exports in table */ 700 struct radix_node_head *nx_rtable[AF_MAX + 1]; /* table of exports (netopts) */ 701 struct nfs_export_stat_counters nx_stats; /* statistic counters for this exported directory */ 702 struct nfs_active_user_list nx_user_list; /* Active User List for this exported directory */ 703 struct timeval nx_exptime; /* time of export for write verifier */ 704 }; 705 706 /* NFS exported file system info */ 707 /* one of these for each exported file system */ 708 struct nfs_exportfs { 709 LIST_ENTRY(nfs_exportfs) nxfs_next; /* exported file system list */ 710 uint32_t nxfs_id; /* exported file system ID */ 711 char *nxfs_path; /* exported file system path */ 712 LIST_HEAD(, nfs_export) nxfs_exports; /* list of exports for this file system */ 713 }; 714 715 extern LIST_HEAD(nfsrv_expfs_list, nfs_exportfs) nfsrv_exports; 716 extern lck_rw_t nfsrv_export_rwlock; // lock for export data structures 717 #define NFSRVEXPHASHSZ 64 718 #define NFSRVEXPHASHVAL(FSID, EXPID) \ 719 (((FSID) >> 24) ^ ((FSID) >> 16) ^ ((FSID) >> 8) ^ (EXPID)) 720 #define NFSRVEXPHASH(FSID, EXPID) \ 721 (&nfsrv_export_hashtbl[NFSRVEXPHASHVAL((FSID),(EXPID)) & nfsrv_export_hash]) 722 extern LIST_HEAD(nfsrv_export_hashhead, nfs_export) * nfsrv_export_hashtbl; 723 extern u_long nfsrv_export_hash; 724 725 #if CONFIG_FSE 726 /* 727 * NFS server file mod fsevents 728 */ 729 struct nfsrv_fmod { 730 LIST_ENTRY(nfsrv_fmod) fm_link; 731 vnode_t fm_vp; 732 struct vfs_context fm_context; 733 uint64_t fm_deadline; 734 }; 735 736 #define NFSRVFMODHASHSZ 128 737 #define NFSRVFMODHASH(vp) (((uintptr_t) vp) & nfsrv_fmod_hash) 738 extern LIST_HEAD(nfsrv_fmod_hashhead, nfsrv_fmod) * nfsrv_fmod_hashtbl; 739 extern u_long nfsrv_fmod_hash; 740 extern lck_mtx_t nfsrv_fmod_mutex; 741 extern int nfsrv_fmod_pending, nfsrv_fsevents_enabled; 742 #endif 743 744 extern int nfsrv_async, nfsrv_export_hash_size, 745 nfsrv_reqcache_size, nfsrv_sock_max_rec_queue_length; 746 extern uint32_t nfsrv_gss_context_ttl; 747 extern struct nfsclntstats nfsclntstats; 748 extern struct nfsrvstats nfsrvstats; 749 #define NFS_UC_Q_DEBUG 750 #ifdef NFS_UC_Q_DEBUG 751 extern int nfsrv_uc_use_proxy; 752 extern uint32_t nfsrv_uc_queue_limit; 753 extern uint32_t nfsrv_uc_queue_max_seen; 754 extern volatile uint32_t nfsrv_uc_queue_count; 755 #endif 756 757 #endif // KERNEL 758 759 /* 760 * XXX to allow amd to include nfs.h without nfsproto.h 761 */ 762 #ifdef NFS_NPROCS 763 /* 764 * Stats structure 765 */ 766 struct nfsclntstats { 767 uint64_t attrcache_hits; 768 uint64_t attrcache_misses; 769 uint64_t lookupcache_hits; 770 uint64_t lookupcache_misses; 771 uint64_t direofcache_hits; 772 uint64_t direofcache_misses; 773 uint64_t biocache_reads; 774 uint64_t read_bios; 775 uint64_t read_physios; 776 uint64_t biocache_writes; 777 uint64_t write_bios; 778 uint64_t write_physios; 779 uint64_t biocache_readlinks; 780 uint64_t readlink_bios; 781 uint64_t biocache_readdirs; 782 uint64_t readdir_bios; 783 uint64_t rpccntv3[NFS_NPROCS]; 784 uint64_t opcntv4[NFS_OP_COUNT]; 785 uint64_t rpcretries; 786 uint64_t rpcrequests; 787 uint64_t rpctimeouts; 788 uint64_t rpcunexpected; 789 uint64_t rpcinvalid; 790 uint64_t pageins; 791 uint64_t pageouts; 792 }; 793 794 struct nfsrvstats { 795 uint64_t srvrpccntv3[NFS_NPROCS]; 796 uint64_t srvrpc_errs; 797 uint64_t srv_errs; 798 uint64_t srvcache_inproghits; 799 uint64_t srvcache_idemdonehits; 800 uint64_t srvcache_nonidemdonehits; 801 uint64_t srvcache_misses; 802 uint64_t srvvop_writes; 803 }; 804 805 #endif 806 807 /* 808 * Flags for nfssvc() system call. 809 */ 810 #define NFSSVC_NFSD 0x004 811 #define NFSSVC_ADDSOCK 0x008 812 #define NFSSVC_EXPORTSTATS 0x010 /* gets exported directory stats */ 813 #define NFSSVC_USERSTATS 0x020 /* gets exported directory active user stats */ 814 #define NFSSVC_USERCOUNT 0x040 /* gets current count of active nfs users */ 815 #define NFSSVC_ZEROSTATS 0x080 /* zero nfs server statistics */ 816 #define NFSSVC_SRVSTATS 0x100 /* struct: struct nfsrvstats */ 817 #define NFSSVC_EXPORT 0x200 818 819 /* 820 * Flags for nfsclnt() system call. 821 */ 822 #define NFSCLNT_LOCKDANS 0x200 823 #define NFSCLNT_LOCKDNOTIFY 0x400 824 #define NFSCLNT_TESTIDMAP 0x001 825 826 /* nfsclnt() system call character device */ 827 #define NFSCLNT_DEVICE "nfsclnt" 828 829 #include <sys/_types/_guid_t.h> /* for guid_t below */ 830 #define MAXIDNAMELEN 1024 831 struct nfs_testmapid { 832 uint32_t ntm_lookup; /* lookup name 2 id or id 2 name */ 833 uint32_t ntm_grpflag; /* Is this a group or user maping */ 834 uint32_t ntm_id; /* id to map or return */ 835 uint32_t pad; 836 guid_t ntm_guid; /* intermidiate guid used in conversion */ 837 char ntm_name[MAXIDNAMELEN]; /* name to map or return */ 838 }; 839 840 #define NTM_ID2NAME 0 841 #define NTM_NAME2ID 1 842 #define NTM_NAME2GUID 2 843 #define NTM_GUID2NAME 3 844 845 /* 846 * fs.nfs sysctl(3) identifiers 847 */ 848 #define NFS_NFSSTATS 1 /* struct: struct nfsclntstats */ 849 #define NFS_MOUNTINFO 6 /* gets information about an NFS mount */ 850 #define NFS_NFSZEROSTATS 7 /* zero nfs client statistics */ 851 852 #ifndef NFS_WDELAYHASHSIZ 853 #define NFS_WDELAYHASHSIZ 16 /* and with this */ 854 #endif 855 856 #ifdef KERNEL 857 #include <sys/kernel_types.h> 858 #include <kern/thread_call.h> 859 #include <sys/kdebug.h> 860 861 #ifdef KERNEL_PRIVATE 862 863 /* NFS hooks */ 864 865 /* NFS hooks struct */ 866 struct nfs_hooks { 867 int (*f_vinvalbuf)(vnode_t, int, vfs_context_t, int); 868 int (*f_buf_page_inval)(vnode_t, off_t); 869 }; 870 871 /* NFS hooks registration functions */ 872 void nfs_register_hooks(struct nfs_hooks *hooks); 873 void nfs_unregister_hooks(void); 874 875 #ifdef XNU_KERNEL_PRIVATE 876 877 /* NFS hooks wrappers */ 878 int nfs_vinvalbuf(vnode_t, int, vfs_context_t, int); 879 int nfs_buf_page_inval(vnode_t, off_t); 880 881 #endif /* XNU_KERNEL_PRIVATE */ 882 883 #endif /* KERNEL_PRIVATE */ 884 885 #define NFS_KERNEL_DEBUG KERNEL_DEBUG 886 887 /* kernel debug trace macros */ 888 #define FSDBG(A, B, C, D, E) \ 889 NFS_KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, (A))) | DBG_FUNC_NONE, \ 890 (int)(B), (int)(C), (int)(D), (int)(E), 0) 891 #define FSDBG_TOP(A, B, C, D, E) \ 892 NFS_KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, (A))) | DBG_FUNC_START, \ 893 (int)(B), (int)(C), (int)(D), (int)(E), 0) 894 #define FSDBG_BOT(A, B, C, D, E) \ 895 NFS_KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, (A))) | DBG_FUNC_END, \ 896 (int)(B), (int)(C), (int)(D), (int)(E), 0) 897 898 #ifdef MALLOC_DECLARE 899 MALLOC_DECLARE(M_NFSMNT); 900 MALLOC_DECLARE(M_NFSBIO); 901 MALLOC_DECLARE(M_NFSDIROFF); 902 MALLOC_DECLARE(M_NFSRVDESC); 903 MALLOC_DECLARE(M_NFSD); 904 MALLOC_DECLARE(M_NFSBIGFH); 905 MALLOC_DECLARE(M_FHANDLE); 906 #endif 907 908 struct vnode_attr; struct nameidata; struct dqblk; struct sockaddr_in; /* XXX */ 909 struct nfsbuf; 910 struct nfs_vattr; 911 struct nfs_fsattr; 912 struct nfsnode; 913 typedef struct nfsnode * nfsnode_t; 914 struct nfs_open_owner; 915 struct nfs_open_file; 916 struct nfs_lock_owner; 917 struct nfs_file_lock; 918 struct nfsreq; 919 struct nfs_rpc_record_state; 920 struct nfs_fs_locations; 921 struct nfs_location_index; 922 struct nfs_socket; 923 struct nfs_socket_search; 924 struct nfsrv_uc_arg; 925 struct direntry; 926 927 /* 928 * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts. 929 * What should be in this set is open to debate, but I believe that since 930 * I/O system calls on ufs are never interrupted by signals the set should 931 * be minimal. My reasoning is that many current programs that use signals 932 * such as SIGALRM will not expect file I/O system calls to be interrupted 933 * by them and break. 934 */ 935 #define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \ 936 sigmask(SIGHUP)|sigmask(SIGQUIT)) 937 938 extern size_t nfs_mbuf_mhlen, nfs_mbuf_minclsize; 939 940 /* 941 * NFS mbuf chain structure used for managing the building/dissection of RPCs 942 */ 943 struct nfsm_chain { 944 mbuf_t nmc_mhead; /* mbuf chain head */ 945 mbuf_t nmc_mcur; /* current mbuf */ 946 caddr_t nmc_ptr; /* pointer into current mbuf */ 947 size_t nmc_left; /* bytes remaining in current mbuf */ 948 uint32_t nmc_flags; /* flags for this nfsm_chain */ 949 }; 950 #define NFSM_CHAIN_FLAG_ADD_CLUSTERS 0x1 /* always add mbuf clusters */ 951 952 /* 953 * Each retransmission of an RPCSEC_GSS request 954 * has an additional sequence number. 955 */ 956 struct gss_seq { 957 SLIST_ENTRY(gss_seq) gss_seqnext; 958 uint32_t gss_seqnum; 959 }; 960 961 /** 962 * nfsreq callback args 963 */ 964 struct nfsreq_cbargs { 965 off_t offset; 966 size_t length; 967 uint32_t stategenid; 968 }; 969 970 /* 971 * async NFS request callback info 972 */ 973 struct nfsreq_cbinfo { 974 void (*rcb_func)(struct nfsreq *); /* async request callback function */ 975 struct nfsbuf *rcb_bp; /* buffer I/O RPC is for */ 976 struct nfsreq_cbargs rcb_args; /* nfsreq callback args */ 977 }; 978 979 /* 980 * Arguments to use if a request needs to call SECINFO to handle a WRONGSEC error 981 * 982 * If only node is set, use the parent file handle and this node's name; otherwise, 983 * use any file handle and name provided. 984 */ 985 struct nfsreq_secinfo_args { 986 nfsnode_t rsia_np; /* the node */ 987 const char *rsia_name; /* alternate name string */ 988 u_char *rsia_fh; /* alternate file handle */ 989 uint32_t rsia_namelen; /* length of string */ 990 uint32_t rsia_fhsize; /* length of fh */ 991 }; 992 #define NFSREQ_SECINFO_SET(SI, NP, FH, FHSIZE, NAME, NAMELEN) \ 993 do { \ 994 (SI)->rsia_np = (NP); \ 995 (SI)->rsia_fh = (FH); \ 996 (SI)->rsia_fhsize = (FHSIZE); \ 997 (SI)->rsia_name = (NAME); \ 998 (SI)->rsia_namelen = (NAMELEN); \ 999 } while (0) 1000 1001 /* 1002 * NFS outstanding request list element 1003 */ 1004 struct nfsreq { 1005 lck_mtx_t r_mtx; /* NFS request mutex */ 1006 TAILQ_ENTRY(nfsreq) r_chain; /* request queue chain */ 1007 TAILQ_ENTRY(nfsreq) r_achain; /* mount's async I/O request queue chain */ 1008 TAILQ_ENTRY(nfsreq) r_rchain; /* mount's async I/O resend queue chain */ 1009 TAILQ_ENTRY(nfsreq) r_cchain; /* mount's cwnd queue chain */ 1010 mbuf_t r_mrest; /* request body mbufs */ 1011 mbuf_t r_mhead; /* request header mbufs */ 1012 struct nfsm_chain r_nmrep; /* reply mbufs */ 1013 nfsnode_t r_np; /* NFS node */ 1014 struct nfsmount *r_nmp; /* NFS mount point */ 1015 uint64_t r_xid; /* RPC transaction ID */ 1016 uint32_t r_procnum; /* NFS procedure number */ 1017 size_t r_mreqlen; /* request length */ 1018 int r_flags; /* flags on request, see below */ 1019 int r_lflags; /* flags protected by list mutex, see below */ 1020 int r_refs; /* # outstanding references */ 1021 uint8_t r_delay; /* delay to use for jukebox error */ 1022 uint32_t r_retry; /* max retransmission count */ 1023 uint8_t r_rexmit; /* current retrans count */ 1024 int r_rtt; /* RTT for rpc */ 1025 thread_t r_thread; /* thread that did I/O system call */ 1026 kauth_cred_t r_cred; /* credential used for request */ 1027 time_t r_start; /* request start time */ 1028 time_t r_lastmsg; /* time of last tprintf */ 1029 time_t r_resendtime; /* time of next jukebox error resend */ 1030 struct nfs_gss_clnt_ctx *r_gss_ctx; /* RPCSEC_GSS context */ 1031 SLIST_HEAD(, gss_seq) r_gss_seqlist; /* RPCSEC_GSS sequence numbers */ 1032 size_t r_gss_argoff; /* RPCSEC_GSS offset to args */ 1033 uint32_t r_gss_arglen; /* RPCSEC_GSS arg length */ 1034 uint32_t r_auth; /* security flavor request sent with */ 1035 uint32_t *r_wrongsec; /* wrongsec: other flavors to try */ 1036 int r_error; /* request error */ 1037 struct nfsreq_cbinfo r_callback; /* callback info */ 1038 struct nfsreq_secinfo_args r_secinfo; /* secinfo args */ 1039 }; 1040 1041 /* 1042 * Queue head for nfsreq's 1043 */ 1044 TAILQ_HEAD(nfs_reqqhead, nfsreq); 1045 extern struct nfs_reqqhead nfs_reqq; 1046 extern lck_grp_t nfs_request_grp; 1047 1048 #define R_XID32(x) ((x) & 0xffffffff) 1049 1050 #define NFSNOLIST ((void *)0x0badcafe) /* sentinel value for nfs lists */ 1051 #define NFSREQNOLIST NFSNOLIST /* sentinel value for nfsreq lists */ 1052 1053 /* Flag values for r_flags */ 1054 #define R_TIMING 0x00000001 /* timing request (in mntp) */ 1055 #define R_CWND 0x00000002 /* request accounted for in congestion window */ 1056 #define R_SOFTTERM 0x00000004 /* request terminated (e.g. soft mnt) */ 1057 #define R_RESTART 0x00000008 /* RPC should be restarted. */ 1058 #define R_INITTED 0x00000010 /* request has been initialized */ 1059 #define R_TPRINTFMSG 0x00000020 /* Did a tprintf msg. */ 1060 #define R_MUSTRESEND 0x00000040 /* Must resend request */ 1061 #define R_ALLOCATED 0x00000080 /* request was allocated */ 1062 #define R_SENT 0x00000100 /* request has been sent */ 1063 #define R_WAITSENT 0x00000200 /* someone is waiting for request to be sent */ 1064 #define R_RESENDERR 0x00000400 /* resend failed */ 1065 #define R_JBTPRINTFMSG 0x00000800 /* Did a tprintf msg for jukebox error */ 1066 #define R_ASYNC 0x00001000 /* async request */ 1067 #define R_ASYNCWAIT 0x00002000 /* async request now being waited on */ 1068 #define R_RESENDQ 0x00004000 /* async request currently on resendq */ 1069 #define R_SENDING 0x00008000 /* request currently being sent */ 1070 #define R_SOFT 0x00010000 /* request is soft - don't retry or reconnect */ 1071 #define R_IOD 0x00020000 /* request is being managed by an IOD */ 1072 1073 #define R_NOINTR 0x20000000 /* request should not be interupted by a signal */ 1074 #define R_RECOVER 0x40000000 /* a state recovery RPC - during NFSSTA_RECOVER */ 1075 #define R_SETUP 0x80000000 /* a setup RPC - during (re)connection */ 1076 #define R_OPTMASK 0xe0000000 /* mask of all RPC option flags */ 1077 1078 /* Flag values for r_lflags */ 1079 #define RL_BUSY 0x0001 /* Locked. */ 1080 #define RL_WAITING 0x0002 /* Someone waiting for lock. */ 1081 #define RL_QUEUED 0x0004 /* request is on the queue */ 1082 1083 extern u_int64_t nfs_xid, nfs_xidwrap; 1084 extern int nfs_iosize, nfs_allow_async, nfs_statfs_rate_limit; 1085 extern int nfs_access_cache_timeout, nfs_access_delete, nfs_access_dotzfs, nfs_access_for_getattr; 1086 extern int nfs_lockd_mounts, nfs_lockd_request_sent; 1087 extern int nfs_tprintf_initial_delay, nfs_tprintf_delay; 1088 extern int nfsiod_thread_count, nfsiod_thread_max, nfs_max_async_writes; 1089 extern int nfs_idmap_ctrl, nfs_callback_port, nfs_split_open_owner; 1090 extern int nfs_is_mobile, nfs_readlink_nocache, nfs_root_steals_ctx; 1091 extern int nfs_mount_timeout, nfs_mount_quick_timeout; 1092 extern uint32_t nfs_tcp_sockbuf; 1093 extern uint32_t nfs_squishy_flags; 1094 extern uint32_t nfsclnt_debug_ctl, nfsrv_debug_ctl; 1095 1096 /* bits for nfs_idmap_ctrl: */ 1097 #define NFS_IDMAP_CTRL_USE_IDMAP_SERVICE 0x00000001 /* use the ID mapping service */ 1098 #define NFS_IDMAP_CTRL_FALLBACK_NO_COMMON_IDS 0x00000002 /* fallback should NOT handle common IDs like "root" and "nobody" */ 1099 #define NFS_IDMAP_CTRL_LOG_FAILED_MAPPINGS 0x00000020 /* log failed ID mapping attempts */ 1100 #define NFS_IDMAP_CTRL_LOG_SUCCESSFUL_MAPPINGS 0x00000040 /* log successful ID mapping attempts */ 1101 1102 #define NFSIOD_MAX (MIN(nfsiod_thread_max, NFS_MAXASYNCTHREAD)) 1103 1104 struct nfs_dulookup { 1105 int du_flags; /* state of ._ lookup */ 1106 #define NFS_DULOOKUP_DOIT 0x1 1107 #define NFS_DULOOKUP_INPROG 0x2 1108 struct componentname du_cn; /* ._ name being looked up */ 1109 struct nfsreq du_req; /* NFS request for lookup */ 1110 char du_smallname[48]; /* buffer for small names */ 1111 }; 1112 1113 /* 1114 * One nfsrv_sock structure is maintained for each socket the 1115 * server is servicing requests on. 1116 */ 1117 struct nfsrv_sock { 1118 TAILQ_ENTRY(nfsrv_sock) ns_chain; /* List of all nfsrv_sock's */ 1119 TAILQ_ENTRY(nfsrv_sock) ns_svcq; /* List of sockets needing servicing */ 1120 TAILQ_ENTRY(nfsrv_sock) ns_wgq; /* List of sockets with a pending write gather */ 1121 struct nfsrv_uc_arg *ns_ua; /* Opaque pointer to upcall */ 1122 lck_rw_t ns_rwlock; /* lock for most fields */ 1123 socket_t ns_so; 1124 mbuf_t ns_nam; 1125 mbuf_t ns_raw; 1126 mbuf_t ns_rawend; 1127 mbuf_t ns_rec; 1128 mbuf_t ns_recend; 1129 mbuf_t ns_frag; 1130 int ns_flag; 1131 int ns_sotype; 1132 size_t ns_cc; 1133 size_t ns_reclen; 1134 int ns_reccnt; 1135 int ns_sobufsize; 1136 u_int32_t ns_sref; 1137 time_t ns_timestamp; /* socket timestamp */ 1138 lck_mtx_t ns_wgmutex; /* mutex for write gather fields */ 1139 time_t ns_wgtime; /* next Write deadline (usec) */ 1140 LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */ 1141 LIST_HEAD(nfsrv_wg_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ]; 1142 }; 1143 1144 /* Bits for "ns_flag" */ 1145 #define SLP_VALID 0x0001 /* nfs sock valid */ 1146 #define SLP_DOREC 0x0002 /* nfs sock has received data to process */ 1147 #define SLP_NEEDQ 0x0004 /* network socket has data to receive */ 1148 #define SLP_DISCONN 0x0008 /* socket needs to be zapped */ 1149 #define SLP_GETSTREAM 0x0010 /* currently in nfsrv_getstream() */ 1150 #define SLP_LASTFRAG 0x0020 /* on last fragment of RPC record */ 1151 #define SLP_DOWRITES 0x0040 /* nfs sock has gathered writes to service */ 1152 #define SLP_WORKTODO 0x004e /* mask of all "work to do" flags */ 1153 #define SLP_ALLFLAGS 0x007f 1154 #define SLP_WAITQ 0x4000 /* nfs sock is on the wait queue */ 1155 #define SLP_WORKQ 0x8000 /* nfs sock is on the work queue */ 1156 #define SLP_QUEUED 0xc000 /* nfs sock is on a queue */ 1157 1158 #define SLPNOLIST ((struct nfsrv_sock *)0xdeadbeef) /* sentinel value for sockets not in the nfsrv_sockwg list */ 1159 1160 extern struct nfsrv_sock *nfsrv_udpsock, *nfsrv_udp6sock; 1161 1162 /* 1163 * global NFS server socket lists: 1164 * 1165 * nfsrv_socklist - list of all sockets (ns_chain) 1166 * nfsrv_sockwait - sockets w/new data waiting to be worked on (ns_svcq) 1167 * nfsrv_sockwork - sockets being worked on which may have more work to do (ns_svcq) 1168 * nfsrv_sockwg - sockets with pending write gather input (ns_wgq) 1169 */ 1170 extern TAILQ_HEAD(nfsrv_sockhead, nfsrv_sock) nfsrv_socklist, nfsrv_sockwg, 1171 nfsrv_sockwait, nfsrv_sockwork; 1172 1173 /* lock groups for nfsrv_sock's */ 1174 extern lck_grp_t nfsrv_slp_rwlock_group; 1175 extern lck_grp_t nfsrv_slp_mutex_group; 1176 1177 /* 1178 * One of these structures is allocated for each nfsd. 1179 */ 1180 struct nfsd { 1181 TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */ 1182 TAILQ_ENTRY(nfsd) nfsd_queue; /* List of waiting nfsd's */ 1183 int nfsd_flag; /* NFSD_ flags */ 1184 struct nfsrv_sock *nfsd_slp; /* Current socket */ 1185 struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */ 1186 }; 1187 1188 /* Bits for "nfsd_flag" */ 1189 #define NFSD_WAITING 0x01 1190 #define NFSD_REQINPROG 0x02 1191 1192 /* 1193 * This structure is used by the server for describing each request. 1194 * Some fields are used only when write request gathering is performed. 1195 */ 1196 struct nfsrv_descript { 1197 time_t nd_time; /* Write deadline (usec) */ 1198 off_t nd_off; /* Start byte offset */ 1199 off_t nd_eoff; /* and end byte offset */ 1200 LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */ 1201 LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */ 1202 LIST_HEAD(, nfsrv_descript) nd_coalesce; /* coalesced writes */ 1203 struct nfsm_chain nd_nmreq; /* Request mbuf chain */ 1204 mbuf_t nd_mrep; /* Reply mbuf list (WG) */ 1205 mbuf_t nd_nam; /* and socket addr */ 1206 mbuf_t nd_nam2; /* return socket addr */ 1207 u_int32_t nd_procnum; /* RPC # */ 1208 int nd_stable; /* storage type */ 1209 int nd_vers; /* NFS version */ 1210 int nd_len; /* Length of this write */ 1211 int nd_repstat; /* Reply status */ 1212 u_int32_t nd_retxid; /* Reply xid */ 1213 struct timeval nd_starttime; /* Time RPC initiated */ 1214 struct nfs_filehandle nd_fh; /* File handle */ 1215 uint32_t nd_sec; /* Security flavor */ 1216 struct nfs_gss_svc_ctx *nd_gss_context;/* RPCSEC_GSS context */ 1217 uint32_t nd_gss_seqnum; /* RPCSEC_GSS seq num */ 1218 mbuf_t nd_gss_mb; /* RPCSEC_GSS results mbuf */ 1219 kauth_cred_t nd_cr; /* Credentials */ 1220 }; 1221 1222 extern TAILQ_HEAD(nfsd_head, nfsd) nfsd_head, nfsd_queue; 1223 1224 typedef int (*nfsrv_proc_t)(struct nfsrv_descript *, struct nfsrv_sock *, 1225 vfs_context_t, mbuf_t *); 1226 1227 /* mutex for nfs server */ 1228 extern lck_mtx_t nfsd_mutex; 1229 extern int nfsd_thread_count, nfsd_thread_max; 1230 1231 /* request list mutex */ 1232 extern lck_mtx_t nfs_request_mutex; 1233 extern int nfs_request_timer_on; 1234 1235 /* mutex for nfs client globals */ 1236 extern lck_mtx_t nfs_global_mutex; 1237 1238 #if CONFIG_NFS4 1239 /* NFSv4 callback globals */ 1240 extern int nfs4_callback_timer_on; 1241 extern in_port_t nfs4_cb_port, nfs4_cb_port6; 1242 1243 /* nfs 4 default domain for user mapping */ 1244 extern char nfs4_default_domain[MAXPATHLEN]; 1245 /* nfs 4 timer call structure */ 1246 extern thread_call_t nfs4_callback_timer_call; 1247 #endif 1248 1249 /* nfs timer call structures */ 1250 extern thread_call_t nfs_request_timer_call; 1251 extern thread_call_t nfs_buf_timer_call; 1252 extern thread_call_t nfsrv_idlesock_timer_call; 1253 #if CONFIG_FSE 1254 extern thread_call_t nfsrv_fmod_timer_call; 1255 #endif 1256 1257 __BEGIN_DECLS 1258 1259 nfstype vtonfs_type(enum vtype, int); 1260 enum vtype nfstov_type(nfstype, int); 1261 int vtonfsv2_mode(enum vtype, mode_t); 1262 1263 void nfs_mbuf_init(void); 1264 1265 void nfs_nhinit_finish(void); 1266 u_long nfs_hash(u_char *, int); 1267 1268 /* nfsclnt() system call character device setup */ 1269 int nfsclnt_device_add(void); 1270 1271 #if CONFIG_NFS4 1272 int nfs4_init_clientid(struct nfsmount *); 1273 int nfs4_setclientid(struct nfsmount *); 1274 int nfs4_renew(struct nfsmount *, int); 1275 void nfs4_renew_timer(void *, void *); 1276 void nfs4_mount_callback_setup(struct nfsmount *); 1277 void nfs4_mount_callback_shutdown(struct nfsmount *); 1278 void nfs4_cb_accept(socket_t, void *, int); 1279 void nfs4_cb_rcv(socket_t, void *, int); 1280 void nfs4_callback_timer(void *, void *); 1281 int nfs4_secinfo_rpc(struct nfsmount *, struct nfsreq_secinfo_args *, kauth_cred_t, uint32_t *, int *); 1282 int nfs4_get_fs_locations(struct nfsmount *, nfsnode_t, u_char *, int, const char *, vfs_context_t, struct nfs_fs_locations *); 1283 void nfs4_default_attrs_for_referral_trigger(nfsnode_t, char *, int, struct nfs_vattr *, fhandle_t *); 1284 #endif 1285 1286 void nfs_fs_locations_cleanup(struct nfs_fs_locations *); 1287 1288 int nfs_sockaddr_cmp(struct sockaddr *, struct sockaddr *); 1289 int nfs_connect(struct nfsmount *, int, int); 1290 void nfs_disconnect(struct nfsmount *); 1291 void nfs_need_reconnect(struct nfsmount *); 1292 void nfs_mount_sock_thread_wake(struct nfsmount *); 1293 int nfs_mount_check_dead_timeout(struct nfsmount *); 1294 int nfs_mount_gone(struct nfsmount *); 1295 void nfs_mount_rele(struct nfsmount *); 1296 void nfs_mount_zombie(struct nfsmount *, int); 1297 void nfs_mount_make_zombie(struct nfsmount *); 1298 1299 void nfs_rpc_record_state_init(struct nfs_rpc_record_state *); 1300 void nfs_rpc_record_state_cleanup(struct nfs_rpc_record_state *); 1301 int nfs_rpc_record_read(socket_t, struct nfs_rpc_record_state *, int, int *, mbuf_t *); 1302 1303 int nfs_getattr(nfsnode_t, struct nfs_vattr *, vfs_context_t, int); 1304 int nfs_getattrcache(nfsnode_t, struct nfs_vattr *, int); 1305 int nfs_loadattrcache(nfsnode_t, struct nfs_vattr *, u_int64_t *, int); 1306 long nfs_attrcachetimeout(nfsnode_t); 1307 1308 int nfs_buf_page_inval_internal(vnode_t vp, off_t offset); 1309 int nfs_vinvalbuf1(vnode_t, int, vfs_context_t, int); 1310 int nfs_vinvalbuf2(vnode_t, int, thread_t, kauth_cred_t, int); 1311 int nfs_vinvalbuf_internal(nfsnode_t, int, thread_t, kauth_cred_t, int, int); 1312 void nfs_wait_bufs(nfsnode_t); 1313 1314 int nfs_request_create(nfsnode_t, mount_t, struct nfsm_chain *, int, thread_t, kauth_cred_t, struct nfsreq **); 1315 void nfs_request_destroy(struct nfsreq *); 1316 void nfs_request_ref(struct nfsreq *, int); 1317 void nfs_request_rele(struct nfsreq *); 1318 int nfs_request_add_header(struct nfsreq *); 1319 int nfs_request_send(struct nfsreq *, int); 1320 void nfs_request_wait(struct nfsreq *); 1321 int nfs_request_finish(struct nfsreq *, struct nfsm_chain *, int *); 1322 int nfs_request(nfsnode_t, mount_t, struct nfsm_chain *, int, vfs_context_t, struct nfsreq_secinfo_args *, struct nfsm_chain *, u_int64_t *, int *); 1323 int nfs_request2(nfsnode_t, mount_t, struct nfsm_chain *, int, thread_t, kauth_cred_t, struct nfsreq_secinfo_args *, int, struct nfsm_chain *, u_int64_t *, int *); 1324 int nfs_request_gss(mount_t, struct nfsm_chain *, thread_t, kauth_cred_t, int, struct nfs_gss_clnt_ctx *, struct nfsm_chain *, int *); 1325 int nfs_request_async(nfsnode_t, mount_t, struct nfsm_chain *, int, thread_t, kauth_cred_t, struct nfsreq_secinfo_args *, int, struct nfsreq_cbinfo *, struct nfsreq **); 1326 int nfs_request_async_finish(struct nfsreq *, struct nfsm_chain *, u_int64_t *, int *); 1327 void nfs_request_async_cancel(struct nfsreq *); 1328 void nfs_request_timer(void *, void *); 1329 int nfs_request_using_gss(struct nfsreq *); 1330 void nfs_get_xid(uint64_t *); 1331 int nfs_sigintr(struct nfsmount *, struct nfsreq *, thread_t, int); 1332 int nfs_noremotehang(thread_t); 1333 1334 int nfs_send(struct nfsreq *, int); 1335 int nfs_sndlock(struct nfsreq *); 1336 void nfs_sndunlock(struct nfsreq *); 1337 1338 int nfs_uaddr2sockaddr(const char *, struct sockaddr *); 1339 1340 int nfs_aux_request(struct nfsmount *, thread_t, struct sockaddr *, socket_t, int, mbuf_t, uint32_t, int, int, struct nfsm_chain *); 1341 int nfs_portmap_lookup(struct nfsmount *, vfs_context_t, struct sockaddr *, socket_t, uint32_t, uint32_t, uint32_t, int); 1342 1343 void nfs_location_next(struct nfs_fs_locations *, struct nfs_location_index *); 1344 int nfs_location_index_cmp(struct nfs_location_index *, struct nfs_location_index *); 1345 void nfs_location_mntfromname(struct nfs_fs_locations *, struct nfs_location_index, char *, size_t, int); 1346 int nfs_socket_create(struct nfsmount *, struct sockaddr *, uint8_t, in_port_t, uint32_t, uint32_t, int, struct nfs_socket **); 1347 void nfs_socket_destroy(struct nfs_socket *); 1348 void nfs_socket_options(struct nfsmount *, struct nfs_socket *); 1349 void nfs_connect_upcall(socket_t, void *, int); 1350 int nfs_connect_error_class(int); 1351 int nfs_connect_search_loop(struct nfsmount *, struct nfs_socket_search *); 1352 void nfs_socket_search_update_error(struct nfs_socket_search *, int); 1353 void nfs_socket_search_cleanup(struct nfs_socket_search *); 1354 void nfs_mount_connect_thread(void *, __unused wait_result_t); 1355 1356 int nfs_lookitup(nfsnode_t, char *, int, vfs_context_t, nfsnode_t *); 1357 void nfs_dulookup_init(struct nfs_dulookup *, nfsnode_t, const char *, int, vfs_context_t); 1358 void nfs_dulookup_start(struct nfs_dulookup *, nfsnode_t, vfs_context_t); 1359 void nfs_dulookup_finish(struct nfs_dulookup *, nfsnode_t, vfs_context_t); 1360 int nfs_dir_buf_cache_lookup(nfsnode_t, nfsnode_t *, struct componentname *, vfs_context_t, int, int *); 1361 int nfs_dir_buf_search(struct nfsbuf *, struct componentname *, fhandle_t *, struct nfs_vattr *, uint64_t *, time_t *, daddr64_t *, int); 1362 void nfs_name_cache_purge(nfsnode_t, nfsnode_t, struct componentname *, vfs_context_t); 1363 1364 #if CONFIG_NFS4 1365 uint32_t nfs4_ace_nfstype_to_vfstype(uint32_t, int *); 1366 uint32_t nfs4_ace_vfstype_to_nfstype(uint32_t, int *); 1367 uint32_t nfs4_ace_nfsflags_to_vfsflags(uint32_t); 1368 uint32_t nfs4_ace_vfsflags_to_nfsflags(uint32_t); 1369 uint32_t nfs4_ace_nfsmask_to_vfsrights(uint32_t); 1370 uint32_t nfs4_ace_vfsrights_to_nfsmask(uint32_t); 1371 int nfs4_id2guid(char *, guid_t *, int); 1372 int nfs4_guid2id(guid_t *, char *, size_t *, int); 1373 1374 int nfs4_parsefattr(struct nfsm_chain *, struct nfs_fsattr *, struct nfs_vattr *, fhandle_t *, struct dqblk *, struct nfs_fs_locations *); 1375 #endif 1376 1377 int nfs_parsefattr(struct nfsmount *nmp, struct nfsm_chain *, int, 1378 struct nfs_vattr *); 1379 void nfs_vattr_set_supported(uint32_t *, struct vnode_attr *); 1380 void nfs_vattr_set_bitmap(struct nfsmount *, uint32_t *, struct vnode_attr *); 1381 void nfs3_pathconf_cache(struct nfsmount *, struct nfs_fsattr *); 1382 int nfs3_check_lockmode(struct nfsmount *, struct sockaddr *, int, int); 1383 int nfs3_mount_rpc(struct nfsmount *, struct sockaddr *, int, int, char *, vfs_context_t, int, fhandle_t *, struct nfs_sec *); 1384 void nfs3_umount_rpc(struct nfsmount *, vfs_context_t, int); 1385 void nfs_rdirplus_update_node_attrs(nfsnode_t, struct direntry *, fhandle_t *, struct nfs_vattr *, uint64_t *); 1386 int nfs_node_access_slot(nfsnode_t, uid_t, int); 1387 void nfs_vnode_notify(nfsnode_t, uint32_t); 1388 1389 void nfs_avoid_needless_id_setting_on_create(nfsnode_t, struct vnode_attr *, vfs_context_t); 1390 int nfs_open_state_set_busy(nfsnode_t, thread_t); 1391 void nfs_open_state_clear_busy(nfsnode_t); 1392 struct nfs_open_owner *nfs_open_owner_find(struct nfsmount *, kauth_cred_t, proc_t, int); 1393 void nfs_open_owner_destroy(struct nfs_open_owner *); 1394 void nfs_open_owner_ref(struct nfs_open_owner *); 1395 void nfs_open_owner_rele(struct nfs_open_owner *); 1396 int nfs_open_owner_set_busy(struct nfs_open_owner *, thread_t); 1397 void nfs_open_owner_clear_busy(struct nfs_open_owner *); 1398 void nfs_owner_seqid_increment(struct nfs_open_owner *, struct nfs_lock_owner *, int); 1399 int nfs_open_file_find(nfsnode_t, struct nfs_open_owner *, struct nfs_open_file **, uint32_t, uint32_t, int); 1400 int nfs_open_file_find_internal(nfsnode_t, struct nfs_open_owner *, struct nfs_open_file **, uint32_t, uint32_t, int); 1401 void nfs_open_file_destroy(struct nfs_open_file *); 1402 int nfs_open_file_set_busy(struct nfs_open_file *, thread_t); 1403 void nfs_open_file_clear_busy(struct nfs_open_file *); 1404 void nfs_open_file_add_open(struct nfs_open_file *, uint32_t, uint32_t, int); 1405 void nfs_open_file_remove_open_find(struct nfs_open_file *, uint32_t, uint32_t, uint8_t *, uint8_t *, int *); 1406 void nfs_open_file_remove_open(struct nfs_open_file *, uint32_t, uint32_t); 1407 void nfs_get_stateid(nfsnode_t, thread_t, kauth_cred_t, nfs_stateid *, int); 1408 int nfs_check_for_locks(struct nfs_open_owner *, struct nfs_open_file *); 1409 int nfs_close(nfsnode_t, struct nfs_open_file *, uint32_t, uint32_t, vfs_context_t); 1410 1411 void nfs_release_open_state_for_node(nfsnode_t, int); 1412 void nfs_revoke_open_state_for_node(nfsnode_t); 1413 struct nfs_lock_owner *nfs_lock_owner_find(nfsnode_t, proc_t, caddr_t, int); 1414 void nfs_lock_owner_destroy(struct nfs_lock_owner *); 1415 void nfs_lock_owner_ref(struct nfs_lock_owner *); 1416 void nfs_lock_owner_rele(nfsnode_t, struct nfs_lock_owner *, thread_t, kauth_cred_t); 1417 int nfs_lock_owner_set_busy(struct nfs_lock_owner *, thread_t); 1418 void nfs_lock_owner_clear_busy(struct nfs_lock_owner *); 1419 void nfs_lock_owner_insert_held_lock(struct nfs_lock_owner *, struct nfs_file_lock *); 1420 struct nfs_file_lock *nfs_file_lock_alloc(struct nfs_lock_owner *); 1421 void nfs_file_lock_destroy(nfsnode_t, struct nfs_file_lock *, thread_t, kauth_cred_t); 1422 int nfs_file_lock_conflict(struct nfs_file_lock *, struct nfs_file_lock *, int *); 1423 int nfs_unlock_rpc(nfsnode_t, struct nfs_lock_owner *, int, uint64_t, uint64_t, thread_t, kauth_cred_t, int); 1424 int nfs_advlock_getlock(nfsnode_t, struct nfs_lock_owner *, struct flock *, uint64_t, uint64_t, vfs_context_t); 1425 int nfs_advlock_setlock(nfsnode_t, struct nfs_open_file *, struct nfs_lock_owner *, int, uint64_t, uint64_t, int, short, vfs_context_t); 1426 int nfs_advlock_unlock(nfsnode_t, struct nfs_open_file *, struct nfs_lock_owner *, uint64_t, uint64_t, int, vfs_context_t); 1427 1428 #if CONFIG_NFS4 1429 int nfs4_release_lockowner_rpc(nfsnode_t, struct nfs_lock_owner *, thread_t, kauth_cred_t); 1430 int nfs4_create_rpc(vfs_context_t, nfsnode_t, struct componentname *, struct vnode_attr *, int, char *, nfsnode_t *); 1431 int nfs4_open(nfsnode_t, struct nfs_open_file *, uint32_t, uint32_t, vfs_context_t); 1432 int nfs4_open_delegated(nfsnode_t, struct nfs_open_file *, uint32_t, uint32_t, vfs_context_t); 1433 int nfs4_reopen(struct nfs_open_file *, thread_t); 1434 int nfs4_open_rpc(struct nfs_open_file *, vfs_context_t, struct componentname *, struct vnode_attr *, vnode_t, vnode_t *, int, int, int); 1435 int nfs4_open_rpc_internal(struct nfs_open_file *, vfs_context_t, thread_t, kauth_cred_t, struct componentname *, struct vnode_attr *, vnode_t, vnode_t *, int, int, int); 1436 int nfs4_open_confirm_rpc(struct nfsmount *, nfsnode_t, u_char *, int, struct nfs_open_owner *, nfs_stateid *, thread_t, kauth_cred_t, struct nfs_vattr *, uint64_t *); 1437 int nfs4_open_reopen_rpc(struct nfs_open_file *, thread_t, kauth_cred_t, struct componentname *, vnode_t, vnode_t *, int, int); 1438 int nfs4_open_reclaim_rpc(struct nfs_open_file *, int, int); 1439 int nfs4_claim_delegated_open_rpc(struct nfs_open_file *, int, int, int); 1440 int nfs4_claim_delegated_state_for_open_file(struct nfs_open_file *, int); 1441 int nfs4_claim_delegated_state_for_node(nfsnode_t, int); 1442 int nfs4_open_downgrade_rpc(nfsnode_t, struct nfs_open_file *, vfs_context_t); 1443 int nfs4_close_rpc(nfsnode_t, struct nfs_open_file *, thread_t, kauth_cred_t, int); 1444 void nfs4_delegation_return_enqueue(nfsnode_t); 1445 int nfs4_delegation_return(nfsnode_t, int, thread_t, kauth_cred_t); 1446 int nfs4_lock_rpc(nfsnode_t, struct nfs_open_file *, struct nfs_file_lock *, int, int, thread_t, kauth_cred_t); 1447 int nfs4_delegreturn_rpc(struct nfsmount *, u_char *, int, struct nfs_stateid *, int, thread_t, kauth_cred_t); 1448 1449 nfsnode_t nfs4_named_attr_dir_get(nfsnode_t, int, vfs_context_t); 1450 int nfs4_named_attr_get(nfsnode_t, struct componentname *, uint32_t, int, vfs_context_t, nfsnode_t *, struct nfs_open_file **); 1451 int nfs4_named_attr_remove(nfsnode_t, nfsnode_t, const char *, vfs_context_t); 1452 #endif 1453 1454 int nfs_mount_state_in_use_start(struct nfsmount *, thread_t); 1455 int nfs_mount_state_in_use_end(struct nfsmount *, int); 1456 int nfs_mount_state_error_should_restart(int); 1457 int nfs_mount_state_error_delegation_lost(int); 1458 uint nfs_mount_state_max_restarts(struct nfsmount *); 1459 int nfs_mount_state_wait_for_recovery(struct nfsmount *); 1460 void nfs_need_recover(struct nfsmount *nmp, int error); 1461 void nfs_recover(struct nfsmount *); 1462 1463 int nfs_vnop_access(struct vnop_access_args *); 1464 int nfs_vnop_remove(struct vnop_remove_args *); 1465 int nfs_vnop_read(struct vnop_read_args *); 1466 int nfs_vnop_write(struct vnop_write_args *); 1467 int nfs_vnop_open(struct vnop_open_args *); 1468 int nfs_vnop_close(struct vnop_close_args *); 1469 int nfs_vnop_advlock(struct vnop_advlock_args *); 1470 int nfs_vnop_mmap(struct vnop_mmap_args *); 1471 int nfs_vnop_mmap_check(struct vnop_mmap_check_args *ap); 1472 int nfs_vnop_mnomap(struct vnop_mnomap_args *); 1473 1474 #if CONFIG_NFS4 1475 int nfs4_vnop_create(struct vnop_create_args *); 1476 int nfs4_vnop_mknod(struct vnop_mknod_args *); 1477 int nfs4_vnop_close(struct vnop_close_args *); 1478 int nfs4_vnop_getattr(struct vnop_getattr_args *); 1479 int nfs4_vnop_link(struct vnop_link_args *); 1480 int nfs4_vnop_mkdir(struct vnop_mkdir_args *); 1481 int nfs4_vnop_rmdir(struct vnop_rmdir_args *); 1482 int nfs4_vnop_symlink(struct vnop_symlink_args *); 1483 int nfs4_vnop_getxattr(struct vnop_getxattr_args *); 1484 int nfs4_vnop_setxattr(struct vnop_setxattr_args *); 1485 int nfs4_vnop_removexattr(struct vnop_removexattr_args *); 1486 int nfs4_vnop_listxattr(struct vnop_listxattr_args *); 1487 #if NAMEDSTREAMS 1488 int nfs4_vnop_getnamedstream(struct vnop_getnamedstream_args *); 1489 int nfs4_vnop_makenamedstream(struct vnop_makenamedstream_args *); 1490 int nfs4_vnop_removenamedstream(struct vnop_removenamedstream_args *); 1491 #endif 1492 1493 int nfs4_access_rpc(nfsnode_t, u_int32_t *, int, vfs_context_t); 1494 int nfs4_getattr_rpc(nfsnode_t, mount_t, u_char *, size_t, int, vfs_context_t, struct nfs_vattr *, u_int64_t *); 1495 int nfs4_setattr_rpc(nfsnode_t, struct vnode_attr *, vfs_context_t); 1496 int nfs4_read_rpc_async(nfsnode_t, off_t, size_t, thread_t, kauth_cred_t, struct nfsreq_cbinfo *, struct nfsreq **); 1497 int nfs4_read_rpc_async_finish(nfsnode_t, struct nfsreq *, uio_t, size_t *, int *); 1498 int nfs4_write_rpc_async(nfsnode_t, uio_t, size_t, thread_t, kauth_cred_t, int, struct nfsreq_cbinfo *, struct nfsreq **); 1499 int nfs4_write_rpc_async_finish(nfsnode_t, struct nfsreq *, int *, size_t *, uint64_t *); 1500 int nfs4_readdir_rpc(nfsnode_t, struct nfsbuf *, vfs_context_t); 1501 int nfs4_readlink_rpc(nfsnode_t, char *, size_t *, vfs_context_t); 1502 int nfs4_commit_rpc(nfsnode_t, uint64_t, uint64_t, kauth_cred_t, uint64_t); 1503 int nfs4_lookup_rpc_async(nfsnode_t, char *, int, vfs_context_t, struct nfsreq **); 1504 int nfs4_lookup_rpc_async_finish(nfsnode_t, char *, int, vfs_context_t, struct nfsreq *, u_int64_t *, fhandle_t *, struct nfs_vattr *); 1505 int nfs4_remove_rpc(nfsnode_t, char *, int, thread_t, kauth_cred_t); 1506 int nfs4_rename_rpc(nfsnode_t, char *, int, nfsnode_t, char *, int, vfs_context_t); 1507 int nfs4_pathconf_rpc(nfsnode_t, struct nfs_fsattr *, vfs_context_t); 1508 int nfs4_setlock_rpc(nfsnode_t, struct nfs_open_file *, struct nfs_file_lock *, int, int, thread_t, kauth_cred_t); 1509 int nfs4_unlock_rpc(nfsnode_t, struct nfs_lock_owner *, int, uint64_t, uint64_t, int, thread_t, kauth_cred_t); 1510 int nfs4_getlock_rpc(nfsnode_t, struct nfs_lock_owner *, struct flock *, uint64_t, uint64_t, vfs_context_t); 1511 #endif 1512 1513 int nfs_read_rpc(nfsnode_t, uio_t, vfs_context_t); 1514 int nfs_write_rpc(nfsnode_t, uio_t, vfs_context_t, int *, uint64_t *); 1515 int nfs_write_rpc2(nfsnode_t, uio_t, thread_t, kauth_cred_t, int *, uint64_t *); 1516 1517 int nfs3_access_rpc(nfsnode_t, u_int32_t *, int, vfs_context_t); 1518 int nfs3_getattr_rpc(nfsnode_t, mount_t, u_char *, size_t, int, vfs_context_t, struct nfs_vattr *, u_int64_t *); 1519 int nfs3_setattr_rpc(nfsnode_t, struct vnode_attr *, vfs_context_t); 1520 int nfs3_read_rpc_async(nfsnode_t, off_t, size_t, thread_t, kauth_cred_t, struct nfsreq_cbinfo *, struct nfsreq **); 1521 int nfs3_read_rpc_async_finish(nfsnode_t, struct nfsreq *, uio_t, size_t *, int *); 1522 int nfs3_write_rpc_async(nfsnode_t, uio_t, size_t, thread_t, kauth_cred_t, int, struct nfsreq_cbinfo *, struct nfsreq **); 1523 int nfs3_write_rpc_async_finish(nfsnode_t, struct nfsreq *, int *, size_t *, uint64_t *); 1524 int nfs3_readdir_rpc(nfsnode_t, struct nfsbuf *, vfs_context_t); 1525 int nfs3_readlink_rpc(nfsnode_t, char *, size_t *, vfs_context_t); 1526 int nfs3_commit_rpc(nfsnode_t, uint64_t, uint64_t, kauth_cred_t, uint64_t); 1527 int nfs3_lookup_rpc_async(nfsnode_t, char *, int, vfs_context_t, struct nfsreq **); 1528 int nfs3_lookup_rpc_async_finish(nfsnode_t, char *, int, vfs_context_t, struct nfsreq *, u_int64_t *, fhandle_t *, struct nfs_vattr *); 1529 int nfs3_remove_rpc(nfsnode_t, char *, int, thread_t, kauth_cred_t); 1530 int nfs3_rename_rpc(nfsnode_t, char *, int, nfsnode_t, char *, int, vfs_context_t); 1531 int nfs3_pathconf_rpc(nfsnode_t, struct nfs_fsattr *, vfs_context_t); 1532 int nfs3_setlock_rpc(nfsnode_t, struct nfs_open_file *, struct nfs_file_lock *, int, int, thread_t, kauth_cred_t); 1533 int nfs3_unlock_rpc(nfsnode_t, struct nfs_lock_owner *, int, uint64_t, uint64_t, int, thread_t, kauth_cred_t); 1534 int nfs3_getlock_rpc(nfsnode_t, struct nfs_lock_owner *, struct flock *, uint64_t, uint64_t, vfs_context_t); 1535 1536 void nfsrv_active_user_list_reclaim(void); 1537 void nfsrv_cleancache(void); 1538 void nfsrv_cleanup(void); 1539 int nfsrv_credcheck(struct nfsrv_descript *, vfs_context_t, struct nfs_export *, 1540 struct nfs_export_options *); 1541 void nfsrv_idlesock_timer(void *, void *); 1542 int nfsrv_dorec(struct nfsrv_sock *, struct nfsd *, struct nfsrv_descript **); 1543 int nfsrv_errmap(struct nfsrv_descript *, int); 1544 int nfsrv_export(struct user_nfs_export_args *, vfs_context_t); 1545 int nfsrv_fhmatch(struct nfs_filehandle *, struct nfs_filehandle *); 1546 int nfsrv_fhtovp(struct nfs_filehandle *, struct nfsrv_descript *, vnode_t *, 1547 struct nfs_export **, struct nfs_export_options **); 1548 int nfsrv_check_exports_allow_address(mbuf_t); 1549 #if CONFIG_FSE 1550 void nfsrv_fmod_timer(void *, void *); 1551 #endif 1552 int nfsrv_getcache(struct nfsrv_descript *, struct nfsrv_sock *, mbuf_t *); 1553 void nfsrv_group_sort(gid_t *, int); 1554 void nfsrv_init(void); 1555 void nfsrv_initcache(void); 1556 int nfsrv_is_initialized(void); 1557 int nfsrv_namei(struct nfsrv_descript *, vfs_context_t, struct nameidata *, 1558 struct nfs_filehandle *, vnode_t *, 1559 struct nfs_export **, struct nfs_export_options **); 1560 void nfsrv_rcv(socket_t, void *, int); 1561 void nfsrv_rcv_locked(socket_t, struct nfsrv_sock *, int); 1562 int nfsrv_rephead(struct nfsrv_descript *, struct nfsrv_sock *, struct nfsm_chain *, size_t); 1563 int nfsrv_send(struct nfsrv_sock *, mbuf_t, mbuf_t); 1564 void nfsrv_updatecache(struct nfsrv_descript *, int, mbuf_t); 1565 void nfsrv_update_user_stat(struct nfs_export *, struct nfsrv_descript *, uid_t, u_int, u_int, u_int); 1566 int nfsrv_vptofh(struct nfs_export *, int, struct nfs_filehandle *, 1567 vnode_t, vfs_context_t, struct nfs_filehandle *); 1568 void nfsrv_wakenfsd(struct nfsrv_sock *); 1569 void nfsrv_wg_timer(void *, void *); 1570 int nfsrv_writegather(struct nfsrv_descript **, struct nfsrv_sock *, 1571 vfs_context_t, mbuf_t *); 1572 1573 int nfsrv_access(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1574 int nfsrv_commit(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1575 int nfsrv_create(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1576 int nfsrv_fsinfo(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1577 int nfsrv_getattr(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1578 int nfsrv_link(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1579 int nfsrv_lookup(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1580 int nfsrv_mkdir(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1581 int nfsrv_mknod(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1582 int nfsrv_noop(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1583 int nfsrv_null(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1584 int nfsrv_pathconf(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1585 int nfsrv_read(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1586 int nfsrv_readdir(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1587 int nfsrv_readdirplus(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1588 int nfsrv_readlink(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1589 int nfsrv_remove(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1590 int nfsrv_rename(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1591 int nfsrv_rmdir(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1592 int nfsrv_setattr(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1593 int nfsrv_statfs(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1594 int nfsrv_symlink(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1595 int nfsrv_write(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1596 1597 void nfs_interval_timer_start(thread_call_t, time_t); 1598 int nfs_use_cache(struct nfsmount *); 1599 void nfs_up(struct nfsmount *, thread_t, int, const char *); 1600 void nfs_down(struct nfsmount *, thread_t, int, int, const char *, int); 1601 int nfs_msg(thread_t, const char *, const char *, int); 1602 1603 int nfs_maperr(const char *, int); 1604 #define NFS_MAPERR(ERR) nfs_maperr(__FUNCTION__, (ERR)) 1605 1606 int nfs_mountroot(void); 1607 struct nfs_diskless; 1608 int nfs_boot_init(struct nfs_diskless *); 1609 int nfs_boot_getfh(struct nfs_diskless *, int, int); 1610 1611 #if CONFIG_TRIGGERS 1612 resolver_result_t nfs_mirror_mount_trigger_resolve(vnode_t, const struct componentname *, enum path_operation, int, void *, vfs_context_t); 1613 resolver_result_t nfs_mirror_mount_trigger_unresolve(vnode_t, int, void *, vfs_context_t); 1614 resolver_result_t nfs_mirror_mount_trigger_rearm(vnode_t, int, void *, vfs_context_t); 1615 int nfs_mirror_mount_domount(vnode_t, vnode_t, vfs_context_t); 1616 void nfs_ephemeral_mount_harvester_start(void); 1617 void nfs_ephemeral_mount_harvester(__unused void *arg, __unused wait_result_t wr); 1618 #endif 1619 1620 /* socket upcall interfaces */ 1621 void nfsrv_uc_init(void); 1622 void nfsrv_uc_cleanup(void); 1623 void nfsrv_uc_addsock(struct nfsrv_sock *, int); 1624 void nfsrv_uc_dequeue(struct nfsrv_sock *); 1625 1626 /* Debug support */ 1627 #define __NFS_DEBUG_LEVEL(dbgctl) ((dbgctl) & 0xf) 1628 #define __NFS_DEBUG_FACILITY(dbgctl) (((dbgctl) >> 4) & 0xfff) 1629 #define __NFS_DEBUG_FLAGS(dbgctl) (((dbgctl) >> 16) & 0xf) 1630 #define __NFS_DEBUG_VALUE(dbgctl) (((dbgctl) >> 20) & 0xfff) 1631 #define __NFS_IS_DBG(dbgctl, fac, lev) (__builtin_expect((__NFS_DEBUG_FACILITY(dbgctl) & (fac)) && ((lev) <= __NFS_DEBUG_LEVEL(dbgctl)), 0)) 1632 #define __NFS_DBG(dbgctl, fac, lev, fmt, ...) nfs_printf((dbgctl), (fac), (lev), "%s: %d: " fmt, __func__, __LINE__, ## __VA_ARGS__) 1633 void nfs_printf(unsigned int, unsigned int, unsigned int, const char *, ...) __printflike(4, 5); 1634 void nfs_dump_mbuf(const char *, int, const char *, mbuf_t); 1635 int nfs_mountopts(struct nfsmount *, char *, int); 1636 1637 /* Client debug support */ 1638 #define NFSCLNT_FAC_SOCK 0x001 1639 #define NFSCLNT_FAC_STATE 0x002 1640 #define NFSCLNT_FAC_NODE 0x004 1641 #define NFSCLNT_FAC_VNOP 0x008 1642 #define NFSCLNT_FAC_BIO 0x010 1643 #define NFSCLNT_FAC_GSS 0x020 1644 #define NFSCLNT_FAC_VFS 0x040 1645 #define NFSCLNT_FAC_SRV 0x080 1646 #define NFSCLNT_DEBUG_LEVEL __NFS_DEBUG_LEVEL(nfsclnt_debug_ctl) 1647 #define NFSCLNT_DEBUG_FACILITY __NFS_DEBUG_FACILITY(nfsclnt_debug_ctl) 1648 #define NFSCLNT_DEBUG_FLAGS __NFS_DEBUG_FLAGS(nfsclnt_debug_ctl) 1649 #define NFSCLNT_DEBUG_VALUE __NFS_DEBUG_VALUE(nfsclnt_debug_ctl) 1650 #define NFSCLNT_IS_DBG(fac, lev) __NFS_IS_DBG(nfsclnt_debug_ctl, fac, lev) 1651 #define NFSCLNT_DBG(fac, lev, fmt, ...) __NFS_DBG(nfsclnt_debug_ctl, fac, lev, fmt, ## __VA_ARGS__) 1652 1653 /* Server debug support */ 1654 #define NFSRV_FAC_GSS 0x001 1655 #define NFSRV_FAC_SRV 0x002 1656 #define NFSRV_DEBUG_LEVEL __NFS_DEBUG_LEVEL(nfsrv_debug_ctl) 1657 #define NFSRV_DEBUG_FACILITY __NFS_DEBUG_FACILITY(nfsrv_debug_ctl) 1658 #define NFSRV_DEBUG_FLAGS __NFS_DEBUG_FLAGS(nfsrv_debug_ctl) 1659 #define NFSRV_DEBUG_VALUE __NFS_DEBUG_VALUE(nfsrv_debug_ctl) 1660 #define NFSRV_IS_DBG(fac, lev) __NFS_IS_DBG(nfsrv_debug_ctl, fac, lev) 1661 #define NFSRV_DBG(fac, lev, fmt, ...) __NFS_DBG(nfsrv_debug_ctl, fac, lev, fmt, ## __VA_ARGS__) 1662 1663 #if XNU_KERNEL_PRIVATE 1664 #include <kern/kalloc.h> 1665 1666 ZONE_VIEW_DECLARE(ZV_NFSDIROFF); 1667 KALLOC_TYPE_DECLARE(KT_NFS_VATTR); 1668 extern zone_t nfs_buf_zone; 1669 extern zone_t nfsrv_descript_zone; 1670 extern zone_t nfsnode_zone; 1671 extern zone_t nfs_fhandle_zone; 1672 extern zone_t nfs_req_zone; 1673 extern zone_t nfsrv_descript_zone; 1674 extern zone_t nfsmnt_zone; 1675 1676 #endif /* XNU_KERNEL_PRIVATE */ 1677 __END_DECLS 1678 1679 #endif /* KERNEL */ 1680 #endif /* __APPLE_API_PRIVATE */ 1681 1682 #endif 1683