What is a File System?


For most users, the file system is the most visible aspect of a general-purpose operating system.

[1]

The file systems are a method of abstraction. A file system simplifies access to the operating system resources. They mainly focus on the simplification of storage devices.

What is a File System

With file system abstractions, the operating system provides a uniform logical view of stored information.

[1]

File systems abstract away the complexity of the resources by providing simple interfaces. The main objective of a file system is to provide an abstract data type called a File to provide uniform access to storage devices. File systems also provide the same uniform access methods for other system resources thereby reducing the overall complexity of an operating system.

The physical properties of the storage device abstracted away with a logical storage unit, file, provided by the OS.

[1]

The level of sophistication of an operating system can potentially be measured by looking at how advanced its file systems are. The most sophisticated operating systems only provide a file system interface to access all the system resources. Thereby, the operating system API complexity is reduced which results in an increase in learnability and high developer experience.

As the file systems get more sophisticated, it allows the operating system to extend its feature set without introducing additional complexity.

File systems provide efficient and convenient access to the storage device by allowing data to be stored, located, and retrieved easily.

[1]

File System Design Problems

A file system poses two quite different design problems.

1 – How the file system should look to the user?

  • The task involves defining the following aspects:
    • Defining a file and its attributes
    • Defining the operations allowed on a file.
    • Defining a directory structure for organizing files.

2 – How to map logical fs level algorithms and data structures to the physical storage devices.

File Abstraction

File Abstract Type

File FieldField Description
NameHuman readable file identifier.
IdentifierA unique number to identify the file internally.
TypeThe way the file is processed changes depending on its type.
LocationPointer to the storage medium
SizeThe current file length
ProtectionAccess control information. Who can read-write-execute?
TimestampsLast access, last modification, and formation timestamps.
UserThe file owner.

Basic File Operations

A file is an abstract data type.

1 – Forming a file

  • Search empty space for the new file.
  • Insert new file directory entry.

2 – Opening a file

Instead of using file names in all operations, the file opening concept increases the efficiency of the file system.

The handle obtained when opening a file will be used throughout the file lifetime, thereby most of the operations required to locate the file will not be required.

The use of a file handle rather than a file name removes the need for file name evaluation and access permission checks.

3 – Writing a file

The file system keeps track of the writes using a pointer called file offset. File offset advanced whenever a write occurs.

4 – Reading a file

The file system keeps track of the reads using a pointer called file offset. The file offset is advanced whenever a read occurs.

5 – Repositioning within a file

Reposition the file offset. Repositioning is known as seeking.

  • It does not involve any actual IO.

6 – Deleting a file

  • Search for the directory entry associated with the given file name.
  • Release file resources.
  • Mark the entry as free.

7 – Truncating a file

Truncation allows the change of the file length without change in other file attributes.

  • File length can also be increased in addition to reducing the file length.

File System Modules

1 – File organization module

  • File metadata
  • Filenames

2 – Directory organization module

3 – Free Space Management

Keeps track of unallocated blocks.

  • Slack Space Management
  • Fragmentation

4 – Caching

Caches hold various frequently accessed file system structures, directory entries, and data blocks for efficiency.

5 -Volume management

  • Boot control block per volume
    • It is used by the system to boot an OS from a bootable volume.
    • In UFS, it is called the boot block.
  • Volume control block per volume
    • Volume metadata.
    • In UFS it is called the superblock.

References

[1] Operating System Concepts, Abraham Silberschatz 10th edition, File Systems


Leave a Reply

Your email address will not be published. Required fields are marked *