operating-systems file-management
Definition
File Directory
A directory (or folder) is a special system file containing mappings that translate user-defined file names into references to physical data.
Structure
Flat List
A single list of entries for the entire partition. Found in early or simple operating systems.
Hierarchical Tree
Nested structure where directories contain files and sub-directories. Standard for modern operating systems.
Pathnames
Absolute Pathname
Specifies location from the root directory (e.g.,
/home/user/notes.txtin Unix,C:\Users\User\notes.txtin Windows).
Relative Pathname
Locates a file relative to the Current Working Directory (CWD).
.refers to the current directory..refers to the parent directory
Implementation
Attributes in Directory
Directory entry contains file name, all attributes, and physical address (e.g., early Windows/MS-DOS).
Long filenames in Windows 95/98 use “extension” entries marked with attribute byte 0x0F.
Attributes in i-nodes
Directory entry contains only file name and i-node number. Attributes and block pointers stored in the i-node (Unix/Linux standard).
Operations
| Operation | Description |
|---|---|
create / delete | Create or remove a directory |
opendir / closedir | Open or close a directory stream |
readdir | Read the next entry |
rename | Change directory name |
link / unlink | Manage hard links to files |