What is a file?
File attributes
File Systems:
Fundamentals
File operations
File
Directory
Directories
Disk
Files
Map file names to inode numbers
Contain data and have metadata like creation time, length, etc.
Data
The contents that users actually care about
Metadata
Data blocks.
2.
Large
Small
Contiguous allocation
Linked allocation
!
I
!
!
Pluses
Minuses
Fragmentation!
Problems with file growth
Pre-allocation?
On-demand allocation?
Minuses
Impossible to do true
random access
Reliability
10
Solution approaches
11
12
Direct allocation
Indexed allocation
Indexed Allocation
Handling large files
IB
I
!
Pluses
Minuses
Create a non-data block for each file called the index block
Pluses
Minuses
IB
IB
IB
Inode
1st Level
Indirection
Block
10 Data Blocks
n
Data
Blocks
Implications
Upper limit on file size (~2 TB)
Blocks are allocated dynamically (allocate indirect blocks only for
large files)
15
IB
14
13
IB
IB
IB
IB
2 Level
Indirection
Block
Features
Simple
Files can easily expand
Small files are cheap
IB
Cons
IB
IB
Pros
3rd Level
Indirection
Block
IB
16
17
n2
Data
Blocks
IB
nd
IB
IB
n3
Data
Blocks
IB
IB
IB
IB
18
A. 1 byte
B. 16 bytes
C. 128 bytes
D. 1 KB
E. 16 KB
Need an inode
20
!
!
!
Directory operations:
List contents of a directory
Search (find a file)
21
Linear search
Binary search
Hash table
Create a file
Delete a file
22
23
24
!
!
C is a file
B/ is a directory that contains the I-number for file C
A/ is a directory that contains the I-number for file B
How do you find I-number for A?
Directory traversal:
Once you have the file header, you can access all blocks within
a file
In early Unix:
Optimization:
Ext2 (linux):
25
26
A. True
B. False
Grouped lists
D
G
Next
group
block
Allocated block
28
Empty block
29
27