File System: CIT 595 Spring 2008
File System: CIT 595 Spring 2008
CIT 595 2
OS maintains info on which blocks belong to a file Disk can be prepared for use, or even dedicated to different uses
Allows one to apply OS-specific logical formatting per partition
Data structures use logical block numbers
Allow more than one OS per partition
¾ Starting at 0 and running through consecutive integers up
to some maximum Encapsulate your data
Corruption is local to a partition, so stand to lose only some of your
data if an accident occurs
Logicalblock number is converted into physical disk
address Also improve disk efficiency
E.g. Windows depending on the File System, assigns block sizes
i.e. Physical Disk Address -> track/cylinder, surface, sector based on partition size
Conversion is performed by the device driver which outputs ¾ Larger disk size implies larger block size that can result in wasted
space
low-level hardware specific instructions to disk controller
1
Disk Layout Boot Block
Master Boot Block (MBR) Upon boot, the BIOS (Basic Input/Output System)
A known sector on disk is used to boot the computer
program is executed
Partition Table Is stored in ROM that gets executed on startup
Starting and Ending Addressing of each partition Conducts a basic hardware check, to determine whether all of
One of the partitions is marked as active the attachments are present and working
Disk Partitions Then executes program located in the MBR
Boot Block
¾ Contains a program where the OS resides in the partition
MBR program locates active partition, reads in its first
¾ Even if no OS for that partition, a boot block is set aside
block i.e. boot block and execute it
Partition Control Block
¾ Magic number to denote what kind of file system e.g. FAT, NTFS,
UFS Boot block loads the OS and then the OS takes over
¾ Number of Blocks and the size of blocks
Data Structure for Free Blocks, Directory, File Allocation Info, and the
files itself
2
Contiguous Allocation Contiguous Allocation (contd..)
3
File Allocation Table (FAT) FAT (contd..)
One implementation of Linked Random Access is possible
Allocation scheme
Pointers to data blocks are Does not solve the seek problem
stored in FAT Considerable arm movement to read the FAT and actual file
blocks
FAT is an array – one entry for
each disk block Seek time can be minimized by caching the FAT
Indexed by the block number Store in main memory
Each array entry is a pointer to EOF No disk I/O needed for FAT lookup – only block requests are
the next block sent to disk
4
File Index File Index (contd..)
If the number of blocks need cannot fit in one index
block, then apply levels of indirection
Directory
File Index
CIT595doc 17
Free-Space Management
A free-space list is maintained that records all free
blocks
Linked-list Technique
Just like linked allocation – Pointer to first free block is
maintained in fixed location on disk
Or can be accounted in part of the allocation data structure
¾ E.g. in FAT, block entries that not occupied have special
symbol written in them
Grouping Technique
Store the address of n free blocks in the first free block
n – 1 entries are actually free and the last block contains a the
address of the next n free blocks
CIT 595 19