xref: /openbsd/sys/nfs/nfs_var.h (revision 09467b48)
1 /*	$OpenBSD: nfs_var.h,v 1.63 2017/02/22 11:42:46 mpi 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 struct nfsm_info;
46 
47 /* nfs_bio.c */
48 int nfs_bioread(struct vnode *, struct uio *, int, struct ucred *);
49 int nfs_write(void *);
50 int nfs_vinvalbuf(struct vnode *, int, struct ucred *, struct proc *);
51 int nfs_asyncio(struct buf *, int readahead);
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_ninit(struct nfsmount *);
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_readlink(void *);
65 int nfs_readlinkrpc(struct vnode *, struct uio *, struct ucred *);
66 int nfs_readrpc(struct vnode *, struct uio *);
67 int nfs_writerpc(struct vnode *, struct uio *, int *, int *);
68 int nfs_removeit(struct sillyrename *);
69 int nfs_mmap(void *);
70 int nfs_blkatoff(void *);
71 int nfs_writebp(struct buf *, int);
72 
73 #define	nfs_ioctl	((int (*)(void *))enoioctl)
74 
75 /* nfs_serv.c */
76 int nfsrv3_access(struct nfsrv_descript *, struct nfssvc_sock *,
77 		       struct proc *, struct mbuf **);
78 int nfsrv_getattr(struct nfsrv_descript *, struct nfssvc_sock *,
79 		       struct proc *, struct mbuf **);
80 int nfsrv_setattr(struct nfsrv_descript *, struct nfssvc_sock *,
81 		       struct proc *, struct mbuf **);
82 int nfsrv_lookup(struct nfsrv_descript *, struct nfssvc_sock *,
83 		      struct proc *, struct mbuf **);
84 int nfsrv_readlink(struct nfsrv_descript *, struct nfssvc_sock *,
85 			struct proc *, struct mbuf **);
86 int nfsrv_read(struct nfsrv_descript *, struct nfssvc_sock *,
87 		    struct proc *, struct mbuf **);
88 int nfsrv_write(struct nfsrv_descript *, struct nfssvc_sock *,
89 		     struct proc *, struct mbuf **);
90 int nfsrv_create(struct nfsrv_descript *, struct nfssvc_sock *,
91 		      struct proc *, struct mbuf **);
92 int nfsrv_mknod(struct nfsrv_descript *, struct nfssvc_sock *,
93 		     struct proc *, struct mbuf **);
94 int nfsrv_remove(struct nfsrv_descript *, struct nfssvc_sock *,
95 		      struct proc *, struct mbuf **);
96 int nfsrv_rename(struct nfsrv_descript *, struct nfssvc_sock *,
97 		      struct proc *, struct mbuf **);
98 int nfsrv_link(struct nfsrv_descript *, struct nfssvc_sock *,
99 		    struct proc *, struct mbuf **);
100 int nfsrv_symlink(struct nfsrv_descript *, struct nfssvc_sock *,
101 		       struct proc *, struct mbuf **);
102 int nfsrv_mkdir(struct nfsrv_descript *, struct nfssvc_sock *,
103 		     struct proc *, struct mbuf **);
104 int nfsrv_rmdir(struct nfsrv_descript *, struct nfssvc_sock *,
105 		     struct proc *, struct mbuf **);
106 int nfsrv_readdir(struct nfsrv_descript *, struct nfssvc_sock *,
107 		       struct proc *, struct mbuf **);
108 int nfsrv_readdirplus(struct nfsrv_descript *, struct nfssvc_sock *,
109 			   struct proc *, struct mbuf **);
110 int nfsrv_commit(struct nfsrv_descript *, struct nfssvc_sock *,
111 		      struct proc *, struct mbuf **);
112 int nfsrv_statfs(struct nfsrv_descript *, struct nfssvc_sock *,
113 		      struct proc *, struct mbuf **);
114 int nfsrv_fsinfo(struct nfsrv_descript *, struct nfssvc_sock *,
115 		      struct proc *, struct mbuf **);
116 int nfsrv_pathconf(struct nfsrv_descript *, struct nfssvc_sock *,
117 		        struct proc *, struct mbuf **);
118 int nfsrv_null(struct nfsrv_descript *, struct nfssvc_sock *,
119 		    struct proc *, struct mbuf **);
120 int nfsrv_noop(struct nfsrv_descript *, struct nfssvc_sock *,
121 		    struct proc *, struct mbuf **);
122 
123 /* nfs_socket.c */
124 int nfs_connect(struct nfsmount *, struct nfsreq *);
125 void nfs_disconnect(struct nfsmount *);
126 int nfs_send(struct socket *, struct mbuf *, struct mbuf *,
127 		  struct nfsreq *);
128 int nfs_request(struct vnode *, int, struct nfsm_info *);
129 int nfs_rephead(int, struct nfsrv_descript *, struct nfssvc_sock *, int,
130 		struct mbuf **, struct mbuf **);
131 void nfs_timer(void *);
132 int nfs_sigintr(struct nfsmount *, struct nfsreq *, struct proc *);
133 int nfs_sndlock(int *, struct nfsreq *);
134 void nfs_sndunlock(int *);
135 void nfsrv_rcv(struct socket *, caddr_t, int);
136 int nfsrv_dorec(struct nfssvc_sock *, struct nfsd *,
137 		     struct nfsrv_descript **);
138 void nfsrv_wakenfsd(struct nfssvc_sock *);
139 
140 /* nfs_srvcache.c */
141 void nfsrv_initcache(void );
142 int nfsrv_getcache(struct nfsrv_descript *, struct nfssvc_sock *,
143 			struct mbuf **);
144 void nfsrv_updatecache(struct nfsrv_descript *, int, struct mbuf *);
145 void nfsrv_cleancache(void);
146 
147 /* nfs_subs.c */
148 struct mbuf *nfsm_reqhead(int);
149 void nfsm_rpchead(struct nfsreq *, struct ucred *, int);
150 void *nfsm_build(struct mbuf **, u_int);
151 int nfsm_mbuftouio(struct mbuf **, struct uio *, int, caddr_t *);
152 void nfsm_uiotombuf(struct mbuf **, struct uio *, size_t);
153 void nfsm_strtombuf(struct mbuf **, void *, size_t);
154 void nfsm_buftombuf(struct mbuf **, void *, size_t);
155 int nfsm_disct(struct mbuf **, caddr_t *, int, int, caddr_t *);
156 int nfs_adv(struct mbuf **, caddr_t *, int, int);
157 int nfsm_strtmbuf(struct mbuf **, char **, char *, long);
158 int nfs_vfs_init(struct vfsconf *);
159 int nfs_attrtimeo(struct nfsnode *);
160 int nfs_loadattrcache(struct vnode **, struct mbuf **, caddr_t *,
161 			   struct vattr *);
162 int nfs_getattrcache(struct vnode *, struct vattr *);
163 int nfs_namei(struct nameidata *, fhandle_t *, int, struct nfssvc_sock *,
164 		   struct mbuf *, struct mbuf **, caddr_t *, struct vnode **,
165 		   struct proc *);
166 void nfsm_v3attrbuild(struct mbuf **, struct vattr *, int);
167 void nfsm_adj(struct mbuf *, int, int);
168 void nfsm_srvwcc(struct nfsrv_descript *, int, struct vattr *, int,
169 		      struct vattr *, struct nfsm_info *);
170 void nfsm_srvpostop_attr(struct nfsrv_descript *, int, struct vattr *,
171 			     struct nfsm_info *);
172 void nfsm_srvfattr(struct nfsrv_descript *, struct vattr *,
173 			struct nfs_fattr *);
174 int nfsrv_fhtovp(fhandle_t *, int, struct vnode **, struct ucred *,
175 		      struct nfssvc_sock *, struct mbuf *, int *);
176 int netaddr_match(int, union nethostaddr *, struct mbuf *);
177 void nfs_clearcommit(struct mount *);
178 int nfs_in_committed_range(struct vnode *, struct buf *);
179 int nfs_in_tobecommitted_range(struct vnode *, struct buf *);
180 void nfs_add_committed_range(struct vnode *, struct buf *);
181 void nfs_del_committed_range(struct vnode *, struct buf *);
182 void nfs_add_tobecommitted_range(struct vnode *, struct buf *);
183 void nfs_del_tobecommitted_range(struct vnode *, struct buf *);
184 void nfs_merge_commit_ranges(struct vnode *);
185 int nfsrv_errmap(struct nfsrv_descript *, int);
186 int nfsm_srvsattr(struct mbuf **, struct vattr *, struct mbuf *, caddr_t *);
187 void nfsm_fhtom(struct nfsm_info *, struct vnode *, int);
188 void nfsm_srvfhtom(struct mbuf **, fhandle_t *, int);
189 
190 /* nfs_syscalls.c */
191 int sys_nfssvc(struct proc *, void *, register_t *);
192 void nfsrv_init(int);
193 void start_nfsio(void *);
194 void nfs_getset_niothreads(int);
195 
196 /* nfs_kq.c */
197 int  nfs_kqfilter(void *);
198 
199 /* Internal NFS utility macros */
200 #define	mb_offset(m)	(mtod((m), caddr_t) + (m)->m_len)
201 #define	nfsm_padlen(s)	(nfsm_rndup(s) - (s))
202 
203 #endif /* _KERNEL */
204 #endif /* _NFS_NFS_VAR_H_ */
205