File Systems: Structure, Operations, and Management

1. File Systems

The visual aspect of an operating system (OS), the file system, consists of two parts:

  • A collection of files, each containing related data.
  • A directory structure that organizes and provides information on all files.

2. Long-Term Memory Storage

Three requirements for long-term memory storage are:

  1. The ability to store a large amount of information.
  2. Persistence of information after the completion of processes using it.
  3. Simultaneous access to information by multiple processes.

The solution is to store data in mass storage devices, in units called files. File information is persistent, unaffected by process creation or termination, and only disappears when deleted by the owner. The file system, a part of the OS, manages files. A file is the smallest logical unit of secondary storage, generally containing simply structured information.

3. File Attributes

File attributes vary across operating systems. Common attributes include:

  • Name: The assigned name, often divided into a name and an extension (type).
  • Type: Allows the OS to recognize and operate with the file if identifiable.
  • Location: Specifies the starting address (cylinder and sector) on the disk.
  • Size: The current file size.
  • Protection: Specifies user access permissions.
  • Date and Time: Timestamps of file creation or modification.

4. File Operations

Common file operations include:

  • Creation: Involves allocating disk space and creating a directory entry.
  • Writing: Requires a system call specifying the file name and data to write.
  • Reading: Requires the file name and a memory buffer address to store the read content.
  • Positioning: Sets the read/write pointer within the file.
  • Deletion: Requires the file name.

To minimize directory searches, the OS uses the file open operation. This copies the directory entry to the open file table in main memory. The operation returns a file descriptor, typically an index to the open file table. Multiuser systems have two levels of open file tables: the process’s local table and the system table. Opening a file creates entries in both. Multiple openings by the same process increment a counter in the local table. When this counter reaches zero, the system table entry is deleted.

5. Directories

  • Single-Level Directory: Simple to implement but problematic for multiple users due to naming conflicts. Even single users find it difficult to manage numerous files.
  • Two-Level Directory: Uses a master directory and user directories. Improves organization but hinders collaboration.
  • Tree-Structured Directory: Allows users to create their own hierarchical structure, offering flexibility and organization. The root directory is a special file with a structure known to the OS.

6. Free Space Allocation

: In a magnetic disk, for his great ability, stored a large amount of files. The main problem that arises is how to allocate space to these files so that disk space is used efficiently (without
waste) and subject to the speed of data access to all components of each file. – Next: each file occupies a series of contiguous blocks on disk. Is supported but any access method. External fragmentation, because as you create and delete files on disk space will decompose into smaller and smaller holes (not usable) The only solution to this problem is compaction. determine how much space you need for a file, ie how to know when creating a file what will be its maximum size. “linked list : each file is composed of a list of chained blocks, so that now every block can be located anywhere on the disk. and there is no external fragmentation, and any free block can be used to satisfy a request is espacio.no indicate the size required to create a file, it grows as blocks are added to the linked list and, of course, never required compaction.only be used efficiently for sequential access, also take up space pointers last problem file consist of a list of pointers scattered throughout the disc, loss or damage to one of them also causes the loss of
file information contained in the remaining blocks of the list. – Allowance is indexed to solve problems linked list with the shortcut. For that, all it does is bring together all the pointers for the blocks of a file in one place: the block of indices / problem with this system is the waste of space, as the index block size is usually larger than that required for the pointers in the linked list.’s dilemma: if the index block is large, much space is wasted, if small, may not fit all indexes of a large file. / Solution: Unix maintains a few pointers blocks of data in the I-node (direct pointers), but if these blocks are filled, then use another pointer
(indirect pointer) indicating the direction of an index block, which contains pointers to data blocks.