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*51572Smckusick * @(#)nfsnode.h 7.13 (Berkeley) 11/05/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 */ 5548043Smckusick 5648043Smckusick /* 5748043Smckusick * Prototypes for NFS vnode operations 5848043Smckusick */ 5948043Smckusick int nfs_lookup __P(( 6048043Smckusick struct vnode *vp, 6148043Smckusick struct nameidata *ndp, 6248043Smckusick struct proc *p)); 6348043Smckusick int nfs_create __P(( 6448043Smckusick struct nameidata *ndp, 6548043Smckusick struct vattr *vap, 6648043Smckusick struct proc *p)); 6748043Smckusick int nfs_mknod __P(( 6848043Smckusick struct nameidata *ndp, 6948043Smckusick struct vattr *vap, 7048043Smckusick struct ucred *cred, 7148043Smckusick struct proc *p)); 7248043Smckusick int nfs_open __P(( 7348043Smckusick struct vnode *vp, 7448043Smckusick int mode, 7548043Smckusick struct ucred *cred, 7648043Smckusick struct proc *p)); 7748043Smckusick int nfs_close __P(( 7848043Smckusick struct vnode *vp, 7948043Smckusick int fflag, 8048043Smckusick struct ucred *cred, 8148043Smckusick struct proc *p)); 8248043Smckusick int nfs_access __P(( 8348043Smckusick struct vnode *vp, 8448043Smckusick int mode, 8548043Smckusick struct ucred *cred, 8648043Smckusick struct proc *p)); 8748043Smckusick int nfs_getattr __P(( 8848043Smckusick struct vnode *vp, 8948043Smckusick struct vattr *vap, 9048043Smckusick struct ucred *cred, 9148043Smckusick struct proc *p)); 9248043Smckusick int nfs_setattr __P(( 9348043Smckusick struct vnode *vp, 9448043Smckusick struct vattr *vap, 9548043Smckusick struct ucred *cred, 9648043Smckusick struct proc *p)); 9748043Smckusick int nfs_read __P(( 9848043Smckusick struct vnode *vp, 9948043Smckusick struct uio *uio, 10048043Smckusick int ioflag, 10148043Smckusick struct ucred *cred)); 10248043Smckusick int nfs_write __P(( 10348043Smckusick struct vnode *vp, 10448043Smckusick struct uio *uio, 10548043Smckusick int ioflag, 10648043Smckusick struct ucred *cred)); 10748043Smckusick #define nfs_ioctl ((int (*) __P(( \ 10848043Smckusick struct vnode *vp, \ 10948043Smckusick int command, \ 11048043Smckusick caddr_t data, \ 11148043Smckusick int fflag, \ 11248043Smckusick struct ucred *cred, \ 11348043Smckusick struct proc *p))) enoioctl) 11448043Smckusick #define nfs_select ((int (*) __P(( \ 11548043Smckusick struct vnode *vp, \ 11648043Smckusick int which, \ 11748043Smckusick int fflags, \ 11848043Smckusick struct ucred *cred, \ 11948043Smckusick struct proc *p))) seltrue) 12048043Smckusick int nfs_mmap __P(( 12148043Smckusick struct vnode *vp, 12248043Smckusick int fflags, 12348043Smckusick struct ucred *cred, 12448043Smckusick struct proc *p)); 12548043Smckusick int nfs_fsync __P(( 12648043Smckusick struct vnode *vp, 12748043Smckusick int fflags, 12848043Smckusick struct ucred *cred, 12948043Smckusick int waitfor, 13048043Smckusick struct proc *p)); 13148043Smckusick #define nfs_seek ((int (*) __P(( \ 13248043Smckusick struct vnode *vp, \ 13348043Smckusick off_t oldoff, \ 13448043Smckusick off_t newoff, \ 13548043Smckusick struct ucred *cred))) nullop) 13648043Smckusick int nfs_remove __P(( 13748043Smckusick struct nameidata *ndp, 13848043Smckusick struct proc *p)); 13948043Smckusick int nfs_link __P(( 14048043Smckusick struct vnode *vp, 14148043Smckusick struct nameidata *ndp, 14248043Smckusick struct proc *p)); 14348043Smckusick int nfs_rename __P(( 14448043Smckusick struct nameidata *fndp, 14548043Smckusick struct nameidata *tdnp, 14648043Smckusick struct proc *p)); 14748043Smckusick int nfs_mkdir __P(( 14848043Smckusick struct nameidata *ndp, 14948043Smckusick struct vattr *vap, 15048043Smckusick struct proc *p)); 15148043Smckusick int nfs_rmdir __P(( 15248043Smckusick struct nameidata *ndp, 15348043Smckusick struct proc *p)); 15448043Smckusick int nfs_symlink __P(( 15548043Smckusick struct nameidata *ndp, 15648043Smckusick struct vattr *vap, 15748043Smckusick char *target, 15848043Smckusick struct proc *p)); 15948043Smckusick int nfs_readdir __P(( 16048043Smckusick struct vnode *vp, 16148043Smckusick struct uio *uio, 16248043Smckusick struct ucred *cred, 16348043Smckusick int *eofflagp)); 16448043Smckusick int nfs_readlink __P(( 16548043Smckusick struct vnode *vp, 16648043Smckusick struct uio *uio, 16748043Smckusick struct ucred *cred)); 16848043Smckusick int nfs_abortop __P(( 16948043Smckusick struct nameidata *ndp)); 17048043Smckusick int nfs_inactive __P(( 17148043Smckusick struct vnode *vp, 17248043Smckusick struct proc *p)); 17348043Smckusick int nfs_reclaim __P(( 17448043Smckusick struct vnode *vp)); 17548043Smckusick int nfs_lock __P(( 17648043Smckusick struct vnode *vp)); 17748043Smckusick int nfs_unlock __P(( 17848043Smckusick struct vnode *vp)); 17948043Smckusick int nfs_bmap __P(( 18048043Smckusick struct vnode *vp, 18148043Smckusick daddr_t bn, 18248043Smckusick struct vnode **vpp, 18348043Smckusick daddr_t *bnp)); 18448043Smckusick int nfs_strategy __P(( 18548043Smckusick struct buf *bp)); 18648043Smckusick int nfs_print __P(( 18748043Smckusick struct vnode *vp)); 18848043Smckusick int nfs_islocked __P(( 18948043Smckusick struct vnode *vp)); 19048043Smckusick int nfs_advlock __P(( 19148043Smckusick struct vnode *vp, 19248043Smckusick caddr_t id, 19348043Smckusick int op, 19448043Smckusick struct flock *fl, 19548043Smckusick int flags)); 196*51572Smckusick int nfs_blkatoff __P(( 197*51572Smckusick struct vnode *vp, 198*51572Smckusick off_t offset, 199*51572Smckusick char **res, 200*51572Smckusick struct buf **bpp)); 201*51572Smckusick int nfs_vget __P(( 202*51572Smckusick struct mount *mp, 203*51572Smckusick ino_t ino, 204*51572Smckusick struct vnode **vpp)); 205*51572Smckusick int nfs_valloc __P(( 206*51572Smckusick struct vnode *pvp, 207*51572Smckusick int mode, 208*51572Smckusick struct ucred *cred, 209*51572Smckusick struct vnode **vpp)); 210*51572Smckusick void nfs_vfree __P(( 211*51572Smckusick struct vnode *pvp, 212*51572Smckusick ino_t ino, 213*51572Smckusick int mode)); 214*51572Smckusick int nfs_truncate __P(( 215*51572Smckusick struct vnode *vp, 216*51572Smckusick u_long length, 217*51572Smckusick int flags)); 218*51572Smckusick int nfs_update __P(( 219*51572Smckusick struct vnode *vp, 220*51572Smckusick struct timeval *ta, 221*51572Smckusick struct timeval *tm, 222*51572Smckusick int waitfor)); 223*51572Smckusick int bwrite(); /* NFS needs a bwrite routine */ 224