Home | History | Annotate | Line # | Download | only in nfs
nfsnode.h revision 1.4
      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.4 1993/08/02 23:12:32 mycroft 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_long	n_size;		/* 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_long	n_direofoffset;	/* Dir. EOF offset cache */
     67 };
     68 
     69 #define	n_forw		n_chain[0]
     70 #define	n_back		n_chain[1]
     71 
     72 #ifdef KERNEL
     73 /*
     74  * Convert between nfsnode pointers and vnode pointers
     75  */
     76 #define VTONFS(vp)	((struct nfsnode *)(vp)->v_data)
     77 #define NFSTOV(np)	((struct vnode *)(np)->n_vnode)
     78 #endif
     79 /*
     80  * Flags for n_flag
     81  */
     82 #define	NLOCKED		0x1	/* Lock the node for other local accesses */
     83 #define	NWANT		0x2	/* Want above lock */
     84 #define	NMODIFIED	0x4	/* Might have a modified buffer in bio */
     85 #define	NWRITEERR	0x8	/* Flag write errors so close will know */
     86 
     87 /*
     88  * Prototypes for NFS vnode operations
     89  */
     90 int	nfs_lookup __P((
     91 		struct vnode *vp,
     92 		struct nameidata *ndp,
     93 		struct proc *p));
     94 int	nfs_create __P((
     95 		struct nameidata *ndp,
     96 		struct vattr *vap,
     97 		struct proc *p));
     98 int	nfs_mknod __P((
     99 		struct nameidata *ndp,
    100 		struct vattr *vap,
    101 		struct ucred *cred,
    102 		struct proc *p));
    103 int	nfs_open __P((
    104 		struct vnode *vp,
    105 		int mode,
    106 		struct ucred *cred,
    107 		struct proc *p));
    108 int	nfs_close __P((
    109 		struct vnode *vp,
    110 		int fflag,
    111 		struct ucred *cred,
    112 		struct proc *p));
    113 int	nfs_access __P((
    114 		struct vnode *vp,
    115 		int mode,
    116 		struct ucred *cred,
    117 		struct proc *p));
    118 int	nfs_getattr __P((
    119 		struct vnode *vp,
    120 		struct vattr *vap,
    121 		struct ucred *cred,
    122 		struct proc *p));
    123 int	nfs_setattr __P((
    124 		struct vnode *vp,
    125 		struct vattr *vap,
    126 		struct ucred *cred,
    127 		struct proc *p));
    128 int	nfs_read __P((
    129 		struct vnode *vp,
    130 		struct uio *uio,
    131 		int ioflag,
    132 		struct ucred *cred));
    133 int	nfs_write __P((
    134 		struct vnode *vp,
    135 		struct uio *uio,
    136 		int ioflag,
    137 		struct ucred *cred));
    138 #define nfs_ioctl ((int (*) __P(( \
    139 		struct vnode *vp, \
    140 		int command, \
    141 		caddr_t data, \
    142 		int fflag, \
    143 		struct ucred *cred, \
    144 		struct proc *p))) enoioctl)
    145 #define nfs_select ((int (*) __P(( \
    146 		struct vnode *vp, \
    147 		int which, \
    148 		int fflags, \
    149 		struct ucred *cred, \
    150 		struct proc *p))) seltrue)
    151 int	nfs_mmap __P((
    152 		struct vnode *vp,
    153 		int fflags,
    154 		struct ucred *cred,
    155 		struct proc *p));
    156 int	nfs_fsync __P((
    157 		struct vnode *vp,
    158 		int fflags,
    159 		struct ucred *cred,
    160 		int waitfor,
    161 		struct proc *p));
    162 #define nfs_seek ((int (*) __P(( \
    163 		struct vnode *vp, \
    164 		off_t oldoff, \
    165 		off_t newoff, \
    166 		struct ucred *cred))) nullop)
    167 int	nfs_remove __P((
    168 		struct nameidata *ndp,
    169 		struct proc *p));
    170 int	nfs_link __P((
    171 		struct vnode *vp,
    172 		struct nameidata *ndp,
    173 		struct proc *p));
    174 int	nfs_rename __P((
    175 		struct nameidata *fndp,
    176 		struct nameidata *tdnp,
    177 		struct proc *p));
    178 int	nfs_mkdir __P((
    179 		struct nameidata *ndp,
    180 		struct vattr *vap,
    181 		struct proc *p));
    182 int	nfs_rmdir __P((
    183 		struct nameidata *ndp,
    184 		struct proc *p));
    185 int	nfs_symlink __P((
    186 		struct nameidata *ndp,
    187 		struct vattr *vap,
    188 		char *target,
    189 		struct proc *p));
    190 int	nfs_readdir __P((
    191 		struct vnode *vp,
    192 		struct uio *uio,
    193 		struct ucred *cred,
    194 		int *eofflagp));
    195 int	nfs_readlink __P((
    196 		struct vnode *vp,
    197 		struct uio *uio,
    198 		struct ucred *cred));
    199 int	nfs_abortop __P((
    200 		struct nameidata *ndp));
    201 int	nfs_inactive __P((
    202 		struct vnode *vp,
    203 		struct proc *p));
    204 int	nfs_reclaim __P((
    205 		struct vnode *vp));
    206 int	nfs_lock __P((
    207 		struct vnode *vp));
    208 int	nfs_unlock __P((
    209 		struct vnode *vp));
    210 int	nfs_bmap __P((
    211 		struct vnode *vp,
    212 		daddr_t bn,
    213 		struct vnode **vpp,
    214 		daddr_t *bnp));
    215 int	nfs_strategy __P((
    216 		struct buf *bp));
    217 void	nfs_print __P((
    218 		struct vnode *vp));
    219 int	nfs_islocked __P((
    220 		struct vnode *vp));
    221 int	nfs_advlock __P((
    222 		struct vnode *vp,
    223 		caddr_t id,
    224 		int op,
    225 		struct flock *fl,
    226 		int flags));
    227 
    228 #endif /* !_NFS_NFSNODE_H_ */
    229