xref: /csrg-svn/sys/nfs/nfsnode.h (revision 55519)
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*55519Smckusick  *	@(#)nfsnode.h	7.27 (Berkeley) 07/22/92
1138414Smckusick  */
1238414Smckusick 
1338414Smckusick /*
1452196Smckusick  * Silly rename structure that hangs off the nfsnode until the name
1552196Smckusick  * can be removed by nfs_inactive()
1652196Smckusick  */
1752196Smckusick struct sillyrename {
1852196Smckusick 	struct	ucred *s_cred;
1952196Smckusick 	struct	vnode *s_dvp;
2052196Smckusick 	long	s_namlen;
2152196Smckusick 	char	s_name[20];
2252196Smckusick };
2352196Smckusick 
2452196Smckusick /*
2538414Smckusick  * The nfsnode is the nfs equivalent to ufs's inode. Any similarity
2638414Smckusick  * is purely coincidental.
2738414Smckusick  * There is a unique nfsnode allocated for each active file,
2838414Smckusick  * each current directory, each mounted-on file, text file, and the root.
2938414Smckusick  * An nfsnode is 'named' by its file handle. (nget/nfs_node.c)
3038414Smckusick  */
3138414Smckusick 
3238414Smckusick struct nfsnode {
33*55519Smckusick 	struct	nfsnode *n_forw;	/* hash, forward */
34*55519Smckusick 	struct	nfsnode **n_back;	/* hash, backward */
3538414Smckusick 	nfsv2fh_t n_fh;			/* NFS File Handle */
3638414Smckusick 	long	n_flag;			/* Flag for locking.. */
3752196Smckusick 	struct	vnode *n_vnode;		/* vnode associated with this node */
3853803Smckusick 	struct	vattr n_vattr;		/* Vnode attribute cache */
3952196Smckusick 	time_t	n_attrstamp;		/* Time stamp for cached attributes */
4052196Smckusick 	struct	sillyrename *n_sillyrename; /* Ptr to silly rename struct */
4153479Smckusick 	off_t	n_size;			/* Current size of file */
4252196Smckusick 	int	n_error;		/* Save write error value */
4352196Smckusick 	u_long	n_direofoffset;		/* Dir. EOF offset cache */
4452196Smckusick 	union {
4552196Smckusick 		struct {
4652196Smckusick 			time_t	un_mtime; /* Prev modify time. */
4752196Smckusick 			time_t	un_ctime; /* Prev create time. */
4852196Smckusick 		} un_nfs;
4952196Smckusick 		struct {
5052196Smckusick 			u_quad_t un_brev; /* Modify rev when cached */
5152196Smckusick 			u_quad_t un_lrev; /* Modify rev for lease */
5252196Smckusick 			time_t	un_expiry; /* Lease expiry time */
5352196Smckusick 			struct	nfsnode *un_tnext; /* Nqnfs timer chain */
5452196Smckusick 			struct	nfsnode *un_tprev;
5554502Smckusick 			long	un_spare; /* pad to 8-byte boundary */
5652196Smckusick 		} un_nqnfs;
5752196Smckusick 	} n_un;
5852196Smckusick 	struct	sillyrename n_silly;	/* Silly rename struct */
5953626Smckusick 	struct	timeval n_atim;		/* Special file times */
6053626Smckusick 	struct	timeval n_mtim;
6154502Smckusick 	long	n_spare[4];		/* Up to a power of 2 */
6238414Smckusick };
6338414Smckusick 
6452196Smckusick #define	n_mtime		n_un.un_nfs.un_mtime
6552196Smckusick #define	n_ctime		n_un.un_nfs.un_ctime
6652196Smckusick #define	n_brev		n_un.un_nqnfs.un_brev
6752196Smckusick #define	n_lrev		n_un.un_nqnfs.un_lrev
6852196Smckusick #define	n_expiry	n_un.un_nqnfs.un_expiry
6952196Smckusick #define	n_tnext		n_un.un_nqnfs.un_tnext
7052196Smckusick #define	n_tprev		n_un.un_nqnfs.un_tprev
7152196Smckusick 
7238414Smckusick #ifdef KERNEL
7338414Smckusick /*
7438414Smckusick  * Convert between nfsnode pointers and vnode pointers
7538414Smckusick  */
7638414Smckusick #define VTONFS(vp)	((struct nfsnode *)(vp)->v_data)
7739393Smckusick #define NFSTOV(np)	((struct vnode *)(np)->n_vnode)
7838414Smckusick #endif
7938414Smckusick /*
8038414Smckusick  * Flags for n_flag
8138414Smckusick  */
8252196Smckusick #define	NMODIFIED	0x0004	/* Might have a modified buffer in bio */
8352196Smckusick #define	NWRITEERR	0x0008	/* Flag write errors so close will know */
8452196Smckusick #define	NQNFSNONCACHE	0x0020	/* Non-cachable lease */
8552196Smckusick #define	NQNFSWRITE	0x0040	/* Write lease */
8652196Smckusick #define	NQNFSEVICTED	0x0080	/* Has been evicted */
8753626Smckusick #define	NACC		0x0100	/* Special file accessed */
8853626Smckusick #define	NUPD		0x0200	/* Special file updated */
8953626Smckusick #define	NCHG		0x0400	/* Special file times changed */
9048043Smckusick 
9148043Smckusick /*
9248043Smckusick  * Prototypes for NFS vnode operations
9348043Smckusick  */
9453556Sheideman int	nfs_lookup __P((struct vop_lookup_args *));
9553556Sheideman int	nfs_create __P((struct vop_create_args *));
9653556Sheideman int	nfs_mknod __P((struct vop_mknod_args *));
9753556Sheideman int	nfs_open __P((struct vop_open_args *));
9853556Sheideman int	nfs_close __P((struct vop_close_args *));
9953626Smckusick int	nfsspec_close __P((struct vop_close_args *));
10053626Smckusick #ifdef FIFO
10153626Smckusick int	nfsfifo_close __P((struct vop_close_args *));
10253626Smckusick #endif
10353556Sheideman int	nfs_access __P((struct vop_access_args *));
10453556Sheideman int	nfs_getattr __P((struct vop_getattr_args *));
10553556Sheideman int	nfs_setattr __P((struct vop_setattr_args *));
10653556Sheideman int	nfs_read __P((struct vop_read_args *));
10753556Sheideman int	nfs_write __P((struct vop_write_args *));
10853626Smckusick int	nfsspec_read __P((struct vop_read_args *));
10953626Smckusick int	nfsspec_write __P((struct vop_write_args *));
11053626Smckusick #ifdef FIFO
11153626Smckusick int	nfsfifo_read __P((struct vop_read_args *));
11253626Smckusick int	nfsfifo_write __P((struct vop_write_args *));
11353626Smckusick #endif
11453556Sheideman #define nfs_ioctl ((int (*) __P((struct  vop_ioctl_args *)))enoioctl)
11553556Sheideman #define nfs_select ((int (*) __P((struct  vop_select_args *)))seltrue)
11653556Sheideman int	nfs_mmap __P((struct vop_mmap_args *));
11753556Sheideman int	nfs_fsync __P((struct vop_fsync_args *));
11853556Sheideman #define nfs_seek ((int (*) __P((struct  vop_seek_args *)))nullop)
11953556Sheideman int	nfs_remove __P((struct vop_remove_args *));
12053556Sheideman int	nfs_link __P((struct vop_link_args *));
12153556Sheideman int	nfs_rename __P((struct vop_rename_args *));
12253556Sheideman int	nfs_mkdir __P((struct vop_mkdir_args *));
12353556Sheideman int	nfs_rmdir __P((struct vop_rmdir_args *));
12453556Sheideman int	nfs_symlink __P((struct vop_symlink_args *));
12553556Sheideman int	nfs_readdir __P((struct vop_readdir_args *));
12653556Sheideman int	nfs_readlink __P((struct vop_readlink_args *));
12753556Sheideman int	nfs_abortop __P((struct vop_abortop_args *));
12853556Sheideman int	nfs_inactive __P((struct vop_inactive_args *));
12953556Sheideman int	nfs_reclaim __P((struct vop_reclaim_args *));
13053556Sheideman int	nfs_lock __P((struct vop_lock_args *));
13153556Sheideman int	nfs_unlock __P((struct vop_unlock_args *));
13253556Sheideman int	nfs_bmap __P((struct vop_bmap_args *));
13353556Sheideman int	nfs_strategy __P((struct vop_strategy_args *));
13453556Sheideman int	nfs_print __P((struct vop_print_args *));
13553556Sheideman int	nfs_islocked __P((struct vop_islocked_args *));
13653556Sheideman int	nfs_advlock __P((struct vop_advlock_args *));
13753556Sheideman int	nfs_blkatoff __P((struct vop_blkatoff_args *));
13854663Smckusick int	nfs_vget __P((struct mount *, ino_t, struct vnode **));
13953556Sheideman int	nfs_valloc __P((struct vop_valloc_args *));
14053581Sheideman int	nfs_vfree __P((struct vop_vfree_args *));
14153556Sheideman int	nfs_truncate __P((struct vop_truncate_args *));
14253556Sheideman int	nfs_update __P((struct vop_update_args *));
14351572Smckusick int	bwrite();		/* NFS needs a bwrite routine */
144