The File Subsystem

Explain the file subsystem.

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 inode, but it may have several names, all of which map into the inode. 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 inode for the file. For example, if a process calls open 07fs2/mjb/rje/sourcefile", 1)the kernel retrieves the inode for "/fs2/mjb/rje/sourcefile". 

When a process creates a new file, the kernel assigns it an unused inode. Inodes are stored in the file system, as will be seen shortly, but the kernel reads them into an in-core1 inode table when manipulating files. 

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 creats a file, the kernel allocates an entry from each table, corresponding to the file's inode. Entries in the three structures — user file descriptor table, file table, and inode table —maintain the state of the file and the user's access to it.

File Subsystem

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. 

Figure 2.2 shows the tables and their relationship to each other. The kernel returns a file descriptor for the open and create system calls, which is an index into the user file descriptor table. 

The UNIX system keeps regular files and directories on block devices such as tapes or disks. An installation may have several physical disk units, each containing one or more file systems. 

Partitioning a disk into several file systems makes it easier for administrators to manage the data stored there. The kernel deals on a logical level with file systems rather than with disks, treating each one as a logical device identified by a logical device number. 

The conversion between logical device (file system) addresses and physical device (disk) addresses is done by the disk driver. 

A file system consists of a sequence of logical blocks, each containing 512, 1024, 2048, or any convenient multiple of 512 bytes, depending on the system implementation. The size of a logical block is homogeneous within a file system but may vary between different file systems in a system configuration.

Read Also
How To Write A Makefile

Have a Unix Problem
Do you have a UNIX Question?

Unix Books :-
UNIX Programming, Certification, System Administration, Performance Tuning Reference Books

Return to : - Unix System Administration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.
The site www.gotothings.com is in no way affiliated with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.