]> git.saurik.com Git - apple/xnu.git/blame - bsd/nfs/nfsmount.h
xnu-1228.0.2.tar.gz
[apple/xnu.git] / bsd / nfs / nfsmount.h
CommitLineData
1c79356b 1/*
2d21ac55 2 * Copyright (c) 2000-2007 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
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
9bccf70c
A
72#include <sys/appleapiopts.h>
73
74#ifdef __APPLE_API_PRIVATE
2d21ac55
A
75
76/*
77 * NFS mount file system attributes
78 */
79struct nfs_fsattr {
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 */
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_FHTYPE_MASK 0xFF000000
109#define NFS_FSFLAG_FHTYPE_SHIFT 24
110
111/*
112 * function table for calling version-specific NFS functions
113 */
114struct nfs_funcs {
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, u_long, int, struct dqblk *);
118 int (*nf_access_rpc)(nfsnode_t, u_long *, 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, int);
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 *, struct uio *, size_t *, int *);
123 int (*nf_readlink_rpc)(nfsnode_t, char *, uint32_t *, vfs_context_t);
124 int (*nf_write_rpc_async)(nfsnode_t, struct uio *, 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);
131};
132
1c79356b
A
133/*
134 * Mount structure.
135 * One allocated on every NFS mount.
136 * Holds NFS specific information for mount.
137 */
2d21ac55
A
138struct nfsmount {
139 lck_mtx_t nm_lock; /* nfs mount lock */
1c79356b 140 int nm_flag; /* Flags for soft/hard... */
55e303ae 141 int nm_state; /* Internal state flags */
2d21ac55
A
142 int nm_vers; /* NFS version */
143 struct nfs_funcs *nm_funcs; /* version-specific functions */
144 mount_t nm_mountp; /* VFS structure for this filesystem */
145 nfsnode_t nm_dnp; /* root directory nfsnode pointer */
1c79356b 146 int nm_numgrps; /* Max. size of groupslist */
2d21ac55 147 TAILQ_HEAD(, nfs_gss_clnt_ctx) nm_gsscl; /* GSS user contexts */
1c79356b
A
148 int nm_timeo; /* Init timer for NFSMNT_DUMBTIMR */
149 int nm_retry; /* Max retries */
1c79356b
A
150 int nm_rsize; /* Max size of read rpc */
151 int nm_wsize; /* Max size of write rpc */
0c530ab8 152 int nm_biosize; /* buffer I/O size */
1c79356b
A
153 int nm_readdirsize; /* Size of a readdir rpc */
154 int nm_readahead; /* Num. of blocks to readahead */
91447636
A
155 int nm_acregmin; /* reg file min attr cache timeout */
156 int nm_acregmax; /* reg file max attr cache timeout */
157 int nm_acdirmin; /* dir min attr cache timeout */
158 int nm_acdirmax; /* dir max attr cache timeout */
2d21ac55
A
159 uint32_t nm_auth; /* security mechanism flavor */
160 /* mount info */
161 uint32_t nm_fsattrstamp; /* timestamp for fs attrs */
162 struct nfs_fsattr nm_fsattr; /* file system attributes */
163 uint64_t nm_verf; /* v3/v4 write verifier */
164 union {
165 struct { /* v2/v3 specific fields */
166 u_short rqport; /* cached rquota port */
167 uint32_t rqportstamp; /* timestamp of rquota port */
168 } v3;
169 struct { /* v4 specific fields */
170 uint64_t clientid; /* client ID */
171 uint64_t mounttime; /* mount verifier */
172 thread_call_t renew_timer; /* RENEW timer call */
173 } v4;
174 } nm_un;
175 /* async I/O queue */
176 struct nfs_reqqhead nm_resendq; /* async I/O resend queue */
177 struct nfs_reqqhead nm_iodq; /* async I/O request queue */
178 struct nfsiod *nm_niod; /* nfsiod processing this mount */
179 TAILQ_ENTRY(nfsmount) nm_iodlink; /* chain of mounts awaiting nfsiod */
180 int nm_asyncwrites; /* outstanding async I/O writes */
181 /* socket state */
182 int nm_sotype; /* Type of socket */
183 int nm_soproto; /* and protocol */
184 mbuf_t nm_nam; /* Address of server */
185 u_short nm_sockflags; /* socket state flags */
186 socket_t nm_so; /* RPC socket */
187 int nm_reconnect_start; /* reconnect start time */
55e303ae
A
188 int nm_tprintf_initial_delay; /* delay first "server down" */
189 int nm_tprintf_delay; /* delay between "server down" */
2d21ac55
A
190 int nm_srtt[4]; /* Timers for RPCs */
191 int nm_sdrtt[4];
192 int nm_timeouts; /* Request timeouts */
193 union {
194 struct {
195 int sent; /* Request send count */
196 int cwnd; /* Request congestion window */
197 struct nfs_reqqhead cwndq; /* requests waiting on cwnd */
198 } udp;
199 struct {
200 u_int32_t mleft;/* marker bytes remaining */
201 u_int32_t fleft;/* fragment bytes remaining */
202 u_int32_t len; /* length of RPC record */
203 mbuf_t m; /* mbufs for current record */
204 mbuf_t mlast;
205 } tcp;
206 } nm_sockstate;
207 TAILQ_ENTRY(nfsmount) nm_pokeq; /* mount poke queue chain */
208 thread_t nm_sockthd; /* socket thread for this mount */
1c79356b
A
209};
210
2d21ac55
A
211/*
212 * NFS mount state flags (nm_state)
213 */
214#define NFSSTA_JUKEBOXTIMEO 0x00001000 /* experienced a jukebox timeout */
215#define NFSSTA_LOCKTIMEO 0x00002000 /* experienced a lock req timeout */
216#define NFSSTA_MOUNTED 0x00004000 /* completely mounted */
217#define NFSSTA_LOCKSWORK 0x00008000 /* lock ops have worked. */
218#define NFSSTA_TIMEO 0x00010000 /* experienced a timeout. */
219#define NFSSTA_FORCE 0x00020000 /* doing a forced unmount. */
220#define NFSSTA_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */
221#define NFSSTA_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */
222#define NFSSTA_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */
223#define NFSSTA_SNDLOCK 0x01000000 /* Send socket lock */
224#define NFSSTA_WANTSND 0x02000000 /* Want above */
225
226/* flags for nm_sockflags */
227#define NMSOCK_READY 0x0001 /* socket is ready for use */
228#define NMSOCK_CONNECTING 0x0002 /* socket is being connect()ed */
229#define NMSOCK_SETUP 0x0004 /* socket/connection is being set up */
230#define NMSOCK_UNMOUNT 0x0008 /* unmounted, no more socket activity */
231#define NMSOCK_LASTFRAG 0x0010 /* on last fragment of RPC record */
232#define NMSOCK_POKE 0x0020 /* socket needs to be poked */
233#define NMSOCK_UPCALL 0x0040 /* socket upcall in progress */
234
235/* aliases for socket state variables */
236#define nm_sent nm_sockstate.udp.sent
237#define nm_cwnd nm_sockstate.udp.cwnd
238#define nm_cwndq nm_sockstate.udp.cwndq
239#define nm_markerleft nm_sockstate.tcp.mleft
240#define nm_fragleft nm_sockstate.tcp.fleft
241#define nm_reclen nm_sockstate.tcp.len
242#define nm_m nm_sockstate.tcp.m
243#define nm_mlast nm_sockstate.tcp.mlast
244
245/* aliases for version-specific fields */
246#define nm_rqport nm_un.v3.rqport
247#define nm_rqportstamp nm_un.v3.rqportstamp
248#define nm_clientid nm_un.v4.clientid
249#define nm_mounttime nm_un.v4.mounttime
250#define nm_renew_timer nm_un.v4.renew_timer
55e303ae 251
1c79356b
A
252#if defined(KERNEL)
253/*
2d21ac55 254 * Macros to convert from various things to mount structures.
1c79356b 255 */
91447636 256#define VFSTONFS(mp) ((mp) ? ((struct nfsmount *)vfs_fsprivate(mp)) : NULL)
2d21ac55
A
257#define VTONMP(vp) VFSTONFS(vnode_mount(vp))
258#define NFSTONMP(np) VTONMP(NFSTOV(np))
259#define NFSTOMP(np) (vnode_mount(NFSTOV(np)))
1c79356b
A
260
261#endif /* KERNEL */
262
9bccf70c
A
263#endif /* __APPLE_API_PRIVATE */
264#endif /* _NFS_NFSMOUNT_H_ */