Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

UNIX File System Structure

UNIX File System Structure -

The file subsystem controls the storage and retrieval of data in user files. Files are organized into file systems, which are treated as logical devices; a physical devices such as a disk can contain several logical devices (file systems). A file system consists of a sequence of logical blocks, each containing 512, 1024, 2048 or any other multiple of 512 bytes. The use of large logical blocks increases the effective data transfer rate between disk thus make fewer time-consuming operations.

The major kernel data structures used in file subsystem are Inode, file table and the user file descriptor table.
              The inode (index node) is a data structure that describes the internal representation of a file. Each file in a file system is described by an inode that gives the attributes of the file. The inode contains the description of the disk layout of the file data and other information such as the file owner, access permissions, and access times.
              The file table is a global kernal structure that keeps track of the byte offset in the file where the user's next read or write will start.
              The user file descriptor table is allocated per process that identifies all open files for a process.
              When a process opens or creates a file, the kernel allocates an entry from each table, corresponding to the file's inode. The state of the file is maintained by the entries in the three data structures - User file descriptor table, file table and inode table.


Following figure shows the table and relationships to each other.

Relationship between File descriptor, File table and Inode table

For the open and create system calls, the kernel returns a file descriptor, which works as an index into the user file descriptor table, when executing read and write system calls, the kernel uses the file descriptor to access the entries and finally from the inode, finds the data in the file.
             A file system has the following structure as shown in figure-

Diagram for File System Layout
 The function of each module is -

1.    The boot block occupies the first sector of a file system and contains a bootstrap code that is read into the machine to boot or initialize the operating system.

2.    The super block describes the state of a file system -  how large it is, how many files it can store, where to find free space on the file system, and other information.

3.    The inode list is a list of inodes where the kernel references inodes by index.

4.    The data blocks start at the end of the inode list and contain file data and administrative data.

This post first appeared on BCA MCA NOTES, please read the originial post: here

Share the post

UNIX File System Structure


Subscribe to Bca Mca Notes

Get updates delivered right to your inbox!

Thank you for your subscription