/*	Convergent Technologies - System V - May 1983	*/
/*	"@(#)file.h	1.4"	*/

#ifndef file_h
#define file_h

#include <sys/types.h>
#include <sys/inode.h>

/*
 * One file structure is allocated for each open/creat/pipe call.
 * Main use is to hold the read/write pointer associated with
 * each open file.
 */
struct	file
{
	short	f_flag;
	cnt_t	f_count;	/* reference count */
	union {
		struct inode *f_uinode;	/* pointer to inode structure */
		struct file  *f_unext;	/* next entry in freelist */
	} f_up;
	union {
		off_t	f_off;		/* read/write character pointer */
		wndw_t	f_window;	/* (for PT's, ...) tty window number */
	} f_un;
};

#define	f_inode		f_up.f_uinode
#define	f_next		f_up.f_unext
#define	f_offset	f_un.f_off
#define	f_wndw		f_un.f_window

extern struct file file[];	/* The file table itself */
extern struct file *ffreelist;	/* Head of freelist pool */

/* flags */
#define	FOPEN	(-1)
#define	FREAD	00001		/* open for read */
#define	FWRITE	00002		/* open for write */
#define	FNDELAY	00004		/* delay bit */
#define	FAPPEND	00010		/* append mode */
#define	FSYNC	00020		/* synchronous write */
#define FDIRECT 0100000		/* Direct I/O */
#define	FMASK	0100037		/* mask for allowed flags in f_flag */

/* for use in smount, d_open to inform driver that open is from smount */
#define FMOUNT	00200

/* open only modes */
#define	FCREAT	00400
#define	FTRUNC	01000
#define	FEXCL	02000

#endif
