logo
Operating Systems

04. File System

The file system is an important component of the operating system for managing and storing data. This chapter systematically explains the basic concepts of files and file systems, file attributes and operations, directory structures, file allocation methods, access control and protection, and common file system types.

1. Basic Concepts of Files and File Systems

  • File: A collection of related information named by the user on external storage, the basic unit of data management.
  • File System: System software in the OS responsible for file storage, organization, naming, access, protection, and persistence.

2. File Attributes and Operations

File Attributes

  • File name, type, location, size, creation/modification/access time, permissions, owner, etc.

File Operations

  • Create, delete, read, write, rename, copy, move, open, close, change permissions, etc.

3. Directory Structure

  • Single-level directory: All files in one directory, simple but prone to name conflicts.
  • Two-level directory: Each user has their own directory, solves name conflicts.
  • Tree-structured directory: Supports multi-level subdirectories, flexible and common.
  • Acyclic graph structure: Allows shared subdirectories or files.

4. File Allocation Methods

  • Contiguous allocation: File occupies a group of contiguous disk blocks, fast sequential access, prone to fragmentation.
  • Linked allocation: Each file consists of scattered disk blocks, each block points to the next.
  • Indexed allocation: Each file has an index block storing addresses of all data blocks.

5. File Access Control and Protection

  • Access Control List (ACL): Specifies which users/groups have what permissions (read, write, execute, etc.) for each file.
  • Password protection: Set access passwords for files.
  • Encryption: Encrypt file contents to prevent unauthorized access.
  • Backup and recovery: Prevent data loss.

6. Common File System Types

  • FAT (File Allocation Table): Used in early Windows, simple structure.
  • NTFS (New Technology File System): Main Windows file system, supports permissions, encryption, journaling, etc.
  • ext3/ext4: Common Linux file systems, support journaling, permissions, soft/hard links, etc.
  • APFS/HFS+: Common file systems for Apple macOS.

Exercises

  1. Briefly describe the main functions of a file system.
  2. Compare the advantages and disadvantages of contiguous, linked, and indexed allocation.
  3. State the advantages of a tree-structured directory.
  4. Give examples of common file access control methods.
  5. List two common file system types and briefly describe their features.
Reference Answers

1. Main functions of a file system

Answer: The main functions of a file system include: allocation and management of file storage space, file naming and organization, directory management, file read/write and access control, file protection and security, data persistence, and backup and recovery.


2. Compare contiguous, linked, and indexed allocation

Answer:

  • Contiguous allocation: fast sequential access, simple structure; prone to external fragmentation, difficult file expansion.
  • Linked allocation: no external fragmentation, flexible file expansion; low random access efficiency, pointer overhead.
  • Indexed allocation: efficient random access, flexible file expansion; index block occupies space, large index tables may require multi-level indexing.

3. Advantages of tree-structured directory

Answer: Tree-structured directories support multi-level subdirectories, facilitate file classification and management, avoid name conflicts, support flexible organization and access, and are the most commonly used directory structure in modern OSes.


4. Examples of file access control methods

Answer: Common methods include: access control lists (ACL), user/group permission settings (e.g., rwx), password protection, encryption, read-only/hidden attributes, etc.


5. List two common file system types and briefly describe their features

Answer:

  • NTFS: supports permission management, encryption, journaling, file compression, high security, used in Windows.
  • ext4: supports large files, journaling, soft/hard links, good performance, used in Linux.