vm: fix a null dereference on out-of-memory
[minix.git] / servers / vfs / file.h
blobf2800124978889ac25dfc3e747733fd71b3815c0
1 #ifndef __VFS_FILE_H__
2 #define __VFS_FILE_H__
4 /* This is the filp table. It is an intermediary between file descriptors and
5 * inodes. A slot is free if filp_count == 0.
6 */
8 EXTERN struct filp {
9 mode_t filp_mode; /* RW bits, telling how file is opened */
10 int filp_flags; /* flags from open and fcntl */
11 int filp_state; /* state for crash recovery */
12 int filp_count; /* how many file descriptors share this slot?*/
13 struct vnode *filp_vno; /* vnode belonging to this file */
14 u64_t filp_pos; /* file position */
15 mutex_t filp_lock; /* lock to gain exclusive access */
16 struct fproc *filp_softlock; /* if not NULL; this filp didn't lock the
17 * vnode. Another filp already holds a lock
18 * for this thread */
20 /* the following fields are for select() and are owned by the generic
21 * select() code (i.e., fd-type-specific select() code can't touch these).
23 int filp_selectors; /* select()ing processes blocking on this fd */
24 int filp_select_ops; /* interested in these SEL_* operations */
25 int filp_select_flags; /* Select flags for the filp */
27 /* following are for fd-type-specific select() */
28 int filp_pipe_select_ops;
29 } filp[NR_FILPS];
31 #define FILP_CLOSED 0 /* filp_mode: associated device closed */
33 #define FS_NORMAL 000 /* file descriptor can be used normally */
34 #define FS_NEEDS_REOPEN 001 /* file descriptor needs to be re-opened */
35 #define FS_INVALIDATED 002 /* file was invalidated */
37 #define FSF_UPDATE 001 /* The driver should be informed about new
38 * state.
40 #define FSF_BUSY 002 /* Select operation sent to driver but no
41 * reply yet.
43 #define FSF_RD_BLOCK 010 /* Read request is blocking, the driver should
44 * keep state.
46 #define FSF_WR_BLOCK 020 /* Write request is blocking */
47 #define FSF_ERR_BLOCK 040 /* Exception request is blocking */
48 #define FSF_BLOCKED 070
49 #endif