Core · Module 5 · Lesson 8 of 12
Directory Streams, Hard Links, and Symlinks
Traverse filesystem hierarchies with opendir and readdir, manipulate hard links and symlinks, and manage inode reference lifecycles.
Pro — members onlyAbout 16 minutes
By the end you can
- Traverse directory streams sequentially using opendir, readdir, and closedir
- Differentiate hard links sharing an inode from symbolic links storing target path strings
- Explain deferred file deallocation when unlinking files held open by running processes
- Handle null-termination requirements when inspecting symlink targets with readlink
01 · A question first
Why does deleting a 50-gigabyte log file with unlink() or rm fail to free any disk space if a background service still has the file open? And why does POSIX strictly forbid creating hard links to directories?
Make a guess before you read on.
02 · The idea
Members only
Unlock the full lesson
This lesson is part of the membership. Join to read it in full, along with every other premium deep dive.
What's inside
- Start with the problem
- How the idea works
- Why it is correct
- What it costs
- Pitfalls and variations
- Where it is used
03 · Practice
Asked in interviews
Something wrong with this lesson? Report a problem