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.31 (Berkeley) 11/01/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_forw; /* hash, forward */ 34 struct nfsnode **n_back; /* hash, backward */ 35 nfsv2fh_t n_fh; /* NFS File Handle */ 36 long n_flag; /* Flag for locking.. */ 37 struct vnode *n_vnode; /* vnode associated with this node */ 38 struct vattr n_vattr; /* Vnode attribute cache */ 39 time_t n_attrstamp; /* Time stamp for cached attributes */ 40 struct sillyrename *n_sillyrename; /* Ptr to silly rename struct */ 41 off_t n_size; /* Current size of file */ 42 int n_error; /* Save write error value */ 43 u_long n_direofoffset; /* Dir. EOF offset cache */ 44 time_t n_mtime; /* Prev modify time. */ 45 time_t n_ctime; /* Prev create time. */ 46 u_quad_t n_brev; /* Modify rev when cached */ 47 u_quad_t n_lrev; /* Modify rev for lease */ 48 time_t n_expiry; /* Lease expiry time */ 49 struct nfsnode *n_tnext; /* Nqnfs timer chain */ 50 struct nfsnode *n_tprev; 51 long spare1; /* To 8 byte boundary */ 52 struct sillyrename n_silly; /* Silly rename struct */ 53 struct timeval n_atim; /* Special file times */ 54 struct timeval n_mtim; 55 long n_spare[2]; /* Up to a power of 2 */ 56 }; 57 58 /* 59 * Flags for n_flag 60 */ 61 #define NFLUSHINPROG 0x0002 /* Avoid multiple calls to vinvalbuf() */ 62 #define NMODIFIED 0x0004 /* Might have a modified buffer in bio */ 63 #define NWRITEERR 0x0008 /* Flag write errors so close will know */ 64 #define NQNFSNONCACHE 0x0020 /* Non-cachable lease */ 65 #define NQNFSWRITE 0x0040 /* Write lease */ 66 #define NQNFSEVICTED 0x0080 /* Has been evicted */ 67 #define NACC 0x0100 /* Special file accessed */ 68 #define NUPD 0x0200 /* Special file updated */ 69 #define NCHG 0x0400 /* Special file times changed */ 70 71 #define NFS_VINVBUF(np, vp, flags, cred, p) { \ 72 if ((np->n_flag & NFLUSHINPROG) == 0) { \ 73 np->n_flag |= NFLUSHINPROG; \ 74 (void) vinvalbuf(vp, flags, cred, p); \ 75 np->n_flag &= ~(NFLUSHINPROG|NMODIFIED);\ 76 } \ 77 } 78 79 #define NFS_VINVBUFE(np, vp, flags, cred, p, error) { \ 80 if ((np->n_flag & NFLUSHINPROG) == 0) { \ 81 np->n_flag |= NFLUSHINPROG; \ 82 error = vinvalbuf(vp, flags, cred, p); \ 83 np->n_flag &= ~(NFLUSHINPROG|NMODIFIED);\ 84 } else \ 85 error = 0; \ 86 } 87 88 /* 89 * Convert between nfsnode pointers and vnode pointers 90 */ 91 #define VTONFS(vp) ((struct nfsnode *)(vp)->v_data) 92 #define NFSTOV(np) ((struct vnode *)(np)->n_vnode) 93 94 #ifdef KERNEL 95 /* 96 * Prototypes for NFS vnode operations 97 */ 98 int nfs_lookup __P((struct vop_lookup_args *)); 99 int nfs_create __P((struct vop_create_args *)); 100 int nfs_mknod __P((struct vop_mknod_args *)); 101 int nfs_open __P((struct vop_open_args *)); 102 int nfs_close __P((struct vop_close_args *)); 103 int nfsspec_close __P((struct vop_close_args *)); 104 #ifdef FIFO 105 int nfsfifo_close __P((struct vop_close_args *)); 106 #endif 107 int nfs_access __P((struct vop_access_args *)); 108 int nfsspec_access __P((struct vop_access_args *)); 109 int nfs_getattr __P((struct vop_getattr_args *)); 110 int nfs_setattr __P((struct vop_setattr_args *)); 111 int nfs_read __P((struct vop_read_args *)); 112 int nfs_write __P((struct vop_write_args *)); 113 int nfsspec_read __P((struct vop_read_args *)); 114 int nfsspec_write __P((struct vop_write_args *)); 115 #ifdef FIFO 116 int nfsfifo_read __P((struct vop_read_args *)); 117 int nfsfifo_write __P((struct vop_write_args *)); 118 #endif 119 #define nfs_ioctl ((int (*) __P((struct vop_ioctl_args *)))enoioctl) 120 #define nfs_select ((int (*) __P((struct vop_select_args *)))seltrue) 121 int nfs_mmap __P((struct vop_mmap_args *)); 122 int nfs_fsync __P((struct vop_fsync_args *)); 123 #define nfs_seek ((int (*) __P((struct vop_seek_args *)))nullop) 124 int nfs_remove __P((struct vop_remove_args *)); 125 int nfs_link __P((struct vop_link_args *)); 126 int nfs_rename __P((struct vop_rename_args *)); 127 int nfs_mkdir __P((struct vop_mkdir_args *)); 128 int nfs_rmdir __P((struct vop_rmdir_args *)); 129 int nfs_symlink __P((struct vop_symlink_args *)); 130 int nfs_readdir __P((struct vop_readdir_args *)); 131 int nfs_readlink __P((struct vop_readlink_args *)); 132 int nfs_abortop __P((struct vop_abortop_args *)); 133 int nfs_inactive __P((struct vop_inactive_args *)); 134 int nfs_reclaim __P((struct vop_reclaim_args *)); 135 int nfs_lock __P((struct vop_lock_args *)); 136 int nfs_unlock __P((struct vop_unlock_args *)); 137 int nfs_bmap __P((struct vop_bmap_args *)); 138 int nfs_strategy __P((struct vop_strategy_args *)); 139 int nfs_print __P((struct vop_print_args *)); 140 int nfs_islocked __P((struct vop_islocked_args *)); 141 int nfs_advlock __P((struct vop_advlock_args *)); 142 int nfs_blkatoff __P((struct vop_blkatoff_args *)); 143 int nfs_vget __P((struct mount *, ino_t, struct vnode **)); 144 int nfs_valloc __P((struct vop_valloc_args *)); 145 int nfs_vfree __P((struct vop_vfree_args *)); 146 int nfs_truncate __P((struct vop_truncate_args *)); 147 int nfs_update __P((struct vop_update_args *)); 148 int bwrite(); /* NFS needs a bwrite routine */ 149 #endif /* KERNEL */ 150