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