Unformatted text preview: gs, the current ﬁle position and a reference count of the number of descriptor entries that currently point to it. The ﬁle table entry in turn points to an i-node table entry that characterizes the physical location of the ﬁle on disk, and contains most of the information in the stat structure, including the st mode and st size members. 12.4. UNIX FILE I/O 627 Typically there is a one-to-one mapping between descriptors and ﬁles. For example, suppose we have the situation in Figure 12.20 where descriptor 1 (stdout) corresponds to ﬁle (say a terminal), while descriptor 4 corresponds to ﬁle (say a disk). The reference counts for the and are both equal to 1.
open file table entries file A file pos refcnt = 1 ... file B file B file pos refcnt = 1 ... ... st_mode st_size i-node table entries file A per process descriptor table
0 1 2 3 4 5 6 7 ... st_mode st_size Figure 12.20: Kernel data structures before dup2(4,1) The dup2 function allows multiple descriptors to be associated with the same ﬁle. For example, Figure 12.21 shows the situat...
View Full Document