nfsnode.h revision 1.8 1 /*
2 * Copyright (c) 1989 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Rick Macklem at The University of Guelph.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * from: @(#)nfsnode.h 7.12 (Berkeley) 4/16/91
37 * $Id: nfsnode.h,v 1.8 1994/04/21 23:23:45 cgd Exp $
38 */
39
40 #ifndef _NFS_NFSNODE_H_
41 #define _NFS_NFSNODE_H_
42
43 /*
44 * The nfsnode is the nfs equivalent to ufs's inode. Any similarity
45 * is purely coincidental.
46 * There is a unique nfsnode allocated for each active file,
47 * each current directory, each mounted-on file, text file, and the root.
48 * An nfsnode is 'named' by its file handle. (nget/nfs_node.c)
49 */
50
51 struct nfsnode {
52 struct nfsnode *n_chain[2]; /* must be first */
53 nfsv2fh_t n_fh; /* NFS File Handle */
54 long n_flag; /* Flag for locking.. */
55 struct vnode *n_vnode; /* vnode associated with this nfsnode */
56 time_t n_attrstamp; /* Time stamp (sec) for attributes */
57 struct vattr n_vattr; /* Vnode attribute cache */
58 struct sillyrename *n_sillyrename; /* Ptr to silly rename struct */
59 u_long n_size; /* Current size of file */
60 struct lockf *n_lockf; /* Locking record of file */
61 time_t n_mtime; /* Prev modify time to maintain data cache consistency*/
62 time_t n_ctime; /* Prev create time for name cache consistency*/
63 int n_error; /* Save write error value */
64 u_long n_direofoffset; /* Dir. EOF offset cache */
65 struct timeval n_delayed_atime; /* Non-urgent access/modified time */
66 struct timeval n_delayed_mtime; /* updates are stored here. */
67 };
68
69 #define n_forw n_chain[0]
70 #define n_back n_chain[1]
71
72 #ifdef KERNEL
73 /*
74 * Convert between nfsnode pointers and vnode pointers
75 */
76 #define VTONFS(vp) ((struct nfsnode *)(vp)->v_data)
77 #define NFSTOV(np) ((struct vnode *)(np)->n_vnode)
78 #endif
79 /*
80 * Flags for n_flag
81 */
82 #define NMODIFIED 0x1 /* Might have a modified buffer in bio */
83 #define NWRITEERR 0x2 /* Flag write errors so close will know */
84
85 /*
86 * Prototypes for NFS vnode operations
87 */
88 int nfs_lookup __P((
89 struct vnode *vp,
90 struct nameidata *ndp,
91 struct proc *p));
92 int nfs_create __P((
93 struct nameidata *ndp,
94 struct vattr *vap,
95 struct proc *p));
96 int nfs_mknod __P((
97 struct nameidata *ndp,
98 struct vattr *vap,
99 struct ucred *cred,
100 struct proc *p));
101 int nfs_open __P((
102 struct vnode *vp,
103 int mode,
104 struct ucred *cred,
105 struct proc *p));
106 int nfs_close __P((
107 struct vnode *vp,
108 int fflag,
109 struct ucred *cred,
110 struct proc *p));
111 int nfs_access __P((
112 struct vnode *vp,
113 int mode,
114 struct ucred *cred,
115 struct proc *p));
116 int nfs_getattr __P((
117 struct vnode *vp,
118 struct vattr *vap,
119 struct ucred *cred,
120 struct proc *p));
121 int nfs_setattr __P((
122 struct vnode *vp,
123 struct vattr *vap,
124 struct ucred *cred,
125 struct proc *p));
126 int nfs_read __P((
127 struct vnode *vp,
128 struct uio *uio,
129 int ioflag,
130 struct ucred *cred));
131 int nfs_write __P((
132 struct vnode *vp,
133 struct uio *uio,
134 int ioflag,
135 struct ucred *cred));
136 #define nfs_ioctl ((int (*) __P(( \
137 struct vnode *vp, \
138 int command, \
139 caddr_t data, \
140 int fflag, \
141 struct ucred *cred, \
142 struct proc *p))) enoioctl)
143 #define nfs_select ((int (*) __P(( \
144 struct vnode *vp, \
145 int which, \
146 int fflags, \
147 struct ucred *cred, \
148 struct proc *p))) seltrue)
149 int nfs_mmap __P((
150 struct vnode *vp,
151 int fflags,
152 struct ucred *cred,
153 struct proc *p));
154 int nfs_fsync __P((
155 struct vnode *vp,
156 int fflags,
157 struct ucred *cred,
158 int waitfor,
159 struct proc *p));
160 #define nfs_seek ((int (*) __P(( \
161 struct vnode *vp, \
162 off_t oldoff, \
163 off_t newoff, \
164 struct ucred *cred))) nullop)
165 int nfs_remove __P((
166 struct nameidata *ndp,
167 struct proc *p));
168 int nfs_link __P((
169 struct vnode *vp,
170 struct nameidata *ndp,
171 struct proc *p));
172 int nfs_rename __P((
173 struct nameidata *fndp,
174 struct nameidata *tdnp,
175 struct proc *p));
176 int nfs_mkdir __P((
177 struct nameidata *ndp,
178 struct vattr *vap,
179 struct proc *p));
180 int nfs_rmdir __P((
181 struct nameidata *ndp,
182 struct proc *p));
183 int nfs_symlink __P((
184 struct nameidata *ndp,
185 struct vattr *vap,
186 char *target,
187 struct proc *p));
188 int nfs_readdir __P((
189 struct vnode *vp,
190 struct uio *uio,
191 struct ucred *cred,
192 int *eofflagp,
193 u_int *cookies,
194 int ncookies));
195 int nfs_readlink __P((
196 struct vnode *vp,
197 struct uio *uio,
198 struct ucred *cred));
199 int nfs_abortop __P((
200 struct nameidata *ndp));
201 int nfs_inactive __P((
202 struct vnode *vp,
203 struct proc *p));
204 int nfs_reclaim __P((
205 struct vnode *vp));
206 int nfs_lock __P((
207 struct vnode *vp));
208 int nfs_unlock __P((
209 struct vnode *vp));
210 int nfs_bmap __P((
211 struct vnode *vp,
212 daddr_t bn,
213 struct vnode **vpp,
214 daddr_t *bnp));
215 int nfs_strategy __P((
216 struct buf *bp));
217 int nfs_print __P((
218 struct vnode *vp));
219 int nfs_islocked __P((
220 struct vnode *vp));
221 int nfs_advlock __P((
222 struct vnode *vp,
223 caddr_t id,
224 int op,
225 struct flock *fl,
226 int flags));
227 int nfsspec_close __P((
228 struct vnode *vp,
229 int fflag,
230 struct ucred *cred,
231 struct proc *p));
232 int nfsspec_read __P((
233 struct vnode *vp,
234 struct uio *uio,
235 int ioflag,
236 struct ucred *cred));
237 int nfsspec_write __P((
238 struct vnode *vp,
239 struct uio *uio,
240 int ioflag,
241 struct ucred *cred));
242 int nfsfifo_close __P((
243 struct vnode *vp,
244 int fflag,
245 struct ucred *cred,
246 struct proc *p));
247 int nfsfifo_read __P((
248 struct vnode *vp,
249 struct uio *uio,
250 int ioflag,
251 struct ucred *cred));
252 int nfsfifo_write __P((
253 struct vnode *vp,
254 struct uio *uio,
255 int ioflag,
256 struct ucred *cred));
257 #endif /* !_NFS_NFSNODE_H_ */
258