16.05.2015 Views

Working with the Unix OS

Working with the Unix OS

Working with the Unix OS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Introduction to kernel<br />

File System<br />

regular files - contain data – standard I/O system calls<br />

directory files - backbone of fs – directory system calls<br />

special files - peripherals – standard I/O system calls<br />

! Disk architecture<br />

cylinders<br />

tracks<br />

sectors<br />

blocks 4K bytes<br />

! Interleaving<br />

1:1 interleave - logically contiguous blocks<br />

3:1 interleave - e.g. 8 sectors, blocks 1 4 7 2 5 8 3 6<br />

! Fragmentation<br />

loss of storage due to under-use of last block<br />

! Scattered<br />

file blocks are rarely contiguous<br />

! Block I/O<br />

To read <strong>the</strong> first byte of data from a file, using <strong>the</strong> read system call, <strong>the</strong> device driver issues an I/O request to <strong>the</strong><br />

disk controller to read <strong>the</strong> first 4K block into a kernel buffer, <strong>the</strong>n copies <strong>the</strong> first byte to your process.<br />

! Inodes<br />

Index Node to store information about each file.<br />

The Inode of regular or directory file contains <strong>the</strong> location or its disk blocks, <strong>the</strong> inode of special file contains<br />

peripheral device information.<br />

type of file<br />

file permissions<br />

user and group ids<br />

hard link count<br />

last modified, last accesses times<br />

location of blocks or major and minor numbers<br />

symbolic link<br />

! Block Map<br />

Only <strong>the</strong> first 10 blocks of a file are stored directly in <strong>the</strong> inode. Larger files use indirect addressing schemes.<br />

File System Layout<br />

The first logical block of disk is <strong>the</strong> "boot block". The second logical block is <strong>the</strong> superblock, contains information<br />

about disk. Followed by <strong>the</strong> inode list, each block holding about 40 inodes. The remaining blocks store directory<br />

and user files.<br />

Superblock<br />

- Total number of blocks in file system<br />

- Number of inodes in inode free list<br />

- Free block bitmap - linear sequence of bits, one per disk block, 1 indicates it is free<br />

- Size of block in bytes<br />

- Number of free blocks<br />

- Number of used blocks<br />

! Bad blocks<br />

mkfs - location of all bad blocks on disk<br />

inode number 1<br />

90

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!