ReactOS
0.4.16-dev-306-g647d351
fatfs.h
Go to the documentation of this file.
1
/*
2
* Copyright 2004 Martin Fuchs
3
*
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2.1 of the License, or (at your option) any later version.
8
*
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
13
*
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
*/
18
19
20
//
21
// Explorer clone
22
//
23
// fatfs.h
24
//
25
// Martin Fuchs, 01.02.2004
26
//
27
28
30
struct
FATEntry
:
public
Entry
31
{
32
FATEntry
(
Entry
*
parent
,
unsigned
cluster) :
Entry
(
parent
,
ET_FAT
),
_cluster
(cluster) {}
33
34
protected
:
35
FATEntry
() :
Entry
(
ET_FAT
) {}
36
37
virtual
bool
get_path
(
PTSTR
path
,
size_t
path_count)
const
;
38
virtual
ShellPath
create_absolute_pidl
()
const
;
39
40
DWORD
_cluster
;
41
};
42
43
44
struct
FATDrive
;
45
47
struct
FATDirectory
:
public
FATEntry
,
public
Directory
48
{
49
FATDirectory
(
FATDrive
&
drive
,
LPCTSTR
root_path);
50
FATDirectory
(
FATDrive
&
drive
,
Entry
*
parent
,
LPCTSTR
path
,
unsigned
cluster);
51
~FATDirectory
();
52
53
virtual
void
read_directory
(
int
scan_flags=0);
54
virtual
const
void
*
get_next_path_component
(
const
void
*)
const
;
55
virtual
Entry
*
find_entry
(
const
void
*);
56
57
protected
:
58
FATDrive
&
_drive
;
59
60
struct
dirsecz
*
_secarr
;
61
int
_cur_bufs
;
62
int
_ents
;
63
struct
dirent
*
_dir
;
64
struct
Kette
*
_alloc
;
65
66
bool
read_dir
();
67
};
68
69
70
#pragma pack(push, 1)
71
72
struct
BootSector
{
73
BYTE
jmp
[3];
74
char
OEM
[8];
75
WORD
BytesPerSector
;
// dpb.bsec
76
BYTE
SectorsPerCluster
;
// dpb.sclus + 1
77
WORD
ReservedSectors
;
// dpb.ffatsec
78
BYTE
NumberFATs
;
79
WORD
RootEntries
;
// dpb.ndir
80
WORD
Sectors16
;
81
BYTE
MediaDescr
;
82
WORD
SectorsPerFAT
;
83
WORD
SectorsPerTrack
;
84
WORD
Heads
;
85
DWORD
HiddenSectors
;
86
DWORD
Sectors32
;
87
BYTE
DriveUnit
;
88
WORD
ExtBootFlag
;
89
DWORD
SerialNr
;
90
char
Label
[11];
91
char
FileSystem
[8];
92
BYTE
BootCode
[448];
93
BYTE
BootSignature
[2];
94
};
95
96
struct
BootSector32
{
97
BYTE
jmp
[3];
98
char
OEM
[8];
99
WORD
BytesPerSector
;
100
BYTE
SectorsPerCluster
;
101
WORD
ReservedSectors
;
102
BYTE
NumberFATs
;
103
WORD
reserved1
;
// immer 0 für FAT32
104
WORD
Sectors16
;
105
BYTE
MediaDescr
;
106
WORD
reserved2
;
// immer 0 für FAT32
107
WORD
SectorsPerTrack
;
108
WORD
Heads
;
109
DWORD
HiddenSectors
;
110
DWORD
Sectors32
;
111
DWORD
SectorsPerFAT32
;
112
DWORD
unknown1
;
113
DWORD
RootSectors
;
// correct?
114
char
unknown2
[6];
115
char
FileSystem
[8];
116
BYTE
BootCode
[448];
117
BYTE
BootSignature
[2];
118
};
119
120
121
struct
filetime
{
122
WORD
sec2
: 5;
123
WORD
min
: 6;
124
WORD
hour
: 5;
125
};
126
127
struct
filedate
{
128
WORD
day
: 5;
129
WORD
month
: 4;
130
WORD
year
: 7;
131
};
132
133
typedef
struct
{
134
unsigned
readonly
: 1;
135
unsigned
hidden
: 1;
136
unsigned
system
: 1;
137
unsigned
volume
: 1;
138
unsigned
directory
: 1;
139
unsigned
archived
: 1;
140
unsigned
deleted
: 1;
141
}
fattr
;
142
143
typedef
union
{
144
char
b
;
145
fattr
a
;
146
}
FAT_attribute
;
147
148
struct
DEntry_E
{
149
char
name
[8];
150
char
ext
[3];
151
char
attr
;
152
char
rsrvd
[10];
153
struct
filetime
time
;
154
struct
filedate
date
;
155
WORD
fclus
;
156
DWORD
size
;
157
};
158
159
union
DEntry
{
160
DEntry_E
E
;
161
BYTE
B
[8+3+1+10+
sizeof
(
struct
filetime
)+
sizeof
(
struct
filedate
)+
sizeof
(
WORD
)+
sizeof
(
DWORD
)];
162
};
163
164
#pragma pack(pop)
165
166
167
#define BufLen 512
168
169
struct
Buffer
{
170
BYTE
dat
[
BufLen
];
171
};
172
173
struct
Cache
{
174
BYTE
dat
[
BufLen
];
175
};
176
177
struct
dskrwblk
{
178
DWORD
sec
;
179
WORD
anz
;
180
struct
buffer
far
*
buf
;
181
};
182
183
#define RONLY 0x01
184
#define HIDDEN 0x02
185
#define SYSTEM 0x04
186
#define VOLUME 0x08
187
#define DIRENT 0x10
188
#define ARCHIVE 0x20
189
190
#define _A_DELETED 0x40
191
#define _A_ILLEGAL 0x80
192
#define IS_LNAME(a) ((a&0xFF)==0x0F)
// "& 0xFF" correct?
193
194
#define FAT_DEL_CHAR (char)0xe5
195
196
#define AddP(p,s) {(int&)p += s;}
197
198
struct
dirent
{
199
union
DEntry
ent
[1];
200
};
201
202
struct
dirsecz
{
203
DWORD
s
[32];
// 32 only as placeholder
204
};
205
206
struct
Kette
{
207
struct
Kette
*
Vorw
;
208
struct
Kette
*
Rueck
;
209
union
DEntry
*
Ent
;
210
};
211
212
213
#define MK_P(ofs) ((void*) ((size_t)(ofs)))
214
#define MK_LONG(l,h) ((DWORD)WORD(l)|((DWORD)WORD(h)<<16))
215
216
#define spoke(ofs,w) (*((BYTE*)MK_P(ofs)) = (BYTE)(w))
217
#define wpoke(ofs,w) (*((WORD*)MK_P(ofs)) = (WORD)(w))
218
#define dpoke(ofs,w) (*((DWORD*)MK_P(ofs)) = (DWORD)(w))
219
#define speek(ofs) (*((BYTE*)MK_P(ofs)))
220
#define wpeek(ofs) (*((WORD*)MK_P(ofs)))
221
#define dpeek(p) (*((DWORD*)MK_P(p)))
222
223
225
struct
FATDrive
:
public
FATDirectory
226
{
227
FATDrive
(
LPCTSTR
path
);
228
/*
229
FATDrive(Entry* parent, LPCTSTR path)
230
: FATEntry(parent)
231
{
232
_path = _tcsdup(path);
233
}
234
*/
235
~FATDrive
();
236
237
HANDLE
_hDrive
;
238
BootSector
_boot_sector
;
239
int
_bufl
;
240
int
_bufents
;
241
int
_SClus
;
242
243
#define CACHE_SIZE_LOW 32
244
Cache
*
_FATCache
;
245
int
_CacheCount
;
246
DWORD
*
_CacheSec
;
// numbers of buffered cache sectors
247
int
*
_CacheCnt
;
// counters for cache usage
248
bool
*
_CacheDty
;
// dirty flags for cache
249
int
_Caches
;
250
bool
_cache_empty
;
251
int
_read_ahead
;
252
253
bool
read_sector
(
DWORD
sec,
Buffer
*
buf
,
int
len
);
254
DWORD
read_FAT
(
DWORD
Clus,
bool
&
ok
);
255
256
void
small_cache
();
257
void
reset_cache
();
258
bool
read_cache
(
DWORD
sec,
Buffer
**
bufptr
);
259
int
get_cache_buffer
();
260
};
ok
#define ok(value,...)
Definition:
atltest.h:57
B
Definition:
ehthrow.cxx:54
Buffer
Definition:
bufpool.h:45
Buffer::dat
BYTE dat[BufLen]
Definition:
fatfs.h:170
parent
r parent
Definition:
btrfs.c:3010
ET_FAT
@ ET_FAT
Definition:
entries.h:40
BufLen
#define BufLen
Definition:
fatfs.h:167
DWORD
unsigned long DWORD
Definition:
ntddk_ex.h:95
WORD
unsigned short WORD
Definition:
ntddk_ex.h:93
s
GLdouble s
Definition:
gl.h:2039
buffer
GLuint buffer
Definition:
glext.h:5915
buf
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition:
glext.h:7751
len
GLenum GLsizei len
Definition:
glext.h:6722
struct
Definition:
axextend.idl:118
void
Definition:
nsiface.idl:2307
BootSector32
Definition:
fatfs.h:96
BootSector32::SectorsPerFAT32
DWORD SectorsPerFAT32
Definition:
fatfs.h:111
BootSector32::SectorsPerCluster
BYTE SectorsPerCluster
Definition:
fatfs.h:100
BootSector32::SectorsPerTrack
WORD SectorsPerTrack
Definition:
fatfs.h:107
BootSector32::BootSignature
BYTE BootSignature[2]
Definition:
fatfs.h:117
BootSector32::FileSystem
char FileSystem[8]
Definition:
fatfs.h:115
BootSector32::unknown1
DWORD unknown1
Definition:
fatfs.h:112
BootSector32::Sectors32
DWORD Sectors32
Definition:
fatfs.h:110
BootSector32::Sectors16
WORD Sectors16
Definition:
fatfs.h:104
BootSector32::reserved2
WORD reserved2
Definition:
fatfs.h:106
BootSector32::jmp
BYTE jmp[3]
Definition:
fatfs.h:97
BootSector32::BootCode
BYTE BootCode[448]
Definition:
fatfs.h:116
BootSector32::NumberFATs
BYTE NumberFATs
Definition:
fatfs.h:102
BootSector32::MediaDescr
BYTE MediaDescr
Definition:
fatfs.h:105
BootSector32::BytesPerSector
WORD BytesPerSector
Definition:
fatfs.h:99
BootSector32::RootSectors
DWORD RootSectors
Definition:
fatfs.h:113
BootSector32::OEM
char OEM[8]
Definition:
fatfs.h:98
BootSector32::unknown2
char unknown2[6]
Definition:
fatfs.h:114
BootSector32::ReservedSectors
WORD ReservedSectors
Definition:
fatfs.h:101
BootSector32::reserved1
WORD reserved1
Definition:
fatfs.h:103
BootSector32::Heads
WORD Heads
Definition:
fatfs.h:108
BootSector32::HiddenSectors
DWORD HiddenSectors
Definition:
fatfs.h:109
BootSector
Definition:
fatfs.h:72
BootSector::Heads
WORD Heads
Definition:
fatfs.h:84
BootSector::Sectors16
WORD Sectors16
Definition:
fatfs.h:80
BootSector::SerialNr
DWORD SerialNr
Definition:
fatfs.h:89
BootSector::FileSystem
char FileSystem[8]
Definition:
fatfs.h:91
BootSector::RootEntries
WORD RootEntries
Definition:
fatfs.h:79
BootSector::NumberFATs
BYTE NumberFATs
Definition:
fatfs.h:78
BootSector::Label
char Label[11]
Definition:
fatfs.h:90
BootSector::HiddenSectors
DWORD HiddenSectors
Definition:
fatfs.h:85
BootSector::BootCode
BYTE BootCode[448]
Definition:
fatfs.h:92
BootSector::jmp
BYTE jmp[3]
Definition:
fatfs.h:73
BootSector::SectorsPerTrack
WORD SectorsPerTrack
Definition:
fatfs.h:83
BootSector::ReservedSectors
WORD ReservedSectors
Definition:
fatfs.h:77
BootSector::ExtBootFlag
WORD ExtBootFlag
Definition:
fatfs.h:88
BootSector::Sectors32
DWORD Sectors32
Definition:
fatfs.h:86
BootSector::SectorsPerFAT
WORD SectorsPerFAT
Definition:
fatfs.h:82
BootSector::DriveUnit
BYTE DriveUnit
Definition:
fatfs.h:87
BootSector::SectorsPerCluster
BYTE SectorsPerCluster
Definition:
fatfs.h:76
BootSector::MediaDescr
BYTE MediaDescr
Definition:
fatfs.h:81
BootSector::BootSignature
BYTE BootSignature[2]
Definition:
fatfs.h:93
BootSector::BytesPerSector
WORD BytesPerSector
Definition:
fatfs.h:75
BootSector::OEM
char OEM[8]
Definition:
fatfs.h:74
Cache
Definition:
fatfs.h:173
Cache::dat
BYTE dat[BufLen]
Definition:
fatfs.h:174
DEntry_E
Definition:
fatfs.h:148
DEntry_E::fclus
WORD fclus
Definition:
fatfs.h:155
DEntry_E::size
DWORD size
Definition:
fatfs.h:156
DEntry_E::attr
char attr
Definition:
fatfs.h:151
DEntry_E::ext
char ext[3]
Definition:
fatfs.h:150
DEntry_E::rsrvd
char rsrvd[10]
Definition:
fatfs.h:152
DEntry_E::time
struct filetime time
Definition:
fatfs.h:153
DEntry_E::date
struct filedate date
Definition:
fatfs.h:154
Directory
base for all directory entries
Definition:
entries.h:138
Entry
base of all file and directory entries
Definition:
entries.h:83
FATDirectory
FAT file system directory-entry.
Definition:
fatfs.h:48
FATDirectory::FATDirectory
FATDirectory(FATDrive &drive, LPCTSTR root_path)
FATDirectory::_alloc
struct Kette * _alloc
Definition:
fatfs.h:64
FATDirectory::_drive
FATDrive & _drive
Definition:
fatfs.h:58
FATDirectory::_secarr
struct dirsecz * _secarr
Definition:
fatfs.h:60
FATDirectory::FATDirectory
FATDirectory(FATDrive &drive, Entry *parent, LPCTSTR path, unsigned cluster)
FATDirectory::get_next_path_component
virtual const void * get_next_path_component(const void *) const
FATDirectory::_ents
int _ents
Definition:
fatfs.h:62
FATDirectory::_dir
struct dirent * _dir
Definition:
fatfs.h:63
FATDirectory::~FATDirectory
~FATDirectory()
FATDirectory::read_directory
virtual void read_directory(int scan_flags=0)
FATDirectory::_cur_bufs
int _cur_bufs
Definition:
fatfs.h:61
FATDirectory::read_dir
bool read_dir()
FATDirectory::find_entry
virtual Entry * find_entry(const void *)
FATDrive
FAT drive root entry.
Definition:
fatfs.h:226
FATDrive::_CacheSec
DWORD * _CacheSec
Definition:
fatfs.h:246
FATDrive::_bufl
int _bufl
Definition:
fatfs.h:239
FATDrive::~FATDrive
~FATDrive()
FATDrive::_cache_empty
bool _cache_empty
Definition:
fatfs.h:250
FATDrive::read_cache
bool read_cache(DWORD sec, Buffer **bufptr)
FATDrive::_bufents
int _bufents
Definition:
fatfs.h:240
FATDrive::_CacheCnt
int * _CacheCnt
Definition:
fatfs.h:247
FATDrive::_Caches
int _Caches
Definition:
fatfs.h:249
FATDrive::FATDrive
FATDrive(LPCTSTR path)
FATDrive::get_cache_buffer
int get_cache_buffer()
FATDrive::_SClus
int _SClus
Definition:
fatfs.h:241
FATDrive::_read_ahead
int _read_ahead
Definition:
fatfs.h:251
FATDrive::_boot_sector
BootSector _boot_sector
Definition:
fatfs.h:238
FATDrive::reset_cache
void reset_cache()
FATDrive::_hDrive
HANDLE _hDrive
Definition:
fatfs.h:237
FATDrive::_CacheDty
bool * _CacheDty
Definition:
fatfs.h:248
FATDrive::_FATCache
Cache * _FATCache
Definition:
fatfs.h:244
FATDrive::read_FAT
DWORD read_FAT(DWORD Clus, bool &ok)
FATDrive::read_sector
bool read_sector(DWORD sec, Buffer *buf, int len)
FATDrive::_CacheCount
int _CacheCount
Definition:
fatfs.h:245
FATDrive::small_cache
void small_cache()
FATEntry
FAT file system file-entry.
Definition:
fatfs.h:31
FATEntry::FATEntry
FATEntry(Entry *parent, unsigned cluster)
Definition:
fatfs.h:32
FATEntry::get_path
virtual bool get_path(PTSTR path, size_t path_count) const
FATEntry::FATEntry
FATEntry()
Definition:
fatfs.h:35
FATEntry::create_absolute_pidl
virtual ShellPath create_absolute_pidl() const
FATEntry::_cluster
DWORD _cluster
Definition:
fatfs.h:40
Kette
Definition:
fatfs.h:206
Kette::Ent
union DEntry * Ent
Definition:
fatfs.h:209
Kette::Rueck
struct Kette * Rueck
Definition:
fatfs.h:208
Kette::Vorw
struct Kette * Vorw
Definition:
fatfs.h:207
ShellPath
wrapper class for item ID lists
Definition:
shellclasses.h:652
dirent
Definition:
fatfs.h:198
dirent::ent
union DEntry ent[1]
Definition:
fatfs.h:199
dirsecz
Definition:
fatfs.h:202
drive
Definition:
filesystem.c:103
dskrwblk
Definition:
fatfs.h:177
dskrwblk::buf
struct buffer far * buf
Definition:
fatfs.h:180
dskrwblk::sec
DWORD sec
Definition:
fatfs.h:178
dskrwblk::anz
WORD anz
Definition:
fatfs.h:179
fattr
Definition:
fatfs.h:133
fattr::deleted
unsigned deleted
Definition:
fatfs.h:140
fattr::directory
unsigned directory
Definition:
fatfs.h:138
fattr::readonly
unsigned readonly
Definition:
fatfs.h:134
fattr::hidden
unsigned hidden
Definition:
fatfs.h:135
fattr::system
unsigned system
Definition:
fatfs.h:136
fattr::archived
unsigned archived
Definition:
fatfs.h:139
fattr::volume
unsigned volume
Definition:
fatfs.h:137
filedate
Definition:
fatfs.h:127
filedate::year
WORD year
Definition:
fatfs.h:130
filedate::month
WORD month
Definition:
fatfs.h:129
filedate::day
WORD day
Definition:
fatfs.h:128
filetime
Definition:
fatfs.h:121
filetime::hour
WORD hour
Definition:
fatfs.h:124
filetime::sec2
WORD sec2
Definition:
fatfs.h:122
filetime::min
WORD min
Definition:
fatfs.h:123
name
Definition:
name.c:39
path
Definition:
wbemprox_private.h:188
bufptr
static unsigned int bufptr
Definition:
tncon.cpp:77
DEntry
Definition:
fatfs.h:159
DEntry::E
DEntry_E E
Definition:
fatfs.h:160
FAT_attribute
Definition:
fatfs.h:143
FAT_attribute::a
fattr a
Definition:
fatfs.h:145
FAT_attribute::b
char b
Definition:
fatfs.h:144
far
#define far
Definition:
windef.h:114
sizeof
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
PTSTR
CHAR * PTSTR
Definition:
xmlstorage.h:191
LPCTSTR
const CHAR * LPCTSTR
Definition:
xmlstorage.h:193
BYTE
unsigned char BYTE
Definition:
xxhash.c:193
modules
rosapps
applications
explorer-old
shell
fatfs.h
Generated on Mon Dec 2 2024 06:08:26 for ReactOS by
1.9.6