File System Structure
  1. Storage
    1. Traditional storage device is a mechanical disk drive.
      1. Data is recorded by magnetizing (or not) spots on the platter surface.
      2. The platter spins constantly.
      3. The head moves on the arm as needed to access specific data.
      4. Data are recorded in circles called tracks.
      5. Tracks are divided into sectors.
      6. A sector is the minimum amount of data which can be transferred, traditionally 512 bytes.
      7. To read or write, the head must move to the track, wait for the sector, then perform the transfer while the sector passes underneath.
      8. Head motion is the slowest.
      9. Larger (or more often just older) drives use a stack of platters.
      10. There are heads for each platter, but they move together, so they are always positioned at a group of tracks which are aligned.
      11. Such a stack of tracks is called a cylinder. Sectors in the same cylinder may be read without moving the head.
      12. All common file systems have been designed to make efficient use of such a device, especially to minimize head motion.
    2. Many devices today, especially mobile ones, use flash storage.
      1. Flash drives are electronic, and generally faster.
      2. Behavior and optimization of flash is totally different.
      3. Current practice is to treat flash drives like hard drives anyway, using existing techniques.
      4. We have a section on flash later.
  2. Disk layout
    1. The OS treats a disk as a series of sectors.
    2. Physical disks are usually divided into partitions.
      1. The partition table at the front of the disk defines partitions as ranges of sectors of the physical disk.
      2. Each partition contains a separate file system, often of different file types.
      3. When the OS starts using a disk, it looks for a partition table.
        1. If none, it's just a single disk.
        2. If present, each partition is treated as a separate disk.
    3. Traditional PC format is Master Boot Record (MBR) layout. (AKA DOS layout.)
      1. MBR is sector zero.
      2. Partition table is part of the MBR, and is of fixed size four.
      3. The format also allows for “extended partitions” so a disk may have more.
        1. A partition may be marked extended in the MBR.
        2. Such a partition contains another partition table which subdivides it.
        3. These subdivisions are treated as partitions of the disk, rather than the extended partition.
      4. Partitions have one-byte type codes which are not managed. Codes are used inconsistently by different software.
      5. Disk offsets are 32-bits. Denoting a 512-byte sector, this limits disks to 2 TB.
    4. Newer: GUID Partition Table (GPT) layout.
      1. Variable-sized table, so many partitions are possible.
      2. Partition types given by GUIDs, which are large identifiers.
      3. Supports much larger offset numbers.
    5. Text figure illustrates layout of a Unix fs, but layout in a partition will depend on OS.
  3. There are many different file system designs.
    1. Usually associated with a particular O/S.
    2. Or with media type.
    3. Most OSes must support more than one type of FS.
    4. File systems are generally part of the OS, but some may be supported in user space.
  4. File layout.
    1. Efficiency of operations:
      1. Sequential reading.
      2. Random-access reading.
      3. File growth.
    2. Basic approaches.
      1. Contiguous.
      2. Linked.
        1. Simple linked files.
        2. FAT.
      3. Indexed (i-nodes).
        1. Basic indexes.
        2. Index with blocks.
      4. Real systems make variations and combinations of these.
  5. Directory layout.
    1. A directory is just a list of files, given by location on disk.
    2. File name may be recorded in the directory entry, or the file. Other meta-data likewise.
    3. Directory may be a list of fixed-size entries.
      1. Easy to maintain.
      2. Tends to create a short limit on file names.
    4. Directory may be a list variable-size entries.
      1. Same sort of problems as variable partitions.
      2. More flexible
    5. May combine fixed records with a head area for file names.
    6. In practice, don't seem to use fancy search-able structures.
  6. Multiple directory entries
    1. Hard linking.
      1. Some FSs allow a file to have multiple directory entries (Unix).
      2. Some do not (Windows).
      3. Allows a file to have multiple names. (At least different full path names.)
    2. Soft linking.
      1. Some systems allow a special file which name another.
      2. Allows a file to have multiple names with only one directory entry.
  7. Text mentions log-structured file systems.
  8. Text mentions virtual file systems.