File System Implementation
File System Implementation
File-System Structure
File-System Implementation
Directory Implementation
Allocation Methods
Free-Space Management
File-System Structure
File Systems provide efficient and convenient access to the disk by allowing
A file system poses two quite different design problems. The first problem is
defining how the file system should look to the user.
This task involves defining a file and its attributes, the operations allowed on a file,
and the directory structure for organizing files.
The second problem is creating algorithms and data structures to map the
Each level in the design uses the features of lower levels to create new features for
use by higher levels.
The lowest level, the I/O control, consists of device drivers and interrupt handlers to
transfer information between the main memory and the disk system.
Layered File System
File System Implementation
Several On Disk and In Memory Structures are used.
In-memory structures
Update the directory with the new file name and FCB
and writes back to disk.
In Memory Structures –Open an Existing file
The call first searches the system-wide open – file table to see if the file is
already in use by another process.
If the file is not alreay open,the directory structure is searched for the given
file name.
Parts of the directory structure are cached in memory.
Once the file is found, The FCB is copied into an entry in the system-wide
open file table in memory.
The following figure illustrates the necessary file system structures
provided by the operating systems.
Disk space should be allocated so that disk space is utilized effectively and
Contiguous allocation
Linked allocation
Indexed allocation
Contiguous Allocation of Disk Space
Each file occupies a set of contiguous blocks on the disk
Random access
External Fragmentation
block = pointer
Linked Allocation (Cont.)
Solves all problems of contiguous allocation.
Directory entry has a pointer to the first and last blocks of the file
Advantages:
Simple – need only starting address
No External Fragmentation
Size of a file need not be declared when the file is created
Files can continue to grow as long as free blocks are availble
Compaction not needed.
Linked Allocation
Dis advantages
No random access(Only sequential access)
Space required for pointers
(Each and every disk block has a pointer to the next disk block)
If pointers are lost or damaged?
Logical view.
index table
Example of Indexed Allocation
Indexed Allocation (Cont.)
I th entry in the index block points to the ith block of the file.
Random access
Dis advantages
Suffers from wasted space
More pointer overhead.
outer-index
0 block[i] free
bit[i] =
1 block[i] occupied
1101101101111111111111011
Free-Space Management (Cont.)
Advantages
Simple
Efficient in finding the first free block, m consecutive free blocks
Dis Advantages
Requires extra space and is kept in main memory
Block size = 212 bytes
Disk size = 230 bytes
Number of blocks = 230 / 212 = 218
Keep a pointer to the first free block on the disk and cache it in memory
No waste of space
Keep the address of the first free block and the number n of free
contiguous blocks that follow the first block