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