Advanced UNIX CIS 218 Advanced UNIX Director ies again CIS 218 - - PowerPoint PPT Presentation

advanced unix
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

CIS 218 Advanced UNIX 1

Advanced UNIX

CIS 218 Advanced UNIX

Directories again …

slide-2
SLIDE 2

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

slide-3
SLIDE 3

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”

slide-4
SLIDE 4

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

slide-5
SLIDE 5

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 : :

slide-6
SLIDE 6

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

slide-7
SLIDE 7

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

slide-8
SLIDE 8

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

slide-9
SLIDE 9

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”

slide-10
SLIDE 10

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

slide-11
SLIDE 11

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

slide-12
SLIDE 12

CIS 218 Advanced UNIX 12

 “.” and “..” entries are added automatically

 mode must include execute permissions so

the user(s) can use cd.

e.g. 0755