File Systems

A file system is responsible for:

It stores information about a file's name (name, extension), type (e.g. directory, file, link), and some attributes. It also provides user functions, such as create, open and delete and support functions such as locking, caching and address translation.

1. File Attributes

File attributes contain some information about each file:

It also contains some address information:

It also contains some access control information:

It also contains some usage information:

2. File System Organization

As file size is variable, we need to dynamically manage space by allocating space in blocks (typically to bytes). We need to choose an appropriate block size as:

Various methods exist for accessing blocks that belong to a file.

2.1 Contiguous Allocation

We place file data at contiguous addresses on the storage device. Although successive logical records are typically physically adjancent, which speeds up access, it suffers from:

2.2 Block Chaining

In block linkage, each block contains a pointer to the next block. When locating a block, the chain must be searched from the beginning. If blocks are dispersed throughout the disk, chain searching can be slow, as block-to-block seeks occur.

Although this wastes pointer space in each block, insertion / deletion can occur simply by modifying the pointer in the previous block.

invert center screen small

2.3 File Allocation Table (FAT)

A block allocation table (BAT) stores pointers to file blocks:

A file allocation table (FAT):

The tables reduce the number of seeks to access a given record. But, the files can become fragmented, and the tables can become very large.

invert center screen small

2.4 Index Blocks

Each file contains one or more index blocks, which contain a list of pointers to file data blocks. The file's directory entry points to its index block. We use chaining by reserving the last few entry in an index block to point to more index blocks. This:

(!) inodes

In UNIX/Linux, index blocks are called inodes. When a file is opened, the OS opens an inode table. This is structured as an inode on disk, but contains:

  • Disk device number.
  • Inode number.
  • Number of processes with opened file.
  • Major / minor device number.
  • etc.
  • Contains pointers to data blocks, or to more index blocks.

3. Free Space Management

We need to manage free space, or provide quick access to free blocks for reuse. There are a few methods to do this, to keep track of free blocks.

3.1 Free List

A free list is a linked list of blocks cointaining the location of all free blocks. Blocks are allocated from the beginning of the list, and newly freed blocks are appended to the end of the list.

Although there is low overhead to maintain the list, it is likely to allocate in noncontiguous blocks, which increases file access time.

3.2 Bitmap

A bitmap contains one bit for each disk block, which indicates whether the block is in use. This can quickly determine available contigious blocks at certain locations in storage, but execution overhead can occur when searching the entire bitmap to find a free block.

3.3 File System Layout

A fixed disk layout contains a:

The super block contains:

4. Directory Organization

A directory maps symbolic file names to logical disk locations. This helps with file organisation, and ensures the uniqueness of file names.

4.1 Multi-Level Structure

A multi-level (tree) directory structure is used by heirarchical file systems (most OS). The root indicates where on disk the root directory begins. Each directory can contain other directory or files with unique names within that directory.

To describe the location of a file, we can use pathnames:

A directory also has a number of operations:

A link describes a reference to a file or directory in another part of the filesystem.

Introducing links can cause problems:

4.3 Mounting

A mount operation combines multiple file systems into a single namespace. It allows reference from a single root directory. Soft links are allowed to be mounted, but hard links are not.

A mount point is a directory in the native file system that is assigned to the root of the mounted file system. File systems manage mounted directories with mount tables, which store the location of mount points and devices. When a native file system encounters a mount point, it uses the table to determine the device and type of mounted file system.

Linux ext2fs

A high performance, robust file system with typical block sizes of KB. % of the blocks are reserved for root. The ext inode:

  • Represents files and directories on the file system.
  • Stores information relevant to a single file or directory.
  • First pointers are direct pointers to data blocks.
  • The th pointer is a single indirect pointer to a block of pointers.
  • The th pointer is a double indirect pointer to a block of single indirect pointers.
  • The th pointer is a triple indirect pointer to a block of double indirect pointers.

This provides fast access to small files while supporting very large files.

Block groups are clusters of contiguous blocks in which the file system attempts to store related data, with the aim of reducing average seek time. Each block group contains:

  • The superblock - critical data about the entire file system. This includes the total number of blocks / inodes, size of block groups, the time the file system was mounted, etc. Some block groups may have a redundant copy of the superblock.
  • The inode Table contains an entry for each inode in the block group.
  • The inode Allocation Bitmap for inodes used within the block group.
  • The Block Allocation Bitmaps for blocks used within the block group.
  • The Group Descriptor contains block numbers for the location of the inode Allocation Bitmap, Block Allocation Bitmaps, inode Table and the Accounting Information.
  • The remaining space is used to store file / directory data. Directory information is stored in directory entries, composed of the inode number, directory entry length, file name length, file type, and file name.
Back to Home