FAT32文件系统格式(for sd)

来源:互联网 发布:java百度离线地图开发 编辑:程序博客网 时间:2024/04/30 20:19

看了两天FAT32文件系统格式(从网上和sdspec),根据自己手中的SD卡对比了一下, 自己略微总结了一下,有不对的请指正。谢谢。

 

 

1 MBR:

 

 MBR格式

Addr

Length

Name

Contents

0-1BD

446

Master boot code

 

1BE-1CD

16

Partition table 1

 

1CE-1DD

16

Partition table 2

0

1DE-1ED

16

Partition table 3

0

1EE-1FD

16

Partition table 4

0

1FE-1FF

2

Signature Word

55 AA

 

Partition table

Offset

Length

Name

Contents

0

1

启动标志 0x00/0x80(启动)

80

1

1

Starting Head

00

2

2

Starting Sector/Starting Cylinder Sector(6 bit)Cyliner(10bit)

01 01

4

1

System ID01(<32680 sectors)04(<65536)06

04

5

1

Ending Head

00

6

2

Ending Sector/Ending Cylinder

0E C5

8

4

MBR开始到这个扇区的相对扇区数

20 00 00 00 = 0x20

12

4

总扇区数

E0 2B 76 00 =0x762BE0

 

Head: 0-255

Cylinder: 0 – 1023

Sector 0-63

 

相对扇区数: 0x20 =32 = 32 * 512 = 0x4000

也就是从0x4000处开始为第一分区

MBR:  sector 0 - 31

 

总扇区数E0 2B 76 00 =0x762BE0 = 3.69G

总的大小0x4000+3.69G=3.7G

2. PBR

 

Offset

Length

Name

Contents

0

3

跳转代码地址

EB 00 90

3

8

OEM名字

MSWIN4.1

11

2

每扇区的字节数

00 02 = 0x200 = 512byte

13

1

每簇的扇区数

0x20 = 32

14

2

保留的扇区数

0x20=32

16

1

FAT表数

02

17

2

根目录表数

0

19

2

总扇区数

00 00

21

1

介质类型

F8

22

2

FAT的扇区数

00 00

24

2

Sectors/Track

00 10

26

2

Number of Sides

00 00

28

4

此分区之前的隐藏扇区数

0x20=32

32

4

总扇区数(如果19/200时)

E0 2B 76 00

36

1

物理磁盘号

80(实际为70)

37

1

Reserved

00实际为07

38

1

Extended Boot Record Signature

29

39

4

Volume ID Number

5F 44 6D 38

43

11

Volume Label

PHONE CARD

54

8

File System Type

FAT32

62

448

Reserved for system use

 

510

2

Signature word

55 AA

 

The Cluster Size shall be the multiple size of the erase block size determined by the physical

layer. If the erase block size is larger than 32KB, the Cluster Size shall be 32KB and this field shall be

recorded 64.

FAT32

36

4

每个FAT表占用的扇区数

70 07 00 00 =0x770

40

2

Flags

00 00

42

2

FAT32驱动版本(固定值:00 00

00 00

44

4

根目录区的开始簇号(00 01 两个簇号不使用)

02 00 00 00

48

2

文件系统信息(后面有相关的说明)扇区所在位置的扇区号(此扇区号为相对位置)

01 00

50

2

备份引导扇区所在位置的扇区号(此扇区号为相对位置)

06 00

52

12

Reserved

0

64

 

分区的逻辑驱动号

00

65

 

Reserved

00

66

1

Extended Boot Record Signature

29

67

4

Volume ID Number

5F 44 6D 38

71

11

Volume Label

PHONE CARD

82

8

File System Type

FAT32

90

448

Reserved for system use

 

510

2

Signature word

55 AA

奇怪的是Volume ID的前两位总是读不对

PBR只占一个 sector

紧后面是文件系统信息区(1sector)和一些其他未知信息和reserved sectors

 

后面是FAT表,每个FAT表占0x770扇区(见上表)

PBR从扇区32(0x4000))开始

FAT表从32 + 保留扇区数(32= 64(0x8000)开始

第二个FAT表从64+0x770=1968(0xF6000)开始

数据区从64 + 0x770 *2 = 38720x1E4000)开始

                

3. FAT

 

没有分配的簇 00 00 00 00

坏簇FF FF FF F7

文件的最后一簇FF FF FF 0F

0000000H00000001H两簇号不使用, 相应地方F8 FF FF 0F

已经分配的簇 00 00 00 02 – FF FF FF EF

 

4.数据区

 

FAT16的目录项定义

Offset

Length

Name

Contents

0

8

File name

 

8

3

Extention

 

11

1

Attributes

 

12

10

Reserveed

 

22

2

Time

 

24

2

Date

 

26

2

Starting Cluster number

 

28

4

File length

 

对于FAT32的目录项定义

 

Offset

Length

Name

0

8

File name

8

3

Extention

11

1

Attributes

12

1

仅长文件名目录项用,用来存储其对应的短文件名目录项的文件名字节校验和等

13

3

24位二进制的文件建立时间,其中的高5位为小时,次6位为分钟

16

2

16位二进制的文件建立日期,其中的高7位为相对于1980年的年份值,次4位为月份,后5位为月内日期

18

2

16位二进制的文件最新访问日期,定义同上

20

2

起始簇号的高16

22

2

16位二进制的文件最新修改时间,其中的高5位为小时,次6位为分钟,后5位的二倍为秒数

24

2

16位二进制的文件建立日期,其中的高7位为相对于1980年的年份值,次4位为月份,后5位为月内日期

26

2

起始簇号的低16

28

42

32位的文件字节长度(对于子目录,此项为0

         文件属性(最高两位保留未用,05位分别是b0只读位、b1隐藏位、b2系统位、b3卷标位、b4子目录位、b5归档位 00读写

 

对于长文件名的目录项定义

 

Offset

Length

Name

Contents

0

1

Attributes

 

1

10

File name (Unicode)

 

11

1

长文件名目录项标志

0F

12

1

Reserveed

 

13

1

Checksum根据短文件名计算出来

 

14

12

File name (Unicode)

 

26

2

Starting Cluster number

00 00

28

4

File name (Unicode)

 

属性定义bit 0-4顺序号,bit5 & 7 Reserveed,  bit6 如果1表示长文件最后一个目录项

 

 

原创粉丝点击