Unix&Network Programming: Study of Multiuser Operating System and Their Features"
Unix&Network Programming: Study of Multiuser Operating System and Their Features"
Ihr Logo
File sharing
The unix system supports the sharing of open files among different
processes.
The kernel uses 3 data structures(ds) to represent an open file and the
relationship among them to check out the influence factor of one process with the other.
The three d.s are
Your Logo
fd flag fptr
Fd0
Fd1 Fd2 File status flags Current file offset V-node pointer
. ..
Your Logo
2. File table:
kernel maintains the file table for all open files. File table entry contains (a) file status flag which keeps track file whether
file is in read, write,seek state etc.. Respectively. (b) Current file offset which specifies initial position file pointer. (c) A pointer to the v-node table entry for the file.
Your Logo
changes happened to the open file(updated info and current file status after modification)
Your Logo
But, only single v-node table entry is required for a given file.
One reason for the above criteria is each process gets its own file table
entry is because each process has its own current file offset for the file.
Your Logo
V-node table entry V-node information i-node information Current file size
p2 Fd0
Fd1 Fd2 Fd3 Fd4
Fdflg fptr
Your Logo
when certain operations implemented on to the open file. Operations like read,write,seek etc...
After each write operation is complete, the current file offset in the file
table entry is incremented by no. Of bytes written. If this causes the current file offset to exceed the current file size, then the current file size in the i-node table entry is set current file offset(for eg, the file is extended).
If a file is opened with the O_append flag, a corresponding flag is set
current file offset in the file table entry is first set to the current file size from i-node entry. This forces every write operation to restrict within available current file size and it reaches the current end of file.
Your Logo