nfsnode.h revision 1.7 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.7 1994/02/15 21:07:15 pk 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 pid_t n_lockholder; /* holder of nfsnode lock */
65 pid_t n_lockwaiter; /* most recent waiter for nfsnode lock */
66 u_long n_direofoffset; /* Dir. EOF offset cache */
67 struct timeval n_delayed_atime; /* Non-urgent access/modified time */
68 struct timeval n_delayed_mtime; /* updates are stored here. */
69 };
70
71 #define n_forw n_chain[0]
72 #define n_back n_chain[1]
73
74 #ifdef KERNEL
75 /*
76 * Convert between nfsnode pointers and vnode pointers
77 */
78 #define VTONFS(vp) ((struct nfsnode *)(vp)->v_data)
79 #define NFSTOV(np) ((struct vnode *)(np)->n_vnode)
80 #endif
81 /*
82 * Flags for n_flag
83 */
84 #define NLOCKED 0x1 /* Lock the node for other local accesses */
85 #define NWANT 0x2 /* Want above lock */
86 #define NMODIFIED 0x4 /* Might have a modified buffer in bio */
87 #define NWRITEERR 0x8 /* Flag write errors so close will know */
88
89 /*
90 * Prototypes for NFS vnode operations
91 */
92 int nfs_lookup __P((
93 struct vnode *vp,
94 struct nameidata *ndp,
95 struct proc *p));
96 int nfs_create __P((
97 struct nameidata *ndp,
98 struct vattr *vap,
99 struct proc *p));
100 int nfs_mknod __P((
101 struct nameidata *ndp,
102 struct vattr *vap,
103 struct ucred *cred,
104 struct proc *p));
105 int nfs_open __P((
106 struct vnode *vp,
107 int mode,
108 struct ucred *cred,
109 struct proc *p));
110 int nfs_close __P((
111 struct vnode *vp,
112 int fflag,
113 struct ucred *cred,
114 struct proc *p));
115 int nfs_access __P((
116 struct vnode *vp,
117 int mode,
118 struct ucred *cred,
119 struct proc *p));
120 int nfs_getattr __P((
121 struct vnode *vp,
122 struct vattr *vap,
123 struct ucred *cred,
124 struct proc *p));
125 int nfs_setattr __P((
126 struct vnode *vp,
127 struct vattr *vap,
128 struct ucred *cred,
129 struct proc *p));
130 int nfs_read __P((
131 struct vnode *vp,
132 struct uio *uio,
133 int ioflag,
134 struct ucred *cred));
135 int nfs_write __P((
136 struct vnode *vp,
137 struct uio *uio,
138 int ioflag,
139 struct ucred *cred));
140 #define nfs_ioctl ((int (*) __P(( \
141 struct vnode *vp, \
142 int command, \
143 caddr_t data, \
144 int fflag, \
145 struct ucred *cred, \
146 struct proc *p))) enoioctl)
147 #define nfs_select ((int (*) __P(( \
148 struct vnode *vp, \
149 int which, \
150 int fflags, \
151 struct ucred *cred, \
152 struct proc *p))) seltrue)
153 int nfs_mmap __P((
154 struct vnode *vp,
155 int fflags,
156 struct ucred *cred,
157 struct proc *p));
158 int nfs_fsync __P((
159 struct vnode *vp,
160 int fflags,
161 struct ucred *cred,
162 int waitfor,
163 struct proc *p));
164 #define nfs_seek ((int (*) __P(( \
165 struct vnode *vp, \
166 off_t oldoff, \
167 off_t newoff, \
168 struct ucred *cred))) nullop)
169 int nfs_remove __P((
170 struct nameidata *ndp,
171 struct proc *p));
172 int nfs_link __P((
173 struct vnode *vp,
174 struct nameidata *ndp,
175 struct proc *p));
176 int nfs_rename __P((
177 struct nameidata *fndp,
178 struct nameidata *tdnp,
179 struct proc *p));
180 int nfs_mkdir __P((
181 struct nameidata *ndp,
182 struct vattr *vap,
183 struct proc *p));
184 int nfs_rmdir __P((
185 struct nameidata *ndp,
186 struct proc *p));
187 int nfs_symlink __P((
188 struct nameidata *ndp,
189 struct vattr *vap,
190 char *target,
191 struct proc *p));
192 int nfs_readdir __P((
193 struct vnode *vp,
194 struct uio *uio,
195 struct ucred *cred,
196 int *eofflagp,
197 u_int *cookies,
198 int ncookies));
199 int nfs_readlink __P((
200 struct vnode *vp,
201 struct uio *uio,
202 struct ucred *cred));
203 int nfs_abortop __P((
204 struct nameidata *ndp));
205 int nfs_inactive __P((
206 struct vnode *vp,
207 struct proc *p));
208 int nfs_reclaim __P((
209 struct vnode *vp));
210 int nfs_lock __P((
211 struct vnode *vp));
212 int nfs_unlock __P((
213 struct vnode *vp));
214 int nfs_bmap __P((
215 struct vnode *vp,
216 daddr_t bn,
217 struct vnode **vpp,
218 daddr_t *bnp));
219 int nfs_strategy __P((
220 struct buf *bp));
221 int nfs_print __P((
222 struct vnode *vp));
223 int nfs_islocked __P((
224 struct vnode *vp));
225 int nfs_advlock __P((
226 struct vnode *vp,
227 caddr_t id,
228 int op,
229 struct flock *fl,
230 int flags));
231 int nfsspec_close __P((
232 struct vnode *vp,
233 int fflag,
234 struct ucred *cred,
235 struct proc *p));
236 int nfsspec_read __P((
237 struct vnode *vp,
238 struct uio *uio,
239 int ioflag,
240 struct ucred *cred));
241 int nfsspec_write __P((
242 struct vnode *vp,
243 struct uio *uio,
244 int ioflag,
245 struct ucred *cred));
246 int nfsfifo_close __P((
247 struct vnode *vp,
248 int fflag,
249 struct ucred *cred,
250 struct proc *p));
251 int nfsfifo_read __P((
252 struct vnode *vp,
253 struct uio *uio,
254 int ioflag,
255 struct ucred *cred));
256 int nfsfifo_write __P((
257 struct vnode *vp,
258 struct uio *uio,
259 int ioflag,
260 struct ucred *cred));
261 #endif /* !_NFS_NFSNODE_H_ */
262