the file system files -------- long-term storage ram --------- short-term storage programs, data,...

16
THE FILE SYSTEM Files -------- long-term storage RAM --------- short-term storage Programs, data, and text are all stored in files, which is stored on hard disk and other media, such as tape and floppy disk.

Upload: kevin-oconnor

Post on 06-Jan-2018

221 views

Category:

Documents


1 download

DESCRIPTION

Disk Architecture Sector Track Platter Arm Block: 4kb Read/write head

TRANSCRIPT

Page 1: THE FILE SYSTEM Files -------- long-term storage RAM --------- short-term storage Programs, data, and text are all stored in files, which is stored on

THE FILE SYSTEM

Files -------- long-term storageRAM --------- short-term storage

Programs, data, and text are all stored in files, which is stored on hard disk and other media, such as tape and floppy disk.

Page 2: THE FILE SYSTEM Files -------- long-term storage RAM --------- short-term storage Programs, data, and text are all stored in files, which is stored on

THE FILE SYSTEMUNIX files are organized by a hierarchy of labels ---- directory structure

Three kinds:+ Regular files, containing a sequence of bytes that generally corresponds to code or data. Referenced via the standard I/O system calls.+ Directory files, a special format and forming the backbone of the file system. Referenced only via directory-specific system calls.+ Special files, correspond to peripherals such as printers and disks, and interprocess communication mechanisms, such as pipes and sockets. Referenced via the standard I/O system calls.

Page 3: THE FILE SYSTEM Files -------- long-term storage RAM --------- short-term storage Programs, data, and text are all stored in files, which is stored on

Disk ArchitectureSector

Track

Platter

Arm

Block: 4kb

Read/write head

Page 4: THE FILE SYSTEM Files -------- long-term storage RAM --------- short-term storage Programs, data, and text are all stored in files, which is stored on

Interleaving1:1 interleave

1

2

3

45

6

7

89

10

11

1213

14

15

16

Delay, interleave factor, between each block due to the overhead of the communication between the disk controller and the device driver

Page 5: THE FILE SYSTEM Files -------- long-term storage RAM --------- short-term storage Programs, data, and text are all stored in files, which is stored on

Interleaving1:3 interleave

1

2

3 4

5

6

78

9

10

11 12

13

14

1516

Page 6: THE FILE SYSTEM Files -------- long-term storage RAM --------- short-term storage Programs, data, and text are all stored in files, which is stored on

Storing a File

1

2

3

45

6

7

89

10

11

121314

15

16

First 4K

Second 4K

Last 1K

Page 7: THE FILE SYSTEM Files -------- long-term storage RAM --------- short-term storage Programs, data, and text are all stored in files, which is stored on

Inodes—Index nodeTo store information about each file+ the type of the file: regular, directory, block special, character special, etc.+ file permissions+ the owner and group IDs+ a hard link count+ the last modification time and last access time+ the location of the blocks if the file is a regular or directory file+ the major and minor device numbers if the file is a special file+ the value of the symbolic link if the file is a symbolic link

In other words, it contains all of the information when you perform an “ls -l”, except for the filename

Page 8: THE FILE SYSTEM Files -------- long-term storage RAM --------- short-term storage Programs, data, and text are all stored in files, which is stored on

Inodes—Index node

Every inode in a particular file system is allocated a unique inode number.

Every file has exactly one inode.

All the inodes associated with the files on a disk are stored in a special area at the start of the disk called the inode list

Page 9: THE FILE SYSTEM Files -------- long-term storage RAM --------- short-term storage Programs, data, and text are all stored in files, which is stored on

Every file has an inode

1

2

3

45

6

7

89

10

11

121314

15

16

Block mapInode

0123

72

14

Page 10: THE FILE SYSTEM Files -------- long-term storage RAM --------- short-term storage Programs, data, and text are all stored in files, which is stored on

The Block MapInode only stores the first 10 blocks of a file. (most UNIX files are less than 40K)

An indirect access scheme is used for addressing larger files.

Direct block pointers

Indirect pointer

Disk blocks

Inode

Page 11: THE FILE SYSTEM Files -------- long-term storage RAM --------- short-term storage Programs, data, and text are all stored in files, which is stored on

Direct block pointers

Indirect pointer

Disk blocks

Inode

Double indirect pointer

Page 12: THE FILE SYSTEM Files -------- long-term storage RAM --------- short-term storage Programs, data, and text are all stored in files, which is stored on

File System Layout

boot block: first logical block of a disk, containing some executable code that is used when UNIX is first activated.

super block: second logical block of a disk, containing information concerning the disk itself.

inode list: following fixed-size set of blocks, holding all of the inodes associated with the files on the disk.

Page 13: THE FILE SYSTEM Files -------- long-term storage RAM --------- short-term storage Programs, data, and text are all stored in files, which is stored on

File System Layout

Boot block

Super block

Inode 1…40

Inode 41..80

User block

User block

User block

Logical disk layout

Physical disk layout

Page 14: THE FILE SYSTEM Files -------- long-term storage RAM --------- short-term storage Programs, data, and text are all stored in files, which is stored on

The SuperblockIt contains information pertaining to the entire file system.

+ the total number of blocks in the file system+ the number of inodes in the inode free list+ the size of a block in bytes+ the number of free blocks+ the number of used blocks

Free

Used

Free

Free

Used

Free

Disk blocks

1 0 1 1 0 1

Bitmap

Page 15: THE FILE SYSTEM Files -------- long-term storage RAM --------- short-term storage Programs, data, and text are all stored in files, which is stored on

DirectoriesInode number 2 contains the location of the block possessing the root directory. (inode number 1 for bad blocks)

/2

bin3

ls5 cp7

usr4

Test.c6

. 2

.. 2

bin 3

usr 4

label Inode #

Hard Link

Page 16: THE FILE SYSTEM Files -------- long-term storage RAM --------- short-term storage Programs, data, and text are all stored in files, which is stored on

Mounting File SystemsThe mount utility allows a superuser to splice the root directory of a file system into the existing directory hierarchy.

/

bin usrmnt

/

tmp1 tmp2

/

bin usrmnt

tmp1 tmp2

$ mount /dev/flp /mnt

$ unmount /dev/flp or $unmount /mnt