File System Abstraction
  1. File system can be viewed as an abstract data type.
    1. Present the reading, writing and other operations to to the client.
    2. Implement using blocks of file storage.
    3. Changes to the system must survive the processes make them, and across system reboot.
  2. Visible file structure.
    1. A file is a sequence of bytes.
    2. Previously
      1. A sequence of fixed-size records.
      2. Key/value pairs.
    3. Current practice is to allow applications or library to build whatever needed structure in the byte-array file.
  3. File names
    1. Various limits on length or characters.
    2. Case sensitive or not.
    3. Unix is case-sensitive.
    4. DOS is famous 8/3, case insensitive.
    5. Windows is case insensitive, but remembers the case used when the name was created.
    6. Extensions and applications.
      1. Some (notably Windows) use part of the file name to indicate content.
      2. Associate an application with a file by its ending.
      3. Some systems record this separately from the file name.
      4. Some just leave it to the user.
  4. File types.
    1. Special types recognized by the kernel.
      1. Directories (most OSs).
      2. Device files which represent a device instead of storage.
      3. Communications channels (Unix).
    2. File formats
      1. A particular arrangement of the bytes in the file, eg. jpg image format, mpg audio format, favorite word processor format, etc.
      2. Any OS must recognize
        1. It's own executable format.
        2. It may recognize others, or leave them to applications.
      3. Associating files with applications which understand them.
        1. Windows uses file extensions (part of the name). Windows.
        2. Some OS's record this with the file apart from the name.
        3. Sometimes applications use name extensions, but not the kernel.
  5. File access.
    1. Sequential. Start to finish in order.
    2. Random. Read in order directed by a program.
  6. File attributes
    1. Information associated with the file besides the data.
    2. Most essential: name.
    3. Size
    4. Write date and other dates.
    5. Creator, owner, permissions.
    6. Many others.
    7. Some OSs support arbitrary user-defined attributes.
  7. There are many file operations, varying a bit by OS.
    Create, delete, open, close, read, write, append, seek, get attributes, set attributes, rename.
  8. Directory layout.
    1. Early OSs had a single directory for the whole system.
    2. Some have had one directory per user, and other special arrangements.
    3. Modern systems have general trees.
      1. Files arranged in a tree, where files are leaves and internal nodes are directories.
      2. Root node at the top of the tree.
    4. File Paths.
      1. Full file names represent paths through the tree.
      2. Separator character varies.
      3. Windows uses one tree per device, rather than a single tree.
      4. File names starting with the separator are full path names.
      5. File names starting without the separator are relative.
        1. Each process has a current directory to which the kernel treats them as relative.
        2. Other software may have directory name or names which it uses to build a full path.
  9. Directory operations.
    Create, delete, opendir, closedir, readdir, rename, link, unlink
    1. Read and write operations are specialized to reading directory entries, rather than general reading ans writing.
    2. Link and unlink refer to adding and removing directory entries.