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.17 (Berkeley) 01/22/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 *dvp, 92 struct vnode **vpp, 93 struct componentname *cnp)); 94 int nfs_create __P(( 95 struct vnode *dvp, 96 struct vnode **vpp, 97 struct componentname *cnp, 98 struct vattr *vap)); 99 int nfs_mknod __P(( 100 struct vnode *dvp, 101 struct vnode **vpp, 102 struct componentname *cnp, 103 struct vattr *vap)); 104 int nfs_open __P(( 105 struct vnode *vp, 106 int mode, 107 struct ucred *cred, 108 struct proc *p)); 109 int nfs_close __P(( 110 struct vnode *vp, 111 int fflag, 112 struct ucred *cred, 113 struct proc *p)); 114 int nfs_access __P(( 115 struct vnode *vp, 116 int mode, 117 struct ucred *cred, 118 struct proc *p)); 119 int nfs_getattr __P(( 120 struct vnode *vp, 121 struct vattr *vap, 122 struct ucred *cred, 123 struct proc *p)); 124 int nfs_setattr __P(( 125 struct vnode *vp, 126 struct vattr *vap, 127 struct ucred *cred, 128 struct proc *p)); 129 int nfs_read __P(( 130 struct vnode *vp, 131 struct uio *uio, 132 int ioflag, 133 struct ucred *cred)); 134 int nfs_write __P(( 135 struct vnode *vp, 136 struct uio *uio, 137 int ioflag, 138 struct ucred *cred)); 139 #define nfs_ioctl ((int (*) __P(( \ 140 struct vnode *vp, \ 141 int command, \ 142 caddr_t data, \ 143 int fflag, \ 144 struct ucred *cred, \ 145 struct proc *p))) enoioctl) 146 #define nfs_select ((int (*) __P(( \ 147 struct vnode *vp, \ 148 int which, \ 149 int fflags, \ 150 struct ucred *cred, \ 151 struct proc *p))) seltrue) 152 int nfs_mmap __P(( 153 struct vnode *vp, 154 int fflags, 155 struct ucred *cred, 156 struct proc *p)); 157 int nfs_fsync __P(( 158 struct vnode *vp, 159 int fflags, 160 struct ucred *cred, 161 int waitfor, 162 struct proc *p)); 163 #define nfs_seek ((int (*) __P(( \ 164 struct vnode *vp, \ 165 off_t oldoff, \ 166 off_t newoff, \ 167 struct ucred *cred))) nullop) 168 int nfs_remove __P(( 169 struct vnode *dvp, 170 struct vnode *vp, 171 struct componentname *cnp)); 172 int nfs_link __P(( 173 register struct vnode *vp, 174 struct vnode *tdvp, 175 struct componentname *cnp)); 176 int nfs_rename __P(( 177 struct vnode *fdvp, 178 struct vnode *fvp, 179 struct componentname *fcnp, 180 struct vnode *tdvp, 181 struct vnode *tvp, 182 struct componentname *tcnp)); 183 int nfs_mkdir __P(( 184 struct vnode *dvp, 185 struct vnode **vpp, 186 struct componentname *cnp, 187 struct vattr *vap)); 188 int nfs_rmdir __P(( 189 struct vnode *dvp, 190 struct vnode *vp, 191 struct componentname *cnp)); 192 int nfs_symlink __P(( 193 struct vnode *dvp, 194 struct vnode **vpp, 195 struct componentname *cnp, 196 struct vattr *vap, 197 char *nm)); 198 int nfs_readdir __P(( 199 struct vnode *vp, 200 struct uio *uio, 201 struct ucred *cred, 202 int *eofflagp)); 203 int nfs_readlink __P(( 204 struct vnode *vp, 205 struct uio *uio, 206 struct ucred *cred)); 207 int nfs_abortop __P(( 208 struct vnode *, 209 struct componentname *)); 210 int nfs_inactive __P(( 211 struct vnode *vp, 212 struct proc *p)); 213 int nfs_reclaim __P(( 214 struct vnode *vp)); 215 int nfs_lock __P(( 216 struct vnode *vp)); 217 int nfs_unlock __P(( 218 struct vnode *vp)); 219 int nfs_bmap __P(( 220 struct vnode *vp, 221 daddr_t bn, 222 struct vnode **vpp, 223 daddr_t *bnp)); 224 int nfs_strategy __P(( 225 struct buf *bp)); 226 int nfs_print __P(( 227 struct vnode *vp)); 228 int nfs_islocked __P(( 229 struct vnode *vp)); 230 int nfs_advlock __P(( 231 struct vnode *vp, 232 caddr_t id, 233 int op, 234 struct flock *fl, 235 int flags)); 236 int nfs_blkatoff __P(( 237 struct vnode *vp, 238 off_t offset, 239 char **res, 240 struct buf **bpp)); 241 int nfs_vget __P(( 242 struct mount *mp, 243 ino_t ino, 244 struct vnode **vpp)); 245 int nfs_valloc __P(( 246 struct vnode *pvp, 247 int mode, 248 struct ucred *cred, 249 struct vnode **vpp)); 250 void nfs_vfree __P(( 251 struct vnode *pvp, 252 ino_t ino, 253 int mode)); 254 int nfs_truncate __P(( 255 struct vnode *vp, 256 u_long length, 257 int flags)); 258 int nfs_update __P(( 259 struct vnode *vp, 260 struct timeval *ta, 261 struct timeval *tm, 262 int waitfor)); 263 int bwrite(); /* NFS needs a bwrite routine */ 264