Directory structures
Five organisations side by side, with a quiz.
Module 4
Session 4.8
Lesson 1 of 2
Directory structures
Five organisations, from one flat list to graphs with links.
| Structure | Same name for two users? | Grouping | Sharing | Main issue |
|---|---|---|---|---|
| Single-level | No | No | Trivial | Naming collisions |
| Two-level | Yes | No | Hard | Isolation between users |
| Tree | Yes | Yes | Via paths only | No shared subdirectories |
| Acyclic graph | Yes | Yes | Links | Aliases, deletion (reference counts) |
| General graph | Yes | Yes | Any links | Cycles: garbage collection |
Links on Linux
$ echo hello > a.txt
$ ln a.txt hard.txt # hard link: same inode, link count 2
$ ln -s a.txt soft.txt # symbolic link: a small file containing the path
$ ls -li
1311 -rw-r--r-- 2 student student 6 a.txt
1311 -rw-r--r-- 2 student student 6 hard.txt
1312 lrwxrwxrwx 1 student student 5 soft.txt -> a.txt
$ rm a.txt # hard.txt still works; soft.txt now danglesQuick check
Which structure first allows grouping of a user's files into folders?
Subdirectories appear with the tree structure.
After deleting the original, a symbolic link…
It only stores a path name.
Why do general graphs need garbage collection?
A self-referencing directory never reaches count 0.