Course list: http://www.c-jump.com/bcc/

File System Data Structures


  1. MBR Data Structure
  2. DOS Partition Entry Data Structure inside MBR
  3. DOS Partition Types
  4. File Systems and Related Data Structures
  5. FAT Boot Sector, bytes 0-35 (FAT12/16 and FAT32)
  6. FAT Boot Sector, remaining bytes (FAT12/16)
  7. FAT Boot Sector, remaining bytes (FAT32)
  8. FAT Boot Sector Interpretation Example
  9. FAT Root Directory Entry Format
  10. FAT Directory Entry Format
  11. FAT File and Directory Attributes
  12. FAT Long File Name (LFN) Directory Entries
  13. Hexadecimal Notation
  14. Hexadecimal to ASCII Conversion

MBR Data Structure

Byte Range Description Essential
0-445 Boot Code No
446-461 Partition Table Entry #1 Yes
462-477 Partition Table Entry #2 Yes
478-493 Partition Table Entry #3 Yes
494-509 Partition Table Entry #4 Yes
510-511 Signature value (0xAA55) Yes

DOS Partition Entry Data Structure inside MBR

Byte Range Description Essential
0-0 Bootable Flag No
1-3 Starting CHS Address Yes
4-4 Partition Type Yes
5-7 Ending CHS Address Yes
8-11 Starting LBA Address Yes
12-15 Size in Sectors Yes

DOS Partition Types

Type Description
0x00 Empty
0x01 FAT12, CHS
0x04 FAT16, 16-32 MB, CHS
0x05 Microsoft Extended, CHS
0x06 FAT16, 32 MB-2 GB, CHS
0x07 NTFS
0x0b FAT32, CHS
0x0c FAT32, LBA
0x0e FAT16, 32 MB-2 GB, LBA
0x0f Microsoft Extended, LBA
0x11 Hidden FAT12, CHS
0x14 Hidden FAT16, 16-32 MB, CHS
0x16 Hidden FAT16, 32 MB-2 GB, CHS
0x1b Hidden FAT32, CHS
0x1c Hidden FAT32, LBA
0x1e Hidden FAT16, 32 MB-2 GB, LBA
0x42 Microsoft MBR. Dynamic Disk
0x82 Solaris x86
0x82 Linux Swap
0x83 Linux
0x84 Hibernation
0x85 Linux Extended
0x86 NTFS Volume Set
0x87 NTFS Volume Set
0xa0 Hibernation
0xa1 Hibernation
0xa5 FreeBSD
0xa6 OpenBSD
0xa8 Mac OSX
0xa9 NetBSD
0xab Mac OSX Boot
0xb7 BSDI
0xb8 BSDI swap
0xee EFI GPT Disk
0xef EFI System Partition
0xfb Vmware File System
0xfc Vmware swap

File Systems and Related Data Structures

File System Data Structs Content Metadata File Name Application
ExtX Superblock, group descriptor Blocks, block bitmap Inodes, inode bitmap, extended attributes Directory entries Journal
FAT Boot sector, FSINFO Clusters, FAT Directory entries, FAT Directory entries N/A
NTFS $Boot, $Volume, $AttrDef Clusters, $Bitmap $MFT, $MFTMirr, $STANDARD_ INFORMATION, $DATA, $ATTRIBUTE_LIST, $SECURITY_DESCRIPTOR $FILE_NAME, $IDX_ROOT, $IDX_ALLOCATION, $BITMAP Disk Quota, Journal, Change Journal
UFS Superblock, group descriptor Blocks, fragments, block bitmap, fragment bitmap Inodes, inode bitmap, extended attributes Directory entries N/A

FAT Boot Sector, bytes 0-35 (FAT12/16 and FAT32)

FAT Boot Sector, remaining bytes (FAT12/16)

FAT Boot Sector, remaining bytes (FAT32)

Byte Range Description Essential
0-35 See above. Yes
36-39 32-bit size in sectors of one FAT. Yes
40-41 Defines how multiple FAT structures are written to. If bit 7 is 1, only one of the FAT structures is active and its index is described in bits 0-3. Otherwise, all FAT structures are mirrors of each other. Yes
42-43 The major and minor version number. Yes
44-47 Cluster where root directory can be found. Yes
48-49 Sector where FSINFO structure can be found. No
50-51 Sector where backup copy of boot sector is located (default is 6). No
52-63 Reserved. No
64-64 BIOS INT13h drive number. No
65-65 Not used. No
66-66 Extended boot signature to identify if the next three values are valid. The signature is 0x29. No
67-70 Volume serial number, which some versions of Windows will calculate based on the creation date and time. No
71-81 Volume label in ASCII. The user chooses this value when creating the file system. No
82-89 File system type label in ASCII. Standard values include "FAT32," but nothing is required. No
90-509 Not used. No
510-511 Signature value (0xAA55). No

