Lecture 12-File Systems Flashcards
What are the Objectives of File System?
Allow creation and deletion of files
Allow access to files by symbolic names
Allow the sharing of files where required, but protect files against unauthorised access
Perform automatic management of secondary storage, allocating files to physical blocks
Protect files against system failure
Concept of File?
The concept of a file is of a uniform logical view of information storage.
A file is a named collection of related information that is recorded on secondary storage.
It allows data to be stored between processes
It allows us to store large volumes of data
It allows multiple processes to access the data concurrently
What is File Structure and Access?
File structure: A file can be stored as
A sequence of bytes. It is up to the program that accesses the file to interpret the byte sequence
A sequence of fixed-length structured records
A tree of variable length records. Each has a key field to be used for record retrieval
File access
Sequential access: good for magnetic tapes
Random access: good for disks
What are the 3 Directory Structures?
One-level system: one root directory contains all files
Two-level system: giving each user a private directory
Hierarchical system: a tree of directories
What is the File System Layout?
A disk is divided into partitions/volumes, each holds an
independent file system
Section 0 is the Master Boot Record (MBR), used to boot the computer via boot block, which may contain the OS
The super block contains the info about the file system
What is Contiguous Allocation?
Disks are split into blocks of a fixed size, e.g., 1KB
Files are stored in blocks in several ways
Contiguous allocation assigns contiguous blocks to a file
Contiguous Allocation Advantages and Disadvantages?
Advantages
Simple to implement: needs to store the first block address and its length
The performance of such an implementation is good.
The read/write heads have to move very little, if at all
Resilient to disk faults: damage to a single block results in only localised loss of data
Allows easy random access.
Disadvantages
Need to “guess” the size of the file when it is first created
Fragmentation: as files are deleted, holes appear; can be overcome by compaction, but this is expensive
What is Linked List Allocation?
Store a file as a linked list of blocks
Need only to store the first block address in the file descriptor
Each block contains data and a pointer to the next block. The final block contains a null pointer
What are the Advantages and Disadvantages of Linked List Allocation?
Advantages
Every block can be used
No space is lost due to disk fragmentation, except for internal fragmentation in the last block
The file size does not have to be known beforehand.
Disadvantages
Random access is very slow
Space is lost within each block due to the pointer.
Reliability could be a problem—can be alleviated by adding reverse links
What is Linked List with File Allocation Table?
Store the pointers in a file allocation table (FAT) in memory
The pointer in a file descriptor points to the location in the FAT representing its first block
What are the advantafes and disadvanatges of Linked List with File Allocation Table?
Advantages
Does not waste space in the block
Random access is much easier as FAT is in memory
Disadvantages
FAT may be too large to hold in main memory, so has to be held on secondary storage
May require several disk accesses to read all relevant FAT entries
Damage to FAT can cause serious data loss. The solution: store several FAT copies in different areas of the disk
What is I-Nodes in UNIX?
Each file has an i-node (index-node) listing all the attributes for the file
The i-node also contains a number of direct pointers to disk blocks. Typically there are ten direct pointers
In addition, there are three indirect pointers. These pointers point to further data structures which eventually lead to a disk block address
The first of these pointers is a single level of indirection, the next pointer is a double indirect pointer and the third is a triple indirect pointer
What is the implementation of directories?
MS-DOS: a directory entry is 32 bytes long
UNIX: a directory entry has an i-node no. and filename
All its attributes are stored in the i-node
All i-nodes have a fixed location on the disk, so locating an i-node is simple and fast