1: /*
2: * Copyright (c) 1982, 1986 Regents of the University of California.
3: * All rights reserved. The Berkeley software License Agreement
4: * specifies the terms and conditions for redistribution.
5: *
6: * @(#)file.h 7.1 (Berkeley) 6/4/86
7: */
8:
9: #ifdef KERNEL
10: /*
11: * Descriptor table entry.
12: * One for each kernel object.
13: */
14: struct file {
15: int f_flag; /* see below */
16: short f_type; /* descriptor type */
17: short f_count; /* reference count */
18: short f_msgcount; /* references from message queue */
19: struct fileops {
20: int (*fo_rw)();
21: int (*fo_ioctl)();
22: int (*fo_select)();
23: int (*fo_close)();
24: } *f_ops;
25: caddr_t f_data; /* inode */
26: off_t f_offset;
27: };
28:
29: struct file *file, *fileNFILE;
30: int nfile;
31: struct file *getf();
32: struct file *falloc();
33: #endif
34:
35: /*
36: * flags- also for fcntl call.
37: */
38: #define FOPEN (-1)
39: #define FREAD 00001 /* descriptor read/receive'able */
40: #define FWRITE 00002 /* descriptor write/send'able */
41: #ifndef F_DUPFD
42: #define FNDELAY 00004 /* no delay */
43: #define FAPPEND 00010 /* append on each write */
44: #endif
45: #define FMARK 00020 /* mark during gc() */
46: #define FDEFER 00040 /* defer for next gc pass */
47: #ifndef F_DUPFD
48: #define FASYNC 00100 /* signal pgrp when data ready */
49: #endif
50: #define FSHLOCK 00200 /* shared lock present */
51: #define FEXLOCK 00400 /* exclusive lock present */
52:
53: /* bits to save after open */
54: #define FMASK 00113
55: #define FCNTLCANT (FREAD|FWRITE|FMARK|FDEFER|FSHLOCK|FEXLOCK)
56:
57: /* open only modes */
58: #define FCREAT 01000 /* create if nonexistant */
59: #define FTRUNC 02000 /* truncate to zero length */
60: #define FEXCL 04000 /* error if already created */
61:
62: #ifndef F_DUPFD
63: /* fcntl(2) requests--from <fcntl.h> */
64: #define F_DUPFD 0 /* Duplicate fildes */
65: #define F_GETFD 1 /* Get fildes flags */
66: #define F_SETFD 2 /* Set fildes flags */
67: #define F_GETFL 3 /* Get file flags */
68: #define F_SETFL 4 /* Set file flags */
69: #define F_GETOWN 5 /* Get owner */
70: #define F_SETOWN 6 /* Set owner */
71: #endif
72:
73: /*
74: * User definitions.
75: */
76:
77: /*
78: * Open call.
79: */
80: #define O_RDONLY 000 /* open for reading */
81: #define O_WRONLY 001 /* open for writing */
82: #define O_RDWR 002 /* open for read & write */
83: #define O_NDELAY FNDELAY /* non-blocking open */
84: #define O_APPEND FAPPEND /* append on each write */
85: #define O_CREAT FCREAT /* open with file create */
86: #define O_TRUNC FTRUNC /* open with truncation */
87: #define O_EXCL FEXCL /* error on create if file exists */
88:
89: /*
90: * Flock call.
91: */
92: #define LOCK_SH 1 /* shared lock */
93: #define LOCK_EX 2 /* exclusive lock */
94: #define LOCK_NB 4 /* don't block when locking */
95: #define LOCK_UN 8 /* unlock */
96:
97: /*
98: * Access call.
99: */
100: #define F_OK 0 /* does file exist */
101: #define X_OK 1 /* is it executable by caller */
102: #define W_OK 2 /* writable by caller */
103: #define R_OK 4 /* readable by caller */
104:
105: /*
106: * Lseek call.
107: */
108: #define L_SET 0 /* absolute offset */
109: #define L_INCR 1 /* relative to current offset */
110: #define L_XTND 2 /* relative to end of file */
111:
112: #ifdef KERNEL
113: #define GETF(fp, fd) { \
114: if ((unsigned)(fd) >= NOFILE || ((fp) = u.u_ofile[fd]) == NULL) { \
115: u.u_error = EBADF; \
116: return; \
117: } \
118: }
119: #define DTYPE_INODE 1 /* file */
120: #define DTYPE_SOCKET 2 /* communications endpoint */
121: #endif
Defined variables
file
defined in line
29; used 9 times
nfile
defined in line
30; used 1 times
Defined struct's
file
defined in line
14; used 170 times
- in line 29-32(6)
- in /usr/src/sys/GENERIC/param.c line
74(2)
- in /usr/src/sys/conf/param.c line
74(2)
- in /usr/src/sys/sys/kern_descrip.c line
57(2),
74(2),
96(2),
112(2),
173(2),
186(2),
205(2),
224(2),
238(2),
255(2),
312(2),
319-322(4),
353-357(4),
371(2),
393(2)
- in /usr/src/sys/sys/kern_exec.c line
400(2)
- in /usr/src/sys/sys/kern_exit.c line
82(2)
- in /usr/src/sys/sys/kern_fork.c line
105(2)
- in /usr/src/sys/sys/kern_mman.c line
60(2),
67(2)
- in /usr/src/sys/sys/sys_generic.c line
113(2),
157(2),
374(2)
- in /usr/src/sys/sys/sys_inode.c line
32(2),
207(2),
245(2),
306(2),
380(2),
452(2),
530(2)
- in /usr/src/sys/sys/sys_socket.c line
30(2),
42(2),
95(2),
145(2)
- in /usr/src/sys/sys/ufs_syscalls.c line
27(2),
120(2),
388(2),
554(2),
621(2),
750(2),
774(2),
1340-1352(8)
- in /usr/src/sys/sys/ufs_xxx.c line
45-50(4)
- in /usr/src/sys/sys/uipc_syscalls.c line
27(2),
38(2),
62(2),
81(2),
96(2),
182(2),
233(2),
366(2),
512(2),
582(2),
599(2),
636(2),
670(2),
724(2),
764(2),
820-824(4)
- in /usr/src/sys/sys/uipc_usrreq.c line
529-530(6),
557-566(8),
583(2),
644(2),
651-652(4),
662(2),
672(2)
- in /usr/src/sys/vax/machdep.c line
111(2)
Defined macros
FEXCL
defined in line
60; used 3 times
FMARK
defined in line
45; used 7 times
FMASK
defined in line
54; used 1 times
FOPEN
defined in line
38; used 3 times
FREAD
defined in line
39; used 45 times
- in line 55
- in /usr/src/sys/net/if_sl.c line
128
- in /usr/src/sys/sys/kern_mman.c line
92
- in /usr/src/sys/sys/sys_generic.c line
118,
169,
381
- in /usr/src/sys/sys/sys_inode.c line
545
- in /usr/src/sys/sys/tty.c line
126,
152,
164,
184,
326-328(2),
365,
384,
481,
610,
644,
728,
779,
807
- in /usr/src/sys/sys/tty_bk.c line
53
- in /usr/src/sys/sys/tty_pty.c line
83,
95,
170,
178,
307-310(2),
512,
547,
560,
567
- in /usr/src/sys/sys/ufs_mount.c line
78(2),
158(2)
- in /usr/src/sys/sys/ufs_syscalls.c line
161
- in /usr/src/sys/sys/uipc_socket.c line
594
- in /usr/src/sys/sys/uipc_syscalls.c line
42,
157,
251,
258,
684
- in /usr/src/sys/sys/vm_sw.c line
144
- in /usr/src/sys/vaxmba/mt.c line
221
FWRITE
defined in line
40; used 62 times
- in line 55
- in /usr/src/sys/net/if_sl.c line
128
- in /usr/src/sys/sys/kern_exec.c line
406
- in /usr/src/sys/sys/kern_mman.c line
88
- in /usr/src/sys/sys/sys_generic.c line
118,
169,
384
- in /usr/src/sys/sys/sys_inode.c line
545
- in /usr/src/sys/sys/tty.c line
157,
184,
326-328(2),
610,
644,
728,
769,
807
- in /usr/src/sys/sys/tty_bk.c line
53
- in /usr/src/sys/sys/tty_pty.c line
83,
95,
134,
186,
308-309(2),
512
- in /usr/src/sys/sys/ufs_mount.c line
78,
158
- in /usr/src/sys/sys/ufs_syscalls.c line
106,
164,
755
- in /usr/src/sys/sys/uipc_socket.c line
596
- in /usr/src/sys/sys/uipc_syscalls.c line
42,
157,
251,
258,
691
- in /usr/src/sys/sys/vm_sw.c line
144
- in /usr/src/sys/vaxmba/ht.c line
138-142(2),
162(2)
- in /usr/src/sys/vaxmba/mt.c line
187-192(2),
207(2),
221-222(3)
- in /usr/src/sys/vaxuba/rx.c line
805
- in /usr/src/sys/vaxuba/tm.c line
238-242(2),
277(2)
- in /usr/src/sys/vaxuba/tmscp.c line
806(2)
- in /usr/src/sys/vaxuba/ts.c line
193,
219(2)
- in /usr/src/sys/vaxuba/ut.c line
160-164(2),
195(2)
F_OK
defined in line
100;
never used
GETF
defined in line
113; used 9 times
R_OK
defined in line
103; used 1 times
W_OK
defined in line
102; used 1 times
X_OK
defined in line
101; used 1 times
Usage of this include