• Every process has an entry in the process table. Within each process table entry is a table of open file descriptors, which we can think of as a vector, with one entry per descriptor. Associated with each file descriptor are

  • The file descriptor flags (close-on-exec; refer to
    [url=mk:@MSITStore:C:\Documents%20and%20Settings\Administrator\桌面\ Advanced%20Programming%20in%20the%20UNIX%20Environment%202Ed\Addison.Wesley,.Advanced.Programming.in.the.UNIX.Environment.(2005),.2Ed.BBL.chm::/0201433079/ch03lev1sec10.html#ch03fig06]Figure 3.6[/url]
    and
    [url=mk:@MSITStore:C:\Documents%20and%20Settings\Administrator\桌面\ Advanced%20Programming%20in%20the%20UNIX%20Environment%202Ed\Addison.Wesley,.Advanced.Programming.in.the.UNIX.Environment.(2005),.2Ed.BBL.chm::/0201433079/ch03lev1sec14.html#ch03lev1sec14]Section 3.14[/url]
    )

  • A pointer to a file table entry

  • The kernel maintains a file table for all open files. Each file table entry contains

  • The file status flags for the file, such as read, write, append, sync, and nonblocking; more on these in
    [url=mk:@MSITStore:C:\Documents%20and%20Settings\Administrator\桌面\ Advanced%20Programming%20in%20the%20UNIX%20Environment%202Ed\Addison.Wesley,.Advanced.Programming.in.the.UNIX.Environment.(2005),.2Ed.BBL.chm::/0201433079/ch03lev1sec14.html#ch03lev1sec14]Section 3.14[/url]

  • The current file offset

  • A pointer to the v-node table entry for the file

  • Each open file (or device) has a v-node structure that contains information about the type of file and pointers to functions that operate on the file. For most files, the v-node also contains the i-node for the file. This information is read from disk when the file is opened, so that all the pertinent information about the file is readily available. For example, the i-node contains the owner of the file, the size of the file, pointers to where the actual data blocks for the file are located on disk, and so on. (We talk more about i-nodes in
    [url=mk:@MSITStore:C:\Documents%20and%20Settings\Administrator\桌面\ Advanced%20Programming%20in%20the%20UNIX%20Environment%202Ed\Addison.Wesley,.Advanced.Programming.in.the.UNIX.Environment.(2005),.2Ed.BBL.chm::/0201433079/ch04lev1sec14.html#ch04lev1sec14]Section 4.14[/url]
    when we describe the typical UNIX file system in more detail.)
    Linux has no v-node. Instead, a generic i-node structure is used. Although the implementations differ, the v-node is conceptually the same as a generic i-node. Both point to an i-node structure specific to the file system.

  • Figure 3.6. Kernel data structures for open files
    [url=mk:@MSITStore:C:\Documents%20and%20Settings\Administrator\桌面\ Advanced%20Programming%20in%20the%20UNIX%20Environment%202Ed\Addison.Wesley,.Advanced.Programming.in.the.UNIX.Environment.(2005),.2Ed.BBL.chm::/0201433079/images/0201433079/graphics/03fig06_alt.gif;423615][View full size image][/url]


    Figure 3.7. Two independent processes with the same file open
    [url=mk:@MSITStore:C:\Documents%20and%20Settings\Administrator\桌面\ Advanced%20Programming%20in%20the%20UNIX%20Environment%202Ed\Addison.Wesley,.Advanced.Programming.in.the.UNIX.Environment.(2005),.2Ed.BBL.chm::/0201433079/images/0201433079/graphics/03fig07_alt.gif;423615][View full size image][/url]