xref: /original-bsd/sys/nfs/nfsnode.h (revision e59fb703)
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.15 (Berkeley) 12/19/91
11  */
12 
13 /*
14  * The nfsnode is the nfs equivalent to ufs's inode. Any similarity
15  * is purely coincidental.
16  * There is a unique nfsnode allocated for each active file,
17  * each current directory, each mounted-on file, text file, and the root.
18  * An nfsnode is 'named' by its file handle. (nget/nfs_node.c)
19  */
20 
21 struct nfsnode {
22 	struct	nfsnode *n_chain[2];	/* must be first */
23 	nfsv2fh_t n_fh;			/* NFS File Handle */
24 	long	n_flag;			/* Flag for locking.. */
25 	struct	vnode *n_vnode;	/* vnode associated with this nfsnode */
26 	time_t	n_attrstamp;	/* Time stamp (sec) for attributes */
27 	struct	vattr n_vattr;	/* Vnode attribute cache */
28 	struct	sillyrename *n_sillyrename;	/* Ptr to silly rename struct */
29 	u_long	n_size;		/* Current size of file */
30 	time_t	n_mtime;	/* Prev modify time to maintain data cache consistency*/
31 	time_t	n_ctime;	/* Prev create time for name cache consistency*/
32 	int	n_error;	/* Save write error value */
33 	pid_t	n_lockholder;	/* holder of nfsnode lock */
34 	pid_t	n_lockwaiter;	/* most recent waiter for nfsnode lock */
35 	u_long	n_direofoffset;	/* Dir. EOF offset cache */
36 	struct	sillyrename n_silly;	/* allocate here since we have room */
37 	long	n_spare[7];	/* round up to size 256 */
38 };
39 
40 #define	n_forw		n_chain[0]
41 #define	n_back		n_chain[1]
42 
43 #ifdef KERNEL
44 /*
45  * Convert between nfsnode pointers and vnode pointers
46  */
47 #define VTONFS(vp)	((struct nfsnode *)(vp)->v_data)
48 #define NFSTOV(np)	((struct vnode *)(np)->n_vnode)
49 #endif
50 /*
51  * Flags for n_flag
52  */
53 #define	NLOCKED		0x1	/* Lock the node for other local accesses */
54 #define	NWANT		0x2	/* Want above lock */
55 #define	NMODIFIED	0x4	/* Might have a modified buffer in bio */
56 #define	NWRITEERR	0x8	/* Flag write errors so close will know */
57 
58 /*
59  * Prototypes for NFS vnode operations
60  */
61 int	nfs_lookup __P((
62 		struct vnode *vp,
63 		struct nameidata *ndp,
64 		struct proc *p));
65 int	nfs_create __P((
66 		struct nameidata *ndp,
67 		struct vattr *vap,
68 		struct proc *p));
69 int	nfs_mknod __P((
70 		struct nameidata *ndp,
71 		struct vattr *vap,
72 		struct ucred *cred,
73 		struct proc *p));
74 int	nfs_open __P((
75 		struct vnode *vp,
76 		int mode,
77 		struct ucred *cred,
78 		struct proc *p));
79 int	nfs_close __P((
80 		struct vnode *vp,
81 		int fflag,
82 		struct ucred *cred,
83 		struct proc *p));
84 int	nfs_access __P((
85 		struct vnode *vp,
86 		int mode,
87 		struct ucred *cred,
88 		struct proc *p));
89 int	nfs_getattr __P((
90 		struct vnode *vp,
91 		struct vattr *vap,
92 		struct ucred *cred,
93 		struct proc *p));
94 int	nfs_setattr __P((
95 		struct vnode *vp,
96 		struct vattr *vap,
97 		struct ucred *cred,
98 		struct proc *p));
99 int	nfs_read __P((
100 		struct vnode *vp,
101 		struct uio *uio,
102 		int ioflag,
103 		struct ucred *cred));
104 int	nfs_write __P((
105 		struct vnode *vp,
106 		struct uio *uio,
107 		int ioflag,
108 		struct ucred *cred));
109 #define nfs_ioctl ((int (*) __P(( \
110 		struct vnode *vp, \
111 		int command, \
112 		caddr_t data, \
113 		int fflag, \
114 		struct ucred *cred, \
115 		struct proc *p))) enoioctl)
116 #define nfs_select ((int (*) __P(( \
117 		struct vnode *vp, \
118 		int which, \
119 		int fflags, \
120 		struct ucred *cred, \
121 		struct proc *p))) seltrue)
122 int	nfs_mmap __P((
123 		struct vnode *vp,
124 		int fflags,
125 		struct ucred *cred,
126 		struct proc *p));
127 int	nfs_fsync __P((
128 		struct vnode *vp,
129 		int fflags,
130 		struct ucred *cred,
131 		int waitfor,
132 		struct proc *p));
133 #define nfs_seek ((int (*) __P(( \
134 		struct vnode *vp, \
135 		off_t oldoff, \
136 		off_t newoff, \
137 		struct ucred *cred))) nullop)
138 int	nfs_remove __P((
139 		struct nameidata *ndp,
140 		struct proc *p));
141 int	nfs_link __P((
142 		struct vnode *vp,
143 		struct nameidata *ndp,
144 		struct proc *p));
145 int	nfs_rename __P((
146 		struct nameidata *fndp,
147 		struct nameidata *tdnp,
148 		struct proc *p));
149 int	nfs_mkdir __P((
150 		struct nameidata *ndp,
151 		struct vattr *vap,
152 		struct proc *p));
153 int	nfs_rmdir __P((
154 		struct nameidata *ndp,
155 		struct proc *p));
156 int	nfs_symlink __P((
157 		struct nameidata *ndp,
158 		struct vattr *vap,
159 		char *target,
160 		struct proc *p));
161 int	nfs_readdir __P((
162 		struct vnode *vp,
163 		struct uio *uio,
164 		struct ucred *cred,
165 		int *eofflagp));
166 int	nfs_readlink __P((
167 		struct vnode *vp,
168 		struct uio *uio,
169 		struct ucred *cred));
170 int	nfs_abortop __P((
171 		struct nameidata *ndp));
172 int	nfs_inactive __P((
173 		struct vnode *vp,
174 		struct proc *p));
175 int	nfs_reclaim __P((
176 		struct vnode *vp));
177 int	nfs_lock __P((
178 		struct vnode *vp));
179 int	nfs_unlock __P((
180 		struct vnode *vp));
181 int	nfs_bmap __P((
182 		struct vnode *vp,
183 		daddr_t bn,
184 		struct vnode **vpp,
185 		daddr_t *bnp));
186 int	nfs_strategy __P((
187 		struct buf *bp));
188 int	nfs_print __P((
189 		struct vnode *vp));
190 int	nfs_islocked __P((
191 		struct vnode *vp));
192 int	nfs_advlock __P((
193 		struct vnode *vp,
194 		caddr_t id,
195 		int op,
196 		struct flock *fl,
197 		int flags));
198 int	nfs_blkatoff __P((
199 		struct vnode *vp,
200 		off_t offset,
201 		char **res,
202 		struct buf **bpp));
203 int	nfs_vget __P((
204 		struct mount *mp,
205 		ino_t ino,
206 		struct vnode **vpp));
207 int	nfs_valloc __P((
208 		struct vnode *pvp,
209 		int mode,
210 		struct ucred *cred,
211 		struct vnode **vpp));
212 void	nfs_vfree __P((
213 		struct vnode *pvp,
214 		ino_t ino,
215 		int mode));
216 int	nfs_truncate __P((
217 		struct vnode *vp,
218 		u_long length,
219 		int flags));
220 int	nfs_update __P((
221 		struct vnode *vp,
222 		struct timeval *ta,
223 		struct timeval *tm,
224 		int waitfor));
225 int	bwrite();		/* NFS needs a bwrite routine */
226