/* $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred.
 */

#ident	"$Header: vfs.h 1.10 89/11/17 $"

#ifndef	_SYS_VFS_H_

/*
 * vfs.h
 *	Virtual File-System structures and definitions.
 */

/* $Log:	vfs.h,v $
 */

/*
 * Structure per mounted file system.
 * Each mounted file system has an array of
 * operations and an instance record.
 * The file systems are put on a singly linked list.
 */
struct vfs {
	struct vfs	*vfs_next;		/* next vfs in vfs list */
	struct vfsops	*vfs_op;		/* operations on vfs */
	struct vnode	*vfs_vnodecovered;	/* vnode we mounted on */
	int		vfs_flag;		/* flags */
	int		vfs_bsize;		/* native block size */
	struct vnode	*vfs_devvp;		/* device being mounted,
						   0 if not valid */
	caddr_t		vfs_data;		/* private data */
};

#define	vfs_dev		vfs_devvp->v_rdev
/*
 * Sema to mutex operations on vfs lists
 */
extern	sema_t	vfs_mutex;

/*
 * vfs flags.
 */
#define	VFS_RDONLY	0x01		/* read only vfs */
#define	VFS_NOSUID	0x02		/* no suid */

/*
 * Operations supported on virtual file system.
 */
struct vfsops {
	int	(*vfs_mount)();
	int	(*vfs_unmount)();
	int	(*vfs_root)();
	int	(*vfs_statfs)();
	int	(*vfs_sync)();
};

#define	VFS_MOUNT(VFSP, PATH, FSPEC, DATA, DATALEN) \
				(*(VFSP)->vfs_op->vfs_mount)(VFSP, PATH, \
							FSPEC, DATA, DATALEN)
#define	VFS_UNMOUNT(VFSP)	(*(VFSP)->vfs_op->vfs_unmount)(VFSP)
#define	VFS_ROOT(VFSP, VPP)	(*(VFSP)->vfs_op->vfs_root)(VFSP,VPP)
#define	VFS_STATFS(VFSP, VP, SB) \
				(*(VFSP)->vfs_op->vfs_statfs)(VFSP,VP,SB)
#define	VFS_SYNC(VFSP)		(*(VFSP)->vfs_op->vfs_sync)()

#ifdef	INKERNEL
extern	void	vfs_mountroot();	/* mount the root */
extern	int	vfs_filldata();		/* fill out misc struct vfs fields */
extern	void	vfs_add();		/* add a new vfs to mounted vfs list */
extern	void	vfs_remove();		/* remove a vfs from mounted vfs list */

#define VFS_INIT(VFSP, OP, DATA)	{ \
	(VFSP)->vfs_next = (struct vfs *)0; \
	(VFSP)->vfs_op = (OP); \
	(VFSP)->vfs_flag = 0; \
	(VFSP)->vfs_devvp = (struct vnode *)0; \
	(VFSP)->vfs_data = (DATA); \
}

extern	struct vfs	*rootvfs;	/* ptr to root vfs structure */
#endif	/* INKERNEL */

#define	_SYS_VFS_H_
#endif	/* _SYS_VFS_H_ */
