ch11

Chapter 10&11: File System Operating Systems

  • Prepared by Silberschatz, Modified by Dr. Yuntong Zhang

11.1 Overview

11.2 File Attributes

  • Name: The name of the file.

  • Identifier: A unique tag (number) that identifies the file within the file system.

  • Type: Required for systems that support different file types.

  • Location: A pointer that indicates the file's location on the device.

  • Size: The current size of the file.

  • Protection: Controls the permissions for reading, writing, and executing the file.

  • Time, Date, and User Identification: Information utilized for protection, security, and usage monitoring.

Typical File Control Block (FCB)

  • Contains information about files.

11.3 File Types

  • Executable: Typically has extensions like .exe, .com, .bin, indicating ready-to-run machine or binary language programs.

  • Object Files: Extensions like .obj, .o, which are compiled machine language but not linked.

  • Source Code: Extensions may include .c, .cc, .java, which represent source code in various programming languages.

  • Batch Files: Extensions such as .bat, .sh which contain command scripts for command interpreters.

  • Text Files: .txt, .doc represent textual data and documents.

  • Libraries: .lib, .a, .so, .dll contain libraries of routines for programmers.

  • Printable/Viewable Files: Formats like .ps, .pdf, .jpg are used for printable or viewable ASCII/binary files.

  • Archives: Extensions such as .arc, .zip, .tar are used for storing related files together, often compressed for archiving.

  • Multimedia: Extensions like .mpeg, .mov, .rm are binary files that contain audio or audiovisual information.

11.4 File Operations

  • Files are considered an abstract data type with the following operations:

    • Create: Initiate a new file.

    • Write: Add data to a file.

    • Read: Retrieve data from a file.

    • Reposition: Move to a specific point within the file.

    • Delete: Remove the file from the system.

    • Truncate: Shorten the file.

    • Open(Fi): Search the directory structure for the entry Fi and load it into memory.

    • Close(Fi): Save changes from memory back to the disk.

11.5 Tree-Structured Directories

  • Directory structures can have:

    • Absolute path: Full path from the root to the file.

    • Relative path: Starts from the current directory.

  • File Management Commands:

    • Delete a file: Command syntax rm <file-name>.

    • Create a new folder: Command syntax mkdir <folder-name>.

    • Deleting directories: Deleting a directory will remove the entire subtree rooted by it.

11.6 Modern OS File-System Implementation

  • On-disk structure:

    • Boot Control Block: Contains boot information.

    • Partition Control Block: Details of disk partitions.

    • Directory Structure: Information on directories.

    • File System Types: e.g., FAT, FAT32, NTFS.

  • In-Memory File System Structures:

    • In-memory partition table: Information about mounted partitions.

    • In-memory directory structure: Holds recently accessed directory information.

    • System-wide open-file table: Keeps copies of FCB for all open files.

    • Per-process open-file table: Points to entries in the system-wide open-file table for each process.

11.7 Disk Block Allocation Methods

  • A disk block: A fixed sequence of bytes on a disk, accessed as a single unit.

  • Allocation methods:

    • Contiguous allocation: Files stored in adjacent blocks.

    • Linked allocation: Each file consists of scattered blocks, linked as a list.

    • Indexed allocation: Pointers to all file blocks are collected in a single index block.

11.8 Contiguous Allocation

  • Files occupy a set of contiguous blocks:

    • Simplicity: Requires only the starting location and length.

    • Minimal seeks: Neighboring blocks reduce seek time.

    • Efficient for access types: Good for both sequential and direct access.

    • Drawbacks:

      • Inefficient space usage due to external fragmentation.

      • Files can't grow if adjacent blocks are occupied.

11.9 Example of Contiguous Allocation

  • Example structure shows how contiguous allocation might organize files in a directory.

11.10 Linked Allocation

  • Each file represented as a linked list of disk blocks scattered across the disk:

    • Directory holds pointers to the first and last blocks.

    • Advantages:

      • Easy to expand files.

    • Drawbacks:

      • Slower access speeds.

      • Decreased disk reliability; damage to a block can result in file loss.

      • Utilization of disk space is not optimal due to the need for pointers.

11.11 Indexed Allocation

  • Pointers organized in an index block (an array of disk-block addresses):

    • Each file has its own index block.

    • Similar to paging in memory allocation schemes.

    • Essential for supporting random access but adds overhead with index blocks.

11.12 Free-Space Management

  • Tracking free disk space using a Bitmap:

    • Each bit represents one disk block, indicating if it is free (0) or occupied (1).