Commit | Line | Data |
---|---|---|
da7c5cc6 | 1 | /* |
5921d41a KM |
2 | * Copyright (c) 1982, 1986, 1989 Regents of the University of California. |
3 | * All rights reserved. | |
da7c5cc6 | 4 | * |
1c15e888 C |
5 | * Redistribution is only permitted until one year after the first shipment |
6 | * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and | |
7 | * binary forms are permitted provided that: (1) source distributions retain | |
8 | * this entire copyright notice and comment, and (2) distributions including | |
9 | * binaries display the following acknowledgement: This product includes | |
10 | * software developed by the University of California, Berkeley and its | |
11 | * contributors'' in the documentation or other materials provided with the | |
12 | * distribution and in all advertising materials mentioning features or use | |
13 | * of this software. Neither the name of the University nor the names of | |
14 | * its contributors may be used to endorse or promote products derived from | |
15 | * this software without specific prior written permission. | |
16 | * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED | |
17 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF | |
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
5921d41a | 19 | * |
1c15e888 | 20 | * @(#)file.h 7.6 (Berkeley) 6/28/90 |
da7c5cc6 | 21 | */ |
7588c899 | 22 | |
b0954044 | 23 | #ifdef KERNEL |
c9017fa0 KB |
24 | #include "fcntl.h" |
25 | #include "unistd.h" | |
26 | ||
7588c899 | 27 | /* |
4147b3f6 BJ |
28 | * Descriptor table entry. |
29 | * One for each kernel object. | |
7588c899 | 30 | */ |
c9017fa0 | 31 | struct file { |
fe3f4869 | 32 | int f_flag; /* see below */ |
c9017fa0 KB |
33 | #define DTYPE_VNODE 1 /* file */ |
34 | #define DTYPE_SOCKET 2 /* communications endpoint */ | |
4147b3f6 | 35 | short f_type; /* descriptor type */ |
6f000f8a SL |
36 | short f_count; /* reference count */ |
37 | short f_msgcount; /* references from message queue */ | |
5921d41a | 38 | struct ucred *f_cred; /* credentials associated with descriptor */ |
6f000f8a | 39 | struct fileops { |
5921d41a KM |
40 | int (*fo_read)(); |
41 | int (*fo_write)(); | |
6f000f8a SL |
42 | int (*fo_ioctl)(); |
43 | int (*fo_select)(); | |
6f000f8a SL |
44 | int (*fo_close)(); |
45 | } *f_ops; | |
46 | caddr_t f_data; /* inode */ | |
47 | off_t f_offset; | |
4147b3f6 | 48 | }; |
7588c899 | 49 | |
c9017fa0 KB |
50 | struct file *file, *fileNFILE; |
51 | int nfile; | |
7588c899 | 52 | |
c9017fa0 | 53 | /* convert O_RDONLY/O_WRONLY/O_RDWR to FREAD/FWRITE */ |
6f000f8a | 54 | #define FOPEN (-1) |
c9017fa0 KB |
55 | #define FREAD 1 |
56 | #define FWRITE 2 | |
6f000f8a | 57 | |
c9017fa0 KB |
58 | /* kernel only versions -- deprecated, should be removed */ |
59 | #define FCREAT O_CREAT | |
60 | #define FDEFER O_DEFER | |
61 | #define FEXCL O_EXCL | |
62 | #define FEXLOCK O_EXLOCK | |
63 | #define FMARK O_MARK | |
64 | #define FSHLOCK O_SHLOCK | |
65 | #define FTRUNC O_TRUNC | |
b0954044 | 66 | |
c9017fa0 KB |
67 | /* bits to save after open */ |
68 | #define FMASK (FREAD|FWRITE|O_APPEND|O_ASYNC|O_NONBLOCK) | |
69 | /* bits not settable by fcntl(F_SETFL, ...) */ | |
70 | #define FCNTLCANT (FREAD|FWRITE|O_DEFER|O_EXLOCK|O_MARK|O_SHLOCK) | |
b0954044 | 71 | |
c9017fa0 | 72 | #else |
b0954044 | 73 | |
c9017fa0 KB |
74 | #include <sys/fcntl.h> |
75 | #include <sys/unistd.h> | |
02dd5a44 | 76 | |
6f000f8a | 77 | #endif |
c9017fa0 KB |
78 | |
79 | /* operation for lseek(2); renamed by POSIX 1003.1 to unistd.h */ | |
80 | #define L_SET 0 /* set file offset to offset */ | |
81 | #define L_INCR 1 /* set file offset to current plus offset */ | |
82 | #define L_XTND 2 /* set file offset to EOF plus offset */ |