xref: /original-bsd/sys/sys/file.h (revision ba762ddc)
1 /*
2  * Copyright (c) 1982, 1986, 1989 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)file.h	7.8 (Berkeley) 04/15/91
8  */
9 
10 #include <sys/fcntl.h>
11 #include <sys/unistd.h>
12 
13 #ifdef KERNEL
14 /*
15  * Kernel descriptor table entry;
16  * one for each open kernel vnode and socket.
17  */
18 struct file {
19 	int	f_flag;		/* see below */
20 #define	DTYPE_VNODE	1	/* file */
21 #define	DTYPE_SOCKET	2	/* communications endpoint */
22 	short	f_type;		/* descriptor type */
23 	short	f_count;	/* reference count */
24 	short	f_msgcount;	/* references from message queue */
25 	struct	ucred *f_cred;	/* credentials associated with descriptor */
26 	struct	fileops {
27 		int	(*fo_read)__P((
28 				struct file *fp,
29 				struct uio *uio,
30 				struct ucred *cred));
31 		int	(*fo_write)__P((
32 				struct file *fp,
33 				struct uio *uio,
34 				struct ucred *cred));
35 		int	(*fo_ioctl)__P((
36 				struct file *fp,
37 				int com,
38 				caddr_t data,
39 				struct proc *p));
40 		int	(*fo_select)__P((
41 				struct file *fp,
42 				int which,
43 				struct proc *p));
44 		int	(*fo_close)__P((
45 				struct file *fp,
46 				struct proc *p));
47 	} *f_ops;
48 	caddr_t	f_data;		/* inode */
49 	off_t	f_offset;
50 };
51 
52 struct file *file, *fileNFILE;
53 int nfile;
54 
55 #endif /* KERNEL */
56