<Advanced programming in UNIX environment> file sharing and fork functions, unixfork
The UNIX system supports sharing and opening files between different processes. The kernel uses three data structures to open files. The relationship between them determines the possible impact of one process on another process in file sharing.
The kernel maintains three tables, namely the input table, file table, and v node table. The details are as follows:
1> each process has a record in the progress table. The record contains an open file descriptor table, and each descriptor occupies one item. Associated with each file descriptor is:
A. file descriptor flag (close_on_exec );
B. pointer to a file table item.
2> the kernel maintains a file table for all opened files. Each file table item includes:
A. File status signs (reading, writing, adding, synchronization, and non-blocking );
B. Current file offset;
C. pointer to the table entry of the file v node.
3> each open file (or device) has a v-node structure. The v node contains the file type and pointers for various operation functions on the file. For most files, the v node also contains the I node (I-node, index node) of the file. This information is used to read files from the disk into the memory. The I node contains the file owner, file length, and pointer to the location of the actual data block of the file on the disk. (In UNIX file systems