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
41struct nfsnode;
42struct sillyrename;
43struct componentname;
44struct nfs_diskless;
45struct nfsm_info;
46
47/* nfs_bio.c */
48int nfs_bioread(struct vnode *, struct uio *, int, struct ucred *);
49int nfs_write(void *);
50int nfs_vinvalbuf(struct vnode *, int, struct ucred *, struct proc *);
51int nfs_asyncio(struct buf *, int readahead);
52int nfs_doio(struct buf *, struct proc *);
53
54/* nfs_boot.c */
55int nfs_boot_init(struct nfs_diskless *, struct proc *);
56
57/* nfs_node.c */
58void nfs_ninit(struct nfsmount *);
59int nfs_nget(struct mount *, nfsfh_t *, int, struct nfsnode **);
60int nfs_inactive(void *);
61int nfs_reclaim(void *);
62
63/* nfs_vnops.c */
64int nfs_readlink(void *);
65int nfs_readlinkrpc(struct vnode *, struct uio *, struct ucred *);
66int nfs_readrpc(struct vnode *, struct uio *);
67int nfs_writerpc(struct vnode *, struct uio *, int *, int *);
68int nfs_removeit(struct sillyrename *);
69int nfs_writebp(struct buf *, int);
70
71#define nfs_ioctl ((int (*)(void *))enoioctl)
72
73/* nfs_serv.c */
74int nfsrv3_access(struct nfsrv_descript *, struct nfssvc_sock *,
75 struct proc *, struct mbuf **);
76int nfsrv_getattr(struct nfsrv_descript *, struct nfssvc_sock *,
77 struct proc *, struct mbuf **);
78int nfsrv_setattr(struct nfsrv_descript *, struct nfssvc_sock *,
79 struct proc *, struct mbuf **);
80int nfsrv_lookup(struct nfsrv_descript *, struct nfssvc_sock *,
81 struct proc *, struct mbuf **);
82int nfsrv_readlink(struct nfsrv_descript *, struct nfssvc_sock *,
83 struct proc *, struct mbuf **);
84int nfsrv_read(struct nfsrv_descript *, struct nfssvc_sock *,
85 struct proc *, struct mbuf **);
86int nfsrv_write(struct nfsrv_descript *, struct nfssvc_sock *,
87 struct proc *, struct mbuf **);
88int nfsrv_create(struct nfsrv_descript *, struct nfssvc_sock *,
89 struct proc *, struct mbuf **);
90int nfsrv_mknod(struct nfsrv_descript *, struct nfssvc_sock *,
91 struct proc *, struct mbuf **);
92int nfsrv_remove(struct nfsrv_descript *, struct nfssvc_sock *,
93 struct proc *, struct mbuf **);
94int nfsrv_rename(struct nfsrv_descript *, struct nfssvc_sock *,
95 struct proc *, struct mbuf **);
96int nfsrv_link(struct nfsrv_descript *, struct nfssvc_sock *,
97 struct proc *, struct mbuf **);
98int nfsrv_symlink(struct nfsrv_descript *, struct nfssvc_sock *,
99 struct proc *, struct mbuf **);
100int nfsrv_mkdir(struct nfsrv_descript *, struct nfssvc_sock *,
101 struct proc *, struct mbuf **);
102int nfsrv_rmdir(struct nfsrv_descript *, struct nfssvc_sock *,
103 struct proc *, struct mbuf **);
104int nfsrv_readdir(struct nfsrv_descript *, struct nfssvc_sock *,
105 struct proc *, struct mbuf **);
106int nfsrv_readdirplus(struct nfsrv_descript *, struct nfssvc_sock *,
107 struct proc *, struct mbuf **);
108int nfsrv_commit(struct nfsrv_descript *, struct nfssvc_sock *,
109 struct proc *, struct mbuf **);
110int nfsrv_statfs(struct nfsrv_descript *, struct nfssvc_sock *,
111 struct proc *, struct mbuf **);
112int nfsrv_fsinfo(struct nfsrv_descript *, struct nfssvc_sock *,
113 struct proc *, struct mbuf **);
114int nfsrv_pathconf(struct nfsrv_descript *, struct nfssvc_sock *,
115 struct proc *, struct mbuf **);
116int nfsrv_null(struct nfsrv_descript *, struct nfssvc_sock *,
117 struct proc *, struct mbuf **);
118int nfsrv_noop(struct nfsrv_descript *, struct nfssvc_sock *,
119 struct proc *, struct mbuf **);
120
121/* nfs_socket.c */
122int nfs_connect(struct nfsmount *, struct nfsreq *);
123void nfs_disconnect(struct nfsmount *);
124int nfs_send(struct socket *, struct mbuf *, struct mbuf *,
125 struct nfsreq *);
126int nfs_request(struct vnode *, int, struct nfsm_info *);
127int nfs_rephead(int, struct nfsrv_descript *, struct nfssvc_sock *, int,
128 struct mbuf **, struct mbuf **);
129void nfs_timer(void *);
130int nfs_sigintr(struct nfsmount *, struct nfsreq *, struct proc *);
131int nfs_sndlock(int *, struct nfsreq *);
132void nfs_sndunlock(int *);
133void nfsrv_rcv(struct socket *, caddr_t, int);
134int nfsrv_dorec(struct nfssvc_sock *, struct nfsd *,
135 struct nfsrv_descript **);
136void nfsrv_wakenfsd(struct nfssvc_sock *);
137
138/* nfs_srvcache.c */
139void nfsrv_initcache(void );
140int nfsrv_getcache(struct nfsrv_descript *, struct nfssvc_sock *,
141 struct mbuf **);
142void nfsrv_updatecache(struct nfsrv_descript *, int, struct mbuf *);
143void nfsrv_cleancache(void);
144
145/* nfs_srvsubs.c */
146int nfs_namei(struct nameidata *, fhandle_t *, int, struct nfssvc_sock *,
147 struct mbuf *, struct mbuf **, caddr_t *, struct vnode **,
148 struct proc *);
149void nfsm_adj(struct mbuf *, int, int);
150void nfsm_srvwcc(struct nfsrv_descript *, int, struct vattr *, int,
151 struct vattr *, struct nfsm_info *);
152void nfsm_srvpostop_attr(struct nfsrv_descript *, int, struct vattr *,
153 struct nfsm_info *);
154void nfsm_srvfattr(struct nfsrv_descript *, struct vattr *,
155 struct nfs_fattr *);
156int nfsrv_fhtovp(fhandle_t *, int, struct vnode **, struct ucred *,
157 struct nfssvc_sock *, struct mbuf *, int *);
158int netaddr_match(int, union nethostaddr *, struct mbuf *);
159int nfsm_srvsattr(struct mbuf **, struct vattr *, struct mbuf *, caddr_t *);
160
161/* nfs_subs.c */
162struct mbuf *nfsm_reqhead(int);
163void nfsm_rpchead(struct nfsreq *, struct ucred *, int);
164void *nfsm_build(struct mbuf **, u_int);
165int nfsm_mbuftouio(struct mbuf **, struct uio *, int, caddr_t *);
166void nfsm_uiotombuf(struct mbuf **, struct uio *, size_t);
167void nfsm_strtombuf(struct mbuf **, void *, size_t);
168void nfsm_buftombuf(struct mbuf **, void *, size_t);
169int nfs_adv(struct mbuf **, caddr_t *, int, int);
170int nfs_vfs_init(struct vfsconf *);
171int nfs_attrtimeo(struct nfsnode *);
172int nfs_loadattrcache(struct vnode **, struct mbuf **, caddr_t *,
173 struct vattr *);
174int nfs_getattrcache(struct vnode *, struct vattr *);
175void nfsm_v3attrbuild(struct mbuf **, struct vattr *, int);
176int nfsm_disct(struct mbuf **, caddr_t *, int, int, caddr_t *);
177void nfs_clearcommit(struct mount *);
178int nfs_in_committed_range(struct vnode *, struct buf *);
179int nfs_in_tobecommitted_range(struct vnode *, struct buf *);
180void nfs_add_committed_range(struct vnode *, struct buf *);
181void nfs_del_committed_range(struct vnode *, struct buf *);
182void nfs_add_tobecommitted_range(struct vnode *, struct buf *);
183void nfs_del_tobecommitted_range(struct vnode *, struct buf *);
184void nfs_merge_commit_ranges(struct vnode *);
185int nfsrv_errmap(struct nfsrv_descript *, int);
186void nfsm_fhtom(struct nfsm_info *, struct vnode *, int);
187void nfsm_srvfhtom(struct mbuf **, fhandle_t *, int);
188
189/* nfs_syscalls.c */
190int sys_nfssvc(struct proc *, void *, register_t *);
191void nfsrv_init(int);
192void nfs_getset_niothreads(int);
193
194/* nfs_kq.c */
195int 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_ */