nfsnode.h revision 1.1 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 * @(#)nfsnode.h 7.12 (Berkeley) 4/16/91
37 */
38
39 #ifndef _NFS_NFSNODE_H_
40 #define _NFS_NFSNODE_H_
41
42 /*
43 * The nfsnode is the nfs equivalent to ufs's inode. Any similarity
44 * is purely coincidental.
45 * There is a unique nfsnode allocated for each active file,
46 * each current directory, each mounted-on file, text file, and the root.
47 * An nfsnode is 'named' by its file handle. (nget/nfs_node.c)
48 */
49
50 struct nfsnode {
51 struct nfsnode *n_chain[2]; /* must be first */
52 nfsv2fh_t n_fh; /* NFS File Handle */
53 long n_flag; /* Flag for locking.. */
54 struct vnode *n_vnode; /* vnode associated with this nfsnode */
55 time_t n_attrstamp; /* Time stamp (sec) for attributes */
56 struct vattr n_vattr; /* Vnode attribute cache */
57 struct sillyrename *n_sillyrename; /* Ptr to silly rename struct */
58 u_long n_size; /* Current size of file */
59 time_t n_mtime; /* Prev modify time to maintain data cache consistency*/
60 time_t n_ctime; /* Prev create time for name cache consistency*/
61 int n_error; /* Save write error value */
62 pid_t n_lockholder; /* holder of nfsnode lock */
63 pid_t n_lockwaiter; /* most recent waiter for nfsnode lock */
64 u_long n_direofoffset; /* Dir. EOF offset cache */
65 };
66
67 #define n_forw n_chain[0]
68 #define n_back n_chain[1]
69
70 #ifdef KERNEL
71 /*
72 * Convert between nfsnode pointers and vnode pointers
73 */
74 #define VTONFS(vp) ((struct nfsnode *)(vp)->v_data)
75 #define NFSTOV(np) ((struct vnode *)(np)->n_vnode)
76 #endif
77 /*
78 * Flags for n_flag
79 */
80 #define NLOCKED 0x1 /* Lock the node for other local accesses */
81 #define NWANT 0x2 /* Want above lock */
82 #define NMODIFIED 0x4 /* Might have a modified buffer in bio */
83 #define NWRITEERR 0x8 /* 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 int nfs_readlink __P((
194 struct vnode *vp,
195 struct uio *uio,
196 struct ucred *cred));
197 int nfs_abortop __P((
198 struct nameidata *ndp));
199 int nfs_inactive __P((
200 struct vnode *vp,
201 struct proc *p));
202 int nfs_reclaim __P((
203 struct vnode *vp));
204 int nfs_lock __P((
205 struct vnode *vp));
206 int nfs_unlock __P((
207 struct vnode *vp));
208 int nfs_bmap __P((
209 struct vnode *vp,
210 daddr_t bn,
211 struct vnode **vpp,
212 daddr_t *bnp));
213 int nfs_strategy __P((
214 struct buf *bp));
215 int nfs_print __P((
216 struct vnode *vp));
217 int nfs_islocked __P((
218 struct vnode *vp));
219 int nfs_advlock __P((
220 struct vnode *vp,
221 caddr_t id,
222 int op,
223 struct flock *fl,
224 int flags));
225
226 #endif /* !_NFS_NFSNODE_H_ */
227