xref: /netbsd/sys/nfs/nfs_var.h (revision c4a72b64)
1 /*	$NetBSD: nfs_var.h,v 1.25 2002/10/23 09:14:51 jdolecek 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 struct vnode;
44 struct uio;
45 struct ucred;
46 struct proc;
47 struct buf;
48 struct nfs_diskless;
49 struct sockaddr_in;
50 struct nfs_dlmount;
51 struct vnode;
52 struct nfsd;
53 struct mbuf;
54 struct file;
55 struct nqlease;
56 struct nqhost;
57 struct nfssvc_sock;
58 struct nfsmount;
59 struct socket;
60 struct nfsreq;
61 struct vattr;
62 struct nameidata;
63 struct nfsnode;
64 struct sillyrename;
65 struct componentname;
66 struct nfsd_srvargs;
67 struct nfsrv_descript;
68 struct nfs_fattr;
69 struct nfsdircache;
70 union nethostaddr;
71 
72 /* nfs_bio.c */
73 int nfs_bioread __P((struct vnode *, struct uio *, int, struct ucred *, int));
74 struct buf *nfs_getcacheblk __P((struct vnode *, daddr_t, int, struct proc *));
75 int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *,
76 		       int));
77 int nfs_asyncio __P((struct buf *));
78 int nfs_doio __P((struct buf *, struct proc *));
79 
80 /* nfs_boot.c */
81 /* see nfsdiskless.h */
82 
83 /* nfs_kq.c */
84 void nfs_kqinit __P((void));
85 
86 /* nfs_node.c */
87 void nfs_nhinit __P((void));
88 void nfs_nhreinit __P((void));
89 void nfs_nhdone __P((void));
90 int nfs_nget __P((struct mount *, nfsfh_t *, int, struct nfsnode **));
91 
92 /* nfs_vnops.c */
93 int nfs_null __P((struct vnode *, struct ucred *, struct proc *));
94 int nfs_setattrrpc __P((struct vnode *, struct vattr *, struct ucred *,
95 			struct proc *));
96 int nfs_readlinkrpc __P((struct vnode *, struct uio *, struct ucred *));
97 int nfs_readrpc __P((struct vnode *, struct uio *));
98 int nfs_writerpc __P((struct vnode *, struct uio *, int *, int *));
99 int nfs_mknodrpc __P((struct vnode *, struct vnode **, struct componentname *,
100 		      struct vattr *));
101 int nfs_removeit __P((struct sillyrename *));
102 int nfs_removerpc __P((struct vnode *, const char *, int, struct ucred *,
103 		       struct proc *));
104 int nfs_renameit __P((struct vnode *, struct componentname *,
105 		      struct sillyrename *));
106 int nfs_renamerpc __P((struct vnode *, const char *, int, struct vnode *,
107 		       const char *, int, struct ucred *, struct proc *));
108 int nfs_readdirrpc __P((struct vnode *, struct uio *, struct ucred *));
109 int nfs_readdirplusrpc __P((struct vnode *, struct uio *, struct ucred *));
110 int nfs_sillyrename __P((struct vnode *, struct vnode *,
111 			 struct componentname *));
112 int nfs_lookitup __P((struct vnode *, const char *, int, struct ucred *,
113 		      struct proc *, struct nfsnode **));
114 int nfs_commit __P((struct vnode *, off_t, uint32_t, struct proc *));
115 int nfs_flush __P((struct vnode *, struct ucred *, int, struct proc *, int));
116 
117 /* nfs_nqlease.c */
118 void nqnfs_lease_updatetime __P((int));
119 void nqnfs_clientlease __P((struct nfsmount *, struct nfsnode *, int, int,
120 			    time_t, u_quad_t));
121 void nqsrv_locklease __P((struct nqlease *));
122 void nqsrv_unlocklease __P((struct nqlease *));
123 int nqsrv_getlease __P((struct vnode *, u_int32_t *, int, struct nfssvc_sock *,
124 			struct proc *, struct mbuf *, int *, u_quad_t *,
125 			struct ucred *));
126 void nqsrv_addhost __P((struct nqhost *, struct nfssvc_sock *, struct mbuf *));
127 void nqsrv_instimeq __P((struct nqlease *, u_int32_t));
128 int nqsrv_cmpnam __P((struct nfssvc_sock *, struct mbuf *, struct nqhost *));
129 void nqsrv_send_eviction __P((struct vnode *, struct nqlease *,
130 			      struct nfssvc_sock *, struct mbuf *,
131 			      struct ucred *));
132 void nqsrv_waitfor_expiry __P((struct nqlease *));
133 void nqnfs_serverd __P((void));
134 int nqnfsrv_getlease __P((struct nfsrv_descript *, struct nfssvc_sock *,
135 			  struct proc *, struct mbuf **));
136 int nqnfsrv_vacated __P((struct nfsrv_descript *, struct nfssvc_sock *,
137 			 struct proc *, struct mbuf **));
138 int nqnfs_getlease __P((struct vnode *, int, struct ucred *, struct proc *));
139 int nqnfs_vacated __P((struct vnode *, struct ucred *));
140 int nqnfs_callback __P((struct nfsmount *, struct mbuf *, struct mbuf *,
141 			caddr_t));
142 
143 /* nfs_serv.c */
144 int nfsrv3_access __P((struct nfsrv_descript *, struct nfssvc_sock *,
145 		       struct proc *, struct mbuf **));
146 int nfsrv_getattr __P((struct nfsrv_descript *, struct nfssvc_sock *,
147 		       struct proc *, struct mbuf **));
148 int nfsrv_setattr __P((struct nfsrv_descript *, struct nfssvc_sock *,
149 		       struct proc *, struct mbuf **));
150 int nfsrv_lookup __P((struct nfsrv_descript *, struct nfssvc_sock *,
151 		      struct proc *, struct mbuf **));
152 int nfsrv_readlink __P((struct nfsrv_descript *, struct nfssvc_sock *,
153 			struct proc *, struct mbuf **));
154 int nfsrv_read __P((struct nfsrv_descript *, struct nfssvc_sock *,
155 		    struct proc *, struct mbuf **));
156 int nfsrv_write __P((struct nfsrv_descript *, struct nfssvc_sock *,
157 		     struct proc *, struct mbuf **));
158 int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *,
159 			   struct proc *, struct mbuf **));
160 void nfsrvw_coalesce __P((struct nfsrv_descript *, struct nfsrv_descript *));
161 int nfsrv_create __P((struct nfsrv_descript *, struct nfssvc_sock *,
162 		      struct proc *, struct mbuf **));
163 int nfsrv_mknod __P((struct nfsrv_descript *, struct nfssvc_sock *,
164 		     struct proc *, struct mbuf **));
165 int nfsrv_remove __P((struct nfsrv_descript *, struct nfssvc_sock *,
166 		      struct proc *, struct mbuf **));
167 int nfsrv_rename __P((struct nfsrv_descript *, struct nfssvc_sock *,
168 		      struct proc *, struct mbuf **));
169 int nfsrv_link __P((struct nfsrv_descript *, struct nfssvc_sock *,
170 		    struct proc *, struct mbuf **));
171 int nfsrv_symlink __P((struct nfsrv_descript *, struct nfssvc_sock *,
172 		       struct proc *, struct mbuf **));
173 int nfsrv_mkdir __P((struct nfsrv_descript *, struct nfssvc_sock *,
174 		     struct proc *, struct mbuf **));
175 int nfsrv_rmdir __P((struct nfsrv_descript *, struct nfssvc_sock *,
176 		     struct proc *, struct mbuf **));
177 int nfsrv_readdir __P((struct nfsrv_descript *, struct nfssvc_sock *,
178 		       struct proc *, struct mbuf **));
179 int nfsrv_readdirplus __P((struct nfsrv_descript *, struct nfssvc_sock *,
180 			   struct proc *, struct mbuf **));
181 int nfsrv_commit __P((struct nfsrv_descript *, struct nfssvc_sock *,
182 		      struct proc *, struct mbuf **));
183 int nfsrv_statfs __P((struct nfsrv_descript *, struct nfssvc_sock *,
184 		      struct proc *, struct mbuf **));
185 int nfsrv_fsinfo __P((struct nfsrv_descript *, struct nfssvc_sock *,
186 		      struct proc *, struct mbuf **));
187 int nfsrv_pathconf __P((struct nfsrv_descript *, struct nfssvc_sock *,
188 		        struct proc *, struct mbuf **));
189 int nfsrv_null __P((struct nfsrv_descript *, struct nfssvc_sock *,
190 		    struct proc *, struct mbuf **));
191 int nfsrv_noop __P((struct nfsrv_descript *, struct nfssvc_sock *,
192 		    struct proc *, struct mbuf **));
193 int nfsrv_access __P((struct vnode *, int, struct ucred *, int, struct proc *,
194 		      int));
195 
196 /* nfs_socket.c */
197 int nfs_connect __P((struct nfsmount *, struct nfsreq *));
198 int nfs_reconnect __P((struct nfsreq *));
199 void nfs_disconnect __P((struct nfsmount *));
200 void nfs_safedisconnect __P((struct nfsmount *));
201 int nfs_send __P((struct socket *, struct mbuf *, struct mbuf *,
202 		  struct nfsreq *));
203 int nfs_receive __P((struct nfsreq *, struct mbuf **, struct mbuf **));
204 int nfs_reply __P((struct nfsreq *));
205 int nfs_request __P((struct vnode *, struct mbuf *, int, struct proc *,
206 		     struct ucred *, struct mbuf **, struct mbuf **,
207 		     caddr_t *));
208 int nfs_rephead __P((int, struct nfsrv_descript *, struct nfssvc_sock *,
209 		     int, int, u_quad_t *, struct mbuf **, struct mbuf **,			     caddr_t *));
210 void nfs_timer __P((void *));
211 int nfs_sigintr __P((struct nfsmount *, struct nfsreq *, struct proc *));
212 int nfs_sndlock __P((int *, struct nfsreq *));
213 void nfs_exit __P((struct proc *, void *));
214 void nfs_sndunlock __P((int *));
215 int nfs_rcvlock __P((struct nfsreq *));
216 void nfs_rcvunlock __P((int *));
217 int nfs_getreq __P((struct nfsrv_descript *, struct nfsd *, int));
218 int nfs_msg __P((struct proc *, char *, char *));
219 void nfsrv_rcv __P((struct socket *, caddr_t, int));
220 int nfsrv_getstream __P((struct nfssvc_sock *, int));
221 int nfsrv_dorec __P((struct nfssvc_sock *, struct nfsd *,
222 		     struct nfsrv_descript **));
223 void nfsrv_wakenfsd __P((struct nfssvc_sock *));
224 
225 /* nfs_srvcache.c */
226 void nfsrv_initcache __P((void ));
227 int nfsrv_getcache __P((struct nfsrv_descript *, struct nfssvc_sock *,
228 			struct mbuf **));
229 void nfsrv_updatecache __P((struct nfsrv_descript *, int, struct mbuf *));
230 void nfsrv_cleancache __P((void));
231 
232 /* nfs_subs.c */
233 struct mbuf *nfsm_reqh __P((struct vnode *, u_long, int, caddr_t *));
234 struct mbuf *nfsm_rpchead __P((struct ucred *, int, int, int, int, char *, int,
235 			       char *, struct mbuf *, int, struct mbuf **,
236 			       u_int32_t *));
237 int nfsm_mbuftouio __P((struct mbuf **, struct uio *, int, caddr_t *));
238 int nfsm_uiotombuf __P((struct uio *, struct mbuf **, int, caddr_t *));
239 int nfsm_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *));
240 int nfs_adv __P((struct mbuf **, caddr_t *, int, int));
241 int nfsm_strtmbuf __P((struct mbuf **, char **, const char *, long));
242 u_long nfs_dirhash __P((off_t));
243 void nfs_initdircache __P((struct vnode *));
244 struct nfsdircache *nfs_searchdircache __P((struct vnode *, off_t, int, int *));
245 struct nfsdircache *nfs_enterdircache __P((struct vnode *, off_t, off_t,						   int, daddr_t));
246 void nfs_invaldircache __P((struct vnode *, int));
247 void nfs_init __P((void));
248 int nfsm_loadattrcache __P((struct vnode **, struct mbuf **, caddr_t *,
249 			   struct vattr *, int flags));
250 int nfs_loadattrcache __P((struct vnode **, struct nfs_fattr *,
251 			   struct vattr *, int flags));
252 int nfs_getattrcache __P((struct vnode *, struct vattr *));
253 void nfs_delayedtruncate __P((struct vnode *));
254 int nfs_namei __P((struct nameidata *, fhandle_t *, int, struct nfssvc_sock *,
255 		   struct mbuf *, struct mbuf **, caddr_t *, struct vnode **,
256 		   struct proc *, int, int));
257 void nfsm_adj __P((struct mbuf *, int, int));
258 void nfsm_srvwcc __P((struct nfsrv_descript *, int, struct vattr *, int,
259 		      struct vattr *, struct mbuf **, char **));
260 void nfsm_srvpostopattr __P((struct nfsrv_descript *, int, struct vattr *,
261 			     struct mbuf **, char **));
262 void nfsm_srvfattr __P((struct nfsrv_descript *, struct vattr *,
263 			struct nfs_fattr *));
264 int nfsrv_fhtovp __P((fhandle_t *, int, struct vnode **, struct ucred *,
265 		      struct nfssvc_sock *, struct mbuf *, int *, int, int));
266 int nfsrv_setpublicfs __P((struct mount *, struct netexport *,
267 			   struct export_args *));
268 int nfs_ispublicfh __P((fhandle_t *));
269 int netaddr_match __P((int, union nethostaddr *, struct mbuf *));
270 
271 /* flags for nfs_loadattrcache and friends */
272 #define	NAC_NOTRUNC	1	/* don't truncate file size */
273 
274 void nfs_clearcommit __P((struct mount *));
275 void nfs_merge_commit_ranges __P((struct vnode *));
276 int nfs_in_committed_range __P((struct vnode *, off_t, off_t));
277 int nfs_in_tobecommitted_range __P((struct vnode *, off_t, off_t));
278 void nfs_add_committed_range __P((struct vnode *, off_t, off_t));
279 void nfs_del_committed_range __P((struct vnode *, off_t, off_t));
280 void nfs_add_tobecommitted_range __P((struct vnode *, off_t, off_t));
281 void nfs_del_tobecommitted_range __P((struct vnode *, off_t, off_t));
282 
283 int nfsrv_errmap __P((struct nfsrv_descript *, int));
284 void nfsrvw_sort __P((gid_t *, int));
285 void nfsrv_setcred __P((struct ucred *, struct ucred *));
286 void nfs_cookieheuristic __P((struct vnode *, int *, struct proc *,
287 			      struct ucred *));
288 
289 /* nfs_syscalls.c */
290 int sys_getfh __P((struct proc *, void *, register_t *));
291 int sys_nfssvc __P((struct proc *, void *, register_t *));
292 int nfssvc_addsock __P((struct file *, struct mbuf *));
293 int nfssvc_nfsd __P((struct nfsd_srvargs *, caddr_t, struct proc *));
294 void nfsrv_zapsock __P((struct nfssvc_sock *));
295 void nfsrv_slpderef __P((struct nfssvc_sock *));
296 void nfsrv_init __P((int));
297 int nfssvc_iod __P((struct proc *));
298 void start_nfsio __P((void *));
299 void nfs_getset_niothreads __P((int));
300 int nfs_getauth __P((struct nfsmount *, struct nfsreq *, struct ucred *,
301 		     char **, int *, char *, int *, NFSKERBKEY_T));
302 int nfs_getnickauth __P((struct nfsmount *, struct ucred *, char **, int *,
303 			 char *, int));
304 int nfs_savenickauth __P((struct nfsmount *, struct ucred *, int, NFSKERBKEY_T,
305 			  struct mbuf **, char **, struct mbuf *));
306