Unix File Access Unix file access is accomplished via a series of tables Process file table System file table v-nodes (sometimes i-nodes)
File Access Facts When an entry is allocated in a process’ file table, it is always the lowest numbered unused file descriptor File table entries can be shared among related processes Symbolic links are files that hold another file path/name; direct analogy to pointers
Simple Version Process A Process file table File Pointer 1. Process B Process file table File Pointer Process C Process file table File Pointer 1. i-node 0 i-node 1 i-node 2 i-node 3 i-node 4 Boot Super i-list block file area System file table Each i- node has pointers into the data area same file!
v-nodes & i-nodes i-nodes contain the actual links to file data –UNIX inode File attributes stored (size, time, ID, etc.) 12 ptrs to direct blocks 3 ptrs to 1, 2, 3 levels of indirection Compromise between fast access for small file, # of levels of indirection (slower access) for larger files v-nodes are used in virtual file systems, where remote file systems can be mounted
v-nodes Virtual Node Layer Network file system Local disk 1 Local disk 0 Special device Client file system uses vnode as much as it would use inodes Purpose is to make access uniform, regardless of whether file/device is local or remote Abstract file location & details of access
i-node Why indirect? Permits more data blocks to be accessed
Files open in a single process
One File open in multiple processes
Questions to Address in Class What happens to a process’ file table on a fork? What happens if a process with a pipe containing data calls fork()? What do file tables look like when complex shell commands are executed? How does dup2 affect the file table? When are entries in the system file table shared? What happens to fully buffered data if a fork occurs between buffering and output? When is output fully buffered? When are system file table entries shared, and when are inodes shared?