xref: /openbsd-src/sys/nfs/nfs_var.h (revision 2b0358df1d88d06ef4139321dd05bd5e05d91eaf)
1 /*	$OpenBSD: nfs_var.h,v 1.49 2009/03/30 19:58:50 blambert Exp $	*/
2 /*	$NetBSD: nfs_var.h,v 1.3 1996/02/18 11:53:54 fvdl Exp $	*/
3 
4 /*
5  * Copyright (c) 1996 Christos Zoulas.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *	This product includes software developed by Christos Zoulas.
18  * 4. The name of the author may not be used to endorse or promote products
19  *    derived from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 /*
34  * XXX needs <nfs/rpcv2.h> and <nfs/nfs.h> because of typedefs.
35  */
36 #ifndef _NFS_NFS_VAR_H_
37 #define _NFS_NFS_VAR_H_
38 
39 #ifdef _KERNEL
40 
41 struct nfsnode;
42 struct sillyrename;
43 struct componentname;
44 struct nfs_diskless;
45 
46 /* nfs_bio.c */
47 int nfs_bioread(struct vnode *, struct uio *, int, struct ucred *);
48 int nfs_write(void *);
49 struct buf *nfs_getcacheblk(struct vnode *, daddr64_t, int, struct proc *);
50 int nfs_vinvalbuf(struct vnode *, int, struct ucred *, struct proc *);
51 int nfs_asyncio(struct buf *);
52 int nfs_doio(struct buf *, struct proc *);
53 
54 /* nfs_boot.c */
55 int nfs_boot_init(struct nfs_diskless *, struct proc *);
56 
57 /* nfs_node.c */
58 void nfs_nhinit(void);
59 int nfs_nget(struct mount *, nfsfh_t *, int, struct nfsnode **);
60 int nfs_inactive(void *);
61 int nfs_reclaim(void *);
62 
63 /* nfs_vnops.c */
64 int nfs_poll(void *);
65 int nfs_null(struct vnode *, struct ucred *, struct proc *);
66 int nfs_access(void *);
67 int nfs_open(void *);
68 int nfs_close(void *);
69 int nfs_getattr(void *);
70 int nfs_setattr(void *);
71 int nfs_setattrrpc(struct vnode *, struct vattr *, struct ucred *,
72 			struct proc *);
73 int nfs_lookup(void *);
74 int nfs_read(void *);
75 int nfs_readlink(void *);
76 int nfs_readlinkrpc(struct vnode *, struct uio *, struct ucred *);
77 int nfs_readrpc(struct vnode *, struct uio *);
78 int nfs_writerpc(struct vnode *, struct uio *, int *, int *);
79 int nfs_mknodrpc(struct vnode *, struct vnode **, struct componentname *,
80 		      struct vattr *);
81 int nfs_mknod(void *);
82 int nfs_create(void *);
83 int nfs_remove(void *);
84 int nfs_removeit(struct sillyrename *);
85 int nfs_removerpc(struct vnode *, char *, int, struct ucred *,
86 		       struct proc *);
87 int nfs_rename(void *);
88 int nfs_renameit(struct vnode *, struct componentname *,
89 		      struct sillyrename *);
90 int nfs_renamerpc(struct vnode *, char *, int, struct vnode *, char *, int,
91 		       struct ucred *, struct proc *);
92 int nfs_link(void *);
93 int nfs_symlink(void *);
94 int nfs_mkdir(void *);
95 int nfs_rmdir(void *);
96 int nfs_readdir(void *);
97 int nfs_readdirrpc(struct vnode *, struct uio *, struct ucred *, int *);
98 int nfs_readdirplusrpc(struct vnode *, struct uio *, struct ucred *, int *);
99 int nfs_sillyrename(struct vnode *, struct vnode *,
100 			 struct componentname *);
101 int nfs_lookitup(struct vnode *, char *, int, struct ucred *,
102 		      struct proc *, struct nfsnode **);
103 int nfs_commit(struct vnode *, u_quad_t, int, struct proc *);
104 int nfs_bmap(void *);
105 int nfs_strategy(void *);
106 int nfs_mmap(void *);
107 int nfs_fsync(void *);
108 int nfs_flush(struct vnode *, struct ucred *, int, struct proc *, int);
109 int nfs_pathconf(void *);
110 int nfs_advlock(void *);
111 int nfs_print(void *);
112 int nfs_blkatoff(void *);
113 int nfs_bwrite(void *);
114 int nfs_writebp(struct buf *, int);
115 int nfsspec_access(void *);
116 int nfsspec_read(void *);
117 int nfsspec_write(void *);
118 int nfsspec_close(void *);
119 int nfsfifo_read(void *);
120 int nfsfifo_write(void *);
121 int nfsfifo_close(void *);
122 int nfsfifo_reclaim(void *);
123 
124 #define	nfs_ioctl	((int (*)(void *))enoioctl)
125 
126 /* nfs_serv.c */
127 int nfsrv3_access(struct nfsrv_descript *, struct nfssvc_sock *,
128 		       struct proc *, struct mbuf **);
129 int nfsrv_getattr(struct nfsrv_descript *, struct nfssvc_sock *,
130 		       struct proc *, struct mbuf **);
131 int nfsrv_setattr(struct nfsrv_descript *, struct nfssvc_sock *,
132 		       struct proc *, struct mbuf **);
133 int nfsrv_lookup(struct nfsrv_descript *, struct nfssvc_sock *,
134 		      struct proc *, struct mbuf **);
135 int nfsrv_readlink(struct nfsrv_descript *, struct nfssvc_sock *,
136 			struct proc *, struct mbuf **);
137 int nfsrv_read(struct nfsrv_descript *, struct nfssvc_sock *,
138 		    struct proc *, struct mbuf **);
139 int nfsrv_write(struct nfsrv_descript *, struct nfssvc_sock *,
140 		     struct proc *, struct mbuf **);
141 int nfsrv_writegather(struct nfsrv_descript **, struct nfssvc_sock *,
142 			   struct proc *, struct mbuf **);
143 void nfsrvw_coalesce(struct nfsrv_descript *, struct nfsrv_descript *);
144 int nfsrv_create(struct nfsrv_descript *, struct nfssvc_sock *,
145 		      struct proc *, struct mbuf **);
146 int nfsrv_mknod(struct nfsrv_descript *, struct nfssvc_sock *,
147 		     struct proc *, struct mbuf **);
148 int nfsrv_remove(struct nfsrv_descript *, struct nfssvc_sock *,
149 		      struct proc *, struct mbuf **);
150 int nfsrv_rename(struct nfsrv_descript *, struct nfssvc_sock *,
151 		      struct proc *, struct mbuf **);
152 int nfsrv_link(struct nfsrv_descript *, struct nfssvc_sock *,
153 		    struct proc *, struct mbuf **);
154 int nfsrv_symlink(struct nfsrv_descript *, struct nfssvc_sock *,
155 		       struct proc *, struct mbuf **);
156 int nfsrv_mkdir(struct nfsrv_descript *, struct nfssvc_sock *,
157 		     struct proc *, struct mbuf **);
158 int nfsrv_rmdir(struct nfsrv_descript *, struct nfssvc_sock *,
159 		     struct proc *, struct mbuf **);
160 int nfsrv_readdir(struct nfsrv_descript *, struct nfssvc_sock *,
161 		       struct proc *, struct mbuf **);
162 int nfsrv_readdirplus(struct nfsrv_descript *, struct nfssvc_sock *,
163 			   struct proc *, struct mbuf **);
164 int nfsrv_commit(struct nfsrv_descript *, struct nfssvc_sock *,
165 		      struct proc *, struct mbuf **);
166 int nfsrv_statfs(struct nfsrv_descript *, struct nfssvc_sock *,
167 		      struct proc *, struct mbuf **);
168 int nfsrv_fsinfo(struct nfsrv_descript *, struct nfssvc_sock *,
169 		      struct proc *, struct mbuf **);
170 int nfsrv_pathconf(struct nfsrv_descript *, struct nfssvc_sock *,
171 		        struct proc *, struct mbuf **);
172 int nfsrv_null(struct nfsrv_descript *, struct nfssvc_sock *,
173 		    struct proc *, struct mbuf **);
174 int nfsrv_noop(struct nfsrv_descript *, struct nfssvc_sock *,
175 		    struct proc *, struct mbuf **);
176 int nfsrv_access(struct vnode *, int, struct ucred *, int, struct proc *,
177 		    int);
178 
179 /* nfs_socket.c */
180 int nfs_connect(struct nfsmount *, struct nfsreq *);
181 int nfs_reconnect(struct nfsreq *);
182 void nfs_disconnect(struct nfsmount *);
183 int nfs_send(struct socket *, struct mbuf *, struct mbuf *,
184 		  struct nfsreq *);
185 int nfs_receive(struct nfsreq *, struct mbuf **, struct mbuf **);
186 int nfs_reply(struct nfsreq *);
187 int nfs_request(struct vnode *, struct mbuf *, int, struct proc *,
188 		     struct ucred *, struct mbuf **, struct mbuf **,
189 		     caddr_t *);
190 int nfs_request1(struct nfsreq *, struct ucred *, struct mbuf **,
191 		    struct mbuf **, caddr_t *);
192 int nfs_rephead(int, struct nfsrv_descript *, struct nfssvc_sock *, int,
193 		struct mbuf **, struct mbuf **);
194 void nfs_timer(void *);
195 int nfs_sigintr(struct nfsmount *, struct nfsreq *, struct proc *);
196 int nfs_sndlock(int *, struct nfsreq *);
197 void nfs_sndunlock(int *);
198 int nfs_rcvlock(struct nfsreq *);
199 void nfs_rcvunlock(int *);
200 int nfs_getreq(struct nfsrv_descript *, struct nfsd *, int);
201 void nfs_msg(struct nfsreq *, char *);
202 void nfsrv_rcv(struct socket *, caddr_t, int);
203 int nfsrv_getstream(struct nfssvc_sock *, int);
204 int nfsrv_dorec(struct nfssvc_sock *, struct nfsd *,
205 		     struct nfsrv_descript **);
206 void nfsrv_wakenfsd(struct nfssvc_sock *);
207 
208 /* nfs_srvcache.c */
209 void nfsrv_initcache(void );
210 int nfsrv_getcache(struct nfsrv_descript *, struct nfssvc_sock *,
211 			struct mbuf **);
212 void nfsrv_updatecache(struct nfsrv_descript *, int, struct mbuf *);
213 void nfsrv_cleancache(void);
214 
215 /* nfs_subs.c */
216 struct mbuf *nfsm_reqhead(int);
217 u_int32_t nfs_get_xid(void);
218 void nfsm_rpchead(struct nfsreq *, struct ucred *, int);
219 void *nfsm_build(struct mbuf **, u_int);
220 int nfsm_mbuftouio(struct mbuf **, struct uio *, int, caddr_t *);
221 void nfsm_uiotombuf(struct mbuf **, struct uio *, size_t);
222 void nfsm_strtombuf(struct mbuf **, void *, size_t);
223 void nfsm_buftombuf(struct mbuf **, void *, size_t);
224 int nfsm_disct(struct mbuf **, caddr_t *, int, int, caddr_t *);
225 int nfs_adv(struct mbuf **, caddr_t *, int, int);
226 int nfsm_strtmbuf(struct mbuf **, char **, char *, long);
227 int nfs_vfs_init(struct vfsconf *);
228 int nfs_attrtimeo(struct nfsnode *);
229 int nfs_loadattrcache(struct vnode **, struct mbuf **, caddr_t *,
230 			   struct vattr *);
231 int nfs_getattrcache(struct vnode *, struct vattr *);
232 int nfs_namei(struct nameidata *, fhandle_t *, int, struct nfssvc_sock *,
233 		   struct mbuf *, struct mbuf **, caddr_t *, struct vnode **,
234 		   struct proc *);
235 void nfsm_v3attrbuild(struct mbuf **, struct vattr *, int);
236 void nfsm_adj(struct mbuf *, int, int);
237 void nfsm_srvwcc(struct nfsrv_descript *, int, struct vattr *, int,
238 		      struct vattr *, struct mbuf **);
239 void nfsm_srvpostop_attr(struct nfsrv_descript *, int, struct vattr *,
240 			     struct mbuf **);
241 void nfsm_srvfattr(struct nfsrv_descript *, struct vattr *,
242 			struct nfs_fattr *);
243 int nfsrv_fhtovp(fhandle_t *, int, struct vnode **, struct ucred *,
244 		      struct nfssvc_sock *, struct mbuf *, int *);
245 int netaddr_match(int, union nethostaddr *, struct mbuf *);
246 void nfs_clearcommit(struct mount *);
247 int nfs_in_committed_range(struct vnode *, struct buf *);
248 int nfs_in_tobecommitted_range(struct vnode *, struct buf *);
249 void nfs_add_committed_range(struct vnode *, struct buf *);
250 void nfs_del_committed_range(struct vnode *, struct buf *);
251 void nfs_add_tobecommitted_range(struct vnode *, struct buf *);
252 void nfs_del_tobecommitted_range(struct vnode *, struct buf *);
253 void nfs_merge_commit_ranges(struct vnode *);
254 int nfsrv_errmap(struct nfsrv_descript *, int);
255 void nfsrvw_sort(gid_t *, int);
256 void nfsrv_setcred(struct ucred *, struct ucred *);
257 int nfsm_srvsattr(struct mbuf **, struct vattr *, struct mbuf *, caddr_t *);
258 
259 /* nfs_syscalls.c */
260 int sys_nfssvc(struct proc *, void *, register_t *);
261 int nfssvc_addsock(struct file *, struct mbuf *);
262 int nfssvc_nfsd(struct nfsd_srvargs *, caddr_t, struct proc *);
263 void nfsrv_zapsock(struct nfssvc_sock *);
264 void nfsrv_slpderef(struct nfssvc_sock *);
265 void nfsrv_init(int);
266 void nfssvc_iod(void *);
267 void start_nfsio(void *);
268 void nfs_getset_niothreads(int);
269 
270 /* nfs_kq.c */
271 int  nfs_kqfilter(void *);
272 
273 /* Internal NFS utility macros */
274 #define	mb_offset(m)	(mtod((m), caddr_t) + (m)->m_len)
275 #define	nfsm_padlen(s)	(nfsm_rndup(s) - (s))
276 
277 #endif /* _KERNEL */
278 #endif /* _NFS_NFS_VAR_H_ */
279