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