File Structure - aryanjoshi0823/5143-Operating-System GitHub Wiki
In operating systems, the file system provides a structured way to store, organize, and manage files on storage devices. The file structure within a file system represents how files and directories are organized and accessed.
File Structure in File Systems
-
Hierarchical Structure (Tree-Based Model)
- The most common file structure resembles a tree, where directories (folders) act as nodes and files are the leaves.
- The root directory (
/
in Unix/Linux orC:\
in Windows) is the starting point. - Directories can contain other directories (subdirectories) and files.
Example:
/ ├── home │ ├── user │ │ ├── documents │ │ │ └── resume.docx │ │ └── music │ │ └── song.mp3 ├── etc │ └── config.conf └── var └── log └── system.log
-
Flat Structure
- All files exist at the same level, and there is no hierarchy.
- This was common in older operating systems but is not scalable for modern systems.
Example:
file1.txt file2.txt file3.txt
-
Relational Structure
- Used in some databases where files are managed as relations (tables).
- Each file can have metadata and attributes.
-
Graph Structure
- A more flexible structure where files or directories can have multiple parents, creating a Directed Acyclic Graph (DAG).
- Common in systems that support symbolic links or shortcuts.
-
Layered Structure
- Layers abstract the file operations, ensuring consistent access regardless of the underlying file system type.
- Example: Virtual File System (VFS) in Linux.
Key Components of File Structures
- Files: Contain data or information (text, images, programs, etc.).
- Directories: Containers that hold files and other directories.
- Root Directory: The top-most directory in the hierarchy.
- Metadata: Includes file name, type, size, permissions, creation/modification time, etc.
- Links:
- Hard Links: Multiple directory entries that refer to the same file.
- Soft Links (Symbolic Links): Pointers to another file or directory.
Common File Systems
- Windows: FAT32, NTFS
- Unix/Linux: EXT3/EXT4, Btrfs, XFS
- MacOS: APFS, HFS+
- Network File Systems: NFS, SMB/CIFS