CIS 218 Advanced UNIX 1
Advanced UNIX CIS 218 Advanced UNIX Director ies again CIS 218 - - PowerPoint PPT Presentation
Advanced UNIX CIS 218 Advanced UNIX Director ies again CIS 218 - - PowerPoint PPT Presentation
Advanced UNIX CIS 218 Advanced UNIX Director ies again CIS 218 Advanced UNIX 1 Directory Implementation The starting (root) directory of each filesystem is created by formatting . A UNIX directory is a file : it has an owner, group
CIS 218 Advanced UNIX 2
Directory Implementation
The starting (root) directory of each
filesystem is created by formatting .
A UNIX directory is a file:
– it has an owner, group owner, size, access permissions, etc. – many file operations can be used on directories
Differences:
– A directory is a special system file – UNIXs have special directory operations e.g. mkdir, rmdir
CIS 218 Advanced UNIX 3
Structure
A directory ‘file’ is a sequence of lines; each
line holds an i-node number and a file name.
First directory (root) in each file system is
automatically created when filesystem is formatted.
The data is stored as binary, so we cannot
simply use cat to view it
– some older UNIXs allow: $ od -c dir-name : :
120 207 135 “fred.html” “abc” “bookmark.c”
CIS 218 Advanced UNIX 4
UNIX Memory Structure
partition partition partition disk drive file system
super block boot block
I-list Data blocks for files, dirs, etc.
. . . . . . . . .
i-node i-node i-node i-node
CIS 218 Advanced UNIX 5
File System in More Detail
data dir blk i-list data data dir blk Data Blocks i-node i-node i-node filename i-node number no : : filename no : :
CIS 218 Advanced UNIX 6
Boot block: a hardware specific program
that is called automatically to load UNIX at system startup time.
Super block -- it contains two lists:
– a chain of free data block numbers – a chain of free i-node numbers
CIS 218 Advanced UNIX 7
“Soft” ln and unlinking
Meaning of: ln –s (“abc”, “xyz”)
Create directory xyz point to abc
(indirect pointer)
rm linkname clears the directory record
– usually means that the i-node number is set to 0 – the file may not be affected
The i-node is only deleted when the last link
to it is removed; the data block for the file is also deleted (reclaimed).
: :
continued
CIS 218 Advanced UNIX 8
Meaning of: ln (“abc”, “xyz”)
Create directory xyz point to same
inode as abc (direct pointer)
rm linkname clears the directory record
– the file not be affected as long as other directory entries remain
The i-node is only deleted when the last link
to it is removed; the data block for the file is also deleted (reclaimed).
“Hard” ln and unlinking
CIS 218 Advanced UNIX 9
Subdirectory Creation
mkdir foo causes:
– the creation of a foo directory file and an i- node for it – an i-node number and name are added to the parent directory file : :
120 207 135 “fred.html” “abc” “bookmark.c” 201 “foo”
CIS 218 Advanced UNIX 10
- 5. “.” and “..”
“.” and “..” are stored as ordinary file names
with i-node numbers pointing to the correct directory files.
Example: ben book memos continued
CIS 218 Advanced UNIX 11
In detail:
123 247 260 “.” “..” “book” 401 “memos” Directory ben 260 123 56 6 “.” “..” “chap1” 567 “chap2” Directory book “chap3” 590 401 123 80 “.” “..” “kh” 81 00 77 “kd” Directory memos “mw” 590
CIS 218 Advanced UNIX 12
“.” and “..” entries are added automatically
mode must include execute permissions so