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 #include <sys/ioccom.h> 76 77 #ifdef KERNEL 78 #include <sys/vnode.h> 79 #include <sys/user.h> 80 #include <net/radix.h> 81 #include <kern/locks.h> 82 #include <kern/lock_group.h> 83 #endif 84 85 #include <nfs/rpcv2.h> 86 #include <nfs/nfsproto.h> 87 88 #ifdef __APPLE_API_PRIVATE 89 /* 90 * Tunable constants for nfs 91 */ 92 93 #define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */ 94 #define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */ 95 extern int nfs_ticks; 96 #define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */ 97 #define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */ 98 #define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */ 99 #define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/ 100 #define NFS_MAXREXMIT 100 /* Stop counting after this many */ 101 #define NFS_RETRANS 10 /* Num of retrans for soft mounts */ 102 #define NFS_TRYLATERDEL 4 /* Initial try later delay (sec) */ 103 #define NFS_MAXGRPS 16U /* Max. size of groups list */ 104 #define NFS_MINATTRTIMO 5 /* Attribute cache timeout in sec */ 105 #define NFS_MAXATTRTIMO 60 106 #define NFS_MINDIRATTRTIMO 5 /* directory attribute cache timeout in sec */ 107 #define NFS_MAXDIRATTRTIMO 60 108 #define NFS_MAXPORT 0xffff 109 #define NFS_IOSIZE (1024 * 1024) /* suggested I/O size */ 110 #define NFS_RWSIZE 32768 /* Def. read/write data size <= 32K */ 111 #define NFS_WSIZE NFS_RWSIZE /* Def. write data size <= 32K */ 112 #define NFS_RSIZE NFS_RWSIZE /* Def. read data size <= 32K */ 113 #define NFS_DGRAM_WSIZE 8192 /* UDP Def. write data size <= 8K */ 114 #define NFS_DGRAM_RSIZE 8192 /* UDP Def. read data size <= 8K */ 115 #define NFS_READDIRSIZE 32768 /* Def. readdir size */ 116 #define NFS_DEFRAHEAD 16 /* Def. read ahead # blocks */ 117 #define NFS_MAXRAHEAD 128 /* Max. read ahead # blocks */ 118 #define NFS_DEFMAXASYNCWRITES 128 /* Def. max # concurrent async write RPCs */ 119 #define NFS_DEFASYNCTHREAD 16 /* Def. # nfsiod threads */ 120 #define NFS_MAXASYNCTHREAD 64 /* max # nfsiod threads */ 121 #define NFS_ASYNCTHREADMAXIDLE 60 /* Seconds before idle nfsiods are reaped */ 122 #define NFS_DEFSTATFSRATELIMIT 10 /* Def. max # statfs RPCs per second */ 123 #define NFS_REQUESTDELAY 10 /* ms interval to check request queue */ 124 #define NFSRV_MAXWGATHERDELAY 100 /* Max. write gather delay (msec) */ 125 #ifndef NFSRV_WGATHERDELAY 126 #define NFSRV_WGATHERDELAY 1 /* Default write gather delay (msec) */ 127 #endif 128 #define NFS_DIRBLKSIZ 4096 /* size of NFS directory buffers */ 129 #if defined(KERNEL) && !defined(DIRBLKSIZ) 130 #define DIRBLKSIZ 512 /* XXX we used to use ufs's DIRBLKSIZ */ 131 /* can't be larger than NFS_FABLKSIZE */ 132 #endif 133 134 /* default values for unresponsive mount timeouts */ 135 #define NFS_TPRINTF_INITIAL_DELAY 5 136 #define NFS_TPRINTF_DELAY 30 137 138 /* NFS client mount timeouts */ 139 #define NFS_MOUNT_TIMEOUT 30 140 #define NFS_MOUNT_QUICK_TIMEOUT 8 141 142 /* 143 * Oddballs 144 */ 145 #define NFS_CMPFH(n, f, s) \ 146 ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s))) 147 #define NFSRV_NDMAXDATA(n) \ 148 (((n)->nd_vers == NFS_VER3) ? (((n)->nd_nam2) ? \ 149 NFS_MAXDGRAMDATA : NFSRV_MAXDATA) : NFS_V2MAXDATA) 150 #define NFS_PORT_INVALID(port) \ 151 (((port) > NFS_MAXPORT) || ((port) < 0)) 152 153 /* 154 * The IO_METASYNC flag should be implemented for local file systems. 155 * (Until then, it is nothin at all.) 156 */ 157 #ifndef IO_METASYNC 158 #define IO_METASYNC 0 159 #endif 160 161 /* 162 * Expected allocation sizes for major data structures. If the actual size 163 * of the structure exceeds these sizes, then malloc() will be allocating 164 * almost twice the memory required. This is used in nfs_init() to warn 165 * the sysadmin that the size of a structure should be reduced. 166 * (These sizes are always a power of 2. If the kernel malloc() changes 167 * to one that does not allocate space in powers of 2 size, then this all 168 * becomes bunk!). 169 * Note that some of these structures come out of their own nfs zones. 170 */ 171 #define NFS_NODEALLOC 1024 172 #define NFS_MNTALLOC 2048 173 #define NFS_SVCALLOC 512 174 175 #define NFS_ARGSVERSION_XDR 88 /* NFS mount args are in XDR format */ 176 177 #define NFS_XDRARGS_VERSION_0 0 178 #define NFS_MATTR_BITMAP_LEN 2 /* length of mount attributes bitmap */ 179 #define NFS_MFLAG_BITMAP_LEN 1 /* length of mount flags bitmap */ 180 181 /* NFS mount attributes */ 182 #define NFS_MATTR_FLAGS 0 /* mount flags (NFS_MATTR_*) */ 183 #define NFS_MATTR_NFS_VERSION 1 /* NFS protocol version */ 184 #define NFS_MATTR_NFS_MINOR_VERSION 2 /* NFS protocol minor version */ 185 #define NFS_MATTR_READ_SIZE 3 /* READ RPC size */ 186 #define NFS_MATTR_WRITE_SIZE 4 /* WRITE RPC size */ 187 #define NFS_MATTR_READDIR_SIZE 5 /* READDIR RPC size */ 188 #define NFS_MATTR_READAHEAD 6 /* block readahead count */ 189 #define NFS_MATTR_ATTRCACHE_REG_MIN 7 /* minimum attribute cache time */ 190 #define NFS_MATTR_ATTRCACHE_REG_MAX 8 /* maximum attribute cache time */ 191 #define NFS_MATTR_ATTRCACHE_DIR_MIN 9 /* minimum attribute cache time for dirs */ 192 #define NFS_MATTR_ATTRCACHE_DIR_MAX 10 /* maximum attribute cache time for dirs */ 193 #define NFS_MATTR_LOCK_MODE 11 /* advisory file locking mode (NFS_LOCK_MODE_*) */ 194 #define NFS_MATTR_SECURITY 12 /* RPC security flavors to use */ 195 #define NFS_MATTR_MAX_GROUP_LIST 13 /* max # of RPC AUTH_SYS groups */ 196 #define NFS_MATTR_SOCKET_TYPE 14 /* socket transport type as a netid-like string */ 197 #define NFS_MATTR_NFS_PORT 15 /* port # to use for NFS protocol */ 198 #define NFS_MATTR_MOUNT_PORT 16 /* port # to use for MOUNT protocol */ 199 #define NFS_MATTR_REQUEST_TIMEOUT 17 /* initial RPC request timeout value */ 200 #define NFS_MATTR_SOFT_RETRY_COUNT 18 /* max RPC retransmissions for soft mounts */ 201 #define NFS_MATTR_DEAD_TIMEOUT 19 /* how long until unresponsive mount is considered dead */ 202 #define NFS_MATTR_FH 20 /* file handle for mount directory */ 203 #define NFS_MATTR_FS_LOCATIONS 21 /* list of locations for the file system */ 204 #define NFS_MATTR_MNTFLAGS 22 /* VFS mount flags (MNT_*) */ 205 #define NFS_MATTR_MNTFROM 23 /* fixed string to use for "f_mntfromname" */ 206 #define NFS_MATTR_REALM 24 /* Realm to authenticate with */ 207 #define NFS_MATTR_PRINCIPAL 25 /* GSS principal to authenticate with */ 208 #define NFS_MATTR_SVCPRINCIPAL 26 /* GSS principal to authenticate to, the server principal */ 209 #define NFS_MATTR_NFS_VERSION_RANGE 27 /* Packed version range to try */ 210 #define NFS_MATTR_KERB_ETYPE 28 /* Enctype to use for kerberos mounts */ 211 #define NFS_MATTR_LOCAL_NFS_PORT 29 /* Unix domain socket for NFS protocol */ 212 #define NFS_MATTR_LOCAL_MOUNT_PORT 30 /* Unix domain socket for MOUNT protocol */ 213 #define NFS_MATTR_SET_MOUNT_OWNER 31 /* Set owner of mount point */ 214 #define NFS_MATTR_READLINK_NOCACHE 32 /* Readlink nocache mode */ 215 #define NFS_MATTR_ATTRCACHE_ROOTDIR_MIN 33 /* minimum attribute cache time for root dir */ 216 #define NFS_MATTR_ATTRCACHE_ROOTDIR_MAX 34 /* maximum attribute cache time for root dir */ 217 #define NFS_MATTR_ACCESS_CACHE 35 /* Access cache size */ 218 219 /* NFS mount flags */ 220 #define NFS_MFLAG_SOFT 0 /* soft mount (requests fail if unresponsive) */ 221 #define NFS_MFLAG_INTR 1 /* allow operations to be interrupted */ 222 #define NFS_MFLAG_RESVPORT 2 /* use a reserved port */ 223 #define NFS_MFLAG_NOCONNECT 3 /* don't connect the socket (UDP) */ 224 #define NFS_MFLAG_DUMBTIMER 4 /* don't estimate RTT dynamically */ 225 #define NFS_MFLAG_CALLUMNT 5 /* call MOUNTPROC_UMNT on unmount */ 226 #define NFS_MFLAG_RDIRPLUS 6 /* request additional info when reading directories */ 227 #define NFS_MFLAG_NONEGNAMECACHE 7 /* don't do negative name caching */ 228 #define NFS_MFLAG_MUTEJUKEBOX 8 /* don't treat jukebox errors as unresponsive */ 229 #define NFS_MFLAG_EPHEMERAL 9 /* ephemeral (mirror) mount */ 230 #define NFS_MFLAG_NOCALLBACK 10 /* don't provide callback RPC service */ 231 #define NFS_MFLAG_NAMEDATTR 11 /* don't use named attributes */ 232 #define NFS_MFLAG_NOACL 12 /* don't support ACLs */ 233 #define NFS_MFLAG_ACLONLY 13 /* only support ACLs - not mode */ 234 #define NFS_MFLAG_NFC 14 /* send NFC strings */ 235 #define NFS_MFLAG_NOQUOTA 15 /* don't support QUOTA requests */ 236 #define NFS_MFLAG_MNTUDP 16 /* MOUNT protocol should use UDP */ 237 #define NFS_MFLAG_MNTQUICK 17 /* use short timeouts while mounting */ 238 #define NFS_MFLAG_NOOPAQUE_AUTH 19 /* don't make the mount AUTH_OPAQUE. Used by V3 */ 239 #define NFS_MFLAG_SKIP_RENEW 20 /* don't send OP_RENEW when no files are opened. Used by V4 */ 240 241 /* Macros for packing and unpacking packed versions */ 242 #define PVER2MAJOR(M) ((uint32_t)(((M) >> 16) & 0xffff)) 243 #define PVER2MINOR(m) ((uint32_t)((m) & 0xffff)) 244 #define VER2PVER(M, m) ((uint32_t)((M) << 16) | ((m) & 0xffff)) 245 246 /* NFS advisory file locking modes */ 247 #define NFS_LOCK_MODE_ENABLED 0 /* advisory file locking enabled */ 248 #define NFS_LOCK_MODE_DISABLED 1 /* do not support advisory file locking */ 249 #define NFS_LOCK_MODE_LOCAL 2 /* perform advisory file locking locally */ 250 251 #define NFS_STRLEN_INT(str) \ 252 (int)strnlen(str, INT_MAX) 253 #define NFS_UIO_ADDIOV(a_uio, a_baseaddr, a_length) \ 254 assert(a_length <= UINT32_MAX); uio_addiov(a_uio, a_baseaddr, (uint32_t)(a_length)); 255 #define NFS_BZERO(off, bytes) \ 256 do { \ 257 uint32_t bytes32 = bytes > UINT32_MAX ? UINT32_MAX : (uint32_t)(bytes); \ 258 bzero(off, bytes32); \ 259 if (bytes > UINT32_MAX) { \ 260 bzero(off + bytes32, (uint32_t)(bytes - UINT32_MAX)); \ 261 } \ 262 } while(0); 263 #define NFS_ZFREE(zone, ptr) \ 264 do { \ 265 if ((ptr)) { \ 266 zfree((zone), (ptr)); \ 267 (ptr) = NULL; \ 268 } \ 269 } while (0); \ 270 271 /* Supported encryption types for kerberos session keys */ 272 typedef enum nfs_supported_kerberos_etypes { 273 NFS_DES3_CBC_SHA1_KD = 16, 274 NFS_AES128_CTS_HMAC_SHA1_96 = 17, 275 NFS_AES256_CTS_HMAC_SHA1_96 = 18 276 } nfs_supported_kerberos_etypes; 277 278 /* Structure to hold an array of kerberos enctypes to allow on a mount */ 279 #define NFS_MAX_ETYPES 3 280 struct nfs_etype { 281 uint32_t count; 282 uint32_t selected; /* index in etypes that is being used. Set to count if nothing has been selected */ 283 nfs_supported_kerberos_etypes etypes[NFS_MAX_ETYPES]; 284 }; 285 286 /* 287 * Old-style arguments to mount NFS 288 */ 289 #define NFS_ARGSVERSION 6 /* change when nfs_args changes */ 290 struct nfs_args { 291 int version; /* args structure version number */ 292 #ifdef KERNEL 293 user32_addr_t addr; /* file server address */ 294 #else 295 struct sockaddr *addr; /* file server address */ 296 #endif 297 uint8_t addrlen; /* length of address */ 298 int sotype; /* Socket type */ 299 int proto; /* and Protocol */ 300 #ifdef KERNEL 301 user32_addr_t fh; /* File handle to be mounted */ 302 #else 303 u_char *fh; /* File handle to be mounted */ 304 #endif 305 int fhsize; /* Size, in bytes, of fh */ 306 int flags; /* flags */ 307 int wsize; /* write size in bytes */ 308 int rsize; /* read size in bytes */ 309 int readdirsize; /* readdir size in bytes */ 310 int timeo; /* initial timeout in .1 secs */ 311 int retrans; /* times to retry send */ 312 int maxgrouplist; /* Max. size of group list */ 313 int readahead; /* # of blocks to readahead */ 314 int leaseterm; /* obsolete: Term (sec) of lease */ 315 int deadthresh; /* obsolete: Retrans threshold */ 316 #ifdef KERNEL 317 user32_addr_t hostname; /* server's name */ 318 #else 319 char *hostname; /* server's name */ 320 #endif 321 /* NFS_ARGSVERSION 3 ends here */ 322 int acregmin; /* reg file min attr cache timeout */ 323 int acregmax; /* reg file max attr cache timeout */ 324 int acdirmin; /* dir min attr cache timeout */ 325 int acdirmax; /* dir max attr cache timeout */ 326 /* NFS_ARGSVERSION 4 ends here */ 327 uint32_t auth; /* security mechanism flavor */ 328 /* NFS_ARGSVERSION 5 ends here */ 329 uint32_t deadtimeout; /* secs until unresponsive mount considered dead */ 330 }; 331 332 /* incremental size additions in each version of nfs_args */ 333 #define NFS_ARGSVERSION4_INCSIZE (4 * sizeof(int)) 334 #define NFS_ARGSVERSION5_INCSIZE (sizeof(uint32_t)) 335 #define NFS_ARGSVERSION6_INCSIZE (sizeof(uint32_t)) 336 337 #ifdef KERNEL 338 /* LP64 version of nfs_args. all pointers and longs 339 * grow when we're dealing with a 64-bit process. 340 * WARNING - keep in sync with nfs_args 341 */ 342 struct user_nfs_args { 343 int version; /* args structure version number */ 344 user_addr_t addr __attribute((aligned(8))); /* file server address */ 345 uint8_t addrlen; /* length of address */ 346 int sotype; /* Socket type */ 347 int proto; /* and Protocol */ 348 user_addr_t fh __attribute((aligned(8))); /* File handle to be mounted */ 349 int fhsize; /* Size, in bytes, of fh */ 350 int flags; /* flags */ 351 int wsize; /* write size in bytes */ 352 int rsize; /* read size in bytes */ 353 int readdirsize; /* readdir size in bytes */ 354 int timeo; /* initial timeout in .1 secs */ 355 int retrans; /* times to retry send */ 356 int maxgrouplist; /* Max. size of group list */ 357 int readahead; /* # of blocks to readahead */ 358 int leaseterm; /* obsolete: Term (sec) of lease */ 359 int deadthresh; /* obsolete: Retrans threshold */ 360 user_addr_t hostname __attribute((aligned(8))); /* server's name */ 361 /* NFS_ARGSVERSION 3 ends here */ 362 int acregmin; /* reg file min attr cache timeout */ 363 int acregmax; /* reg file max attr cache timeout */ 364 int acdirmin; /* dir min attr cache timeout */ 365 int acdirmax; /* dir max attr cache timeout */ 366 /* NFS_ARGSVERSION 4 ends here */ 367 uint32_t auth; /* security mechanism flavor */ 368 /* NFS_ARGSVERSION 5 ends here */ 369 uint32_t deadtimeout; /* secs until unresponsive mount considered dead */ 370 }; 371 #endif // KERNEL 372 373 /* 374 * Old-style NFS mount option flags 375 */ 376 #define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */ 377 #define NFSMNT_WSIZE 0x00000002 /* set write size */ 378 #define NFSMNT_RSIZE 0x00000004 /* set read size */ 379 #define NFSMNT_TIMEO 0x00000008 /* set initial timeout */ 380 #define NFSMNT_RETRANS 0x00000010 /* set number of request retries */ 381 #define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */ 382 #define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */ 383 #define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */ 384 #define NFSMNT_NONEGNAMECACHE 0x00000100 /* Don't do negative name caching */ 385 #define NFSMNT_NFSV3 0x00000200 /* Use NFS Version 3 protocol */ 386 #define NFSMNT_NFSV4 0x00000400 /* Use NFS Version 4 protocol */ 387 #define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */ 388 #define NFSMNT_DEADTIMEOUT 0x00001000 /* unmount after a period of unresponsiveness */ 389 #define NFSMNT_READAHEAD 0x00002000 /* set read ahead */ 390 #define NFSMNT_CALLUMNT 0x00004000 /* call MOUNTPROC_UMNT on unmount */ 391 #define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */ 392 #define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */ 393 #define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */ 394 #define NFSMNT_NOLOCKS 0x00040000 /* don't support file locking */ 395 #define NFSMNT_LOCALLOCKS 0x00080000 /* do file locking locally on client */ 396 #define NFSMNT_ACREGMIN 0x00100000 /* reg min attr cache timeout */ 397 #define NFSMNT_ACREGMAX 0x00200000 /* reg max attr cache timeout */ 398 #define NFSMNT_ACDIRMIN 0x00400000 /* dir min attr cache timeout */ 399 #define NFSMNT_ACDIRMAX 0x00800000 /* dir max attr cache timeout */ 400 #define NFSMNT_SECFLAVOR 0x01000000 /* Use security flavor */ 401 #define NFSMNT_SECSYSOK 0x02000000 /* Server can support auth sys */ 402 #define NFSMNT_MUTEJUKEBOX 0x04000000 /* don't treat jukebox errors as unresponsive */ 403 #define NFSMNT_NOQUOTA 0x08000000 /* don't support QUOTA requests */ 404 405 406 /* 407 * fs.nfs sysctl(3) NFS_MOUNTINFO defines 408 */ 409 #define NFS_MOUNT_INFO_VERSION 0 /* nfsstat mount information version */ 410 #define NFS_MIATTR_BITMAP_LEN 1 /* length of mount info attributes bitmap */ 411 #define NFS_MIFLAG_BITMAP_LEN 1 /* length of mount info flags bitmap */ 412 413 /* NFS mount info attributes */ 414 #define NFS_MIATTR_FLAGS 0 /* mount info flags bitmap (MIFLAG_*) */ 415 #define NFS_MIATTR_ORIG_ARGS 1 /* original mount args passed into mount call */ 416 #define NFS_MIATTR_CUR_ARGS 2 /* current mount args values */ 417 #define NFS_MIATTR_CUR_LOC_INDEX 3 /* current fs location index */ 418 419 /* NFS mount info flags */ 420 #define NFS_MIFLAG_DEAD 0 /* mount is dead */ 421 #define NFS_MIFLAG_NOTRESP 1 /* server is unresponsive */ 422 #define NFS_MIFLAG_RECOVERY 2 /* mount in recovery */ 423 424 425 /* 426 * Structures for the nfssvc(2) syscall. Not that anyone but nfsd 427 * should ever try and use it. 428 */ 429 struct nfsd_args { 430 int sock; /* Socket to serve */ 431 #ifdef KERNEL 432 user32_addr_t name; /* Client addr for connection based sockets */ 433 #else 434 caddr_t name; /* Client addr for connection based sockets */ 435 #endif 436 int namelen; /* Length of name */ 437 }; 438 439 #ifdef KERNEL 440 /* LP64 version of nfsd_args. all pointers and longs 441 * grow when we're dealing with a 64-bit process. 442 * WARNING - keep in sync with nfsd_args 443 */ 444 struct user_nfsd_args { 445 int sock; /* Socket to serve */ 446 user_addr_t name __attribute((aligned(8))); /* Client addr for connection based sockets */ 447 int namelen; /* Length of name */ 448 }; 449 450 #endif // KERNEL 451 452 /* 453 * NFS Server File Handle structures 454 */ 455 456 /* NFS export handle identifies which NFS export */ 457 #define NFS_FH_VERSION 0x4e580000 /* 'NX00' */ 458 struct nfs_exphandle { 459 uint32_t nxh_version; /* data structure version */ 460 uint32_t nxh_fsid; /* File System Export ID */ 461 uint32_t nxh_expid; /* Export ID */ 462 uint16_t nxh_flags; /* export handle flags */ 463 uint8_t nxh_reserved; /* future use */ 464 uint32_t nxh_fidlen; /* length of File ID */ 465 }; 466 467 /* nxh_flags */ 468 #define NXHF_INVALIDFH 0x0001 /* file handle is invalid */ 469 470 #define NFS_MAX_FID_SIZE (NFS_MAX_FH_SIZE - sizeof(struct nfs_exphandle)) 471 #define NFSV4_MAX_FID_SIZE (NFSV4_MAX_FH_SIZE - sizeof(struct nfs_exphandle)) 472 #define NFSV3_MAX_FID_SIZE (NFSV3_MAX_FH_SIZE - sizeof(struct nfs_exphandle)) 473 #define NFSV2_MAX_FID_SIZE (NFSV2_MAX_FH_SIZE - sizeof(struct nfs_exphandle)) 474 475 /* NFS server internal view of fhandle_t */ 476 /* The first sizeof(fhandle_t) bytes must match what goes into fhandle_t. */ 477 /* (fhp is used to allow use of an external buffer) */ 478 struct nfs_filehandle { 479 uint32_t nfh_len; /* total length of file handle */ 480 struct nfs_exphandle nfh_xh; /* export handle */ 481 unsigned char nfh_fid[NFS_MAX_FID_SIZE]; /* File ID */ 482 unsigned char *nfh_fhp; /* pointer to file handle */ 483 }; 484 485 /* 486 * NFS export data structures 487 */ 488 489 /* Structure to hold an array of security flavors */ 490 #define NX_MAX_SEC_FLAVORS 5 491 struct nfs_sec { 492 int count; 493 uint32_t flavors[NX_MAX_SEC_FLAVORS]; 494 }; 495 496 struct nfs_export_net_args { 497 uint32_t nxna_flags; /* export flags */ 498 struct xucred nxna_cred; /* mapped credential for root/all user */ 499 struct sockaddr_storage nxna_addr; /* net address to which exported */ 500 struct sockaddr_storage nxna_mask; /* mask for net address */ 501 struct nfs_sec nxna_sec; /* security mechanism flavors */ 502 }; 503 504 struct nfs_export_args { 505 uint32_t nxa_fsid; /* export FS ID */ 506 uint32_t nxa_expid; /* export ID */ 507 #ifdef KERNEL 508 user32_addr_t nxa_fspath; /* export FS path */ 509 user32_addr_t nxa_exppath; /* export sub-path */ 510 #else 511 char *nxa_fspath; /* export FS path */ 512 char *nxa_exppath; /* export sub-path */ 513 #endif 514 uint32_t nxa_flags; /* export arg flags */ 515 uint32_t nxa_netcount; /* #entries in ex_nets array */ 516 #ifdef KERNEL 517 user32_addr_t nxa_nets; /* array of net args */ 518 #else 519 struct nfs_export_net_args *nxa_nets; /* array of net args */ 520 #endif 521 }; 522 523 #ifdef KERNEL 524 /* LP64 version of export_args */ 525 526 struct user_nfs_export_args { 527 uint32_t nxa_fsid; /* export FS ID */ 528 uint32_t nxa_expid; /* export ID */ 529 user_addr_t nxa_fspath; /* export FS path */ 530 user_addr_t nxa_exppath; /* export sub-path */ 531 uint32_t nxa_flags; /* export arg flags */ 532 uint32_t nxa_netcount; /* #entries in ex_nets array */ 533 user_addr_t nxa_nets; /* array of net args */ 534 }; 535 536 #endif /* KERNEL */ 537 538 /* nfs export arg flags */ 539 #define NXA_DELETE 0x0001 /* delete the specified export(s) */ 540 #define NXA_ADD 0x0002 /* add the specified export(s) */ 541 #define NXA_REPLACE 0x0003 /* delete and add the specified export(s) */ 542 #define NXA_DELETE_ALL 0x0004 /* delete all exports */ 543 #define NXA_OFFLINE 0x0008 /* export is offline */ 544 #define NXA_CHECK 0x0010 /* check if exportable */ 545 546 /* export option flags */ 547 #define NX_READONLY 0x0001 /* exported read-only */ 548 #define NX_DEFAULTEXPORT 0x0002 /* exported to the world */ 549 #define NX_MAPROOT 0x0004 /* map root access to anon credential */ 550 #define NX_MAPALL 0x0008 /* map all access to anon credential */ 551 #define NX_32BITCLIENTS 0x0020 /* restrict directory cookies to 32 bits */ 552 #define NX_OFFLINE 0x0040 /* export is offline */ 553 #define NX_MANGLEDNAMES 0x0080 /* export will return mangled names for names > 255 bytes */ 554 555 /* 556 * fs.nfs sysctl(3) export stats record structures 557 */ 558 #define NFS_EXPORT_STAT_REC_VERSION 1 /* export stat record version */ 559 #define NFS_USER_STAT_REC_VERSION 1 /* active user list record version */ 560 561 /* descriptor describing following records */ 562 struct nfs_export_stat_desc { 563 uint32_t rec_vers; /* version of export stat records */ 564 uint64_t rec_count; /* total record count */ 565 }__attribute__((__packed__)); 566 567 /* export stat record containing path and stat counters */ 568 struct nfs_export_stat_rec { 569 char path[RPCMNT_PATHLEN + 1]; 570 uint64_t ops; /* Count of NFS Requests received for this export */ 571 uint64_t bytes_read; /* Count of bytes read from this export */ 572 uint64_t bytes_written; /* Count of bytes written to this export */ 573 }__attribute__((__packed__)); 574 575 /* Active user list stat buffer descriptor */ 576 struct nfs_user_stat_desc { 577 uint32_t rec_vers; /* version of active user stat records */ 578 uint32_t rec_count; /* total record count */ 579 }__attribute__((__packed__)); 580 581 /* Active user list user stat record format */ 582 struct nfs_user_stat_user_rec { 583 u_char rec_type; 584 uid_t uid; 585 struct sockaddr_storage sock; 586 uint64_t ops; 587 uint64_t bytes_read; 588 uint64_t bytes_written; 589 time_t tm_start; 590 time_t tm_last; 591 }__attribute__((__packed__)); 592 593 /* Active user list path record format */ 594 struct nfs_user_stat_path_rec { 595 u_char rec_type; 596 char path[RPCMNT_PATHLEN + 1]; 597 }__attribute__((__packed__)); 598 599 /* Defines for rec_type field of 600 * nfs_user_stat_rec & nfs_user_stat_rec 601 * data structures 602 */ 603 #define NFS_USER_STAT_USER_REC 0 604 #define NFS_USER_STAT_PATH_REC 1 605 606 607 #ifdef XNU_KERNEL_PRIVATE 608 struct nfs_exportfs; 609 610 struct nfs_export_options { 611 uint32_t nxo_flags; /* export options */ 612 kauth_cred_t nxo_cred; /* mapped credential */ 613 struct nfs_sec nxo_sec; /* security mechanism flavors */ 614 }; 615 616 /* Network address lookup element and individual export options */ 617 struct nfs_netopt { 618 struct radix_node no_rnodes[2]; /* radix tree glue */ 619 struct nfs_export_options no_opt; /* export options */ 620 struct sockaddr *no_addr; /* net address to which exported */ 621 struct sockaddr *no_mask; /* mask for net address */ 622 }; 623 624 /* statistic counters for each exported directory 625 * 626 * Since 64-bit atomic operations are not available on 32-bit platforms, 627 * 64-bit counters are implemented using 32-bit integers and 32-bit 628 * atomic operations 629 */ 630 typedef struct nfsstatcount64 { 631 uint32_t hi; 632 uint32_t lo; 633 } nfsstatcount64; 634 635 struct nfs_export_stat_counters { 636 struct nfsstatcount64 ops; /* Count of NFS Requests received for this export */ 637 struct nfsstatcount64 bytes_read; /* Count of bytes read from this export */ 638 struct nfsstatcount64 bytes_written; /* Count of bytes written to his export */ 639 }; 640 641 /* Macro for updating nfs export stat counters */ 642 #define NFSStatAdd64(PTR, VAL) \ 643 do { \ 644 uint32_t NFSSA_OldValue = \ 645 OSAddAtomic((VAL), &(PTR)->lo); \ 646 if ((NFSSA_OldValue + (VAL)) < NFSSA_OldValue) \ 647 OSAddAtomic(1, &(PTR)->hi); \ 648 } while (0) 649 650 /* Some defines for dealing with active user list stats */ 651 #define NFSRV_USER_STAT_DEF_MAX_NODES 1024 /* default active user list size limit */ 652 #define NFSRV_USER_STAT_DEF_IDLE_SEC 7200 /* default idle seconds (node no longer considered active) */ 653 654 /* active user list globals */ 655 extern uint32_t nfsrv_user_stat_enabled; /* enable/disable active user list */ 656 extern uint32_t nfsrv_user_stat_node_count; /* current count of user stat nodes */ 657 extern uint32_t nfsrv_user_stat_max_idle_sec; /* idle seconds (node no longer considered active) */ 658 extern uint32_t nfsrv_user_stat_max_nodes; /* active user list size limit */ 659 extern lck_grp_t nfsrv_active_user_mutex_group; 660 661 /* An active user node represented in the kernel */ 662 struct nfs_user_stat_node { 663 TAILQ_ENTRY(nfs_user_stat_node) lru_link; 664 LIST_ENTRY(nfs_user_stat_node) hash_link; 665 uid_t uid; 666 struct sockaddr_storage sock; 667 uint64_t ops; 668 uint64_t bytes_read; 669 uint64_t bytes_written; 670 time_t tm_start; 671 time_t tm_last; 672 }; 673 674 /* Hash table for active user nodes */ 675 #define NFS_USER_STAT_HASH_SIZE 16 /* MUST be a power of 2 */ 676 #define NFS_USER_STAT_HASH(userhashtbl, uid) \ 677 &((userhashtbl)[(uid) & (NFS_USER_STAT_HASH_SIZE - 1)]) 678 679 TAILQ_HEAD(nfs_user_stat_lru_head, nfs_user_stat_node); 680 LIST_HEAD(nfs_user_stat_hashtbl_head, nfs_user_stat_node); 681 682 /* Active user list data structure */ 683 /* One per exported directory */ 684 struct nfs_active_user_list { 685 struct nfs_user_stat_lru_head user_lru; 686 struct nfs_user_stat_hashtbl_head user_hashtbl[NFS_USER_STAT_HASH_SIZE]; 687 uint32_t node_count; 688 lck_mtx_t user_mutex; 689 }; 690 691 692 /* Network export information */ 693 /* one of these for each exported directory */ 694 struct nfs_export { 695 LIST_ENTRY(nfs_export) nx_next; /* FS export list */ 696 LIST_ENTRY(nfs_export) nx_hash; /* export hash chain */ 697 struct nfs_export *nx_parent; /* parent export */ 698 uint32_t nx_id; /* export ID */ 699 uint32_t nx_flags; /* export flags */ 700 struct nfs_exportfs *nx_fs; /* exported file system */ 701 char *nx_path; /* exported file system sub-path */ 702 struct nfs_filehandle nx_fh; /* export root file handle */ 703 struct nfs_export_options nx_defopt; /* default options */ 704 uint32_t nx_expcnt; /* # exports in table */ 705 struct radix_node_head *nx_rtable[AF_MAX + 1]; /* table of exports (netopts) */ 706 struct nfs_export_stat_counters nx_stats; /* statistic counters for this exported directory */ 707 struct nfs_active_user_list nx_user_list; /* Active User List for this exported directory */ 708 struct timeval nx_exptime; /* time of export for write verifier */ 709 }; 710 711 /* NFS exported file system info */ 712 /* one of these for each exported file system */ 713 struct nfs_exportfs { 714 LIST_ENTRY(nfs_exportfs) nxfs_next; /* exported file system list */ 715 uint32_t nxfs_id; /* exported file system ID */ 716 char *nxfs_path; /* exported file system path */ 717 LIST_HEAD(, nfs_export) nxfs_exports; /* list of exports for this file system */ 718 }; 719 720 extern LIST_HEAD(nfsrv_expfs_list, nfs_exportfs) nfsrv_exports; 721 extern lck_rw_t nfsrv_export_rwlock; // lock for export data structures 722 #define NFSRVEXPHASHSZ 64 723 #define NFSRVEXPHASHVAL(FSID, EXPID) \ 724 (((FSID) >> 24) ^ ((FSID) >> 16) ^ ((FSID) >> 8) ^ (EXPID)) 725 #define NFSRVEXPHASH(FSID, EXPID) \ 726 (&nfsrv_export_hashtbl[NFSRVEXPHASHVAL((FSID),(EXPID)) & nfsrv_export_hash]) 727 extern LIST_HEAD(nfsrv_export_hashhead, nfs_export) * nfsrv_export_hashtbl; 728 extern u_long nfsrv_export_hash; 729 730 #if CONFIG_FSE 731 /* 732 * NFS server file mod fsevents 733 */ 734 struct nfsrv_fmod { 735 LIST_ENTRY(nfsrv_fmod) fm_link; 736 vnode_t fm_vp; 737 struct vfs_context fm_context; 738 uint64_t fm_deadline; 739 }; 740 741 #define NFSRVFMODHASHSZ 128 742 #define NFSRVFMODHASH(vp) (((uintptr_t) vp) & nfsrv_fmod_hash) 743 extern LIST_HEAD(nfsrv_fmod_hashhead, nfsrv_fmod) * nfsrv_fmod_hashtbl; 744 extern u_long nfsrv_fmod_hash; 745 extern lck_mtx_t nfsrv_fmod_mutex; 746 extern int nfsrv_fmod_pending, nfsrv_fsevents_enabled; 747 #endif 748 749 extern int nfsrv_async, nfsrv_export_hash_size, nfsrv_reqcache_size, nfsrv_sock_max_rec_queue_length; 750 extern uint32_t nfsrv_gss_context_ttl; 751 extern uint32_t nfsrv_unprocessed_rpc_current, nfsrv_unprocessed_rpc_max; 752 753 extern struct nfsrvstats nfsrvstats; 754 #define NFS_UC_Q_DEBUG 755 #ifdef NFS_UC_Q_DEBUG 756 extern int nfsrv_uc_use_proxy; 757 extern uint32_t nfsrv_uc_queue_limit; 758 extern uint32_t nfsrv_uc_queue_max_seen; 759 extern volatile uint32_t nfsrv_uc_queue_count; 760 #endif 761 762 #endif // XNU_KERNEL_PRIVATE 763 764 typedef struct nfserr_info { 765 const char * nei_name; 766 const int nei_error; 767 const int nei_index; 768 } nfserr_info_t; 769 770 /* 771 * NFS Common Errors 772 */ 773 #define NFSERR_INFO_COMMON \ 774 { "NFS_OK", NFS_OK, 0 }, \ 775 { "ERR_PERM", NFSERR_PERM, 1 }, \ 776 { "ERR_NOENT", NFSERR_NOENT, 2 }, \ 777 { "ERR_IO", NFSERR_IO, 3 }, \ 778 { "ERR_NXIO", NFSERR_NXIO, 4 }, \ 779 { "ERR_ACCES", NFSERR_ACCES, 5 }, \ 780 { "ERR_EXIST", NFSERR_EXIST, 6 }, \ 781 { "ERR_XDEV", NFSERR_XDEV, 7 }, \ 782 { "ERR_NODEV", NFSERR_NODEV, 8 }, \ 783 { "ERR_NOTDIR", NFSERR_NOTDIR, 9 }, \ 784 { "ERR_ISDIR", NFSERR_ISDIR, 10 }, \ 785 { "ERR_INVAL", NFSERR_INVAL, 11 }, \ 786 { "ERR_FBIG", NFSERR_FBIG, 12 }, \ 787 { "ERR_NOSPC", NFSERR_NOSPC, 13 }, \ 788 { "ERR_ROFS", NFSERR_ROFS, 14 }, \ 789 { "ERR_MLINK", NFSERR_MLINK, 15 }, \ 790 { "ERR_NAMETOL", NFSERR_NAMETOL, 16 }, \ 791 { "ERR_NOTEMPTY", NFSERR_NOTEMPTY, 17 }, \ 792 { "ERR_DQUOT", NFSERR_DQUOT, 18 }, \ 793 { "ERR_STALE", NFSERR_STALE, 19 }, \ 794 { "ERR_REMOTE", NFSERR_REMOTE, 20 }, \ 795 { "ERR_WFLUSH", NFSERR_WFLUSH, 21 }, \ 796 { "ERR_BADHANDLE", NFSERR_BADHANDLE, 22 }, \ 797 { "ERR_NOT_SYNC", NFSERR_NOT_SYNC, 23 }, \ 798 { "ERR_BAD_COOKIE", NFSERR_BAD_COOKIE, 24 }, \ 799 { "ERR_NOTSUPP", NFSERR_NOTSUPP, 25 }, \ 800 { "ERR_TOOSMALL", NFSERR_TOOSMALL, 26 }, \ 801 { "ERR_SERVERFAULT", NFSERR_SERVERFAULT, 27 }, \ 802 { "ERR_BADTYPE", NFSERR_BADTYPE, 28 }, \ 803 { "ERR_DELAY", NFSERR_DELAY, 29 } 804 805 #define NFSERR_INFO_COMMON_SIZE 30 806 807 /* 808 * NFSv4 Errors 809 */ 810 #define NFSERR_INFO_V4 \ 811 /* NFSv4 Errors */ \ 812 { "ERR_SAME", NFSERR_SAME, 0 }, \ 813 { "ERR_DENIED", NFSERR_DENIED, 1 }, \ 814 { "ERR_EXPIRED", NFSERR_EXPIRED, 2 }, \ 815 { "ERR_LOCKED", NFSERR_LOCKED, 3 }, \ 816 { "ERR_GRACE", NFSERR_GRACE, 4 }, \ 817 { "ERR_FHEXPIRED", NFSERR_FHEXPIRED, 5 }, \ 818 { "ERR_SHARE_DENIED", NFSERR_SHARE_DENIED, 6 }, \ 819 { "ERR_WRONGSEC", NFSERR_WRONGSEC, 7 }, \ 820 { "ERR_CLID_INUSE", NFSERR_CLID_INUSE, 8 }, \ 821 { "ERR_RESOURCE", NFSERR_RESOURCE, 9 }, \ 822 { "ERR_MOVED", NFSERR_MOVED, 10 }, \ 823 { "ERR_NOFILEHANDLE", NFSERR_NOFILEHANDLE, 11 }, \ 824 { "ERR_MINOR_VERS_MISMATCH", NFSERR_MINOR_VERS_MISMATCH, 12 }, \ 825 { "ERR_STALE_CLIENTID", NFSERR_STALE_CLIENTID, 13 }, \ 826 { "ERR_STALE_STATEID", NFSERR_STALE_STATEID, 14 }, \ 827 { "ERR_OLD_STATEID", NFSERR_OLD_STATEID, 15 }, \ 828 { "ERR_BAD_STATEID", NFSERR_BAD_STATEID, 16 }, \ 829 { "ERR_BAD_SEQID", NFSERR_BAD_SEQID, 17 }, \ 830 { "ERR_NOT_SAME", NFSERR_NOT_SAME, 18 }, \ 831 { "ERR_LOCK_RANGE", NFSERR_LOCK_RANGE, 19 }, \ 832 { "ERR_SYMLINK", NFSERR_SYMLINK, 20 }, \ 833 { "ERR_RESTOREFH", NFSERR_RESTOREFH, 21 }, \ 834 { "ERR_LEASE_MOVED", NFSERR_LEASE_MOVED, 22 }, \ 835 { "ERR_ATTRNOTSUPP", NFSERR_ATTRNOTSUPP, 23 }, \ 836 { "ERR_NO_GRACE", NFSERR_NO_GRACE, 24 }, \ 837 { "ERR_RECLAIM_BAD", NFSERR_RECLAIM_BAD, 25 }, \ 838 { "ERR_RECLAIM_CONFLICT", NFSERR_RECLAIM_CONFLICT, 26 }, \ 839 { "ERR_BADXDR", NFSERR_BADXDR, 27 }, \ 840 { "ERR_LOCKS_HELD", NFSERR_LOCKS_HELD, 28 }, \ 841 { "ERR_OPENMODE", NFSERR_OPENMODE, 29 }, \ 842 { "ERR_BADOWNER", NFSERR_BADOWNER, 30 }, \ 843 { "ERR_BADCHAR", NFSERR_BADCHAR, 31 }, \ 844 { "ERR_BADNAME", NFSERR_BADNAME, 32 }, \ 845 { "ERR_BAD_RANGE", NFSERR_BAD_RANGE, 33 }, \ 846 { "ERR_LOCK_NOTSUPP", NFSERR_LOCK_NOTSUPP, 34 }, \ 847 { "ERR_OP_ILLEGAL", NFSERR_OP_ILLEGAL, 35 }, \ 848 { "ERR_DEADLOCK", NFSERR_DEADLOCK, 36 }, \ 849 { "ERR_FILE_OPEN", NFSERR_FILE_OPEN, 37 }, \ 850 { "ERR_ADMIN_REVOKED", NFSERR_ADMIN_REVOKED, 38 }, \ 851 { "ERR_CB_PATH_DOWN", NFSERR_CB_PATH_DOWN, 39 } , \ 852 /* NFSv4.1 Errors */ \ 853 { "ERR_BADIOMODE", NFSERR_BADIOMODE, 40} , \ 854 { "ERR_BADLAYOUT", NFSERR_BADLAYOUT, 41 } , \ 855 { "ERR_BADSESSIONDIGEST", NFSERR_BADSESSIONDIGEST, 42 } , \ 856 { "ERR_BADSESSION", NFSERR_BADSESSION, 43 } , \ 857 { "ERR_BADSLOT", NFSERR_BADSLOT, 44 } , \ 858 { "ERR_COMPLETEALREADY", NFSERR_COMPLETEALREADY, 45 } , \ 859 { "ERR_NOTBNDTOSESS", NFSERR_NOTBNDTOSESS, 46 } , \ 860 { "ERR_DELEGALREADYWANT", NFSERR_DELEGALREADYWANT, 47 } , \ 861 { "ERR_BACKCHANBUSY", NFSERR_BACKCHANBUSY, 48 } , \ 862 { "ERR_LAYOUTTRYLATER", NFSERR_LAYOUTTRYLATER, 49 } , \ 863 { "ERR_LAYOUTUNAVAIL", NFSERR_LAYOUTUNAVAIL, 50 } , \ 864 { "ERR_NOMATCHLAYOUT", NFSERR_NOMATCHLAYOUT, 51 } , \ 865 { "ERR_RECALLCONFLICT", NFSERR_RECALLCONFLICT, 52 } , \ 866 { "ERR_UNKNLAYOUTTYPE", NFSERR_UNKNLAYOUTTYPE, 53 } , \ 867 { "ERR_SEQMISORDERED", NFSERR_SEQMISORDERED, 54 } , \ 868 { "ERR_SEQUENCEPOS", NFSERR_SEQUENCEPOS, 55 } , \ 869 { "ERR_REQTOOBIG", NFSERR_REQTOOBIG, 56 } , \ 870 { "ERR_REPTOOBIG", NFSERR_REPTOOBIG, 57 } , \ 871 { "ERR_REPTOOBIGTOCACHE", NFSERR_REPTOOBIGTOCACHE, 58 } , \ 872 { "ERR_RETRYUNCACHEDREP", NFSERR_RETRYUNCACHEDREP, 59 } , \ 873 { "ERR_UNSAFECOMPOUND", NFSERR_UNSAFECOMPOUND, 60 } , \ 874 { "ERR_TOOMANYOPS", NFSERR_TOOMANYOPS, 61 } , \ 875 { "ERR_OPNOTINSESS", NFSERR_OPNOTINSESS, 62 } , \ 876 { "ERR_HASHALGUNSUPP", NFSERR_HASHALGUNSUPP, 63 } , \ 877 { "ERR_CLIENTIDBUSY", NFSERR_CLIENTIDBUSY, 64 } , \ 878 { "ERR_PNFSIOHOLE", NFSERR_PNFSIOHOLE, 65 } , \ 879 { "ERR_SEQFALSERETRY", NFSERR_SEQFALSERETRY, 66 } , \ 880 { "ERR_BADHIGHSLOT", NFSERR_BADHIGHSLOT, 67 } , \ 881 { "ERR_DEADSESSION", NFSERR_DEADSESSION, 68 } , \ 882 { "ERR_ENCRALGUNSUPP", NFSERR_ENCRALGUNSUPP, 69 } , \ 883 { "ERR_PNFSNOLAYOUT", NFSERR_PNFSNOLAYOUT, 70 } , \ 884 { "ERR_NOTONLYOP", NFSERR_NOTONLYOP, 71 } , \ 885 { "ERR_WRONGCRED", NFSERR_WRONGCRED, 72 } , \ 886 { "ERR_WRONGTYPE", NFSERR_WRONGTYPE, 73 } , \ 887 { "ERR_DIRDELEGUNAVAIL", NFSERR_DIRDELEGUNAVAIL, 74 } , \ 888 { "ERR_REJECTDELEG", NFSERR_REJECTDELEG, 75 } , \ 889 { "ERR_RETURNCONFLICT", NFSERR_RETURNCONFLICT, 76 } , \ 890 { "ERR_DELEGREVOKED", NFSERR_DELEGREVOKED, 77 } 891 892 #define NFSERR_INFO_V4_SIZE 40 893 #define NFSERR_INFO_V41_SIZE 78 894 895 /* 896 * XXX to allow amd to include nfs.h without nfsproto.h 897 */ 898 #ifdef NFS_NPROCS 899 /* 900 * Stats structure 901 */ 902 struct nfsclntstats { 903 uint64_t attrcache_hits; 904 uint64_t attrcache_misses; 905 uint64_t lookupcache_hits; 906 uint64_t lookupcache_misses; 907 uint64_t direofcache_hits; 908 uint64_t direofcache_misses; 909 uint64_t accesscache_hits; 910 uint64_t accesscache_misses; 911 uint64_t biocache_reads; 912 uint64_t read_bios; 913 uint64_t read_physios; 914 uint64_t biocache_writes; 915 uint64_t write_bios; 916 uint64_t write_physios; 917 uint64_t biocache_readlinks; 918 uint64_t readlink_bios; 919 uint64_t biocache_readdirs; 920 uint64_t readdir_bios; 921 uint64_t rpccntv3[NFS_NPROCS]; 922 struct { 923 uint64_t nlm_lock; 924 uint64_t nlm_test; 925 uint64_t nlm_unlock; 926 } nlmcnt; // NFSv3 only 927 uint64_t opcntv4[NFS_V41_OP_COUNT]; 928 uint64_t cbopcntv4[NFS_V41_OP_CB_COUNT]; 929 uint64_t rpcretries; 930 uint64_t rpcrequests; 931 uint64_t rpctimeouts; 932 uint64_t rpcunexpected; 933 uint64_t rpcinvalid; 934 uint64_t pageins; 935 uint64_t pageouts; 936 struct { 937 uint64_t errs_common[NFSERR_INFO_COMMON_SIZE]; 938 uint64_t errs_v4[NFSERR_INFO_V41_SIZE]; 939 uint64_t errs_unknown; 940 } nfs_errs; 941 }; 942 943 struct nfsrvstats { 944 uint64_t srvrpccntv3[NFS_NPROCS]; 945 uint64_t srvrpc_errs; 946 uint64_t srv_errs; 947 uint64_t srvcache_inproghits; 948 uint64_t srvcache_idemdonehits; 949 uint64_t srvcache_nonidemdonehits; 950 uint64_t srvcache_misses; 951 uint64_t srvvop_writes; 952 struct { 953 uint64_t errs_common[NFSERR_INFO_COMMON_SIZE]; 954 uint64_t errs_unknown; 955 } nfs_errs; 956 }; 957 958 #endif 959 960 /* 961 * Flags for nfssvc() system call. 962 */ 963 #define NFSSVC_NFSD 0x004 964 #define NFSSVC_ADDSOCK 0x008 965 #define NFSSVC_EXPORTSTATS 0x010 /* gets exported directory stats */ 966 #define NFSSVC_USERSTATS 0x020 /* gets exported directory active user stats */ 967 #define NFSSVC_USERCOUNT 0x040 /* gets current count of active nfs users */ 968 #define NFSSVC_ZEROSTATS 0x080 /* zero nfs server statistics */ 969 #define NFSSVC_SRVSTATS 0x100 /* struct: struct nfsrvstats */ 970 #define NFSSVC_EXPORT 0x200 971 972 /* 973 * The structure that lockd hands the kernel for each lock answer. 974 */ 975 #define LOCKD_ANS_VERSION 2 976 struct lockd_ans { 977 int la_version; /* lockd_ans version */ 978 int la_errno; /* return status */ 979 u_int64_t la_xid; /* unique message transaction ID */ 980 int la_flags; /* answer flags */ 981 pid_t la_pid; /* pid of lock requester/owner */ 982 off_t la_start; /* lock starting offset */ 983 off_t la_len; /* lock length */ 984 int la_fh_len; /* The file handle length. */ 985 u_int8_t la_fh[NFSV3_MAX_FH_SIZE];/* The file handle. */ 986 }; 987 988 /* 989 * The structure that lockd hands the kernel for each notify. 990 */ 991 #define LOCKD_NOTIFY_VERSION 1 992 struct lockd_notify { 993 int ln_version; /* lockd_notify version */ 994 int ln_flags; /* notify flags */ 995 int ln_pad; /* (for alignment) */ 996 int ln_addrcount; /* # of addresss */ 997 struct sockaddr_storage *ln_addr; /* List of addresses. */ 998 }; 999 1000 #include <sys/_types/_guid_t.h> /* for guid_t below */ 1001 #define MAXIDNAMELEN 1024 1002 struct nfs_testmapid { 1003 uint32_t ntm_lookup; /* lookup name 2 id or id 2 name */ 1004 uint32_t ntm_grpflag; /* Is this a group or user maping */ 1005 uint32_t ntm_id; /* id to map or return */ 1006 uint32_t pad; 1007 guid_t ntm_guid; /* intermidiate guid used in conversion */ 1008 char ntm_name[MAXIDNAMELEN]; /* name to map or return */ 1009 }; 1010 1011 #define NTM_ID2NAME 0 1012 #define NTM_NAME2ID 1 1013 #define NTM_NAME2GUID 2 1014 #define NTM_GUID2NAME 3 1015 1016 /* 1017 * Flags for nfsclnt() system call. 1018 */ 1019 #define NFSCLNT_LOCKDANS _IOW('n', 101, struct lockd_ans) 1020 #define NFSCLNT_LOCKDNOTIFY _IOW('n', 102, struct lockd_notify) 1021 #define NFSCLNT_TESTIDMAP _IOWR('n', 103, struct nfs_testmapid) 1022 1023 /* nfsclnt() system call character device */ 1024 #define NFSCLNT_DEVICE "nfsclnt" 1025 1026 /* nfsclnt() system call */ 1027 int nfsclnt(unsigned long request, void *argstructp); 1028 1029 /* 1030 * fs.nfs sysctl(3) identifiers 1031 */ 1032 #define NFS_NFSSTATS 1 /* struct: struct nfsclntstats */ 1033 #define NFS_MOUNTINFO 6 /* gets information about an NFS mount */ 1034 #define NFS_NFSZEROSTATS 7 /* zero nfs client statistics */ 1035 1036 #ifndef NFS_WDELAYHASHSIZ 1037 #define NFS_WDELAYHASHSIZ 16 /* and with this */ 1038 #endif 1039 1040 #ifdef KERNEL_PRIVATE 1041 1042 /* NFS hooks */ 1043 1044 /* NFS hooks in struct */ 1045 struct nfs_hooks_in { 1046 int (*f_vinvalbuf)(vnode_t, int, vfs_context_t, int); 1047 int (*f_buf_page_inval)(vnode_t, off_t); 1048 }; 1049 1050 /* NFS hooks out struct */ 1051 struct nfs_hooks_out { 1052 void * (*f_get_bsdthreadtask_info)(thread_t); 1053 }; 1054 1055 /* NFS hooks registration functions */ 1056 void nfs_register_hooks(struct nfs_hooks_in *, struct nfs_hooks_out *); 1057 void nfs_unregister_hooks(void); 1058 1059 #ifdef XNU_KERNEL_PRIVATE 1060 1061 /* NFS hooks wrappers */ 1062 int nfs_vinvalbuf(vnode_t, int, vfs_context_t, int); 1063 int nfs_buf_page_inval(vnode_t, off_t); 1064 1065 #endif /* XNU_KERNEL_PRIVATE */ 1066 1067 /* Debug support */ 1068 #define __NFS_DEBUG_LEVEL(dbgctl) ((dbgctl) & 0xf) 1069 #define __NFS_DEBUG_FACILITY(dbgctl) (((dbgctl) >> 4) & 0xfff) 1070 #define __NFS_DEBUG_FLAGS(dbgctl) (((dbgctl) >> 16) & 0xf) 1071 #define __NFS_DEBUG_VALUE(dbgctl) (((dbgctl) >> 20) & 0xfff) 1072 #define __NFS_IS_DBG(dbgctl, fac, lev) (__builtin_expect((__NFS_DEBUG_FACILITY(dbgctl) & (fac)) && ((lev) <= __NFS_DEBUG_LEVEL(dbgctl)), 0)) 1073 #define __NFS_DBG(dbgctl, fac, lev, fmt, ...) nfs_printf((dbgctl), (fac), (lev), "%s: %d: " fmt, __func__, __LINE__, ## __VA_ARGS__) 1074 void nfs_printf(unsigned int, unsigned int, unsigned int, const char *, ...) __printflike(4, 5); 1075 void nfs_dump_mbuf(const char *, int, const char *, mbuf_t); 1076 1077 /* 1078 * NFS mbuf chain structure used for managing the building/dissection of RPCs 1079 */ 1080 struct nfsm_chain { 1081 mbuf_t nmc_mhead; /* mbuf chain head */ 1082 mbuf_t nmc_mcur; /* current mbuf */ 1083 caddr_t nmc_ptr; /* pointer into current mbuf */ 1084 size_t nmc_left; /* bytes remaining in current mbuf */ 1085 uint32_t nmc_flags; /* flags for this nfsm_chain */ 1086 }; 1087 #define NFSM_CHAIN_FLAG_ADD_CLUSTERS 0x1 /* always add mbuf clusters */ 1088 1089 extern size_t nfs_mbuf_mhlen, nfs_mbuf_minclsize; 1090 1091 /* 1092 * Each retransmission of an RPCSEC_GSS request 1093 * has an additional sequence number. 1094 */ 1095 struct gss_seq { 1096 SLIST_ENTRY(gss_seq) gss_seqnext; 1097 uint32_t gss_seqnum; 1098 }; 1099 1100 #endif /* KERNEL_PRIVATE */ 1101 1102 #ifdef XNU_KERNEL_PRIVATE 1103 1104 extern uint32_t nfsrv_debug_ctl; 1105 1106 /* Server debug support */ 1107 #define NFSRV_FAC_GSS 0x001 1108 #define NFSRV_FAC_SRV 0x002 1109 #define NFSRV_DEBUG_LEVEL __NFS_DEBUG_LEVEL(nfsrv_debug_ctl) 1110 #define NFSRV_DEBUG_FACILITY __NFS_DEBUG_FACILITY(nfsrv_debug_ctl) 1111 #define NFSRV_DEBUG_FLAGS __NFS_DEBUG_FLAGS(nfsrv_debug_ctl) 1112 #define NFSRV_DEBUG_VALUE __NFS_DEBUG_VALUE(nfsrv_debug_ctl) 1113 #define NFSRV_IS_DBG(fac, lev) __NFS_IS_DBG(nfsrv_debug_ctl, fac, lev) 1114 #define NFSRV_DBG(fac, lev, fmt, ...) __NFS_DBG(nfsrv_debug_ctl, fac, lev, fmt, ## __VA_ARGS__) 1115 1116 #ifdef MALLOC_DECLARE 1117 MALLOC_DECLARE(M_NFSD); 1118 #endif 1119 1120 struct nameidata; 1121 struct nfsrv_uc_arg; 1122 1123 /* 1124 * One nfsrv_sock structure is maintained for each socket the 1125 * server is servicing requests on. 1126 */ 1127 struct nfsrv_sock { 1128 TAILQ_ENTRY(nfsrv_sock) ns_chain; /* List of all nfsrv_sock's */ 1129 TAILQ_ENTRY(nfsrv_sock) ns_svcq; /* List of sockets needing servicing */ 1130 TAILQ_ENTRY(nfsrv_sock) ns_wgq; /* List of sockets with a pending write gather */ 1131 struct nfsrv_uc_arg *ns_ua; /* Opaque pointer to upcall */ 1132 lck_rw_t ns_rwlock; /* lock for most fields */ 1133 socket_t ns_so; 1134 mbuf_t ns_nam; 1135 mbuf_t ns_raw; 1136 mbuf_t ns_rawend; 1137 mbuf_t ns_rec; 1138 mbuf_t ns_recend; 1139 mbuf_t ns_frag; 1140 int ns_flag; 1141 int ns_sotype; 1142 size_t ns_cc; 1143 u_int32_t ns_reclen; /* Unprocessed RPC record length */ 1144 u_int32_t ns_recslen; /* Total unprocessed RPC records length */ 1145 int ns_reccnt; 1146 u_int32_t ns_sref; 1147 time_t ns_timestamp; /* socket timestamp */ 1148 lck_mtx_t ns_wgmutex; /* mutex for write gather fields */ 1149 time_t ns_wgtime; /* next Write deadline (usec) */ 1150 LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */ 1151 LIST_HEAD(nfsrv_wg_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ]; 1152 }; 1153 1154 /* Bits for "ns_flag" */ 1155 #define SLP_VALID 0x0001 /* nfs sock valid */ 1156 #define SLP_DOREC 0x0002 /* nfs sock has received data to process */ 1157 #define SLP_NEEDQ 0x0004 /* network socket has data to receive */ 1158 #define SLP_DISCONN 0x0008 /* socket needs to be zapped */ 1159 #define SLP_GETSTREAM 0x0010 /* currently in nfsrv_getstream() */ 1160 #define SLP_LASTFRAG 0x0020 /* on last fragment of RPC record */ 1161 #define SLP_DOWRITES 0x0040 /* nfs sock has gathered writes to service */ 1162 #define SLP_WORKTODO 0x004e /* mask of all "work to do" flags */ 1163 #define SLP_ALLFLAGS 0x007f 1164 #define SLP_WAITQ 0x4000 /* nfs sock is on the wait queue */ 1165 #define SLP_WORKQ 0x8000 /* nfs sock is on the work queue */ 1166 #define SLP_QUEUED 0xc000 /* nfs sock is on a queue */ 1167 1168 #define SLPNOLIST ((struct nfsrv_sock *)0xdeadbeef) /* sentinel value for sockets not in the nfsrv_sockwg list */ 1169 1170 extern struct nfsrv_sock *nfsrv_udpsock, *nfsrv_udp6sock; 1171 1172 /* 1173 * global NFS server socket lists: 1174 * 1175 * nfsrv_socklist - list of all sockets (ns_chain) 1176 * nfsrv_sockwait - sockets w/new data waiting to be worked on (ns_svcq) 1177 * nfsrv_sockwork - sockets being worked on which may have more work to do (ns_svcq) 1178 * nfsrv_sockwg - sockets with pending write gather input (ns_wgq) 1179 */ 1180 extern TAILQ_HEAD(nfsrv_sockhead, nfsrv_sock) nfsrv_socklist, nfsrv_sockwg, 1181 nfsrv_sockwait, nfsrv_sockwork; 1182 1183 /* lock groups for nfsrv_sock's */ 1184 extern lck_grp_t nfsrv_slp_rwlock_group; 1185 extern lck_grp_t nfsrv_slp_mutex_group; 1186 1187 /* 1188 * One of these structures is allocated for each nfsd. 1189 */ 1190 struct nfsd { 1191 TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */ 1192 TAILQ_ENTRY(nfsd) nfsd_queue; /* List of waiting nfsd's */ 1193 int nfsd_flag; /* NFSD_ flags */ 1194 struct nfsrv_sock *nfsd_slp; /* Current socket */ 1195 struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */ 1196 }; 1197 1198 /* Bits for "nfsd_flag" */ 1199 #define NFSD_WAITING 0x01 1200 #define NFSD_REQINPROG 0x02 1201 1202 /* 1203 * This structure is used by the server for describing each request. 1204 * Some fields are used only when write request gathering is performed. 1205 */ 1206 struct nfsrv_descript { 1207 time_t nd_time; /* Write deadline (usec) */ 1208 off_t nd_off; /* Start byte offset */ 1209 off_t nd_eoff; /* and end byte offset */ 1210 LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */ 1211 LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */ 1212 LIST_HEAD(, nfsrv_descript) nd_coalesce; /* coalesced writes */ 1213 struct nfsm_chain nd_nmreq; /* Request mbuf chain */ 1214 mbuf_t nd_mrep; /* Reply mbuf list (WG) */ 1215 mbuf_t nd_nam; /* and socket addr */ 1216 mbuf_t nd_nam2; /* return socket addr */ 1217 u_int32_t nd_procnum; /* RPC # */ 1218 int nd_stable; /* storage type */ 1219 int nd_vers; /* NFS version */ 1220 int nd_len; /* Length of this write */ 1221 int nd_repstat; /* Reply status */ 1222 u_int32_t nd_retxid; /* Reply xid */ 1223 struct timeval nd_starttime; /* Time RPC initiated */ 1224 struct nfs_filehandle nd_fh; /* File handle */ 1225 uint32_t nd_sec; /* Security flavor */ 1226 struct nfs_gss_svc_ctx *nd_gss_context;/* RPCSEC_GSS context */ 1227 uint32_t nd_gss_seqnum; /* RPCSEC_GSS seq num */ 1228 mbuf_t nd_gss_mb; /* RPCSEC_GSS results mbuf */ 1229 kauth_cred_t nd_cr; /* Credentials */ 1230 }; 1231 1232 extern TAILQ_HEAD(nfsd_head, nfsd) nfsd_head, nfsd_queue; 1233 1234 typedef int (*nfsrv_proc_t)(struct nfsrv_descript *, struct nfsrv_sock *, 1235 vfs_context_t, mbuf_t *); 1236 1237 /* mutex for nfs server */ 1238 extern lck_mtx_t nfsd_mutex; 1239 extern int nfsd_thread_count, nfsd_thread_max; 1240 1241 /* nfs timer call structures */ 1242 extern thread_call_t nfsrv_idlesock_timer_call; 1243 #if CONFIG_FSE 1244 extern thread_call_t nfsrv_fmod_timer_call; 1245 #endif 1246 1247 __BEGIN_DECLS 1248 1249 nfstype vtonfs_type(enum vtype, int); 1250 enum vtype nfstov_type(nfstype, int); 1251 int vtonfsv2_mode(enum vtype, mode_t); 1252 1253 void nfs_mbuf_init(void); 1254 1255 int nfs_sockaddr_cmp(struct sockaddr *, struct sockaddr *); 1256 1257 void nfsrv_active_user_list_reclaim(void); 1258 void nfsrv_cleancache(void); 1259 void nfsrv_cleanup(void); 1260 int nfsrv_credcheck(struct nfsrv_descript *, vfs_context_t, struct nfs_export *, 1261 struct nfs_export_options *); 1262 void nfsrv_idlesock_timer(void *, void *); 1263 int nfsrv_dorec(struct nfsrv_sock *, struct nfsd *, struct nfsrv_descript **); 1264 int nfsrv_errmap(struct nfsrv_descript *, int); 1265 int nfsrv_export(struct user_nfs_export_args *, vfs_context_t); 1266 int nfsrv_fhmatch(struct nfs_filehandle *, struct nfs_filehandle *); 1267 int nfsrv_fhtovp(struct nfs_filehandle *, struct nfsrv_descript *, vnode_t *, 1268 struct nfs_export **, struct nfs_export_options **); 1269 int nfsrv_check_exports_allow_address(mbuf_t); 1270 #if CONFIG_FSE 1271 void nfsrv_fmod_timer(void *, void *); 1272 #endif 1273 int nfsrv_getcache(struct nfsrv_descript *, struct nfsrv_sock *, mbuf_t *); 1274 void nfsrv_group_sort(gid_t *, int); 1275 void nfsrv_init(void); 1276 void nfsrv_initcache(void); 1277 int nfsrv_is_initialized(void); 1278 int nfsrv_namei(struct nfsrv_descript *, vfs_context_t, struct nameidata *, 1279 struct nfs_filehandle *, vnode_t *, 1280 struct nfs_export **, struct nfs_export_options **); 1281 void nfsrv_rcv(socket_t, void *, int); 1282 void nfsrv_rcv_locked(socket_t, struct nfsrv_sock *, int); 1283 int nfsrv_rephead(struct nfsrv_descript *, struct nfsrv_sock *, struct nfsm_chain *, size_t); 1284 int nfsrv_send(struct nfsrv_sock *, mbuf_t, mbuf_t); 1285 void nfsrv_updatecache(struct nfsrv_descript *, int, mbuf_t); 1286 void nfsrv_update_user_stat(struct nfs_export *, struct nfsrv_descript *, uid_t, u_int, u_int, u_int); 1287 int nfsrv_vptofh(struct nfs_export *, int, struct nfs_filehandle *, 1288 vnode_t, vfs_context_t, struct nfs_filehandle *); 1289 void nfsrv_wakenfsd(struct nfsrv_sock *); 1290 void nfsrv_wg_timer(void *, void *); 1291 int nfsrv_writegather(struct nfsrv_descript **, struct nfsrv_sock *, 1292 vfs_context_t, mbuf_t *); 1293 1294 int nfsrv_access(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1295 int nfsrv_commit(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1296 int nfsrv_create(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1297 int nfsrv_fsinfo(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1298 int nfsrv_getattr(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1299 int nfsrv_link(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1300 int nfsrv_lookup(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1301 int nfsrv_mkdir(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1302 int nfsrv_mknod(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1303 int nfsrv_noop(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1304 int nfsrv_null(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1305 int nfsrv_pathconf(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1306 int nfsrv_read(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1307 int nfsrv_readdir(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1308 int nfsrv_readdirplus(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1309 int nfsrv_readlink(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1310 int nfsrv_remove(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1311 int nfsrv_rename(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1312 int nfsrv_rmdir(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1313 int nfsrv_setattr(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1314 int nfsrv_statfs(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1315 int nfsrv_symlink(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1316 int nfsrv_write(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *); 1317 1318 void nfs_interval_timer_start(thread_call_t, time_t); 1319 1320 /* socket upcall interfaces */ 1321 void nfsrv_uc_init(void); 1322 void nfsrv_uc_cleanup(void); 1323 void nfsrv_uc_addsock(struct nfsrv_sock *, int); 1324 void nfsrv_uc_dequeue(struct nfsrv_sock *); 1325 1326 #include <kern/kalloc.h> 1327 1328 extern zone_t nfsrv_descript_zone; 1329 1330 __END_DECLS 1331 #endif /* XNU_KERNEL_PRIVATE */ 1332 1333 #endif /* __APPLE_API_PRIVATE */ 1334 1335 #endif 1336