25 Feb 2017

Unix 2.2 File Sub-system


FILE SUB-SYSTEM 




The internal representation of a file is given by an inode, which contains a description of the disk layout of the file data and other information such as the file owner, access permissions, and access times. Every file has one mode, but it may have several names, all of which map into the mode. Each name is called a link. When a process refers to a file by name, the kernel parses the file name one component at a time, checks that the process has permission to search the directories in the path, and eventually retrieves the mode for the file.When a process creates a new file, the kernel assigns it an unused mode.

The kernel contains two other data structures, the file table and the user file descriptor table. 


The file table is a global kernel structure, but the user file descriptor table is allocated per process. When a process opens or creates a file, the kernel allocates an entry from each table, corresponding to the file's mode. Entries in the three structures user file descriptor table, file table, and mode table maintain the state of the file and the user's access to it. The file table keeps track of the byte offset in the file where the user's next read or write will start, and the access rights allowed to the opening process. The user file descriptor table identifies all open files for a process. 

The kernel returns a file descriptor for the open and create system calls, which is an index into the user file descriptor table. When executing read and write system calls, the kernel uses the file descriptor to access the user file descriptor table, follows pointers to the file table and mode table entries, and, from the Mode, finds the data in the file. 

A file system has the following structure :


• The boot block occupies the beginning of a file system, typically the first sector, and may contain the bootstrap code that is read into the machine to boot, or initialize, the operating system. Although only one boot block is needed to boot the system, every file system has a (possibly empty) boot block.

• 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.

• The Mode list is a list of modes that follows the super block in the file system. Administrators specify the size of the mode list when configuring a file system. The kernel references Modes by index into the mode list. One Mode is the root Mode of the file system: it is the mode by which the directory structure of the file system is accessible after execution of the mount system call.

• The data blocks start at the end of the mode list and contain file data and administrative data. An allocated data block can belong to one and only one file in the file system.

Friends, if you find this post useful please comment below. If you want quick notes for any topic please mail us at hardikpanchal551@gmail.com, we will try to provide notes if possible. Thanks for reading.

1 comment:

  1. Thanks for sharing the tutorials. Now, just waiting for NIOS Class 12 result announcement...

    ReplyDelete