Monash University · FACULTY OF COMPUTER SCIENCE

FIT2100 Chap.4 Files, Directories and Storage

- one subject, every graph, every model, every mark
8 Chapters4-page Bible
Our own words - no uploaded lecturer files
Updated for this semester
Chapter 4 of 12 · FIT2100

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.

In this chapter

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

Q [6 marks]. A file contains 10,500 bytes and the file system allocates 4,096-byte blocks. Find the required block count, allocated space and unused space. The weighting shown here is not an official university mark allocation.
Name to storage.Name to storage. Path resolution walks directory entries to metadata, which identifies the blocks containing persistent file data. path namedirectoryi-nodedata blockson storage persistent block sequence
Name to storage. Path resolution walks directory entries to metadata, which identifies the blocks containing persistent file data.
  • +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.
The file requires 3 blocks, occupies 12,288 allocated bytes and leaves 1,788 bytes unused in the final allocation. Rounding the block count down would omit part of the file.
Sia tip — Apply the ceiling before multiplying. A partially filled final block still consumes the entire allocation unit.
Glossary

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.
FAQ

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.

Study strategy

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.

A+Everything unlocked
Unlocks this Bible + all 167 of your Monash University subjects - and 1,000+ Bibles across every Australian university.
Sia - your FIT2100 tutor, unlimited, worked the way the exam marks it
The full 4-page Bible + practice bank with worked solutions
Chrome extension - sync your LMS so Sia knows your deadlines
Bilingual EN / Chinese on every Bible and every Sia answer
$0.99 Trial
30-day money-back · cancel in one tap · how it works