As we already know a File System is a huge collection of directories and files which save all kind of information. File Systems are organized by directories which in turn can contain besides files, other directories or sub-directories.
A way of organizing a file system may be:
- Using a 'root' to signal where in the disk the 'root directory' starts.
- The 'root directory' points to 'user directories'
- An 'user directory' contains an entry for every file
- The file names need to be unique inside a certain user directory.
The system name for a file must be unique in the file system. In hierarchical file systems, the system name for a file is usually the "trajectory name" from the 'root directory' to the file.
Directories in UNIX systems are organized keeping certain hierarchy as we can see in the following schematic picture:
File systems include utilities to initialize, alter parameters of and remove an instance of the filesystem. Some include the ability to extend or truncate the space allocated to the file system.
Directory utilities create, rename and delete directory entries and alter metadata associated with a directory. They may include a means to create additional links to a directory (hard links in Unix), rename parent links (".." in Unix-like OS), and create bidirectional links to files.
File utilities create, list, copy, move and delete files, alter metadata. They may be able to truncate data, truncate or extend space allocation, append to, move, and modify files in-place. Depending on the underlying structure of the filesystem, they may provide a mechanism to prepend to, or truncate from, the beginning of a file, insert entries into the middle of a file or deletion entries from a file.
Also in this category are utilities to free space for deleted files if the filesystem provides an undelete function.
Some filesystems defer reorganization of free space, secure erasing of free space and rebuilding of hierarchical structures. They provide utilities to perform these functions at times of minimal activity. Included in this category is the infamous defragmentation utility.
There are two general strategies to store a 'n' bytes file.
1. Assign 'n' consecutive bytes of disk space.
- Downside: If a file size increases, it will probably move in the disk, which can affect performance.
- Generally file systems use this strategy with fixed size blocks.
Some of the most important features of files system utilities involve supervisory activities which may involve bypassing ownership or direct access to the underlying device. These include high performance backup and recovery, data replication and reorganization of various data structures and allocation tables within the filesystem.
Example of emulating a defragmentation algorithm: