xref: /original-bsd/sys/sys/file.h (revision 502e1f47)
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.11 (Berkeley) 03/02/92
8  */
9 
10 #include <sys/fcntl.h>
11 #include <sys/unistd.h>
12 
13 #ifdef KERNEL
14 struct proc;
15 struct uio;
16 
17 /*
18  * Kernel descriptor table.
19  * One entry for each open kernel vnode and socket.
20  */
21 struct file {
22 	struct	file *f_filef;	/* list of active files */
23 	struct	file **f_fileb;	/* list of active files */
24 	short	f_flag;		/* see fcntl.h */
25 #define	DTYPE_VNODE	1	/* file */
26 #define	DTYPE_SOCKET	2	/* communications endpoint */
27 	short	f_type;		/* descriptor type */
28 	short	f_count;	/* reference count */
29 	short	f_msgcount;	/* references from message queue */
30 	struct	ucred *f_cred;	/* credentials associated with descriptor */
31 	struct	fileops {
32 		int	(*fo_read)	__P((struct file *fp, struct uio *uio,
33 					    struct ucred *cred));
34 		int	(*fo_write)	__P((struct file *fp, struct uio *uio,
35 					    struct ucred *cred));
36 		int	(*fo_ioctl)	__P((struct file *fp, int com,
37 					    caddr_t data, struct proc *p));
38 		int	(*fo_select)	__P((struct file *fp, int which,
39 					    struct proc *p));
40 		int	(*fo_close)	__P((struct file *fp, struct proc *p));
41 	} *f_ops;
42 	off_t	f_offset;
43 	caddr_t	f_data;		/* vnode or socket */
44 };
45 
46 extern struct file *filehead;	/* head of list of open files */
47 extern int maxfiles;		/* kernel limit on number of open files */
48 extern int nfiles;		/* actual number of open files */
49 
50 #endif /* KERNEL */
51