码迷,mamicode.com
首页 > 其他好文 > 详细

FAT学习笔记(四)——Dir Entry

时间:2014-11-01 23:10:50      阅读:423      评论:0      收藏:0      [点我收藏+]

标签:des   style   io   os   ar   使用   for   sp   strong   

1,短目录和长目录:

短目录和长目录都是放在Data region里的,一个directory entry占用32byte,具体参考下表:

Short directory entry

 

Name

Offset (byte)

Size (bytes)

Description

DIR_Name

0

11

Short name.

DIR_Attr

11

1

File attributes:

ATTR_READ_ONLY                0x01

ATTR_HIDDEN                       0x02

ATTR_SYSTEM                       0x04

ATTR_VOLUME_ID               0x08

ATTR_DIRECTORY                 0x10

ATTR_ARCHIVE                     0x20

ATTR_LONG_NAME              ATTR_READ_ONLY | ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUME_ID

The upper two bits of the attribute byte are reserved and should always be set to 0 when a file is created and never modified or looked at after that.

 

 

DIR_NTRes 12 1 Reserved for use by Windows NT.
DIR_CrtTimeTenth 13 1 Millisecond stamp at file creation time.
DIR_CrtTime 14 2 Time file was created.
DIR_CrtDate 16 2 Date file was created.
DIR_LstAccDate 18 2 Last access date.
DIR_FstClusHI 20 2 High word of this entry’s first cluster number (always 0 for a FAT12 or FAT16 volume).
DIR_WrtTime 22 2 Time of last write.
DIR_WrtDate 24 2 Date of last write.
DIR_FstClusLO 26 2 Low word of this entry’s first cluster number.
DIR_FileSize 28 4

32-bit DWORD holding this file’s size in bytes.

所以FAT32支持文件的最大大小为4G

 

 

 

DIR_Name不能包含以下字符:

1, 任何小于0X20值的字符,除了0x05(0X05代表的含义是该目录entry可以被重新使用,删除一个文件的时候用0x05来覆盖DIR_Name[0,如果DIR_Name[0]的值为0,表示该entry可以被使用~之前没有被使用过)

2,0x22, 0x2A, 0x2B, 0x2C, 0x2E, 0x2F, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x5B, 0x5C, 0x5D, and 0x7C.

Shaort name举例如下:

“foo.bar”            -> “FOO     BAR”

“FOO.BAR”            -> “FOO     BAR”

“Foo.Bar”            -> “FOO     BAR”

“foo”                -> “FOO        “

“foo.”               -> “FOO        “

“PICKLE.A”           -> “PICKLE  A  “

“prettybg.big”       -> “PRETTYBGBIG”

“.big”               -> illegal, DIR_Name[0] cannot be 0x20

 

 Data format:

a date relative to the MS-DOS epoch of 01/01/1980

 

Bits

Description

15-9

Year (0 = 1980, 127 = 2107)

8-5

Month (1 = January, 12 = December)

4-0

Day (1 - 31)

Time format:

 

The valid time range is from Midnight 00:00:00 to 23:59:58

 

Bits

Description

15-11

Hours (0-23)

10-5

Minutes (0-59)

4-0

Seconds/2 (0-29)

 

 

 

long directory entry

 

Name

Offset

(byte)

Size

(bytes)

Description

LDIR_Ord

0

1

The order of this entry in the sequence of long dir entries associated with the short dir entry at the end of the long dir set.


If masked with 0x40 (LAST_LONG_ENTRY), this indicates the entry is the last long dir entry in a set of long dir entries. All valid sets of long dir entries must begin with an entry having this mask.

LDIR_Name1

1

10

Characters 1-5 of the long-name sub-component in this dir entry.

LDIR_Attr

11

1

Attributes - must be ATTR_LONG_NAME

LDIR_Type

12

1

If zero, indicates a directory entry that is a sub-component of a long name.  NOTE: Other values reserved for future extensions.

Non-zero implies other dirent types.

LDIR_Chksum

13

1

Checksum of name in the short dir entry at the end of the long dir set.

LDIR_Name2

14

12

Characters 6-11 of the long-name sub-component in this dir entry.

LDIR_FstClusLO

26

2

Must be ZERO. This is an artifact of the FAT "first cluster" and must be zero for compatibility with existing disk utilities.  It‘s meaningless in the context of a long dir entry.

LDIR_Name3

28

4

Characters 12-13 of the long-name sub-component in this dir entry.

 

 

Example:

当一个文件名字是"The quick brown.fox". 以下的表格说明了它是如何存放在directory entry里的。

 

 

FAT32对文件名以及文件路径的限制:

1, 短目录名可以包含任何字母数字以及下面的字符:

$   %   ‘   -   _   @   ~    `   !   (    )   {   }  ^  #  &

2, 长目录名不能包含如下字符

+   ,   ;   =   [   ]

3, 短目录名路径最大长度是8+3,端目录完整路径长度最大为80(包含最后的结束NUL字符)

4, 长目录完整路径最大为255(不包含最后的NUL字符)

5, 长目录entry是通过UNICODE来放具体名字的字符的,2个byte对应一个字符,区分大小写。

6, 短目录entry是不区分大小写的。

 

FAT学习笔记(四)——Dir Entry

标签:des   style   io   os   ar   使用   for   sp   strong   

原文地址:http://www.cnblogs.com/zhiliao112/p/4067866.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!