xref: /xnu-8020.121.3/bsd/nfs/nfsmount.h (revision fdd8201d7b966f0c3ea610489d29bd841d358941)
1 /*
2  * Copyright (c) 2000-2018 Apple Inc. All rights reserved.
3  *
4  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5  *
6  * This file contains Original Code and/or Modifications of Original Code
7  * as defined in and that are subject to the Apple Public Source License
8  * Version 2.0 (the 'License'). You may not use this file except in
9  * compliance with the License. The rights granted to you under the License
10  * may not be used to create, or enable the creation or redistribution of,
11  * unlawful or unlicensed copies of an Apple operating system, or to
12  * circumvent, violate, or enable the circumvention or violation of, any
13  * terms of an Apple operating system software license agreement.
14  *
15  * Please obtain a copy of the License at
16  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17  *
18  * The Original Code and all software distributed under the License are
19  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23  * Please see the License for the specific language governing rights and
24  * limitations under the License.
25  *
26  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27  */
28 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
29 /*
30  * Copyright (c) 1989, 1993
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  *	@(#)nfsmount.h	8.3 (Berkeley) 3/30/95
65  * FreeBSD-Id: nfsmount.h,v 1.13 1997/08/16 19:16:05 wollman Exp $
66  */
67 
68 
69 #ifndef _NFS_NFSMOUNT_H_
70 #define _NFS_NFSMOUNT_H_
71 
72 #include <sys/appleapiopts.h>
73 
74 #ifdef __APPLE_API_PRIVATE
75 
76 /*
77  * NFS mount file system attributes
78  */
79 struct nfs_fsattr {
80 	uint32_t        nfsa_flags;             /* file system flags */
81 	uint32_t        nfsa_lease;             /* lease time in seconds */
82 	int32_t         nfsa_maxname;           /* maximum filename size */
83 	uint32_t        nfsa_maxlink;           /* maximum # links */
84 	uint32_t        nfsa_bsize;             /* block size */
85 	uint32_t        nfsa_pad;               /* UNUSED */
86 	uint64_t        nfsa_maxfilesize;       /* maximum file size */
87 	uint32_t        nfsa_maxread;           /* maximum read size */
88 	uint32_t        nfsa_maxwrite;          /* maximum write size */
89 	uint64_t        nfsa_files_avail;       /* file slots available */
90 	uint64_t        nfsa_files_free;        /* file slots free */
91 	uint64_t        nfsa_files_total;       /* file slots total */
92 	uint64_t        nfsa_space_avail;       /* disk space available */
93 	uint64_t        nfsa_space_free;        /* disk space free */
94 	uint64_t        nfsa_space_total;       /* disk space total */
95 	uint32_t        nfsa_supp_attr[NFS_ATTR_BITMAP_LEN]; /* attributes supported on this file system */
96 	uint32_t        nfsa_bitmap[NFS_ATTR_BITMAP_LEN]; /* valid attributes */
97 };
98 #define NFS_FSFLAG_LINK                 0x00000001
99 #define NFS_FSFLAG_SYMLINK              0x00000002
100 #define NFS_FSFLAG_UNIQUE_FH            0x00000004
101 #define NFS_FSFLAG_ACL                  0x00000008
102 #define NFS_FSFLAG_SET_TIME             0x00000010
103 #define NFS_FSFLAG_CASE_INSENSITIVE     0x00000020
104 #define NFS_FSFLAG_CASE_PRESERVING      0x00000040
105 #define NFS_FSFLAG_CHOWN_RESTRICTED     0x00000080
106 #define NFS_FSFLAG_HOMOGENEOUS          0x00000100
107 #define NFS_FSFLAG_NO_TRUNC             0x00000200
108 #define NFS_FSFLAG_NAMED_ATTR           0x00000400
109 #define NFS_FSFLAG_FHTYPE_MASK          0xFF000000
110 #define NFS_FSFLAG_FHTYPE_SHIFT         24
111 
112 /*
113  * NFS file system location structures
114  */
115 struct nfs_fs_server {
116 	char *                  ns_name;                /* name of server */
117 	char **                 ns_addresses;           /* array of addresses for server */
118 	uint32_t                ns_addrcount;           /* # of addresses */
119 };
120 struct nfs_fs_path {
121 	char **                 np_components;          /* array of component pointers */
122 	uint32_t                np_compcount;           /* # components in path */
123 	uint32_t                np_compsize;            /* # allocated components */
124 };
125 struct nfs_fs_location {
126 	struct nfs_fs_server ** nl_servers;             /* array of server pointers */
127 	struct nfs_fs_path      nl_path;                /* file system path */
128 	uint32_t                nl_servcount;           /* # of servers */
129 };
130 
131 struct nfs_location_index {
132 	uint8_t                 nli_flags;              /* misc flags */
133 	uint8_t                 nli_loc;                /* location index */
134 	uint8_t                 nli_serv;               /* server index */
135 	uint8_t                 nli_addr;               /* address index */
136 };
137 #define NLI_VALID       0x01    /* index is valid */
138 
139 struct nfs_fs_locations {
140 	struct nfs_fs_path      nl_root;                /* current server's root file system path */
141 	uint32_t                nl_numlocs;             /* # of locations */
142 	struct nfs_location_index nl_current;           /* index of current location/server/address */
143 	struct nfs_fs_location **nl_locations;          /* array of fs locations */
144 };
145 
146 /*
147  * RPC record marker parsing state
148  */
149 struct nfs_rpc_record_state {
150 	mbuf_t                  nrrs_m;                 /* mbufs for current record */
151 	mbuf_t                  nrrs_mlast;
152 	uint16_t                nrrs_lastfrag;          /* last fragment of record */
153 	uint16_t                nrrs_markerleft;        /* marker bytes remaining */
154 	uint32_t                nrrs_fragleft;          /* fragment bytes remaining */
155 	uint32_t                nrrs_reclen;            /* length of RPC record */
156 };
157 
158 /*
159  * NFS socket structures
160  */
161 struct nfs_socket {
162 	lck_mtx_t               nso_lock;               /* nfs socket lock */
163 	TAILQ_ENTRY(nfs_socket) nso_link;               /* list of sockets */
164 	struct sockaddr *       nso_saddr;              /* socket address */
165 	struct sockaddr *       nso_saddr2;             /* additional socket address */
166 	void *                  nso_wake;               /* address to wake up */
167 	time_t                  nso_timestamp;
168 	time_t                  nso_reqtimestamp;       /* last request sent */
169 	socket_t                nso_so;                 /* socket */
170 	uint8_t                 nso_sotype;             /* Type of socket */
171 	uint16_t                nso_flags;              /* NSO_* flags */
172 	struct nfs_location_index nso_location;         /* location index */
173 	uint32_t                nso_protocol;           /* RPC protocol */
174 	uint32_t                nso_version;            /* RPC protocol version */
175 	uint32_t                nso_pingxid;            /* RPC XID of NULL ping request */
176 	uint32_t                nso_nfs_min_vers;       /* minimum nfs version for connecting sockets */
177 	uint32_t                nso_nfs_max_vers;       /* maximum nfs version for connecting sockets */
178 	int                     nso_error;              /* saved error/status */
179 	struct nfs_rpc_record_state nso_rrs;            /* RPC record parsing state (TCP) */
180 };
181 
182 TAILQ_HEAD(nfssocketlist, nfs_socket);
183 
184 /* nso_flags */
185 #define NSO_UPCALL              0x0001                  /* socket upcall in progress */
186 #define NSO_DEAD                0x0002                  /* socket is dead */
187 #define NSO_CONNECTING          0x0004                  /* socket is being connected */
188 #define NSO_CONNECTED           0x0008                  /* socket connection complete */
189 #define NSO_PINGING             0x0010                  /* socket is being tested */
190 #define NSO_VERIFIED            0x0020                  /* socket appears functional */
191 #define NSO_DISCONNECTING       0x0040                  /* socket is being disconnected */
192 
193 /* NFS connect socket search state */
194 struct nfs_socket_search {
195 	struct nfs_location_index nss_startloc;         /* starting location index */
196 	struct nfs_location_index nss_nextloc;          /* next location index */
197 	struct nfssocketlist    nss_socklist;           /* list of active sockets */
198 	time_t                  nss_timestamp;          /* search start time */
199 	time_t                  nss_last;               /* timestamp of last socket */
200 	struct nfs_socket *     nss_sock;               /* found socket */
201 	uint8_t                 nss_sotype;             /* TCP/UDP */
202 	uint8_t                 nss_sockcnt;            /* # of active sockets */
203 	in_port_t               nss_port;               /* port # to connect to */
204 	uint32_t                nss_protocol;           /* RPC protocol */
205 	uint32_t                nss_version;            /* RPC protocol version */
206 	uint32_t                nss_flags;              /* (see below) */
207 	int                     nss_addrcnt;            /* Number addresses to try or left */
208 	int                     nss_timeo;              /* how long we are willing to wait */
209 	int                     nss_error;              /* best error we've gotten so far */
210 };
211 /* nss_flags */
212 #define NSS_VERBOSE             0x00000001              /* OK to log info about socket search */
213 #define NSS_WARNED              0x00000002              /* logged warning about socket search taking a while */
214 #define NSS_FALLBACK2PMAP       0x00000004              /* Try V4 on NFS_PORT first, if that fails fall back to portmapper */
215 
216 /*
217  * function table for calling version-specific NFS functions
218  */
219 struct nfs_funcs {
220 	int     (*nf_mount)(struct nfsmount *, vfs_context_t, nfsnode_t *);
221 	int     (*nf_update_statfs)(struct nfsmount *, vfs_context_t);
222 	int     (*nf_getquota)(struct nfsmount *, vfs_context_t, uid_t, int, struct dqblk *);
223 	int     (*nf_access_rpc)(nfsnode_t, u_int32_t *, int, vfs_context_t);
224 	int     (*nf_getattr_rpc)(nfsnode_t, mount_t, u_char *, size_t, int, vfs_context_t, struct nfs_vattr *, u_int64_t *);
225 	int     (*nf_setattr_rpc)(nfsnode_t, struct vnode_attr *, vfs_context_t);
226 	int     (*nf_read_rpc_async)(nfsnode_t, off_t, size_t, thread_t, kauth_cred_t, struct nfsreq_cbinfo *, struct nfsreq **);
227 	int     (*nf_read_rpc_async_finish)(nfsnode_t, struct nfsreq *, uio_t, size_t *, int *);
228 	int     (*nf_readlink_rpc)(nfsnode_t, char *, size_t *, vfs_context_t);
229 	int     (*nf_write_rpc_async)(nfsnode_t, uio_t, size_t, thread_t, kauth_cred_t, int, struct nfsreq_cbinfo *, struct nfsreq **);
230 	int     (*nf_write_rpc_async_finish)(nfsnode_t, struct nfsreq *, int *, size_t *, uint64_t *);
231 	int     (*nf_commit_rpc)(nfsnode_t, uint64_t, uint64_t, kauth_cred_t, uint64_t);
232 	int     (*nf_lookup_rpc_async)(nfsnode_t, char *, int, vfs_context_t, struct nfsreq **);
233 	int     (*nf_lookup_rpc_async_finish)(nfsnode_t, char *, int, vfs_context_t, struct nfsreq *, u_int64_t *, fhandle_t *, struct nfs_vattr *);
234 	int     (*nf_remove_rpc)(nfsnode_t, char *, int, thread_t, kauth_cred_t);
235 	int     (*nf_rename_rpc)(nfsnode_t, char *, int, nfsnode_t, char *, int, vfs_context_t);
236 	int     (*nf_setlock_rpc)(nfsnode_t, struct nfs_open_file *, struct nfs_file_lock *, int, int, thread_t, kauth_cred_t);
237 	int     (*nf_unlock_rpc)(nfsnode_t, struct nfs_lock_owner *, int, uint64_t, uint64_t, int, thread_t, kauth_cred_t);
238 	int     (*nf_getlock_rpc)(nfsnode_t, struct nfs_lock_owner *, struct flock *, uint64_t, uint64_t, vfs_context_t);
239 };
240 
241 /*
242  * The long form of the NFSv4 client ID.
243  */
244 struct nfs_client_id {
245 	TAILQ_ENTRY(nfs_client_id)      nci_link;       /* list of client IDs */
246 	char                            *nci_id;        /* client id buffer */
247 	long                            nci_idlen;      /* length of client id buffer */
248 };
249 TAILQ_HEAD(nfsclientidlist, nfs_client_id);
250 extern struct nfsclientidlist nfsclientids;
251 
252 /*
253  * Mount structure.
254  * One allocated on every NFS mount.
255  * Holds NFS specific information for mount.
256  */
257 struct nfsmount {
258 	lck_mtx_t nm_lock;              /* nfs mount lock */
259 	char *  nm_args;                /* NFS mount args (XDR) */
260 	uint32_t nm_mattrs[NFS_MATTR_BITMAP_LEN]; /* mount attributes in mount args */
261 	uint32_t nm_mflags_mask[NFS_MFLAG_BITMAP_LEN]; /* mount flags mask in mount args */
262 	uint32_t nm_mflags[NFS_MFLAG_BITMAP_LEN]; /* mount flags in mount args */
263 	uint32_t nm_flags[NFS_MFLAG_BITMAP_LEN]; /* current mount flags (soft, intr, etc...) */
264 	char *  nm_realm;               /* Kerberos realm to use */
265 	char *  nm_principal;           /* GSS principal to use on initial mount */
266 	char *  nm_sprinc;              /* Kerberos principal of the server */
267 	int     nm_ref;                 /* Reference count on this mount */
268 	int     nm_state;               /* Internal state flags */
269 	int     nm_vers;                /* NFS version */
270 	uint32_t nm_minor_vers;         /* minor version of above */
271 	uint32_t nm_min_vers;           /* minimum packed version to try */
272 	uint32_t nm_max_vers;           /* maximum packed version to try */
273 	const struct nfs_funcs *nm_funcs;/* version-specific functions */
274 	kauth_cred_t nm_mcred;          /* credential used for the mount */
275 	mount_t nm_mountp;              /* VFS structure for this filesystem */
276 	nfsnode_t nm_dnp;               /* root directory nfsnode pointer */
277 	struct nfs_fs_locations nm_locations; /* file system locations */
278 	uint32_t nm_numgrps;            /* Max. size of groupslist */
279 	TAILQ_HEAD(, nfs_gss_clnt_ctx) nm_gsscl;        /* GSS user contexts */
280 	uint32_t nm_ncentries;          /* GSS expired negative cache entries */
281 	int     nm_timeo;               /* Init timer for NFSMNT_DUMBTIMR */
282 	int     nm_retry;               /* Max retries */
283 	uint32_t nm_rsize;              /* Max size of read rpc */
284 	uint32_t nm_wsize;              /* Max size of write rpc */
285 	uint32_t nm_biosize;            /* buffer I/O size */
286 	uint32_t nm_readdirsize;        /* Size of a readdir rpc */
287 	uint32_t nm_readahead;          /* Num. of blocks to readahead */
288 	time_t   nm_acregmin;           /* reg file min attr cache timeout */
289 	time_t   nm_acregmax;           /* reg file max attr cache timeout */
290 	time_t   nm_acdirmin;           /* dir min attr cache timeout */
291 	time_t   nm_acdirmax;           /* dir max attr cache timeout */
292 	uint32_t nm_auth;               /* security mechanism flavor being used */
293 	uint32_t nm_writers;            /* Number of nodes open for writing */
294 	uint32_t nm_mappers;            /* Number of nodes that have mmapped */
295 	struct nfs_sec nm_sec;          /* acceptable security mechanism flavors */
296 	struct nfs_sec nm_servsec;      /* server's acceptable security mechanism flavors */
297 	struct nfs_etype nm_etype;      /* If using kerberos, the support session key encryption types */
298 	fhandle_t *nm_fh;               /* initial file handle */
299 	uint32_t  nm_lockmode;          /* advisory file locking mode */
300 	/* mount info */
301 	time_t nm_fsattrstamp;          /* timestamp for fs attrs */
302 	struct nfs_fsattr nm_fsattr;    /* file system attributes */
303 	uint64_t nm_verf;               /* v3/v4 write verifier */
304 	union {
305 		struct {                /* v2/v3 specific fields */
306 			TAILQ_ENTRY(nfsmount) ldlink; /* chain of mounts registered for lockd use */
307 			int udp_sent;   /* UDP request send count */
308 			int udp_cwnd;   /* UDP request congestion window */
309 			struct nfs_reqqhead udp_cwndq; /* requests waiting on cwnd */
310 			struct sockaddr *rqsaddr;/* cached rquota socket address */
311 			uint64_t rqsaddrstamp; /* timestamp of rquota socket address */
312 		} v3;
313 		struct {                /* v4 specific fields */
314 			struct nfs_client_id *longid; /* client ID, long form */
315 			uint64_t mounttime; /* used as client ID verifier */
316 			uint64_t clientid; /* client ID, short form */
317 			thread_call_t renew_timer; /* RENEW timer call */
318 			nfs_fsid fsid;  /* NFS file system id */
319 			TAILQ_HEAD(, nfsnode) delegations; /* list of nodes with delegations */
320 			TAILQ_HEAD(, nfsnode) dreturnq; /* list of nodes with delegations to return */
321 			TAILQ_ENTRY(nfsmount) cblink; /* chain of mounts registered for callbacks */
322 			uint32_t cbid;  /* callback channel identifier */
323 			uint32_t cbrefs; /* # callbacks using this mount */
324 		} v4;
325 	} nm_un;
326 	/* common state */
327 	TAILQ_HEAD(, nfs_open_owner) nm_open_owners; /* list of open owners */
328 	uint32_t nm_stateinuse;         /* state in use counter */
329 	uint32_t nm_stategenid;         /* state generation counter */
330 	time_t  nm_recover_start;       /* recover start time */
331 	LIST_HEAD(, nfsnode) nm_monlist; /* list of nodes being monitored */
332 	/* async I/O queue */
333 	struct nfs_reqqhead nm_resendq; /* async I/O resend queue */
334 	struct nfs_reqqhead nm_iodq;    /* async I/O request queue */
335 	struct nfsiod *nm_niod;         /* nfsiod processing this mount */
336 	TAILQ_ENTRY(nfsmount) nm_iodlink; /* chain of mounts awaiting nfsiod */
337 	int     nm_asyncwrites;         /* outstanding async I/O writes */
338 	/* socket state */
339 	uint8_t nm_sofamily;            /* (preferred) protocol family of socket */
340 	uint8_t nm_sotype;              /* (preferred) type of socket */
341 	in_port_t       nm_nfsport;     /* NFS protocol port */
342 	in_port_t       nm_mountport;   /* MOUNT protocol port (v2/v3) */
343 	char    *nm_nfs_localport;      /* Unix domain address (port) for nfs */
344 	char    *nm_mount_localport;    /* Unix domain address (port) for mountd */
345 	struct nfs_socket_search *nm_nss; /* current socket search structure */
346 	struct nfs_socket *nm_nso;      /* current socket */
347 	struct sockaddr *nm_saddr;      /* Address of server */
348 	u_short nm_sockflags;           /* socket state flags */
349 	time_t  nm_deadto_start;        /* dead timeout start time */
350 	time_t  nm_reconnect_start;     /* reconnect start time */
351 	int     nm_tprintf_initial_delay;       /* delay first "server down" */
352 	int     nm_tprintf_delay;       /* delay between "server down" */
353 	int     nm_deadtimeout;         /* delay between first "server down" and dead set at mount time */
354 	int     nm_curdeadtimeout;      /* current dead timeout. Adjusted by mount state and mobility */
355 	int     nm_srtt[4];             /* Timers for RPCs */
356 	int     nm_sdrtt[4];
357 	int     nm_timeouts;            /* Request timeouts */
358 	int     nm_jbreqs;              /* # R_JBTPRINTFMSG requests */
359 	int     nm_mounterror;          /* status of mount connect */
360 	TAILQ_ENTRY(nfsmount) nm_pokeq; /* mount poke queue chain */
361 	thread_t nm_sockthd;            /* socket thread for this mount */
362 };
363 
364 /* macro for checking current mount flags */
365 #define NMFLAG(NMP, F)          NFS_BITMAP_ISSET((NMP)->nm_flags, NFS_MFLAG_ ## F)
366 /* macros for checking (original) mount attributes/flags */
367 #define NM_OMATTR_GIVEN(NMP, F) NFS_BITMAP_ISSET((NMP)->nm_mattrs, NFS_MATTR_ ## F)
368 #define NM_OMFLAG_GIVEN(NMP, F) NFS_BITMAP_ISSET((NMP)->nm_mflags_mask, NFS_MFLAG_ ## F)
369 #define NM_OMFLAG(NMP, F)       NFS_BITMAP_ISSET((NMP)->nm_mflags, NFS_MFLAG_ ## F)
370 
371 /*
372  * NFS mount state flags (nm_state)
373  */
374 #define NFSSTA_SPLIT_OPEN_OWNER 0x00000020  /* open-owner is based on uid and pid */
375 #define NFSSTA_MOUNT_THREAD     0x00000040  /* nfs_mount_connect_thread running */
376 #define NFSSTA_MONITOR_SCAN     0x00000080  /* scan of monitored nodes in progress */
377 #define NFSSTA_UNMOUNTING       0x00000100  /* an unmount attempt is in progress */
378 #define NFSSTA_NEEDSECINFO      0x00000200  /* need to fetch security info */
379 #define NFSSTA_CLIENTID         0x00000400  /* short client ID is valid */
380 #define NFSSTA_BIGCOOKIES       0x00000800  /* have seen >32bit dir cookies */
381 #define NFSSTA_JUKEBOXTIMEO     0x00001000  /* experienced a jukebox timeout */
382 #define NFSSTA_LOCKTIMEO        0x00002000  /* experienced a lock req timeout */
383 #define NFSSTA_MOUNTED          0x00004000  /* completely mounted */
384 #define NFSSTA_LOCKSWORK        0x00008000  /* lock ops have worked. */
385 #define NFSSTA_TIMEO            0x00010000  /* experienced a timeout. */
386 #define NFSSTA_FORCE            0x00020000  /* doing a forced unmount. */
387 #define NFSSTA_HASWRITEVERF     0x00040000  /* Has write verifier for V3 */
388 #define NFSSTA_GOTPATHCONF      0x00080000  /* Got the V3 pathconf info */
389 #define NFSSTA_GOTFSINFO        0x00100000  /* Got the V3 fsinfo */
390 #define NFSSTA_WANTRQUOTA       0x00200000  /* Want rquota address */
391 #define NFSSTA_RQUOTAINPROG     0x00400000  /* Getting rquota address */
392 #define NFSSTA_SENDING          0x00800000  /* Sending on socket */
393 #define NFSSTA_SNDLOCK          0x01000000  /* Send socket lock */
394 #define NFSSTA_WANTSND          0x02000000  /* Want above */
395 #define NFSSTA_DEAD             0x04000000  /* mount is dead */
396 #define NFSSTA_RECOVER          0x08000000  /* mount state needs to be recovered */
397 #define NFSSTA_RECOVER_EXPIRED  0x10000000  /* mount state expired */
398 #define NFSSTA_REVOKE           0x20000000  /* need to scan for revoked nodes */
399 #define NFSSTA_SQUISHY          0x40000000  /* we can ask to be forcibly unmounted */
400 #define NFSSTA_MOUNT_DRAIN      0x80000000  /* mount is draining references */
401 
402 /* flags for nm_sockflags */
403 #define NMSOCK_READY            0x0001  /* socket is ready for use */
404 #define NMSOCK_CONNECTING       0x0002  /* socket is being connect()ed */
405 #define NMSOCK_SETUP            0x0004  /* socket/connection is being set up */
406 #define NMSOCK_UNMOUNT          0x0008  /* unmounted, no more socket activity */
407 #define NMSOCK_HASCONNECTED     0x0010  /* socket has connected before */
408 #define NMSOCK_POKE             0x0020  /* socket needs to be poked */
409 #define NMSOCK_DISCONNECTING    0x0080  /* socket is being disconnected */
410 
411 /* aliases for version-specific fields */
412 #define nm_ldlink       nm_un.v3.ldlink
413 #define nm_sent         nm_un.v3.udp_sent
414 #define nm_cwnd         nm_un.v3.udp_cwnd
415 #define nm_cwndq        nm_un.v3.udp_cwndq
416 #define nm_rqproto      nm_un.v3.rqproto
417 #define nm_rqsaddr      nm_un.v3.rqsaddr
418 #define nm_rqsaddrstamp nm_un.v3.rqsaddrstamp
419 #define nm_longid       nm_un.v4.longid
420 #define nm_clientid     nm_un.v4.clientid
421 #define nm_mounttime    nm_un.v4.mounttime
422 #define nm_fsid         nm_un.v4.fsid
423 #define nm_renew_timer  nm_un.v4.renew_timer
424 #define nm_cbid         nm_un.v4.cbid
425 #define nm_cblink       nm_un.v4.cblink
426 #define nm_cbrefs       nm_un.v4.cbrefs
427 #define nm_delegations  nm_un.v4.delegations
428 #define nm_dreturnq     nm_un.v4.dreturnq
429 
430 #if defined(KERNEL)
431 /*
432  * Macros to convert from various things to mount structures.
433  */
434 #define VFSTONFS(mp)    ((mp) ? ((struct nfsmount *)vfs_fsprivate(mp)) : NULL)
435 #define VTONMP(vp)      VFSTONFS(vnode_mount(vp))
436 #define NFSTONMP(np)    VTONMP(NFSTOV(np))
437 #define NFSTOMP(np)     (vnode_mount(NFSTOV(np)))
438 
439 extern bool nfs_fs_path_init(struct nfs_fs_path *fsp, uint32_t count);
440 
441 extern void nfs_fs_path_replace(struct nfs_fs_path *dst, struct nfs_fs_path *src);
442 
443 extern void nfs_fs_path_destroy(struct nfs_fs_path *fsp);
444 
445 #endif /* KERNEL */
446 
447 #endif /* __APPLE_API_PRIVATE */
448 #endif /* _NFS_NFSMOUNT_H_ */
449