160 likes | 313 Views
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. THE FILE SYSTEM.
E N D
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.
THE FILE SYSTEM UNIX 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.
Disk Architecture Sector Platter Track Arm Read/write head Block: 4kb
Interleaving 1:1 interleave 8 1 16 9 2 7 15 10 14 11 6 3 13 12 5 4 Delay, interleave factor, between each block due to the overhead of the communication between the disk controller and the device driver
Interleaving 1:3 interleave 6 1 14 9 3 4 12 11 15 16 8 7 13 10 5 2
Storing a File First 4K 8 1 16 9 Second 4K 2 7 15 10 Last 1K 14 11 6 3 13 12 5 4
Inodes—Index node To 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
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
Every file has an inode Inode Block map 0 7 1 2 8 2 14 1 3 16 9 2 7 15 10 14 11 6 3 13 12 5 4
The Block Map Inode 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. Inode Direct block pointers Indirect pointer Disk blocks
Inode Direct block pointers Indirect pointer Disk blocks Double indirect pointer
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.
File System Layout Logical disk layout Boot block Super block Inode 1…40 Inode 41..80 Physical disk layout User block User block User block
The Superblock It 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 Bitmap Disk blocks Free 1 0 1 1 0 1 Used Free Free Used Free
Directories Inode number 2 contains the location of the block possessing the root directory. (inode number 1 for bad blocks) label Inode # /2 . 2 .. 2 bin 3 usr 4 usr4 bin3 Hard Link Test.c6 ls5 cp7
Mounting File Systems The mount utility allows a superuser to splice the root directory of a file system into the existing directory hierarchy. $ mount /dev/flp /mnt $ unmount /dev/flp or $unmount /mnt / / / mnt usr bin usr tmp2 bin mnt tmp1 tmp1 tmp2