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