1 /* $NetBSD: nfs_var.h,v 1.76 2007/12/20 23:03:14 dsl Exp $ */
4 * Copyright (c) 1996 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
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.
40 * XXX needs <nfs/rpcv2.h> and <nfs/nfs.h> because of typedefs
44 #include <sys/mallocvar.h>
47 MALLOC_DECLARE(M_NFSD
);
48 MALLOC_DECLARE(M_NFSDIROFF
);
71 struct nfsrv_descript
;
77 int nfs_bioread(struct vnode
*, struct uio
*, int, kauth_cred_t
, int);
78 struct buf
*nfs_getcacheblk(struct vnode
*, daddr_t
, int, struct lwp
*);
79 int nfs_vinvalbuf(struct vnode
*, int, kauth_cred_t
, struct lwp
*, int);
80 int nfs_flushstalebuf(struct vnode
*, kauth_cred_t
, struct lwp
*, int);
81 #define NFS_FLUSHSTALEBUF_MYWRITE 1 /* assume writes are ours */
82 int nfs_asyncio(struct buf
*);
83 int nfs_doio(struct buf
*);
86 /* see nfsdiskless.h */
89 void nfs_kqinit(void);
92 void nfs_nhinit(void);
93 void nfs_nhreinit(void);
94 void nfs_nhdone(void);
95 int nfs_nget1(struct mount
*, nfsfh_t
*, int, struct nfsnode
**, int);
96 #define nfs_nget(mp, fhp, fhsize, npp) \
97 nfs_nget1((mp), (fhp), (fhsize), (npp), 0)
100 int nfs_null(struct vnode
*, kauth_cred_t
, struct lwp
*);
101 int nfs_setattrrpc(struct vnode
*, struct vattr
*, kauth_cred_t
, struct lwp
*);
102 int nfs_readlinkrpc(struct vnode
*, struct uio
*, kauth_cred_t
);
103 int nfs_readrpc(struct vnode
*, struct uio
*);
104 int nfs_writerpc(struct vnode
*, struct uio
*, int *, bool, bool *);
105 int nfs_mknodrpc(struct vnode
*, struct vnode
**, struct componentname
*,
107 int nfs_removeit(struct sillyrename
*);
108 int nfs_removerpc(struct vnode
*, const char *, int, kauth_cred_t
,
110 int nfs_renameit(struct vnode
*, struct componentname
*, struct sillyrename
*);
111 int nfs_renamerpc(struct vnode
*, const char *, int, struct vnode
*,
112 const char *, int, kauth_cred_t
, struct lwp
*);
113 int nfs_readdirrpc(struct vnode
*, struct uio
*, kauth_cred_t
);
114 int nfs_readdirplusrpc(struct vnode
*, struct uio
*, kauth_cred_t
);
115 int nfs_sillyrename(struct vnode
*, struct vnode
*, struct componentname
*,
117 int nfs_lookitup(struct vnode
*, const char *, int, kauth_cred_t
,
118 struct lwp
*, struct nfsnode
**);
119 int nfs_commit(struct vnode
*, off_t
, uint32_t, struct lwp
*);
120 int nfs_flush(struct vnode
*, kauth_cred_t
, int, struct lwp
*, int);
123 int nfsrv3_access(struct nfsrv_descript
*, struct nfssvc_sock
*,
124 struct lwp
*, struct mbuf
**);
125 int nfsrv_getattr(struct nfsrv_descript
*, struct nfssvc_sock
*,
126 struct lwp
*, struct mbuf
**);
127 int nfsrv_setattr(struct nfsrv_descript
*, struct nfssvc_sock
*,
128 struct lwp
*, struct mbuf
**);
129 int nfsrv_lookup(struct nfsrv_descript
*, struct nfssvc_sock
*,
130 struct lwp
*, struct mbuf
**);
131 int nfsrv_readlink(struct nfsrv_descript
*, struct nfssvc_sock
*,
132 struct lwp
*, struct mbuf
**);
133 int nfsrv_read(struct nfsrv_descript
*, struct nfssvc_sock
*,
134 struct lwp
*, struct mbuf
**);
135 int nfsrv_write(struct nfsrv_descript
*, struct nfssvc_sock
*,
136 struct lwp
*, struct mbuf
**);
137 int nfsrv_writegather(struct nfsrv_descript
**, struct nfssvc_sock
*,
138 struct lwp
*, struct mbuf
**);
139 void nfsrvw_coalesce(struct nfsrv_descript
*, struct nfsrv_descript
*);
140 int nfsrv_create(struct nfsrv_descript
*, struct nfssvc_sock
*,
141 struct lwp
*, struct mbuf
**);
142 int nfsrv_mknod(struct nfsrv_descript
*, struct nfssvc_sock
*,
143 struct lwp
*, struct mbuf
**);
144 int nfsrv_remove(struct nfsrv_descript
*, struct nfssvc_sock
*,
145 struct lwp
*, struct mbuf
**);
146 int nfsrv_rename(struct nfsrv_descript
*, struct nfssvc_sock
*,
147 struct lwp
*, struct mbuf
**);
148 int nfsrv_link(struct nfsrv_descript
*, struct nfssvc_sock
*,
149 struct lwp
*, struct mbuf
**);
150 int nfsrv_symlink(struct nfsrv_descript
*, struct nfssvc_sock
*,
151 struct lwp
*, struct mbuf
**);
152 int nfsrv_mkdir(struct nfsrv_descript
*, struct nfssvc_sock
*,
153 struct lwp
*, struct mbuf
**);
154 int nfsrv_rmdir(struct nfsrv_descript
*, struct nfssvc_sock
*,
155 struct lwp
*, struct mbuf
**);
156 int nfsrv_readdir(struct nfsrv_descript
*, struct nfssvc_sock
*,
157 struct lwp
*, struct mbuf
**);
158 int nfsrv_readdirplus(struct nfsrv_descript
*, struct nfssvc_sock
*,
159 struct lwp
*, struct mbuf
**);
160 int nfsrv_commit(struct nfsrv_descript
*, struct nfssvc_sock
*,
161 struct lwp
*, struct mbuf
**);
162 int nfsrv_statfs(struct nfsrv_descript
*, struct nfssvc_sock
*,
163 struct lwp
*, struct mbuf
**);
164 int nfsrv_fsinfo(struct nfsrv_descript
*, struct nfssvc_sock
*,
165 struct lwp
*, struct mbuf
**);
166 int nfsrv_pathconf(struct nfsrv_descript
*, struct nfssvc_sock
*,
167 struct lwp
*, struct mbuf
**);
168 int nfsrv_null(struct nfsrv_descript
*, struct nfssvc_sock
*,
169 struct lwp
*, struct mbuf
**);
170 int nfsrv_noop(struct nfsrv_descript
*, struct nfssvc_sock
*,
171 struct lwp
*, struct mbuf
**);
172 int nfsrv_access(struct vnode
*, int, kauth_cred_t
, int, struct lwp
*, int);
175 int nfs_connect(struct nfsmount
*, struct nfsreq
*, struct lwp
*);
176 int nfs_reconnect(struct nfsreq
*);
177 void nfs_disconnect(struct nfsmount
*);
178 void nfs_safedisconnect(struct nfsmount
*);
179 int nfs_send(struct socket
*, struct mbuf
*, struct mbuf
*, struct nfsreq
*,
181 int nfs_receive(struct nfsreq
*, struct mbuf
**, struct mbuf
**, struct lwp
*);
182 int nfs_reply(struct nfsreq
*, struct lwp
*);
183 int nfs_request(struct nfsnode
*, struct mbuf
*, int, struct lwp
*,
184 kauth_cred_t
, struct mbuf
**, struct mbuf
**, char **, int *);
185 int nfs_rephead(int, struct nfsrv_descript
*, struct nfssvc_sock
*,
186 int, int, u_quad_t
*, struct mbuf
**, struct mbuf
**, char **);
187 void nfs_timer(void *);
188 void nfs_timer_init(void);
189 void nfs_timer_start(void);
190 int nfs_sigintr(struct nfsmount
*, struct nfsreq
*, struct lwp
*);
191 int nfs_getreq(struct nfsrv_descript
*, struct nfsd
*, int);
192 int nfs_msg(struct lwp
*, const char *, const char *);
193 void nfsrv_soupcall(struct socket
*, void *, int);
194 void nfsrv_rcv(struct nfssvc_sock
*);
195 int nfsrv_getstream(struct nfssvc_sock
*, int);
196 int nfsrv_dorec(struct nfssvc_sock
*, struct nfsd
*, struct nfsrv_descript
**,
198 void nfsrv_wakenfsd(struct nfssvc_sock
*);
199 int nfsdsock_lock(struct nfssvc_sock
*, bool);
200 void nfsdsock_unlock(struct nfssvc_sock
*);
201 int nfsdsock_drain(struct nfssvc_sock
*);
202 int nfsdsock_sendreply(struct nfssvc_sock
*, struct nfsrv_descript
*);
203 void nfsdreq_init(void);
204 struct nfsrv_descript
*nfsdreq_alloc(void);
205 void nfsdreq_free(struct nfsrv_descript
*);
207 void nfsdsock_setbits(struct nfssvc_sock
*, int);
208 void nfsdsock_clearbits(struct nfssvc_sock
*, int);
209 bool nfsdsock_testbits(struct nfssvc_sock
*, int);
212 void nfsrv_initcache(void);
213 int nfsrv_getcache(struct nfsrv_descript
*, struct nfssvc_sock
*,
215 void nfsrv_updatecache(struct nfsrv_descript
*, int, struct mbuf
*);
216 void nfsrv_cleancache(void);
219 struct mbuf
*nfsm_reqh(struct nfsnode
*, u_long
, int, char **);
220 struct mbuf
*nfsm_rpchead(kauth_cred_t
, int, int, int, int, char *, int,
221 char *, struct mbuf
*, int, struct mbuf
**, u_int32_t
*);
222 int nfsm_mbuftouio(struct mbuf
**, struct uio
*, int, char **);
223 int nfsm_uiotombuf(struct uio
*, struct mbuf
**, int, char **);
224 int nfsm_disct(struct mbuf
**, char **, int, int, char **);
225 int nfs_adv(struct mbuf
**, char **, int, int);
226 int nfsm_strtmbuf(struct mbuf
**, char **, const char *, long);
227 u_long
nfs_dirhash(off_t
);
228 void nfs_initdircache(struct vnode
*);
229 void nfs_initdirxlatecookie(struct vnode
*);
230 struct nfsdircache
*nfs_searchdircache(struct vnode
*, off_t
, int, int *);
231 struct nfsdircache
*nfs_enterdircache(struct vnode
*, off_t
, off_t
, int,
233 void nfs_putdircache(struct nfsnode
*, struct nfsdircache
*);
234 void nfs_invaldircache(struct vnode
*, int);
235 #define NFS_INVALDIRCACHE_FORCE 1
236 #define NFS_INVALDIRCACHE_KEEPEOF 2
237 void nfs_init
__P((void));
238 int nfsm_loadattrcache(struct vnode
**, struct mbuf
**, char **,
239 struct vattr
*, int flags
);
240 int nfs_loadattrcache(struct vnode
**, struct nfs_fattr
*, struct vattr
*,
242 int nfs_getattrcache(struct vnode
*, struct vattr
*);
243 void nfs_delayedtruncate(struct vnode
*);
244 int nfs_check_wccdata(struct nfsnode
*, const struct timespec
*,
245 struct timespec
*, bool);
246 int nfs_namei(struct nameidata
*, nfsrvfh_t
*, uint32_t, struct nfssvc_sock
*,
247 struct mbuf
*, struct mbuf
**, char **, struct vnode
**, struct lwp
*,
249 void nfs_zeropad(struct mbuf
*, int, int);
250 void nfsm_srvwcc(struct nfsrv_descript
*, int, struct vattr
*, int,
251 struct vattr
*, struct mbuf
**, char **);
252 void nfsm_srvpostopattr(struct nfsrv_descript
*, int, struct vattr
*,
253 struct mbuf
**, char **);
254 void nfsm_srvfattr(struct nfsrv_descript
*, struct vattr
*, struct nfs_fattr
*);
255 int nfsrv_fhtovp(nfsrvfh_t
*, int, struct vnode
**, kauth_cred_t
,
256 struct nfssvc_sock
*, struct mbuf
*, int *, int, int);
257 int nfs_ispublicfh
__P((const nfsrvfh_t
*));
258 int netaddr_match(int, union nethostaddr
*, struct mbuf
*);
259 time_t nfs_attrtimeo(struct nfsmount
*, struct nfsnode
*);
261 /* flags for nfs_loadattrcache and friends */
262 #define NAC_NOTRUNC 1 /* don't truncate file size */
264 void nfs_clearcommit(struct mount
*);
265 void nfs_merge_commit_ranges(struct vnode
*);
266 int nfs_in_committed_range(struct vnode
*, off_t
, off_t
);
267 int nfs_in_tobecommitted_range(struct vnode
*, off_t
, off_t
);
268 void nfs_add_committed_range(struct vnode
*, off_t
, off_t
);
269 void nfs_del_committed_range(struct vnode
*, off_t
, off_t
);
270 void nfs_add_tobecommitted_range(struct vnode
*, off_t
, off_t
);
271 void nfs_del_tobecommitted_range(struct vnode
*, off_t
, off_t
);
273 int nfsrv_errmap(struct nfsrv_descript
*, int);
274 void nfs_cookieheuristic(struct vnode
*, int *, struct lwp
*, kauth_cred_t
);
276 u_int32_t
nfs_getxid(void);
277 void nfs_renewxid(struct nfsreq
*);
279 int nfsrv_composefh(struct vnode
*, nfsrvfh_t
*, bool);
280 int nfsrv_comparefh(const nfsrvfh_t
*, const nfsrvfh_t
*);
281 void nfsrv_copyfh(nfsrvfh_t
*, const nfsrvfh_t
*);
284 struct sys_getfh_args
;
285 struct sys_nfssvc_args
;
286 int sys_getfh(struct lwp
*, const struct sys_getfh_args
*, register_t
*);
287 int sys_nfssvc(struct lwp
*, const struct sys_nfssvc_args
*, register_t
*);
288 int nfssvc_addsock(struct file
*, struct mbuf
*);
289 int nfssvc_nfsd(struct nfsd_srvargs
*, void *, struct lwp
*);
290 void nfsrv_zapsock(struct nfssvc_sock
*);
291 void nfsrv_slpderef(struct nfssvc_sock
*);
292 void nfsrv_init(int);
293 void nfs_iodinit(void);
294 int nfs_set_niothreads(int);
295 int nfs_getauth(struct nfsmount
*, struct nfsreq
*, kauth_cred_t
, char **,
296 int *, char *, int *, NFSKERBKEY_T
);
297 int nfs_getnickauth(struct nfsmount
*, kauth_cred_t
, char **, int *, char *,
299 int nfs_savenickauth(struct nfsmount
*, kauth_cred_t
, int, NFSKERBKEY_T
,
300 struct mbuf
**, char **, struct mbuf
*);
303 extern struct nfs_public nfs_pub
;
304 int mountd_set_exports_list(const struct mountd_exports_list
*, struct lwp
*);
305 int netexport_check(const fsid_t
*, struct mbuf
*, struct mount
**, int *,
307 void netexport_rdlock(void);
308 void netexport_rdunlock(void);
310 int nfs_update_exports_30(struct mount
*, const char *,
311 struct mnt_export_args30
*, struct lwp
*);