Home | History | Annotate | Line # | Download | only in nfs
nfsnode.h revision 1.5.2.1
      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  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  * 1. Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  * 2. Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in the
     15  *    documentation and/or other materials provided with the distribution.
     16  * 3. All advertising materials mentioning features or use of this software
     17  *    must display the following acknowledgement:
     18  *	This product includes software developed by the University of
     19  *	California, Berkeley and its contributors.
     20  * 4. Neither the name of the University nor the names of its contributors
     21  *    may be used to endorse or promote products derived from this software
     22  *    without specific prior written permission.
     23  *
     24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     34  * SUCH DAMAGE.
     35  *
     36  *	from: @(#)nfsnode.h	7.12 (Berkeley) 4/16/91
     37  *	$Id: nfsnode.h,v 1.5.2.1 1993/12/16 23:44:23 pk Exp $
     38  */
     39 
     40 #ifndef _NFS_NFSNODE_H_
     41 #define _NFS_NFSNODE_H_
     42 
     43 /*
     44  * The nfsnode is the nfs equivalent to ufs's inode. Any similarity
     45  * is purely coincidental.
     46  * There is a unique nfsnode allocated for each active file,
     47  * each current directory, each mounted-on file, text file, and the root.
     48  * An nfsnode is 'named' by its file handle. (nget/nfs_node.c)
     49  */
     50 
     51 struct nfsnode {
     52 	struct	nfsnode *n_chain[2];	/* must be first */
     53 	nfsv2fh_t n_fh;			/* NFS File Handle */
     54 	long	n_flag;			/* Flag for locking.. */
     55 	struct	vnode *n_vnode;	/* vnode associated with this nfsnode */
     56 	time_t	n_attrstamp;	/* Time stamp (sec) for attributes */
     57 	struct	vattr n_vattr;	/* Vnode attribute cache */
     58 	struct	sillyrename *n_sillyrename;	/* Ptr to silly rename struct */
     59 	u_quad	n_qsize;		/* Current size of file */
     60 	struct lockf *n_lockf; 	/* Locking record of file */
     61 	time_t	n_mtime;	/* Prev modify time to maintain data cache consistency*/
     62 	time_t	n_ctime;	/* Prev create time for name cache consistency*/
     63 	int	n_error;	/* Save write error value */
     64 	pid_t	n_lockholder;	/* holder of nfsnode lock */
     65 	pid_t	n_lockwaiter;	/* most recent waiter for nfsnode lock */
     66 	u_quad	n_qdireofoffset;	/* Dir. EOF offset cache */
     67 };
     68 
     69 #if 1
     70 #if BYTE_ORDER == LITTLE_ENDIAN
     71 #define n_size		n_qsize.val[0]
     72 #define n_direofoffset		n_qdireofoffset.val[0]
     73 #else /* BYTE_ORDER == BIG_ENDIAN */
     74 #define n_size		n_qsize.val[1]
     75 #define n_direofoffset		n_qdireofoffset.val[1]
     76 #endif
     77 #endif
     78 
     79 #define	n_forw		n_chain[0]
     80 #define	n_back		n_chain[1]
     81 
     82 #ifdef KERNEL
     83 /*
     84  * Convert between nfsnode pointers and vnode pointers
     85  */
     86 #define VTONFS(vp)	((struct nfsnode *)(vp)->v_data)
     87 #define NFSTOV(np)	((struct vnode *)(np)->n_vnode)
     88 #endif
     89 /*
     90  * Flags for n_flag
     91  */
     92 #define	NLOCKED		0x1	/* Lock the node for other local accesses */
     93 #define	NWANT		0x2	/* Want above lock */
     94 #define	NMODIFIED	0x4	/* Might have a modified buffer in bio */
     95 #define	NWRITEERR	0x8	/* Flag write errors so close will know */
     96 
     97 /*
     98  * Prototypes for NFS vnode operations
     99  */
    100 int	nfs_lookup __P((
    101 		struct vnode *vp,
    102 		struct nameidata *ndp,
    103 		struct proc *p));
    104 int	nfs_create __P((
    105 		struct nameidata *ndp,
    106 		struct vattr *vap,
    107 		struct proc *p));
    108 int	nfs_mknod __P((
    109 		struct nameidata *ndp,
    110 		struct vattr *vap,
    111 		struct ucred *cred,
    112 		struct proc *p));
    113 int	nfs_open __P((
    114 		struct vnode *vp,
    115 		int mode,
    116 		struct ucred *cred,
    117 		struct proc *p));
    118 int	nfs_close __P((
    119 		struct vnode *vp,
    120 		int fflag,
    121 		struct ucred *cred,
    122 		struct proc *p));
    123 int	nfs_access __P((
    124 		struct vnode *vp,
    125 		int mode,
    126 		struct ucred *cred,
    127 		struct proc *p));
    128 int	nfs_getattr __P((
    129 		struct vnode *vp,
    130 		struct vattr *vap,
    131 		struct ucred *cred,
    132 		struct proc *p));
    133 int	nfs_setattr __P((
    134 		struct vnode *vp,
    135 		struct vattr *vap,
    136 		struct ucred *cred,
    137 		struct proc *p));
    138 int	nfs_read __P((
    139 		struct vnode *vp,
    140 		struct uio *uio,
    141 		int ioflag,
    142 		struct ucred *cred));
    143 int	nfs_write __P((
    144 		struct vnode *vp,
    145 		struct uio *uio,
    146 		int ioflag,
    147 		struct ucred *cred));
    148 #define nfs_ioctl ((int (*) __P(( \
    149 		struct vnode *vp, \
    150 		int command, \
    151 		caddr_t data, \
    152 		int fflag, \
    153 		struct ucred *cred, \
    154 		struct proc *p))) enoioctl)
    155 #define nfs_select ((int (*) __P(( \
    156 		struct vnode *vp, \
    157 		int which, \
    158 		int fflags, \
    159 		struct ucred *cred, \
    160 		struct proc *p))) seltrue)
    161 int	nfs_mmap __P((
    162 		struct vnode *vp,
    163 		int fflags,
    164 		struct ucred *cred,
    165 		struct proc *p));
    166 int	nfs_fsync __P((
    167 		struct vnode *vp,
    168 		int fflags,
    169 		struct ucred *cred,
    170 		int waitfor,
    171 		struct proc *p));
    172 #define nfs_seek ((int (*) __P(( \
    173 		struct vnode *vp, \
    174 		off_t oldoff, \
    175 		off_t newoff, \
    176 		struct ucred *cred))) nullop)
    177 int	nfs_remove __P((
    178 		struct nameidata *ndp,
    179 		struct proc *p));
    180 int	nfs_link __P((
    181 		struct vnode *vp,
    182 		struct nameidata *ndp,
    183 		struct proc *p));
    184 int	nfs_rename __P((
    185 		struct nameidata *fndp,
    186 		struct nameidata *tdnp,
    187 		struct proc *p));
    188 int	nfs_mkdir __P((
    189 		struct nameidata *ndp,
    190 		struct vattr *vap,
    191 		struct proc *p));
    192 int	nfs_rmdir __P((
    193 		struct nameidata *ndp,
    194 		struct proc *p));
    195 int	nfs_symlink __P((
    196 		struct nameidata *ndp,
    197 		struct vattr *vap,
    198 		char *target,
    199 		struct proc *p));
    200 int	nfs_readdir __P((
    201 		struct vnode *vp,
    202 		struct uio *uio,
    203 		struct ucred *cred,
    204 		int *eofflagp,
    205 		u_int *cookies,
    206 		int ncookies));
    207 int	nfs_readlink __P((
    208 		struct vnode *vp,
    209 		struct uio *uio,
    210 		struct ucred *cred));
    211 int	nfs_abortop __P((
    212 		struct nameidata *ndp));
    213 int	nfs_inactive __P((
    214 		struct vnode *vp,
    215 		struct proc *p));
    216 int	nfs_reclaim __P((
    217 		struct vnode *vp));
    218 int	nfs_lock __P((
    219 		struct vnode *vp));
    220 int	nfs_unlock __P((
    221 		struct vnode *vp));
    222 int	nfs_bmap __P((
    223 		struct vnode *vp,
    224 		daddr_t bn,
    225 		struct vnode **vpp,
    226 		daddr_t *bnp));
    227 int	nfs_strategy __P((
    228 		struct buf *bp));
    229 void	nfs_print __P((
    230 		struct vnode *vp));
    231 int	nfs_islocked __P((
    232 		struct vnode *vp));
    233 int	nfs_advlock __P((
    234 		struct vnode *vp,
    235 		caddr_t id,
    236 		int op,
    237 		struct flock *fl,
    238 		int flags));
    239 
    240 #endif /* !_NFS_NFSNODE_H_ */
    241