Ntfs
Ntfs
NTFS
David B. Probert, Ph.D.
Windows Kernel Development
Microsoft Corporation
© Microsoft Corporation 1
Basic Design Points
• Aries Logging
• Meta-data via Cache Manager
• Self describing meta-data
• B-trees for fast index lookup
• Multiple user data streams
© Microsoft Corporation 2
Disk Basics
• Volume exported via device object
• Addressed by byte offset and length
• Enforced on sector boundaries
• NTFS allocation unit - clusters
• Round size down to clusters
© Microsoft Corporation 3
NTFS Knows Files
© Microsoft Corporation 4
Some System Files
• $Bitmap
• $BadClus
• $Boot
• . (root directory)
• $Logfile
• $Volume
© Microsoft Corporation 5
MFT File
• Data is entirely File Records
• File Records are fixed size
• Every file on volume has a File Record
• File records are recycled
• Reserved area for system files
© Microsoft Corporation 6
File Records
© Microsoft Corporation 7
File D:¥Letters (File ID 0x200)
ABCDEFGHIJKLMNOPQRSTUV
File ¥$Mft
100 200 280
200 0 200
JK LM NO ABCDEFGHI PQRST UV
Physical Disk
• Timestamps
• File attributes (DOS + NTFS)
• Filename (+ hard links)
• Data streams
• ACL
• Indexes
© Microsoft Corporation 9
File Building Blocks
• File Records
• Ntfs Attributes
• Allocated clusters
© Microsoft Corporation 10
File Record Header
• USA Header
• Sequence Number
• First Attribute Offset
• First Free Byte and Size
• Base File Record
• IN_USE bit
© Microsoft Corporation 11
NTFS Attributes
• Type code and optional name
• Resident or non-resident
• Header followed by value
• Sorted within file record
• Common code for operations
© Microsoft Corporation 12
MFT File Record
$STANDARD_INFORMATION
(Time Stamps, DOS Attributes)
$FILE_NAME - VeryLongFileName.Txt
$FILE_NAME - VERYLO~1.TXT
• Length
• Form
• Name and name length
• Flags (Compressed, Encrypted, Sparse)
© Microsoft Corporation 14
Resident Attributes
• Data follows attribute header
• ‘Allocation Size’ on 8-byte boundary
• May grow or shrink
• Convert to non-resident
© Microsoft Corporation 15
Non-Resident Attributes
© Microsoft Corporation 16
Some Attribute Types
$STANDARD_INFORMATION
$FILE_NAME
$SECURITY_DESCRIPTOR
$DATA
$INDEX_ROOT
$INDEX_ALLOCATION
$BITMAP
$EA
© Microsoft Corporation 17
Mapping Pairs
© Microsoft Corporation 18
Indexes
• File name and view indexes
• Indexes are B-trees
• Entries stored at each level
• Intermediate nodes have down pointers
• $INDEX_ROOT
• $INDEX_ALLOCATION
• $BITMAP
© Microsoft Corporation 19
Index Implementation
© Microsoft Corporation 20
$INDEX_ROOT
E J R end
ABC GI NPQ Z
$INDEX_ALLOCATION
$BITMAP
0x36 (00110110)
© Microsoft Corporation 21
$ATTRIBUTE_LIST
• Needed for multi-file record file
• Entry for each attribute in file
• Resident or non-resident form
• Must be in base file record
© Microsoft Corporation 22
Attribute List (example)
© Microsoft Corporation 23
Attribute List (example cont.)
© Microsoft Corporation 24
Discussion
© Microsoft Corporation 25