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.6 (Berkeley) 06/28/90 8 */ 9 10 #ifdef KERNEL 11 #include "fcntl.h" 12 #include "unistd.h" 13 14 /* 15 * Descriptor table entry. 16 * One for each kernel object. 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)(); 28 int (*fo_write)(); 29 int (*fo_ioctl)(); 30 int (*fo_select)(); 31 int (*fo_close)(); 32 } *f_ops; 33 caddr_t f_data; /* inode */ 34 off_t f_offset; 35 }; 36 37 struct file *file, *fileNFILE; 38 int nfile; 39 40 /* convert O_RDONLY/O_WRONLY/O_RDWR to FREAD/FWRITE */ 41 #define FOPEN (-1) 42 #define FREAD 1 43 #define FWRITE 2 44 45 /* kernel only versions -- deprecated, should be removed */ 46 #define FCREAT O_CREAT 47 #define FDEFER O_DEFER 48 #define FEXCL O_EXCL 49 #define FEXLOCK O_EXLOCK 50 #define FMARK O_MARK 51 #define FSHLOCK O_SHLOCK 52 #define FTRUNC O_TRUNC 53 54 /* bits to save after open */ 55 #define FMASK (FREAD|FWRITE|O_APPEND|O_ASYNC|O_NONBLOCK) 56 /* bits not settable by fcntl(F_SETFL, ...) */ 57 #define FCNTLCANT (FREAD|FWRITE|O_DEFER|O_EXLOCK|O_MARK|O_SHLOCK) 58 59 #else 60 61 #include <sys/fcntl.h> 62 #include <sys/unistd.h> 63 64 #endif 65 66 /* operation for lseek(2); renamed by POSIX 1003.1 to unistd.h */ 67 #define L_SET 0 /* set file offset to offset */ 68 #define L_INCR 1 /* set file offset to current plus offset */ 69 #define L_XTND 2 /* set file offset to EOF plus offset */ 70