nfs_var.h revision 1.59 1 /* $NetBSD: nfs_var.h,v 1.59 2006/05/14 21:32:21 elad Exp $ */
2
3 /*-
4 * Copyright (c) 1996 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Christos Zoulas.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 /*
40 * XXX needs <nfs/rpcv2.h> and <nfs/nfs.h> because of typedefs
41 */
42
43 #ifdef _KERNEL
44 #include <sys/mallocvar.h>
45 #include <sys/pool.h>
46
47 MALLOC_DECLARE(M_NFSREQ);
48 MALLOC_DECLARE(M_NFSMNT);
49 MALLOC_DECLARE(M_NFSUID);
50 MALLOC_DECLARE(M_NFSD);
51 MALLOC_DECLARE(M_NFSDIROFF);
52 MALLOC_DECLARE(M_NFSBIGFH);
53 MALLOC_DECLARE(M_NQLEASE);
54 extern struct pool nfs_srvdesc_pool;
55
56 struct vnode;
57 struct uio;
58 struct proc;
59 struct buf;
60 struct nfs_diskless;
61 struct sockaddr_in;
62 struct nfs_dlmount;
63 struct vnode;
64 struct nfsd;
65 struct mbuf;
66 struct file;
67 struct nqlease;
68 struct nqhost;
69 struct nfssvc_sock;
70 struct nfsmount;
71 struct socket;
72 struct nfsreq;
73 struct vattr;
74 struct nameidata;
75 struct nfsnode;
76 struct sillyrename;
77 struct componentname;
78 struct nfsd_srvargs;
79 struct nfsrv_descript;
80 struct nfs_fattr;
81 struct nfsdircache;
82 union nethostaddr;
83
84 /* nfs_bio.c */
85 int nfs_bioread(struct vnode *, struct uio *, int, kauth_cred_t, int);
86 struct buf *nfs_getcacheblk(struct vnode *, daddr_t, int, struct lwp *);
87 int nfs_vinvalbuf(struct vnode *, int, kauth_cred_t, struct lwp *, int);
88 int nfs_flushstalebuf(struct vnode *, kauth_cred_t, struct lwp *, int);
89 #define NFS_FLUSHSTALEBUF_MYWRITE 1 /* assume writes are ours */
90 int nfs_asyncio(struct buf *);
91 int nfs_doio(struct buf *);
92
93 /* nfs_boot.c */
94 /* see nfsdiskless.h */
95
96 /* nfs_kq.c */
97 void nfs_kqinit(void);
98
99 /* nfs_node.c */
100 void nfs_nhinit(void);
101 void nfs_nhreinit(void);
102 void nfs_nhdone(void);
103 int nfs_nget1(struct mount *, nfsfh_t *, int, struct nfsnode **, int);
104 #define nfs_nget(mp, fhp, fhsize, npp) \
105 nfs_nget1((mp), (fhp), (fhsize), (npp), 0)
106
107 /* nfs_vnops.c */
108 int nfs_null(struct vnode *, kauth_cred_t, struct lwp *);
109 int nfs_setattrrpc(struct vnode *, struct vattr *, kauth_cred_t, struct lwp *);
110 int nfs_readlinkrpc(struct vnode *, struct uio *, kauth_cred_t);
111 int nfs_readrpc(struct vnode *, struct uio *);
112 int nfs_writerpc(struct vnode *, struct uio *, int *, boolean_t, boolean_t *);
113 int nfs_mknodrpc(struct vnode *, struct vnode **, struct componentname *,
114 struct vattr *);
115 int nfs_removeit(struct sillyrename *);
116 int nfs_removerpc(struct vnode *, const char *, int, kauth_cred_t,
117 struct lwp *);
118 int nfs_renameit(struct vnode *, struct componentname *, struct sillyrename *);
119 int nfs_renamerpc(struct vnode *, const char *, int, struct vnode *,
120 const char *, int, kauth_cred_t, struct lwp *);
121 int nfs_readdirrpc(struct vnode *, struct uio *, kauth_cred_t);
122 int nfs_readdirplusrpc(struct vnode *, struct uio *, kauth_cred_t);
123 int nfs_sillyrename(struct vnode *, struct vnode *, struct componentname *);
124 int nfs_lookitup(struct vnode *, const char *, int, kauth_cred_t,
125 struct lwp *, struct nfsnode **);
126 int nfs_commit(struct vnode *, off_t, uint32_t, struct lwp *);
127 int nfs_flush(struct vnode *, kauth_cred_t, int, struct lwp *, int);
128
129 /* nfs_nqlease.c */
130 void nqnfs_lease_updatetime(int);
131 void nqnfs_clientlease(struct nfsmount *, struct nfsnode *, int, int, time_t,
132 u_quad_t);
133 void nqsrv_locklease(struct nqlease *);
134 void nqsrv_unlocklease(struct nqlease *);
135 int nqsrv_getlease(struct vnode *, u_int32_t *, int, struct nfssvc_sock *,
136 struct lwp *, struct mbuf *, int *, u_quad_t *, kauth_cred_t);
137 void nqsrv_addhost(struct nqhost *, struct nfssvc_sock *, struct mbuf *);
138 void nqsrv_instimeq(struct nqlease *, u_int32_t);
139 int nqsrv_cmpnam(struct nfssvc_sock *, struct mbuf *, struct nqhost *);
140 void nqsrv_send_eviction(struct vnode *, struct nqlease *,
141 struct nfssvc_sock *, struct mbuf *, kauth_cred_t, struct lwp *);
142 void nqsrv_waitfor_expiry(struct nqlease *);
143 void nqnfs_serverd(void);
144 int nqnfsrv_getlease(struct nfsrv_descript *, struct nfssvc_sock *,
145 struct lwp *, struct mbuf **);
146 int nqnfsrv_vacated(struct nfsrv_descript *, struct nfssvc_sock *,
147 struct lwp *, struct mbuf **);
148 int nqnfs_getlease(struct vnode *, int, kauth_cred_t, struct lwp *);
149 int nqnfs_vacated(struct vnode *, kauth_cred_t, struct lwp *);
150 int nqnfs_callback(struct nfsmount *, struct mbuf *, struct mbuf *,
151 caddr_t, struct lwp *);
152
153 /* nfs_serv.c */
154 int nfsrv3_access(struct nfsrv_descript *, struct nfssvc_sock *,
155 struct lwp *, struct mbuf **);
156 int nfsrv_getattr(struct nfsrv_descript *, struct nfssvc_sock *,
157 struct lwp *, struct mbuf **);
158 int nfsrv_setattr(struct nfsrv_descript *, struct nfssvc_sock *,
159 struct lwp *, struct mbuf **);
160 int nfsrv_lookup(struct nfsrv_descript *, struct nfssvc_sock *,
161 struct lwp *, struct mbuf **);
162 int nfsrv_readlink(struct nfsrv_descript *, struct nfssvc_sock *,
163 struct lwp *, struct mbuf **);
164 int nfsrv_read(struct nfsrv_descript *, struct nfssvc_sock *,
165 struct lwp *, struct mbuf **);
166 int nfsrv_write(struct nfsrv_descript *, struct nfssvc_sock *,
167 struct lwp *, struct mbuf **);
168 int nfsrv_writegather(struct nfsrv_descript **, struct nfssvc_sock *,
169 struct lwp *, struct mbuf **);
170 void nfsrvw_coalesce(struct nfsrv_descript *, struct nfsrv_descript *);
171 int nfsrv_create(struct nfsrv_descript *, struct nfssvc_sock *,
172 struct lwp *, struct mbuf **);
173 int nfsrv_mknod(struct nfsrv_descript *, struct nfssvc_sock *,
174 struct lwp *, struct mbuf **);
175 int nfsrv_remove(struct nfsrv_descript *, struct nfssvc_sock *,
176 struct lwp *, struct mbuf **);
177 int nfsrv_rename(struct nfsrv_descript *, struct nfssvc_sock *,
178 struct lwp *, struct mbuf **);
179 int nfsrv_link(struct nfsrv_descript *, struct nfssvc_sock *,
180 struct lwp *, struct mbuf **);
181 int nfsrv_symlink(struct nfsrv_descript *, struct nfssvc_sock *,
182 struct lwp *, struct mbuf **);
183 int nfsrv_mkdir(struct nfsrv_descript *, struct nfssvc_sock *,
184 struct lwp *, struct mbuf **);
185 int nfsrv_rmdir(struct nfsrv_descript *, struct nfssvc_sock *,
186 struct lwp *, struct mbuf **);
187 int nfsrv_readdir(struct nfsrv_descript *, struct nfssvc_sock *,
188 struct lwp *, struct mbuf **);
189 int nfsrv_readdirplus(struct nfsrv_descript *, struct nfssvc_sock *,
190 struct lwp *, struct mbuf **);
191 int nfsrv_commit(struct nfsrv_descript *, struct nfssvc_sock *,
192 struct lwp *, struct mbuf **);
193 int nfsrv_statfs(struct nfsrv_descript *, struct nfssvc_sock *,
194 struct lwp *, struct mbuf **);
195 int nfsrv_fsinfo(struct nfsrv_descript *, struct nfssvc_sock *,
196 struct lwp *, struct mbuf **);
197 int nfsrv_pathconf(struct nfsrv_descript *, struct nfssvc_sock *,
198 struct lwp *, struct mbuf **);
199 int nfsrv_null(struct nfsrv_descript *, struct nfssvc_sock *,
200 struct lwp *, struct mbuf **);
201 int nfsrv_noop(struct nfsrv_descript *, struct nfssvc_sock *,
202 struct lwp *, struct mbuf **);
203 int nfsrv_access(struct vnode *, int, kauth_cred_t, int, struct lwp *, int);
204
205 /* nfs_socket.c */
206 int nfs_connect(struct nfsmount *, struct nfsreq *, struct lwp *);
207 int nfs_reconnect(struct nfsreq *, struct lwp *);
208 void nfs_disconnect(struct nfsmount *);
209 void nfs_safedisconnect(struct nfsmount *);
210 int nfs_send(struct socket *, struct mbuf *, struct mbuf *, struct nfsreq *,
211 struct lwp *);
212 int nfs_receive(struct nfsreq *, struct mbuf **, struct mbuf **, struct lwp *);
213 int nfs_reply(struct nfsreq *, struct lwp *);
214 int nfs_request(struct nfsnode *, struct mbuf *, int, struct lwp *,
215 kauth_cred_t, struct mbuf **, struct mbuf **, caddr_t *, int *);
216 int nfs_rephead(int, struct nfsrv_descript *, struct nfssvc_sock *,
217 int, int, u_quad_t *, struct mbuf **, struct mbuf **, caddr_t *);
218 void nfs_timer(void *);
219 int nfs_sigintr(struct nfsmount *, struct nfsreq *, struct lwp *);
220 int nfs_sndlock(int *, struct nfsreq *);
221 void nfs_exit(struct proc *, void *);
222 void nfs_sndunlock(int *);
223 int nfs_rcvlock(struct nfsreq *);
224 void nfs_rcvunlock(struct nfsmount *);
225 int nfs_getreq(struct nfsrv_descript *, struct nfsd *, int);
226 int nfs_msg(struct lwp *, const char *, const char *);
227 void nfsrv_rcv(struct socket *, caddr_t, int);
228 int nfsrv_getstream(struct nfssvc_sock *, int);
229 int nfsrv_dorec(struct nfssvc_sock *, struct nfsd *, struct nfsrv_descript **);
230 void nfsrv_wakenfsd(struct nfssvc_sock *);
231 int nfsdsock_lock(struct nfssvc_sock *, boolean_t);
232 void nfsdsock_unlock(struct nfssvc_sock *);
233 int nfsdsock_drain(struct nfssvc_sock *);
234 int nfsdsock_sendreply(struct nfssvc_sock *, struct nfsrv_descript *);
235
236 /* nfs_srvcache.c */
237 void nfsrv_initcache(void);
238 int nfsrv_getcache(struct nfsrv_descript *, struct nfssvc_sock *,
239 struct mbuf **);
240 void nfsrv_updatecache(struct nfsrv_descript *, int, struct mbuf *);
241 void nfsrv_cleancache(void);
242
243 /* nfs_subs.c */
244 struct mbuf *nfsm_reqh(struct nfsnode *, u_long, int, caddr_t *);
245 struct mbuf *nfsm_rpchead(kauth_cred_t, int, int, int, int, char *, int,
246 char *, struct mbuf *, int, struct mbuf **, u_int32_t *);
247 int nfsm_mbuftouio(struct mbuf **, struct uio *, int, caddr_t *);
248 int nfsm_uiotombuf(struct uio *, struct mbuf **, int, caddr_t *);
249 int nfsm_disct(struct mbuf **, caddr_t *, int, int, caddr_t *);
250 int nfs_adv(struct mbuf **, caddr_t *, int, int);
251 int nfsm_strtmbuf(struct mbuf **, char **, const char *, long);
252 u_long nfs_dirhash(off_t);
253 void nfs_initdircache(struct vnode *);
254 void nfs_initdirxlatecookie(struct vnode *);
255 struct nfsdircache *nfs_searchdircache(struct vnode *, off_t, int, int *);
256 struct nfsdircache *nfs_enterdircache(struct vnode *, off_t, off_t, int,
257 daddr_t);
258 void nfs_putdircache(struct nfsnode *, struct nfsdircache *);
259 void nfs_invaldircache(struct vnode *, int);
260 #define NFS_INVALDIRCACHE_FORCE 1
261 #define NFS_INVALDIRCACHE_KEEPEOF 2
262 void nfs_init __P((void));
263 int nfsm_loadattrcache(struct vnode **, struct mbuf **, caddr_t *,
264 struct vattr *, int flags);
265 int nfs_loadattrcache(struct vnode **, struct nfs_fattr *, struct vattr *,
266 int flags);
267 int nfs_getattrcache(struct vnode *, struct vattr *);
268 void nfs_delayedtruncate(struct vnode *);
269 int nfs_check_wccdata(struct nfsnode *, const struct timespec *,
270 struct timespec *, boolean_t);
271 int nfs_namei(struct nameidata *, fhandle_t *, uint32_t, struct nfssvc_sock *,
272 struct mbuf *, struct mbuf **, caddr_t *, struct vnode **, struct lwp *,
273 int, int);
274 void nfs_zeropad(struct mbuf *, int, int);
275 void nfsm_srvwcc(struct nfsrv_descript *, int, struct vattr *, int,
276 struct vattr *, struct mbuf **, char **);
277 void nfsm_srvpostopattr(struct nfsrv_descript *, int, struct vattr *,
278 struct mbuf **, char **);
279 void nfsm_srvfattr(struct nfsrv_descript *, struct vattr *, struct nfs_fattr *);
280 int nfsrv_fhtovp(fhandle_t *, int, struct vnode **, kauth_cred_t,
281 struct nfssvc_sock *, struct mbuf *, int *, int, int);
282 int nfs_ispublicfh __P((fhandle_t *));
283 int netaddr_match(int, union nethostaddr *, struct mbuf *);
284
285 /* flags for nfs_loadattrcache and friends */
286 #define NAC_NOTRUNC 1 /* don't truncate file size */
287
288 void nfs_clearcommit(struct mount *);
289 void nfs_merge_commit_ranges(struct vnode *);
290 int nfs_in_committed_range(struct vnode *, off_t, off_t);
291 int nfs_in_tobecommitted_range(struct vnode *, off_t, off_t);
292 void nfs_add_committed_range(struct vnode *, off_t, off_t);
293 void nfs_del_committed_range(struct vnode *, off_t, off_t);
294 void nfs_add_tobecommitted_range(struct vnode *, off_t, off_t);
295 void nfs_del_tobecommitted_range(struct vnode *, off_t, off_t);
296
297 int nfsrv_errmap(struct nfsrv_descript *, int);
298 void nfsrvw_sort(gid_t *, int);
299 void nfsrv_setcred(kauth_cred_t, kauth_cred_t *);
300 void nfs_cookieheuristic(struct vnode *, int *, struct lwp *, kauth_cred_t);
301
302 u_int32_t nfs_getxid(void);
303 void nfs_renewxid(struct nfsreq *);
304
305 /* nfs_syscalls.c */
306 int sys_getfh(struct lwp *, void *, register_t *);
307 int sys_nfssvc(struct lwp *, void *, register_t *);
308 int nfssvc_addsock(struct file *, struct mbuf *);
309 int nfssvc_nfsd(struct nfsd_srvargs *, caddr_t, struct lwp *);
310 void nfsrv_zapsock(struct nfssvc_sock *);
311 void nfsrv_slpderef(struct nfssvc_sock *);
312 void nfsrv_init(int);
313 int nfssvc_iod(struct lwp *);
314 void nfs_iodinit(void);
315 void start_nfsio(void *);
316 void nfs_getset_niothreads(int);
317 int nfs_getauth(struct nfsmount *, struct nfsreq *, kauth_cred_t, char **,
318 int *, char *, int *, NFSKERBKEY_T);
319 int nfs_getnickauth(struct nfsmount *, kauth_cred_t, char **, int *, char *,
320 int);
321 int nfs_savenickauth(struct nfsmount *, kauth_cred_t, int, NFSKERBKEY_T,
322 struct mbuf **, char **, struct mbuf *);
323
324 /* nfs_export.c */
325 extern struct nfs_public nfs_pub;
326 int mountd_set_exports_list(const struct mountd_exports_list *, struct lwp *);
327 int netexport_check(const fsid_t *, struct mbuf *, struct mount **, int *,
328 kauth_cred_t *);
329 void netexport_rdlock(void);
330 void netexport_rdunlock(void);
331 #ifdef COMPAT_30
332 int nfs_update_exports_30(struct mount *, const char *, void *, struct lwp *);
333 #endif
334 #endif /* _KERNEL */
335