138414Smckusick /* 238414Smckusick * Copyright (c) 1989 The Regents of the University of California. 338414Smckusick * All rights reserved. 438414Smckusick * 538414Smckusick * This code is derived from software contributed to Berkeley by 638414Smckusick * Rick Macklem at The University of Guelph. 738414Smckusick * 844515Sbostic * %sccs.include.redist.c% 938414Smckusick * 10*48043Smckusick * @(#)nfsnode.h 7.12 (Berkeley) 04/16/91 1138414Smckusick */ 1238414Smckusick 1338414Smckusick /* 1438414Smckusick * The nfsnode is the nfs equivalent to ufs's inode. Any similarity 1538414Smckusick * is purely coincidental. 1638414Smckusick * There is a unique nfsnode allocated for each active file, 1738414Smckusick * each current directory, each mounted-on file, text file, and the root. 1838414Smckusick * An nfsnode is 'named' by its file handle. (nget/nfs_node.c) 1938414Smckusick */ 2038414Smckusick 2138414Smckusick struct nfsnode { 2238414Smckusick struct nfsnode *n_chain[2]; /* must be first */ 2338414Smckusick nfsv2fh_t n_fh; /* NFS File Handle */ 2438414Smckusick long n_flag; /* Flag for locking.. */ 2539393Smckusick struct vnode *n_vnode; /* vnode associated with this nfsnode */ 2640296Smckusick time_t n_attrstamp; /* Time stamp (sec) for attributes */ 2738414Smckusick struct vattr n_vattr; /* Vnode attribute cache */ 2838414Smckusick struct sillyrename *n_sillyrename; /* Ptr to silly rename struct */ 2938884Smacklem u_long n_size; /* Current size of file */ 3038884Smacklem time_t n_mtime; /* Prev modify time to maintain data cache consistency*/ 3140250Smckusick time_t n_ctime; /* Prev create time for name cache consistency*/ 3239348Smckusick int n_error; /* Save write error value */ 3339903Smckusick pid_t n_lockholder; /* holder of nfsnode lock */ 3439903Smckusick pid_t n_lockwaiter; /* most recent waiter for nfsnode lock */ 3540296Smckusick u_long n_direofoffset; /* Dir. EOF offset cache */ 3638414Smckusick }; 3738414Smckusick 3838414Smckusick #define n_forw n_chain[0] 3938414Smckusick #define n_back n_chain[1] 4038414Smckusick 4138414Smckusick #ifdef KERNEL 4238414Smckusick /* 4338414Smckusick * Convert between nfsnode pointers and vnode pointers 4438414Smckusick */ 4538414Smckusick #define VTONFS(vp) ((struct nfsnode *)(vp)->v_data) 4639393Smckusick #define NFSTOV(np) ((struct vnode *)(np)->n_vnode) 4738414Smckusick #endif 4838414Smckusick /* 4938414Smckusick * Flags for n_flag 5038414Smckusick */ 5139348Smckusick #define NLOCKED 0x1 /* Lock the node for other local accesses */ 5239348Smckusick #define NWANT 0x2 /* Want above lock */ 5339348Smckusick #define NMODIFIED 0x4 /* Might have a modified buffer in bio */ 5441895Smckusick #define NWRITEERR 0x8 /* Flag write errors so close will know */ 55*48043Smckusick 56*48043Smckusick /* 57*48043Smckusick * Prototypes for NFS vnode operations 58*48043Smckusick */ 59*48043Smckusick int nfs_lookup __P(( 60*48043Smckusick struct vnode *vp, 61*48043Smckusick struct nameidata *ndp, 62*48043Smckusick struct proc *p)); 63*48043Smckusick int nfs_create __P(( 64*48043Smckusick struct nameidata *ndp, 65*48043Smckusick struct vattr *vap, 66*48043Smckusick struct proc *p)); 67*48043Smckusick int nfs_mknod __P(( 68*48043Smckusick struct nameidata *ndp, 69*48043Smckusick struct vattr *vap, 70*48043Smckusick struct ucred *cred, 71*48043Smckusick struct proc *p)); 72*48043Smckusick int nfs_open __P(( 73*48043Smckusick struct vnode *vp, 74*48043Smckusick int mode, 75*48043Smckusick struct ucred *cred, 76*48043Smckusick struct proc *p)); 77*48043Smckusick int nfs_close __P(( 78*48043Smckusick struct vnode *vp, 79*48043Smckusick int fflag, 80*48043Smckusick struct ucred *cred, 81*48043Smckusick struct proc *p)); 82*48043Smckusick int nfs_access __P(( 83*48043Smckusick struct vnode *vp, 84*48043Smckusick int mode, 85*48043Smckusick struct ucred *cred, 86*48043Smckusick struct proc *p)); 87*48043Smckusick int nfs_getattr __P(( 88*48043Smckusick struct vnode *vp, 89*48043Smckusick struct vattr *vap, 90*48043Smckusick struct ucred *cred, 91*48043Smckusick struct proc *p)); 92*48043Smckusick int nfs_setattr __P(( 93*48043Smckusick struct vnode *vp, 94*48043Smckusick struct vattr *vap, 95*48043Smckusick struct ucred *cred, 96*48043Smckusick struct proc *p)); 97*48043Smckusick int nfs_read __P(( 98*48043Smckusick struct vnode *vp, 99*48043Smckusick struct uio *uio, 100*48043Smckusick int ioflag, 101*48043Smckusick struct ucred *cred)); 102*48043Smckusick int nfs_write __P(( 103*48043Smckusick struct vnode *vp, 104*48043Smckusick struct uio *uio, 105*48043Smckusick int ioflag, 106*48043Smckusick struct ucred *cred)); 107*48043Smckusick #define nfs_ioctl ((int (*) __P(( \ 108*48043Smckusick struct vnode *vp, \ 109*48043Smckusick int command, \ 110*48043Smckusick caddr_t data, \ 111*48043Smckusick int fflag, \ 112*48043Smckusick struct ucred *cred, \ 113*48043Smckusick struct proc *p))) enoioctl) 114*48043Smckusick #define nfs_select ((int (*) __P(( \ 115*48043Smckusick struct vnode *vp, \ 116*48043Smckusick int which, \ 117*48043Smckusick int fflags, \ 118*48043Smckusick struct ucred *cred, \ 119*48043Smckusick struct proc *p))) seltrue) 120*48043Smckusick int nfs_mmap __P(( 121*48043Smckusick struct vnode *vp, 122*48043Smckusick int fflags, 123*48043Smckusick struct ucred *cred, 124*48043Smckusick struct proc *p)); 125*48043Smckusick int nfs_fsync __P(( 126*48043Smckusick struct vnode *vp, 127*48043Smckusick int fflags, 128*48043Smckusick struct ucred *cred, 129*48043Smckusick int waitfor, 130*48043Smckusick struct proc *p)); 131*48043Smckusick #define nfs_seek ((int (*) __P(( \ 132*48043Smckusick struct vnode *vp, \ 133*48043Smckusick off_t oldoff, \ 134*48043Smckusick off_t newoff, \ 135*48043Smckusick struct ucred *cred))) nullop) 136*48043Smckusick int nfs_remove __P(( 137*48043Smckusick struct nameidata *ndp, 138*48043Smckusick struct proc *p)); 139*48043Smckusick int nfs_link __P(( 140*48043Smckusick struct vnode *vp, 141*48043Smckusick struct nameidata *ndp, 142*48043Smckusick struct proc *p)); 143*48043Smckusick int nfs_rename __P(( 144*48043Smckusick struct nameidata *fndp, 145*48043Smckusick struct nameidata *tdnp, 146*48043Smckusick struct proc *p)); 147*48043Smckusick int nfs_mkdir __P(( 148*48043Smckusick struct nameidata *ndp, 149*48043Smckusick struct vattr *vap, 150*48043Smckusick struct proc *p)); 151*48043Smckusick int nfs_rmdir __P(( 152*48043Smckusick struct nameidata *ndp, 153*48043Smckusick struct proc *p)); 154*48043Smckusick int nfs_symlink __P(( 155*48043Smckusick struct nameidata *ndp, 156*48043Smckusick struct vattr *vap, 157*48043Smckusick char *target, 158*48043Smckusick struct proc *p)); 159*48043Smckusick int nfs_readdir __P(( 160*48043Smckusick struct vnode *vp, 161*48043Smckusick struct uio *uio, 162*48043Smckusick struct ucred *cred, 163*48043Smckusick int *eofflagp)); 164*48043Smckusick int nfs_readlink __P(( 165*48043Smckusick struct vnode *vp, 166*48043Smckusick struct uio *uio, 167*48043Smckusick struct ucred *cred)); 168*48043Smckusick int nfs_abortop __P(( 169*48043Smckusick struct nameidata *ndp)); 170*48043Smckusick int nfs_inactive __P(( 171*48043Smckusick struct vnode *vp, 172*48043Smckusick struct proc *p)); 173*48043Smckusick int nfs_reclaim __P(( 174*48043Smckusick struct vnode *vp)); 175*48043Smckusick int nfs_lock __P(( 176*48043Smckusick struct vnode *vp)); 177*48043Smckusick int nfs_unlock __P(( 178*48043Smckusick struct vnode *vp)); 179*48043Smckusick int nfs_bmap __P(( 180*48043Smckusick struct vnode *vp, 181*48043Smckusick daddr_t bn, 182*48043Smckusick struct vnode **vpp, 183*48043Smckusick daddr_t *bnp)); 184*48043Smckusick int nfs_strategy __P(( 185*48043Smckusick struct buf *bp)); 186*48043Smckusick int nfs_print __P(( 187*48043Smckusick struct vnode *vp)); 188*48043Smckusick int nfs_islocked __P(( 189*48043Smckusick struct vnode *vp)); 190*48043Smckusick int nfs_advlock __P(( 191*48043Smckusick struct vnode *vp, 192*48043Smckusick caddr_t id, 193*48043Smckusick int op, 194*48043Smckusick struct flock *fl, 195*48043Smckusick int flags)); 196