xref: /csrg-svn/sys/nfs/nfsnode.h (revision 52196)
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  * %sccs.include.redist.c%
9  *
10  *	@(#)nfsnode.h	7.16 (Berkeley) 01/14/92
11  */
12 
13 /*
14  * Silly rename structure that hangs off the nfsnode until the name
15  * can be removed by nfs_inactive()
16  */
17 struct sillyrename {
18 	struct	ucred *s_cred;
19 	struct	vnode *s_dvp;
20 	long	s_namlen;
21 	char	s_name[20];
22 };
23 
24 /*
25  * The nfsnode is the nfs equivalent to ufs's inode. Any similarity
26  * is purely coincidental.
27  * There is a unique nfsnode allocated for each active file,
28  * each current directory, each mounted-on file, text file, and the root.
29  * An nfsnode is 'named' by its file handle. (nget/nfs_node.c)
30  */
31 
32 struct nfsnode {
33 	struct	nfsnode *n_chain[2];	/* must be first */
34 	nfsv2fh_t n_fh;			/* NFS File Handle */
35 	long	n_flag;			/* Flag for locking.. */
36 	struct	vnode *n_vnode;		/* vnode associated with this node */
37 	time_t	n_attrstamp;		/* Time stamp for cached attributes */
38 	struct	vattr n_vattr;		/* Vnode attribute cache */
39 	struct	sillyrename *n_sillyrename; /* Ptr to silly rename struct */
40 	u_long	n_size;			/* Current size of file */
41 	int	n_error;		/* Save write error value */
42 	u_long	n_direofoffset;		/* Dir. EOF offset cache */
43 	union {
44 		struct {
45 			time_t	un_mtime; /* Prev modify time. */
46 			time_t	un_ctime; /* Prev create time. */
47 		} un_nfs;
48 		struct {
49 			u_quad_t un_brev; /* Modify rev when cached */
50 			u_quad_t un_lrev; /* Modify rev for lease */
51 			time_t	un_expiry; /* Lease expiry time */
52 			struct	nfsnode *un_tnext; /* Nqnfs timer chain */
53 			struct	nfsnode *un_tprev;
54 		} un_nqnfs;
55 	} n_un;
56 	struct	sillyrename n_silly;	/* Silly rename struct */
57 	long	n_spare[11];		/* Up to a power of 2 */
58 };
59 
60 #define	n_mtime		n_un.un_nfs.un_mtime
61 #define	n_ctime		n_un.un_nfs.un_ctime
62 #define	n_brev		n_un.un_nqnfs.un_brev
63 #define	n_lrev		n_un.un_nqnfs.un_lrev
64 #define	n_expiry	n_un.un_nqnfs.un_expiry
65 #define	n_tnext		n_un.un_nqnfs.un_tnext
66 #define	n_tprev		n_un.un_nqnfs.un_tprev
67 
68 #define	n_forw		n_chain[0]
69 #define	n_back		n_chain[1]
70 
71 #ifdef KERNEL
72 /*
73  * Convert between nfsnode pointers and vnode pointers
74  */
75 #define VTONFS(vp)	((struct nfsnode *)(vp)->v_data)
76 #define NFSTOV(np)	((struct vnode *)(np)->n_vnode)
77 #endif
78 /*
79  * Flags for n_flag
80  */
81 #define	NMODIFIED	0x0004	/* Might have a modified buffer in bio */
82 #define	NWRITEERR	0x0008	/* Flag write errors so close will know */
83 #define	NQNFSNONCACHE	0x0020	/* Non-cachable lease */
84 #define	NQNFSWRITE	0x0040	/* Write lease */
85 #define	NQNFSEVICTED	0x0080	/* Has been evicted */
86 
87 /*
88  * Prototypes for NFS vnode operations
89  */
90 int	nfs_lookup __P((
91 		struct vnode *vp,
92 		struct nameidata *ndp,
93 		struct proc *p));
94 int	nfs_create __P((
95 		struct nameidata *ndp,
96 		struct vattr *vap,
97 		struct proc *p));
98 int	nfs_mknod __P((
99 		struct nameidata *ndp,
100 		struct vattr *vap,
101 		struct ucred *cred,
102 		struct proc *p));
103 int	nfs_open __P((
104 		struct vnode *vp,
105 		int mode,
106 		struct ucred *cred,
107 		struct proc *p));
108 int	nfs_close __P((
109 		struct vnode *vp,
110 		int fflag,
111 		struct ucred *cred,
112 		struct proc *p));
113 int	nfs_access __P((
114 		struct vnode *vp,
115 		int mode,
116 		struct ucred *cred,
117 		struct proc *p));
118 int	nfs_getattr __P((
119 		struct vnode *vp,
120 		struct vattr *vap,
121 		struct ucred *cred,
122 		struct proc *p));
123 int	nfs_setattr __P((
124 		struct vnode *vp,
125 		struct vattr *vap,
126 		struct ucred *cred,
127 		struct proc *p));
128 int	nfs_read __P((
129 		struct vnode *vp,
130 		struct uio *uio,
131 		int ioflag,
132 		struct ucred *cred));
133 int	nfs_write __P((
134 		struct vnode *vp,
135 		struct uio *uio,
136 		int ioflag,
137 		struct ucred *cred));
138 #define nfs_ioctl ((int (*) __P(( \
139 		struct vnode *vp, \
140 		int command, \
141 		caddr_t data, \
142 		int fflag, \
143 		struct ucred *cred, \
144 		struct proc *p))) enoioctl)
145 #define nfs_select ((int (*) __P(( \
146 		struct vnode *vp, \
147 		int which, \
148 		int fflags, \
149 		struct ucred *cred, \
150 		struct proc *p))) seltrue)
151 int	nfs_mmap __P((
152 		struct vnode *vp,
153 		int fflags,
154 		struct ucred *cred,
155 		struct proc *p));
156 int	nfs_fsync __P((
157 		struct vnode *vp,
158 		int fflags,
159 		struct ucred *cred,
160 		int waitfor,
161 		struct proc *p));
162 #define nfs_seek ((int (*) __P(( \
163 		struct vnode *vp, \
164 		off_t oldoff, \
165 		off_t newoff, \
166 		struct ucred *cred))) nullop)
167 int	nfs_remove __P((
168 		struct nameidata *ndp,
169 		struct proc *p));
170 int	nfs_link __P((
171 		struct vnode *vp,
172 		struct nameidata *ndp,
173 		struct proc *p));
174 int	nfs_rename __P((
175 		struct nameidata *fndp,
176 		struct nameidata *tdnp,
177 		struct proc *p));
178 int	nfs_mkdir __P((
179 		struct nameidata *ndp,
180 		struct vattr *vap,
181 		struct proc *p));
182 int	nfs_rmdir __P((
183 		struct nameidata *ndp,
184 		struct proc *p));
185 int	nfs_symlink __P((
186 		struct nameidata *ndp,
187 		struct vattr *vap,
188 		char *target,
189 		struct proc *p));
190 int	nfs_readdir __P((
191 		struct vnode *vp,
192 		struct uio *uio,
193 		struct ucred *cred,
194 		int *eofflagp));
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	nfs_blkatoff __P((
228 		struct vnode *vp,
229 		off_t offset,
230 		char **res,
231 		struct buf **bpp));
232 int	nfs_vget __P((
233 		struct mount *mp,
234 		ino_t ino,
235 		struct vnode **vpp));
236 int	nfs_valloc __P((
237 		struct vnode *pvp,
238 		int mode,
239 		struct ucred *cred,
240 		struct vnode **vpp));
241 void	nfs_vfree __P((
242 		struct vnode *pvp,
243 		ino_t ino,
244 		int mode));
245 int	nfs_truncate __P((
246 		struct vnode *vp,
247 		u_long length,
248 		int flags));
249 int	nfs_update __P((
250 		struct vnode *vp,
251 		struct timeval *ta,
252 		struct timeval *tm,
253 		int waitfor));
254 int	bwrite();		/* NFS needs a bwrite routine */
255