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