FIT2100 Chap.4 Files, Directories and Storage
Files, Directories and Storage
A file system provides persistent, named information that can outlive a process and be shared under controlled rules. Directories map path components toward file objects. Metadata records type, ownership, permissions, size, times and block locations. An open descriptor connects a process to kernel-managed state such as an access mode and current offset.
Allocation policy determines how file bytes reach storage blocks.
Contiguous allocation is simple and fast but resists unpredictable growth. Linked allocation grows easily but makes direct access expensive. Indexed allocation uses an index of block locations, improving lookup at the cost of metadata. Block size also trades internal waste against table size and I/O-operation count.
What this chapter covers
- 01
Persistent storage requirements
- 02
File operations
- 03
Directory trees
- 04
Path resolution
- 05
File metadata
- 06
Contiguous allocation
- 07
Linked and indexed allocation
- 08
Block size and performance
Worked example · free
Calculate allocation and internal waste
- +2Divide file size by block size and round up: ceil(10,500 / 4,096) = ceil(2.563...) = 3 blocks.
- +2Allocated space is 3 × 4,096 = 12,288 bytes because the final partial block occupies a full allocation unit.
- +2Unused internal space is 12,288 − 10,500 = 1,788 bytes. Keep all values in bytes for the subtraction.
Key terms
- Directory Entry
- A namespace record that maps a file name toward the underlying file identity or metadata.
- File Metadata
- Descriptive information such as file type, ownership, permissions, size, timestamps and block references.
- Contiguous Allocation
- A layout storing file blocks next to one another and recording a starting location plus length.
- Linked Allocation
- A layout in which each file block identifies the next, allowing scattered placement and flexible growth.
- Indexed Allocation
- A layout using an index structure to collect the addresses of a file's data blocks.
- Internal Fragmentation
- Allocated space left unused inside a fixed-size unit, often in the final block or page.
Files, Directories and Storage FAQ
Why is a file name separate from the file data?
A directory manages the namespace, while metadata and block pointers identify the stored object. Separating these roles supports links, renaming and cached open state without rewriting every byte whenever a name changes.
Which allocation method supports unpredictable growth?
Linked and indexed layouts can add scattered blocks more easily than strict contiguous placement. Indexed allocation is usually stronger when the workload also needs direct block access, while linked traversal suits sequential use better.
What makes block size a trade-off?
Large blocks reduce the number of addresses and can improve sequential throughput, but small files waste more unused space. Small blocks reduce internal waste while increasing metadata, lookup and operation counts. Workload and storage geometry decide the balance.
What happens when a path is opened?
The file system resolves each directory component, checks access, locates the file metadata and installs open state for the process. The returned descriptor refers to that kernel state; it is not a copy of the file content.
Assessment move
Trace a path from directory entries to metadata and then to data blocks. Compare allocation methods using the same workload so the decision is evidence based. Practise file-size calculations with ceiling, allocated bytes and internal waste. For a lab, create, rename and inspect a file, then explain which namespace information changed and which object remained.
Add a link experiment only if you can distinguish another name from a separate copy. Build path-resolution drills with absolute and relative paths, including a missing intermediate directory and a denied search permission. For each component, say which directory is consulted and which metadata object is reached.
Then separate three kinds of state: the visible name, the underlying file identity and the process’s open descriptor with its offset. Use rename, unlink and another open reference to test which state changes and which can survive. When comparing allocation, hold the workload constant and score contiguous, linked and indexed layouts on growth, direct lookup, sequential access, metadata overhead and damage from a lost pointer.
Note when a hybrid extent design changes the textbook trade-off. For size calculations, vary the file by one byte around an exact block boundary and recompute block count, allocated space and internal waste; the discontinuity makes the ceiling rule memorable. During lab preparation, predict metadata fields before and after create, write, rename and link operations.
Record the observation, then explain it through namespace and object relationships. If a command output surprises you, do not infer that data was copied until you have checked identity, link count and content separately.
Working through Files, Directories and Storage in FIT2100? Sia is AskSia’s AI Computer Science tutor — ask any FIT2100 Files, Directories and Storage question and get a clear, step-by-step explanation grounded in how FIT2100 is taught and assessed. Read this chapter free, then take your hardest questions to Sia.