2 * Copyright (c) 2000-2009 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
28 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
30 * Copyright (c) 1989, 1993
31 * The Regents of the University of California. All rights reserved.
33 * This code is derived from software contributed to Berkeley by
34 * Rick Macklem at The University of Guelph.
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
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.
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
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 $
69 #ifndef _NFS_NFSMOUNT_H_
70 #define _NFS_NFSMOUNT_H_
72 #include <sys/appleapiopts.h>
74 #ifdef __APPLE_API_PRIVATE
77 * NFS mount file system attributes
80 uint32_t nfsa_flags
; /* file system flags */
81 uint32_t nfsa_lease
; /* lease time in seconds */
82 uint32_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 uint64_t nfsa_maxread
; /* maximum read size */
88 uint64_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 */
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_FHTYPE_MASK 0xFF000000
109 #define NFS_FSFLAG_FHTYPE_SHIFT 24
112 * function table for calling version-specific NFS functions
115 int (*nf_mount
)(struct nfsmount
*, vfs_context_t
, struct user_nfs_args
*, nfsnode_t
*);
116 int (*nf_update_statfs
)(struct nfsmount
*, vfs_context_t
);
117 int (*nf_getquota
)(struct nfsmount
*, vfs_context_t
, uid_t
, int, struct dqblk
*);
118 int (*nf_access_rpc
)(nfsnode_t
, u_int32_t
*, vfs_context_t
);
119 int (*nf_getattr_rpc
)(nfsnode_t
, mount_t
, u_char
*, size_t, vfs_context_t
, struct nfs_vattr
*, u_int64_t
*);
120 int (*nf_setattr_rpc
)(nfsnode_t
, struct vnode_attr
*, vfs_context_t
);
121 int (*nf_read_rpc_async
)(nfsnode_t
, off_t
, size_t, thread_t
, kauth_cred_t
, struct nfsreq_cbinfo
*, struct nfsreq
**);
122 int (*nf_read_rpc_async_finish
)(nfsnode_t
, struct nfsreq
*, uio_t
, size_t *, int *);
123 int (*nf_readlink_rpc
)(nfsnode_t
, char *, uint32_t *, vfs_context_t
);
124 int (*nf_write_rpc_async
)(nfsnode_t
, uio_t
, size_t, thread_t
, kauth_cred_t
, int, struct nfsreq_cbinfo
*, struct nfsreq
**);
125 int (*nf_write_rpc_async_finish
)(nfsnode_t
, struct nfsreq
*, int *, size_t *, uint64_t *);
126 int (*nf_commit_rpc
)(nfsnode_t
, uint64_t, uint64_t, kauth_cred_t
);
127 int (*nf_lookup_rpc_async
)(nfsnode_t
, char *, int, vfs_context_t
, struct nfsreq
**);
128 int (*nf_lookup_rpc_async_finish
)(nfsnode_t
, vfs_context_t
, struct nfsreq
*, u_int64_t
*, fhandle_t
*, struct nfs_vattr
*);
129 int (*nf_remove_rpc
)(nfsnode_t
, char *, int, thread_t
, kauth_cred_t
);
130 int (*nf_rename_rpc
)(nfsnode_t
, char *, int, nfsnode_t
, char *, int, vfs_context_t
);
134 * The long form of the NFSv4 client ID.
136 struct nfs_client_id
{
137 TAILQ_ENTRY(nfs_client_id
) nci_link
; /* list of client IDs */
138 char *nci_id
; /* client id buffer */
139 int nci_idlen
; /* length of client id buffer */
141 TAILQ_HEAD(nfsclientidlist
, nfs_client_id
);
142 __private_extern__
struct nfsclientidlist nfsclientids
;
146 * One allocated on every NFS mount.
147 * Holds NFS specific information for mount.
150 lck_mtx_t nm_lock
; /* nfs mount lock */
151 int nm_flag
; /* Flags for soft/hard... */
152 int nm_state
; /* Internal state flags */
153 int nm_vers
; /* NFS version */
154 struct nfs_funcs
*nm_funcs
; /* version-specific functions */
155 mount_t nm_mountp
; /* VFS structure for this filesystem */
156 nfsnode_t nm_dnp
; /* root directory nfsnode pointer */
157 int nm_numgrps
; /* Max. size of groupslist */
158 TAILQ_HEAD(, nfs_gss_clnt_ctx
) nm_gsscl
; /* GSS user contexts */
159 int nm_timeo
; /* Init timer for NFSMNT_DUMBTIMR */
160 int nm_retry
; /* Max retries */
161 uint32_t nm_rsize
; /* Max size of read rpc */
162 uint32_t nm_wsize
; /* Max size of write rpc */
163 uint32_t nm_biosize
; /* buffer I/O size */
164 uint32_t nm_readdirsize
; /* Size of a readdir rpc */
165 int nm_readahead
; /* Num. of blocks to readahead */
166 int nm_acregmin
; /* reg file min attr cache timeout */
167 int nm_acregmax
; /* reg file max attr cache timeout */
168 int nm_acdirmin
; /* dir min attr cache timeout */
169 int nm_acdirmax
; /* dir max attr cache timeout */
170 uint32_t nm_auth
; /* security mechanism flavor */
172 uint32_t nm_fsattrstamp
; /* timestamp for fs attrs */
173 struct nfs_fsattr nm_fsattr
; /* file system attributes */
174 uint64_t nm_verf
; /* v3/v4 write verifier */
176 struct { /* v2/v3 specific fields */
177 u_short rqport
; /* cached rquota port */
178 uint32_t rqportstamp
; /* timestamp of rquota port */
180 struct { /* v4 specific fields */
181 struct nfs_client_id
*longid
; /* client ID, long form */
182 uint64_t mounttime
; /* used as client ID verifier */
183 uint64_t clientid
; /* client ID, short form */
184 thread_call_t renew_timer
; /* RENEW timer call */
185 TAILQ_HEAD(, nfs_open_owner
) open_owners
; /* list of open owners */
186 TAILQ_HEAD(, nfsnode
) recallq
; /* list of nodes with recalled delegations */
187 TAILQ_ENTRY(nfsmount
) cblink
; /* chain of mounts registered for callbacks */
188 uint32_t stateinuse
; /* state in use counter */
189 uint32_t stategenid
; /* state generation counter */
190 kauth_cred_t mcred
; /* credential used for the mount */
191 uint32_t cbid
; /* callback channel identifier */
192 uint32_t cbrefs
; /* # callbacks using this mount */
195 /* async I/O queue */
196 struct nfs_reqqhead nm_resendq
; /* async I/O resend queue */
197 struct nfs_reqqhead nm_iodq
; /* async I/O request queue */
198 struct nfsiod
*nm_niod
; /* nfsiod processing this mount */
199 TAILQ_ENTRY(nfsmount
) nm_iodlink
; /* chain of mounts awaiting nfsiod */
200 int nm_asyncwrites
; /* outstanding async I/O writes */
202 int nm_sotype
; /* Type of socket */
203 int nm_soproto
; /* and protocol */
204 mbuf_t nm_nam
; /* Address of server */
205 u_short nm_sockflags
; /* socket state flags */
206 socket_t nm_so
; /* RPC socket */
207 time_t nm_deadto_start
; /* dead timeout start time */
208 time_t nm_reconnect_start
; /* reconnect start time */
209 int nm_tprintf_initial_delay
; /* delay first "server down" */
210 int nm_tprintf_delay
; /* delay between "server down" */
211 int nm_deadtimeout
; /* delay between first "server down" and dead */
212 int nm_srtt
[4]; /* Timers for RPCs */
214 int nm_timeouts
; /* Request timeouts */
215 int nm_jbreqs
; /* # R_JBTPRINTFMSG requests */
218 int sent
; /* Request send count */
219 int cwnd
; /* Request congestion window */
220 struct nfs_reqqhead cwndq
; /* requests waiting on cwnd */
223 u_int32_t mleft
;/* marker bytes remaining */
224 u_int32_t fleft
;/* fragment bytes remaining */
225 u_int32_t len
; /* length of RPC record */
226 mbuf_t m
; /* mbufs for current record */
230 TAILQ_ENTRY(nfsmount
) nm_pokeq
; /* mount poke queue chain */
231 thread_t nm_sockthd
; /* socket thread for this mount */
235 * NFS mount state flags (nm_state)
237 #define NFSSTA_BIGCOOKIES 0x00000800 /* have seen >32bit dir cookies */
238 #define NFSSTA_JUKEBOXTIMEO 0x00001000 /* experienced a jukebox timeout */
239 #define NFSSTA_LOCKTIMEO 0x00002000 /* experienced a lock req timeout */
240 #define NFSSTA_MOUNTED 0x00004000 /* completely mounted */
241 #define NFSSTA_LOCKSWORK 0x00008000 /* lock ops have worked. */
242 #define NFSSTA_TIMEO 0x00010000 /* experienced a timeout. */
243 #define NFSSTA_FORCE 0x00020000 /* doing a forced unmount. */
244 #define NFSSTA_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */
245 #define NFSSTA_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */
246 #define NFSSTA_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */
247 #define NFSSTA_SNDLOCK 0x01000000 /* Send socket lock */
248 #define NFSSTA_WANTSND 0x02000000 /* Want above */
249 #define NFSSTA_DEAD 0x04000000 /* mount is dead */
250 #define NFSSTA_RECOVER 0x08000000 /* mount state needs to be recovered */
252 /* flags for nm_sockflags */
253 #define NMSOCK_READY 0x0001 /* socket is ready for use */
254 #define NMSOCK_CONNECTING 0x0002 /* socket is being connect()ed */
255 #define NMSOCK_SETUP 0x0004 /* socket/connection is being set up */
256 #define NMSOCK_UNMOUNT 0x0008 /* unmounted, no more socket activity */
257 #define NMSOCK_LASTFRAG 0x0010 /* on last fragment of RPC record */
258 #define NMSOCK_POKE 0x0020 /* socket needs to be poked */
259 #define NMSOCK_UPCALL 0x0040 /* socket upcall in progress */
261 /* aliases for socket state variables */
262 #define nm_sent nm_sockstate.udp.sent
263 #define nm_cwnd nm_sockstate.udp.cwnd
264 #define nm_cwndq nm_sockstate.udp.cwndq
265 #define nm_markerleft nm_sockstate.tcp.mleft
266 #define nm_fragleft nm_sockstate.tcp.fleft
267 #define nm_reclen nm_sockstate.tcp.len
268 #define nm_m nm_sockstate.tcp.m
269 #define nm_mlast nm_sockstate.tcp.mlast
271 /* aliases for version-specific fields */
272 #define nm_rqport nm_un.v3.rqport
273 #define nm_rqportstamp nm_un.v3.rqportstamp
274 #define nm_longid nm_un.v4.longid
275 #define nm_clientid nm_un.v4.clientid
276 #define nm_mounttime nm_un.v4.mounttime
277 #define nm_renew_timer nm_un.v4.renew_timer
278 #define nm_open_owners nm_un.v4.open_owners
279 #define nm_stateinuse nm_un.v4.stateinuse
280 #define nm_stategenid nm_un.v4.stategenid
281 #define nm_mcred nm_un.v4.mcred
282 #define nm_cbid nm_un.v4.cbid
283 #define nm_cblink nm_un.v4.cblink
284 #define nm_cbrefs nm_un.v4.cbrefs
285 #define nm_recallq nm_un.v4.recallq
289 * Macros to convert from various things to mount structures.
291 #define VFSTONFS(mp) ((mp) ? ((struct nfsmount *)vfs_fsprivate(mp)) : NULL)
292 #define VTONMP(vp) VFSTONFS(vnode_mount(vp))
293 #define NFSTONMP(np) VTONMP(NFSTOV(np))
294 #define NFSTOMP(np) (vnode_mount(NFSTOV(np)))
298 #endif /* __APPLE_API_PRIVATE */
299 #endif /* _NFS_NFSMOUNT_H_ */