FAT Boot Sector Interpretation Example


FAT Root Directory Entry Format

FAT Directory Entry Format

Byte Range Description Essential
0-0 First character of file name in ASCII and allocation status (0xe5 or 0x00 if unallocated) Yes
1-10 Characters 2 to 11 of file name in ASCII Yes
11-11 File Attributes (see below) Yes
12-12 Reserved No
13-13 Created time (tenths of second) No
14-15 Created time (hours, minutes, seconds) No
16-17 Created day No
18-19 Accessed day No
20-21 High 2 bytes of first cluster address (0 for FAT12 and FAT16) Yes
22-23 Written time (hours, minutes, seconds) No
24-25 Written day No
26-27 Low 2 bytes of first cluster address Yes
28-31 Size of file (0 for directories) Yes

FAT File and Directory Attributes

Flag Value (in bits) Description Essential
0000 0001 (0x01) Read only No
0000 0010 (0x02) Hidden file No
0000 0100 (0x04) System file No
0000 1000 (0x08) Volume label Yes
0000 1111 (0x0f) Long file name Yes
0001 0000 (0x10) Directory Yes
0010 0000 (0x20) Archive No

FAT Long File Name (LFN) Directory Entries

Byte Range Description Essential
0-0 Sequence number (ORed with 0x40) and allocation status (0xe5 if unallocated) Yes
1-10 File name characters 1-5 (Unicode) Yes
11-11 File attributes (0x0f) Yes
12-12 Reserved No
13-13 Checksum Yes
14-25 File name characters 6-11 (Unicode) Yes
26-27 Reserved No
28-31 File name characters 12-13 (Unicode) Yes

Hexadecimal Notation


  • Simplifies notation of bit patterns.

  • Much better alternative, compared to binary number notation.

  • Simplifies notation of long binary strings, such as entire blocks of computer memory.

  • Hexadecimal notation is used mainly for human convinience.

  • Hexadecimal notation represents numbers
    of base 16, calculated as

    • h3*163 + h2*162 + h1*161 + h0*160

    where h3, h2, h1, and h0 are values from the Hexadecimal column of the table.

  •  

    Decimal Hexadecimal Octal Binary
    0
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    0
    1
    2
    3
    4
    5
    6
    7
    8
    9
    A
    B
    C
    D
    E
    F
    000
    001
    002
    003
    004
    005
    006
    007
    010
    011
    012
    013
    014
    015
    016
    017
    0000
    0001
    0010
    0011
    0100
    0101
    0110
    0111
    1000
    1001
    1010
    1011
    1100
    1101
    1110
    1111

Hexadecimal to ASCII Conversion

00 - NULL 10 - DLE 20 - SPC 30 - 0 40 - @ 50 - P 60 - ` 70 - p
01 - SOH 11 - DC1 21 - ! 31 - 1 41 - A 51 - Q 61 - a 71 - q
02 - STX 12 - DC2 22 - " 32 - 2 42 - B 52 - R 62 - b 72 - r
03 - ETX 13 - DC3 23 - # 33 - 3 43 - C 53 - S 63 - c 73 - s
04 - EOT 14 - DC4 24 - $ 34 - 4 44 - D 54 - T 64 - d 74 - t
05 - ENQ 15 - NAK 25 - % 35 - 5 45 - E 55 - U 65 - e 75 - u
06 - ACK 16 - SYN 26 - & 36 - 6 46 - F 56 - V 66 - f 76 - v
07 - BEL 17 - ETB 27 - ' 37 - 7 47 - G 57 - W 67 - g 77 - w
08 - BS 18 - CAN 28 - ( 38 - 8 48 - H 58 - X 68 - h 78 - x
09 - TAB 19 - EM 29 - ) 39 - 9 49 - I 59 - Y 69 - i 79 - y
0A - LF 1A - SUB 2A - * 3A - ; 4A - J 5A - Z 6A - j 7A - z
0B - BT 1B - ESC 2B - + 3B - ; 4B - K 5B - [ 6B - k 7B - {
0C - FF 1C - FS 2C - , 3C - < 4C - L 5C - \ 6C - l 7C - |
0D - CR 1D - GS 2D - - 3D - = 4D - M 5D - ] 6D - m 7D - }
0E - SO 1E - RS 2E - . 3E - > 4E - N 5E - ^ 6E - n 7E - ~
0F - SI 1F - US 2F - / 3F - ? 4F - O 5F - _ 6F - o 7F -