xref: /openbsd-src/sys/nfs/nfs_var.h (revision d2b6e45e6016ad05bc8d079d97d8cdbaad3d3743)
1 /*	$OpenBSD: nfs_var.h,v 1.66 2024/09/09 03:50:14 jsg 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_writebp(struct buf *, int);
70 
71 #define	nfs_ioctl	((int (*)(void *))enoioctl)
72 
73 /* nfs_serv.c */
74 int nfsrv3_access(struct nfsrv_descript *, struct nfssvc_sock *,
75 		       struct proc *, struct mbuf **);
76 int nfsrv_getattr(struct nfsrv_descript *, struct nfssvc_sock *,
77 		       struct proc *, struct mbuf **);
78 int nfsrv_setattr(struct nfsrv_descript *, struct nfssvc_sock *,
79 		       struct proc *, struct mbuf **);
80 int nfsrv_lookup(struct nfsrv_descript *, struct nfssvc_sock *,
81 		      struct proc *, struct mbuf **);
82 int nfsrv_readlink(struct nfsrv_descript *, struct nfssvc_sock *,
83 			struct proc *, struct mbuf **);
84 int nfsrv_read(struct nfsrv_descript *, struct nfssvc_sock *,
85 		    struct proc *, struct mbuf **);
86 int nfsrv_write(struct nfsrv_descript *, struct nfssvc_sock *,
87 		     struct proc *, struct mbuf **);
88 int nfsrv_create(struct nfsrv_descript *, struct nfssvc_sock *,
89 		      struct proc *, struct mbuf **);
90 int nfsrv_mknod(struct nfsrv_descript *, struct nfssvc_sock *,
91 		     struct proc *, struct mbuf **);
92 int nfsrv_remove(struct nfsrv_descript *, struct nfssvc_sock *,
93 		      struct proc *, struct mbuf **);
94 int nfsrv_rename(struct nfsrv_descript *, struct nfssvc_sock *,
95 		      struct proc *, struct mbuf **);
96 int nfsrv_link(struct nfsrv_descript *, struct nfssvc_sock *,
97 		    struct proc *, struct mbuf **);
98 int nfsrv_symlink(struct nfsrv_descript *, struct nfssvc_sock *,
99 		       struct proc *, struct mbuf **);
100 int nfsrv_mkdir(struct nfsrv_descript *, struct nfssvc_sock *,
101 		     struct proc *, struct mbuf **);
102 int nfsrv_rmdir(struct nfsrv_descript *, struct nfssvc_sock *,
103 		     struct proc *, struct mbuf **);
104 int nfsrv_readdir(struct nfsrv_descript *, struct nfssvc_sock *,
105 		       struct proc *, struct mbuf **);
106 int nfsrv_readdirplus(struct nfsrv_descript *, struct nfssvc_sock *,
107 			   struct proc *, struct mbuf **);
108 int nfsrv_commit(struct nfsrv_descript *, struct nfssvc_sock *,
109 		      struct proc *, struct mbuf **);
110 int nfsrv_statfs(struct nfsrv_descript *, struct nfssvc_sock *,
111 		      struct proc *, struct mbuf **);
112 int nfsrv_fsinfo(struct nfsrv_descript *, struct nfssvc_sock *,
113 		      struct proc *, struct mbuf **);
114 int nfsrv_pathconf(struct nfsrv_descript *, struct nfssvc_sock *,
115 		        struct proc *, struct mbuf **);
116 int nfsrv_null(struct nfsrv_descript *, struct nfssvc_sock *,
117 		    struct proc *, struct mbuf **);
118 int nfsrv_noop(struct nfsrv_descript *, struct nfssvc_sock *,
119 		    struct proc *, struct mbuf **);
120 
121 /* nfs_socket.c */
122 int nfs_connect(struct nfsmount *, struct nfsreq *);
123 void nfs_disconnect(struct nfsmount *);
124 int nfs_send(struct socket *, struct mbuf *, struct mbuf *,
125 		  struct nfsreq *);
126 int nfs_request(struct vnode *, int, struct nfsm_info *);
127 int nfs_rephead(int, struct nfsrv_descript *, struct nfssvc_sock *, int,
128 		struct mbuf **, struct mbuf **);
129 void nfs_timer(void *);
130 int nfs_sigintr(struct nfsmount *, struct nfsreq *, struct proc *);
131 int nfs_sndlock(int *, struct nfsreq *);
132 void nfs_sndunlock(int *);
133 void nfsrv_rcv(struct socket *, caddr_t, int);
134 int nfsrv_dorec(struct nfssvc_sock *, struct nfsd *,
135 		     struct nfsrv_descript **);
136 void nfsrv_wakenfsd(struct nfssvc_sock *);
137 
138 /* nfs_srvcache.c */
139 void nfsrv_initcache(void );
140 int nfsrv_getcache(struct nfsrv_descript *, struct nfssvc_sock *,
141 			struct mbuf **);
142 void nfsrv_updatecache(struct nfsrv_descript *, int, struct mbuf *);
143 void nfsrv_cleancache(void);
144 
145 /* nfs_srvsubs.c */
146 int nfs_namei(struct nameidata *, fhandle_t *, int, struct nfssvc_sock *,
147 		   struct mbuf *, struct mbuf **, caddr_t *, struct vnode **,
148 		   struct proc *);
149 void nfsm_adj(struct mbuf *, int, int);
150 void nfsm_srvwcc(struct nfsrv_descript *, int, struct vattr *, int,
151 		      struct vattr *, struct nfsm_info *);
152 void nfsm_srvpostop_attr(struct nfsrv_descript *, int, struct vattr *,
153 			     struct nfsm_info *);
154 void nfsm_srvfattr(struct nfsrv_descript *, struct vattr *,
155 			struct nfs_fattr *);
156 int nfsrv_fhtovp(fhandle_t *, int, struct vnode **, struct ucred *,
157 		      struct nfssvc_sock *, struct mbuf *, int *);
158 int netaddr_match(int, union nethostaddr *, struct mbuf *);
159 int nfsm_srvsattr(struct mbuf **, struct vattr *, struct mbuf *, caddr_t *);
160 
161 /* nfs_subs.c */
162 struct mbuf *nfsm_reqhead(int);
163 void nfsm_rpchead(struct nfsreq *, struct ucred *, int);
164 void *nfsm_build(struct mbuf **, u_int);
165 int nfsm_mbuftouio(struct mbuf **, struct uio *, int, caddr_t *);
166 void nfsm_uiotombuf(struct mbuf **, struct uio *, size_t);
167 void nfsm_strtombuf(struct mbuf **, void *, size_t);
168 void nfsm_buftombuf(struct mbuf **, void *, size_t);
169 int nfs_adv(struct mbuf **, caddr_t *, int, int);
170 int nfs_vfs_init(struct vfsconf *);
171 int nfs_attrtimeo(struct nfsnode *);
172 int nfs_loadattrcache(struct vnode **, struct mbuf **, caddr_t *,
173 			   struct vattr *);
174 int nfs_getattrcache(struct vnode *, struct vattr *);
175 void nfsm_v3attrbuild(struct mbuf **, struct vattr *, int);
176 int nfsm_disct(struct mbuf **, caddr_t *, int, int, caddr_t *);
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 void nfsm_fhtom(struct nfsm_info *, struct vnode *, int);
187 void nfsm_srvfhtom(struct mbuf **, fhandle_t *, int);
188 
189 /* nfs_syscalls.c */
190 int sys_nfssvc(struct proc *, void *, register_t *);
191 void nfsrv_init(int);
192 void nfs_getset_niothreads(int);
193 
194 /* nfs_kq.c */
195 int  nfs_kqfilter(void *);
196 
197 /* Internal NFS utility macros */
198 #define	mb_offset(m)	(mtod((m), caddr_t) + (m)->m_len)
199 #define	nfsm_padlen(s)	(nfsm_rndup(s) - (s))
200 
201 #endif /* _KERNEL */
202 #endif /* _NFS_NFS_VAR_H_ */
203