File management is a core OS function — it controls how data is stored, retrieved, organized, and protected on storage devices.
🔑 Key Functions
- Creation & Deletion — OS allows creating/removing files and directories.
- Access Control — Sequential, direct (random), or indexed access methods.
- Naming — Assigns names + extensions (e.g.,
report.docx) for identification. - Organization — Groups files into directories/folders.
- Security — Permissions: read, write, execute.
- Backup & Recovery — Guards against accidental loss or corruption.
📋 File Attributes
📑 File Access Methods
| Method | Description | Example |
|---|---|---|
| Sequential | Records read one after another in order. | Text file read line by line |
| Direct (Random) | Access any position without reading through prior data. | Database records |
| Indexed | Uses an index structure to locate data blocks rapidly. | Index at back of textbook |
📚 Directory Structures
- Single-Level — All files in one flat directory. Simple, but cluttered.
- Two-Level — Each user has their own separate directory.
- Tree-Structured — Hierarchical folders & sub-folders (most common today).
- Acyclic Graph — Files can be shared across multiple directories without loops.
- General Graph — Most flexible; allows cycles but needs garbage collection.
🔒 Protection Mechanisms
hello.c — the OS creates the file, records attributes (size, date, type), and enforces permissions so only authorized users can edit or delete it.