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