ReactOS 0.4.15-dev-7953-g1f49173
fat.h
Go to the documentation of this file.
1/*
2 * FreeLoader
3 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20#pragma once
21
22#include <pshpack1.h>
23typedef struct _FAT_BOOTSECTOR
24{
25 UCHAR JumpBoot[3]; // Jump instruction to boot code
26 CHAR OemName[8]; // "MSWIN4.1" for MS formatted volumes
27 USHORT BytesPerSector; // Bytes per sector
28 UCHAR SectorsPerCluster; // Number of sectors in a cluster
29 USHORT ReservedSectors; // Reserved sectors, usually 1 (the bootsector)
30 UCHAR NumberOfFats; // Number of FAT tables
31 USHORT RootDirEntries; // Number of root directory entries (fat12/16)
32 USHORT TotalSectors; // Number of total sectors on the drive, 16-bit
33 UCHAR MediaDescriptor; // Media descriptor byte
34 USHORT SectorsPerFat; // Sectors per FAT table (fat12/16)
35 USHORT SectorsPerTrack; // Number of sectors in a track
36 USHORT NumberOfHeads; // Number of heads on the disk
37 ULONG HiddenSectors; // Hidden sectors (sectors before the partition start like the partition table)
38 ULONG TotalSectorsBig; // This field is the new 32-bit total count of sectors on the volume
39 UCHAR DriveNumber; // Int 0x13 drive number (e.g. 0x80)
40 UCHAR Reserved1; // Reserved (used by Windows NT). Code that formats FAT volumes should always set this byte to 0.
41 UCHAR BootSignature; // Extended boot signature (0x29). This is a signature byte that indicates that the following three fields in the boot sector are present.
42 ULONG VolumeSerialNumber; // Volume serial number
43 CHAR VolumeLabel[11]; // Volume label. This field matches the 11-byte volume label recorded in the root directory
44 CHAR FileSystemType[8]; // One of the strings "FAT12 ", "FAT16 ", or "FAT "
45
46 UCHAR BootCodeAndData[448]; // The remainder of the boot sector
47
48 USHORT BootSectorMagic; // 0xAA55
49
51
52typedef struct _FAT32_BOOTSECTOR
53{
54 UCHAR JumpBoot[3]; // Jump instruction to boot code
55 CHAR OemName[8]; // "MSWIN4.1" for MS formatted volumes
56 USHORT BytesPerSector; // Bytes per sector
57 UCHAR SectorsPerCluster; // Number of sectors in a cluster
58 USHORT ReservedSectors; // Reserved sectors, usually 1 (the bootsector)
59 UCHAR NumberOfFats; // Number of FAT tables
60 USHORT RootDirEntries; // Number of root directory entries (fat12/16)
61 USHORT TotalSectors; // Number of total sectors on the drive, 16-bit
62 UCHAR MediaDescriptor; // Media descriptor byte
63 USHORT SectorsPerFat; // Sectors per FAT table (fat12/16)
64 USHORT SectorsPerTrack; // Number of sectors in a track
65 USHORT NumberOfHeads; // Number of heads on the disk
66 ULONG HiddenSectors; // Hidden sectors (sectors before the partition start like the partition table)
67 ULONG TotalSectorsBig; // This field is the new 32-bit total count of sectors on the volume
68 ULONG SectorsPerFatBig; // This field is the FAT32 32-bit count of sectors occupied by ONE FAT. BPB_FATSz16 must be 0
69 USHORT ExtendedFlags; // Extended flags (fat32)
70 USHORT FileSystemVersion; // File system version (fat32)
71 ULONG RootDirStartCluster; // Starting cluster of the root directory (fat32)
72 USHORT FsInfo; // Sector number of FSINFO structure in the reserved area of the FAT32 volume. Usually 1.
73 USHORT BackupBootSector; // If non-zero, indicates the sector number in the reserved area of the volume of a copy of the boot record. Usually 6.
74 UCHAR Reserved[12]; // Reserved for future expansion
75 UCHAR DriveNumber; // Int 0x13 drive number (e.g. 0x80)
76 UCHAR Reserved1; // Reserved (used by Windows NT). Code that formats FAT volumes should always set this byte to 0.
77 UCHAR BootSignature; // Extended boot signature (0x29). This is a signature byte that indicates that the following three fields in the boot sector are present.
78 ULONG VolumeSerialNumber; // Volume serial number
79 CHAR VolumeLabel[11]; // Volume label. This field matches the 11-byte volume label recorded in the root directory
80 CHAR FileSystemType[8]; // Always set to the string "FAT32 "
81
82 UCHAR BootCodeAndData[420]; // The remainder of the boot sector
83
84 USHORT BootSectorMagic; // 0xAA55
85
87
88typedef struct _FATX_BOOTSECTOR
89{
90 CHAR FileSystemType[4]; /* String "FATX" */
91 ULONG VolumeSerialNumber; /* Volume serial number */
92 ULONG SectorsPerCluster; /* Number of sectors in a cluster */
93 USHORT NumberOfFats; /* Number of FAT tables */
94 ULONG Unknown; /* Always 0? */
95 UCHAR Unused[494]; /* Actually size should be 4078 (boot block is 4096 bytes) */
96
98
99/*
100 * Structure of MSDOS directory entry
101 */
102typedef struct //_DIRENTRY
103{
104 CHAR FileName[11]; /* Filename + extension */
105 UCHAR Attr; /* File attributes */
106 UCHAR ReservedNT; /* Reserved for use by Windows NT */
107 UCHAR TimeInTenths; /* Millisecond stamp at file creation */
108 USHORT CreateTime; /* Time file was created */
109 USHORT CreateDate; /* Date file was created */
110 USHORT LastAccessDate; /* Date file was last accessed */
111 USHORT ClusterHigh; /* High word of this entry's start cluster */
112 USHORT Time; /* Time last modified */
113 USHORT Date; /* Date last modified */
114 USHORT ClusterLow; /* First cluster number low word */
115 ULONG Size; /* File size */
117
118typedef struct
119{
120 UCHAR SequenceNumber; /* Sequence number for slot */
121 WCHAR Name0_4[5]; /* First 5 characters in name */
122 UCHAR EntryAttributes; /* Attribute byte */
123 UCHAR Reserved; /* Always 0 */
124 UCHAR AliasChecksum; /* Checksum for 8.3 alias */
125 WCHAR Name5_10[6]; /* 6 more characters in name */
126 USHORT StartCluster; /* Starting cluster number */
127 WCHAR Name11_12[2]; /* Last 2 characters in name */
129
130typedef struct
131{
132 UCHAR FileNameSize; /* Size of filename (max 42) */
133 UCHAR Attr; /* File attributes */
134 CHAR FileName[42]; /* Filename in ASCII, padded with 0xff (not zero-terminated) */
135 ULONG StartCluster; /* Starting cluster number */
136 ULONG Size; /* File size */
137 USHORT Time; /* Time last modified */
138 USHORT Date; /* Date last modified */
139 USHORT CreateTime; /* Time file was created */
140 USHORT CreateDate; /* Date file was created */
141 USHORT LastAccessTime; /* Time file was last accessed */
142 USHORT LastAccessDate; /* Date file was last accessed */
144#include <poppack.h>
145
147
148typedef struct
149{
151 ULONG FileSize; /* File size */
152 ULONG FilePointer; /* File pointer */
153 ULONG CurrentCluster; /* The cluster for file pointer */
154 ULONG StartCluster; /* The first cluster for file */
155 UCHAR Attributes; /* File attributes */
157
158#define ATTR_NORMAL 0x00
159#define ATTR_READONLY 0x01
160#define ATTR_HIDDEN 0x02
161#define ATTR_SYSTEM 0x04
162#define ATTR_VOLUMENAME 0x08
163#define ATTR_DIRECTORY 0x10
164#define ATTR_ARCHIVE 0x20
165#define ATTR_LONG_NAME (ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUMENAME)
166
167#define FAT12 1
168#define FAT16 2
169#define FAT32 3
170#define FATX16 4
171#define FATX32 5
172
173#define ISFATX(FT) ((FT) == FATX16 || (FT) == FATX32)
174
struct _FATX_BOOTSECTOR FATX_BOOTSECTOR
struct FATX_DIRENTRY * PFATX_DIRENTRY
struct _FATX_BOOTSECTOR * PFATX_BOOTSECTOR
const DEVVTBL * FatMount(ULONG DeviceId)
Definition: fat.c:1560
struct DIRENTRY * PDIRENTRY
struct _FAT32_BOOTSECTOR * PFAT32_BOOTSECTOR
struct _FAT32_BOOTSECTOR FAT32_BOOTSECTOR
struct _FAT_BOOTSECTOR * PFAT_BOOTSECTOR
struct FAT_FILE_INFO * PFAT_FILE_INFO
struct LFN_DIRENTRY * PLFN_DIRENTRY
struct _FAT_BOOTSECTOR FAT_BOOTSECTOR
struct _FAT_VOLUME_INFO * PFAT_VOLUME_INFO
Definition: fat.h:146
unsigned short USHORT
Definition: pedump.c:61
Definition: fat.h:103
UCHAR ReservedNT
Definition: fat.h:106
UCHAR TimeInTenths
Definition: fat.h:107
USHORT LastAccessDate
Definition: fat.h:110
USHORT CreateTime
Definition: fat.h:108
USHORT Date
Definition: fat.h:113
USHORT ClusterLow
Definition: fat.h:114
USHORT CreateDate
Definition: fat.h:109
ULONG Size
Definition: fat.h:115
USHORT Time
Definition: fat.h:112
UCHAR Attr
Definition: fat.h:105
USHORT ClusterHigh
Definition: fat.h:111
ULONG StartCluster
Definition: fat.h:135
USHORT Date
Definition: fat.h:138
USHORT Time
Definition: fat.h:137
USHORT LastAccessTime
Definition: fat.h:141
ULONG Size
Definition: fat.h:136
USHORT CreateDate
Definition: fat.h:140
USHORT LastAccessDate
Definition: fat.h:142
USHORT CreateTime
Definition: fat.h:139
UCHAR FileNameSize
Definition: fat.h:132
UCHAR Attr
Definition: fat.h:133
ULONG CurrentCluster
Definition: fat.h:153
UCHAR Attributes
Definition: fat.h:155
ULONG FileSize
Definition: fat.h:151
ULONG StartCluster
Definition: fat.h:154
PFAT_VOLUME_INFO Volume
Definition: fat.h:150
ULONG FilePointer
Definition: fat.h:152
UCHAR EntryAttributes
Definition: fat.h:122
UCHAR SequenceNumber
Definition: fat.h:120
USHORT StartCluster
Definition: fat.h:126
UCHAR AliasChecksum
Definition: fat.h:124
UCHAR Reserved
Definition: fat.h:123
USHORT BootSectorMagic
Definition: fsutil.c:98
UCHAR BootCodeAndData[420]
Definition: fsutil.c:96
CHAR FileSystemType[8]
Definition: fsutil.c:94
UCHAR MediaDescriptor
Definition: fsutil.c:76
ULONG HiddenSectors
Definition: fsutil.c:80
UCHAR NumberOfFats
Definition: fsutil.c:73
ULONG VolumeSerialNumber
Definition: fsutil.c:92
CHAR VolumeLabel[11]
Definition: fsutil.c:93
USHORT ExtendedFlags
Definition: fsutil.c:83
ULONG SectorsPerFatBig
Definition: fsutil.c:82
UCHAR JumpBoot[3]
Definition: fsutil.c:68
CHAR OemName[8]
Definition: fsutil.c:69
USHORT NumberOfHeads
Definition: fsutil.c:79
USHORT ReservedSectors
Definition: fsutil.c:72
USHORT RootDirEntries
Definition: fsutil.c:74
USHORT FsInfo
Definition: fsutil.c:86
USHORT BytesPerSector
Definition: fsutil.c:70
USHORT FileSystemVersion
Definition: fsutil.c:84
ULONG TotalSectorsBig
Definition: fsutil.c:81
UCHAR BootSignature
Definition: fsutil.c:91
ULONG RootDirStartCluster
Definition: fsutil.c:85
UCHAR DriveNumber
Definition: fsutil.c:89
UCHAR SectorsPerCluster
Definition: fsutil.c:71
USHORT SectorsPerFat
Definition: fsutil.c:77
USHORT SectorsPerTrack
Definition: fsutil.c:78
UCHAR Reserved1
Definition: fsutil.c:90
USHORT BackupBootSector
Definition: fsutil.c:87
USHORT TotalSectors
Definition: fsutil.c:75
ULONG VolumeSerialNumber
Definition: fat.h:91
UCHAR Unused[494]
Definition: fat.h:95
ULONG SectorsPerCluster
Definition: fat.h:92
ULONG Unknown
Definition: fat.h:94
USHORT NumberOfFats
Definition: fat.h:93
CHAR FileSystemType[4]
Definition: fat.h:90
ULONG TotalSectorsBig
Definition: fsutil.c:51
UCHAR JumpBoot[3]
Definition: fsutil.c:38
USHORT SectorsPerTrack
Definition: fsutil.c:48
USHORT TotalSectors
Definition: fsutil.c:45
UCHAR NumberOfFats
Definition: fsutil.c:43
CHAR VolumeLabel[11]
Definition: fsutil.c:56
USHORT NumberOfHeads
Definition: fsutil.c:49
USHORT SectorsPerFat
Definition: fsutil.c:47
CHAR OemName[8]
Definition: fsutil.c:39
USHORT ReservedSectors
Definition: fsutil.c:42
ULONG HiddenSectors
Definition: fsutil.c:50
CHAR FileSystemType[8]
Definition: fsutil.c:57
USHORT BytesPerSector
Definition: fsutil.c:40
USHORT RootDirEntries
Definition: fsutil.c:44
ULONG VolumeSerialNumber
Definition: fsutil.c:55
UCHAR MediaDescriptor
Definition: fsutil.c:46
USHORT BootSectorMagic
Definition: fsutil.c:61
UCHAR Reserved1
Definition: fsutil.c:53
UCHAR BootCodeAndData[448]
Definition: fsutil.c:59
UCHAR DriveNumber
Definition: fsutil.c:52
UCHAR BootSignature
Definition: fsutil.c:54
UCHAR SectorsPerCluster
Definition: fsutil.c:41
ULONG DeviceId
Definition: fat.c:51
Definition: fs.h:25
uint32_t ULONG
Definition: typedefs.h:59
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
unsigned char UCHAR
Definition: xmlstorage.h:181
__wchar_t WCHAR
Definition: xmlstorage.h:180
char CHAR
Definition: xmlstorage.h:175