1. Short directory and long directory:
Both short and long directories are stored in data region. A directory entry occupies 32 bytes. For details, see the following table:
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 shoshould 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. Therefore, the maximum file size supported by FAT32 is 4 GB. |
Dir_name cannot contain the following characters:
1. Any character smaller than 0x20, except 0x05 (0x05 indicates that the directory entry can be reused. When deleting a file, use 0x05 to overwrite dir_name [0, if dir_name [0] is set to 0, this entry can be used ~ Has not been used before)
2, 0x22, 0x2a, 0x2b, 0x2c, 0x2e, 0x2f, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x5b, 0x5c, 0x5d, and 0x7c.
Example of 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:
When a file is named "The quick brown. Fox". The following table shows how it is stored in the directory entry.
FAT32 restrictions on file names and file paths:
1. The short directory name can contain any letters, numbers, and the following characters:
$ % '-_@~ '! () {}^ #&
2. The long directory name cannot contain the following characters:
+,; = []
3. the maximum length of the short directory name path is 8 + 3, and the full path length of the end directory is up to 80 (including the final ending NUL characters)
4. the full path of a long directory is up to 255 (excluding the final NUL characters)
5. The long directory entry uses Unicode to hold characters of a specific name. The two bytes correspond to one character, which is case sensitive.
6. Short directory entries are case-insensitive.
Fat Study Notes (4) -- dir entry