Title: Files in Unix
1Files in Unix
2File Handling Data Structures
- Process Table
- File Table
- V-Node Table
- inodes
3Process Table
Process A
File Descriptor Flags
File Table Entry
Process B
Pointer to File Table Entry
Process C
Process D
4File Table
File 1
File Status Flags Read, Write, Etc.
File 2
Current File Offset
File 3
Pointer to V-node Table Entry
File 4
File Table for Open Files
V-node Table
5V-Node Table Entry
File Type
File Table Entry
Pointers to Functions for this File
Inode Information
Disk Drive
V-node Table Entry
6File Types
- Regular files
- Directory files
- Character special files
- Block special files
- FIFOs
- Sockets
- Symbolic Links
7Special File Protection Bits
- Group Locking
- Set group/User ID on execution
- Sticky Bit (saved-text-bit)
8Disk Drives and File Systems
Partition
Partition
Partition
File System
i-list
directory blocks and data blocks
Boot Block
Super Block
inode
inode
inode
inode
inode
9File Systems Expanded
B
S
i-list
data
data
data
directory
directory
data
data
data
inode inode inode
inode File Name inode File Name inode
File Name
10Direction and Indirection
Disk Blocks
inode
Direct 0 Direct 1 Direct 2 Direct 3 Direct 4
Direct 5 Direct 6 Direct 7 Direct 8 Direct 9
Sgl Ind Dbl Ind Triple Ind
11inodes
- inodes contain a lot of information about a file
- mode and type of file
- number of links to the file
- owner's UID
- owners GID
- number of bytes in file
- times (last accessed, modified, inode changed)
- physical disk addresses (direct and indirect
blocks) - number of blocks
- access information
12In-core inodes
- When a file is being used, it's inode is copied
to memory (core) and additional fields are added - access status
- node is locked
- process is waiting for node to unlock
- in-core inode has been modified
- file has changed so inode has also changed
- Number of processes using inode and file
- Device ID and disk address where inode is located
- Current file position
13RFS (Remote File System)
- An ATT invention
- Independent of any particular network hardware or
software - Designed for transparent sharing of disk storage
and peripherals - RFS mounts a remote directory structure under an
existing structure in the user's filesystem - Remote files are then accessed as though they are
part of the local file system - RFS also supports special files and named pipes
14 - The server keeps track of how many remote users
have the file open at a given time - Server also maintain security by distinguishing
between local and remote opens - Remote access can be restricted to the privileges
of selected local accounts
15NFS (Network File System)
- Developed by Sun Microsystems
- Design goal was portability to other OS's and
architectures - Uses RPCs (Remote Procedure Calls) for protocol
definition and remote system access - Uses the External Data Representation (XDR) to
define data in a machine independent manner - Furthers machine independence by defining a
Virtual File System (VFS) that defines operations
that can be performed on a file
16 - NFS fileservers are stateless and do not track
the state of files or provide any standard Unix
file locking capabilities - Conflicts among users of the same file can arise
- Sun has provided a locking scheme by maintaining
client requested locks in memory only - Both client and server keep locks in memory for
consistency - However, because of the tight coupling between
client and server, loss of a server can cause
data consistency problems
17 - NFS does not allow shared root filesystems
- In concept, shared directories like /dev, /bin,
and /etc should reside on a common file server - This simplifies the design but the failure of the
fileserver then impacts all attached nodes - The user or sysadmin must know what directories
should be mounted at each network node - The number of required mounts can take quite a
while to perform on system reboot - Since files are shared in place (on the server)
there are no revision conflicts
18 - The stateless nature of NFS (except for the
locking kludge) ensures consistency of the system
after recovery from a crash