Advanced Programming in the UNIX® Environment

(lily) #1
ptg10805159

76 File I/O Chapter 3


The v-node was invented to provide support for multiple file system types on a single
computer system. This work was done independently by Peter Weinberger (Bell Laboratories)
and Bill Joy (Sun Microsystems). Sun called this the Virtual File System and called the file
system–independent portion of the i-node the v-node[Kleiman 1986].The v-node propagated
through various vendor implementations as support for Sun’s Network File System(NFS)was
added. The first release from Berkeley to provide v-nodes was the 4.3BSD Reno release, when
NFS was added.
In SVR4, the v-node replaced the file system–independent i-node of SVR3. Solaris is derived
from SVR4 and, therefore, uses v-nodes.
Instead of splitting the data structures into a v-node and an i-node, Linux uses a file
system–independent i-node and a file system–dependent i-node.

If two independent processes have the same file open, we could have the
arrangement shown in Figure3.8.

process table entry

...


fd 0:
fd 1:
fd 2:
fd 3:

flagsfd pointerfile

process table entry

...


fd 0:
fd 1:
fd 2:
fd 3:
fd 4:

flagsfd pointerfile

file status flags
current file offset
v-node pointer

file status flags
current file offset
v-node pointer

file table entry

file table entry

v-node information
v_data

i-node information
current file size
i_vnode

v-node table entry

i-node

Figure 3.8Twoindependent processes with the same file open

We assume herethat the first process has the file open on descriptor 3 and that the
second process has that same file open on descriptor 4. Each process that opens the file
gets its own file table entry,but only a single v-node table entry is required for a given
file. Onereason each process gets its own file table entry is so that each process has its
own current offset for the file.
Given these data structures, we now need to be morespecific about what happens
with certain operations that we’ve already described.
Free download pdf