ReactOS 0.4.15-dev-7907-g95bf896
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
30struct FATEntry : public Entry
31{
32 FATEntry(Entry* parent, unsigned cluster) : Entry(parent, ET_FAT), _cluster(cluster) {}
33
34protected:
36
37 virtual bool get_path(PTSTR path, size_t path_count) const;
39
41};
42
43
44struct FATDrive;
45
47struct FATDirectory : public FATEntry, public Directory
48{
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
57protected:
59
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
72struct BootSector {
74 char OEM[8];
75 WORD BytesPerSector; // dpb.bsec
76 BYTE SectorsPerCluster; // dpb.sclus + 1
77 WORD ReservedSectors; // dpb.ffatsec
79 WORD RootEntries; // dpb.ndir
90 char Label[11];
91 char FileSystem[8];
94};
95
98 char OEM[8];
103 WORD reserved1; // immer 0 für FAT32
106 WORD reserved2; // immer 0 für FAT32
113 DWORD RootSectors; // correct?
114 char unknown2[6];
115 char FileSystem[8];
118};
119
120
121struct filetime {
125};
126
127struct filedate {
131};
132
133typedef 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
143typedef union {
144 char b;
147
148struct DEntry_E {
149 char name[8];
150 char ext[3];
151 char attr;
152 char rsrvd[10];
157};
158
159union DEntry {
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
169struct Buffer {
171};
172
173struct Cache {
175};
176
177struct dskrwblk {
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
198struct dirent {
199 union DEntry ent[1];
200};
201
202struct dirsecz {
203 DWORD s[32]; // 32 only as placeholder
204};
205
206struct 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
225struct FATDrive : public FATDirectory
226{
228/*
229 FATDrive(Entry* parent, LPCTSTR path)
230 : FATEntry(parent)
231 {
232 _path = _tcsdup(path);
233 }
234*/
236
239 int _bufl;
242
243#define CACHE_SIZE_LOW 32
246 DWORD* _CacheSec; // numbers of buffered cache sectors
247 int* _CacheCnt; // counters for cache usage
248 bool* _CacheDty; // dirty flags for cache
252
253 bool read_sector(DWORD sec, Buffer* buf, int len);
254 DWORD read_FAT(DWORD Clus, bool& ok);
255
260};
#define ok(value,...)
Definition: atltest.h:57
Definition: ehthrow.cxx:54
Definition: bufpool.h:45
BYTE dat[BufLen]
Definition: fatfs.h:170
r parent
Definition: btrfs.c:3010
@ ET_FAT
Definition: entries.h:40
#define BufLen
Definition: fatfs.h:167
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
GLdouble s
Definition: gl.h:2039
GLuint buffer
Definition: glext.h:5915
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLsizei len
Definition: glext.h:6722
DWORD SectorsPerFAT32
Definition: fatfs.h:111
BYTE SectorsPerCluster
Definition: fatfs.h:100
WORD SectorsPerTrack
Definition: fatfs.h:107
BYTE BootSignature[2]
Definition: fatfs.h:117
char FileSystem[8]
Definition: fatfs.h:115
DWORD unknown1
Definition: fatfs.h:112
DWORD Sectors32
Definition: fatfs.h:110
WORD Sectors16
Definition: fatfs.h:104
WORD reserved2
Definition: fatfs.h:106
BYTE jmp[3]
Definition: fatfs.h:97
BYTE BootCode[448]
Definition: fatfs.h:116
BYTE NumberFATs
Definition: fatfs.h:102
BYTE MediaDescr
Definition: fatfs.h:105
WORD BytesPerSector
Definition: fatfs.h:99
DWORD RootSectors
Definition: fatfs.h:113
char OEM[8]
Definition: fatfs.h:98
char unknown2[6]
Definition: fatfs.h:114
WORD ReservedSectors
Definition: fatfs.h:101
WORD reserved1
Definition: fatfs.h:103
WORD Heads
Definition: fatfs.h:108
DWORD HiddenSectors
Definition: fatfs.h:109
WORD Heads
Definition: fatfs.h:84
WORD Sectors16
Definition: fatfs.h:80
DWORD SerialNr
Definition: fatfs.h:89
char FileSystem[8]
Definition: fatfs.h:91
WORD RootEntries
Definition: fatfs.h:79
BYTE NumberFATs
Definition: fatfs.h:78
char Label[11]
Definition: fatfs.h:90
DWORD HiddenSectors
Definition: fatfs.h:85
BYTE BootCode[448]
Definition: fatfs.h:92
BYTE jmp[3]
Definition: fatfs.h:73
WORD SectorsPerTrack
Definition: fatfs.h:83
WORD ReservedSectors
Definition: fatfs.h:77
WORD ExtBootFlag
Definition: fatfs.h:88
DWORD Sectors32
Definition: fatfs.h:86
WORD SectorsPerFAT
Definition: fatfs.h:82
BYTE DriveUnit
Definition: fatfs.h:87
BYTE SectorsPerCluster
Definition: fatfs.h:76
BYTE MediaDescr
Definition: fatfs.h:81
BYTE BootSignature[2]
Definition: fatfs.h:93
WORD BytesPerSector
Definition: fatfs.h:75
char OEM[8]
Definition: fatfs.h:74
Definition: fatfs.h:173
BYTE dat[BufLen]
Definition: fatfs.h:174
WORD fclus
Definition: fatfs.h:155
DWORD size
Definition: fatfs.h:156
char attr
Definition: fatfs.h:151
char ext[3]
Definition: fatfs.h:150
char rsrvd[10]
Definition: fatfs.h:152
struct filetime time
Definition: fatfs.h:153
struct filedate date
Definition: fatfs.h:154
base for all directory entries
Definition: entries.h:138
base of all file and directory entries
Definition: entries.h:83
FAT file system directory-entry.
Definition: fatfs.h:48
FATDirectory(FATDrive &drive, LPCTSTR root_path)
struct Kette * _alloc
Definition: fatfs.h:64
FATDrive & _drive
Definition: fatfs.h:58
struct dirsecz * _secarr
Definition: fatfs.h:60
FATDirectory(FATDrive &drive, Entry *parent, LPCTSTR path, unsigned cluster)
virtual const void * get_next_path_component(const void *) const
int _ents
Definition: fatfs.h:62
struct dirent * _dir
Definition: fatfs.h:63
virtual void read_directory(int scan_flags=0)
int _cur_bufs
Definition: fatfs.h:61
bool read_dir()
virtual Entry * find_entry(const void *)
FAT drive root entry.
Definition: fatfs.h:226
DWORD * _CacheSec
Definition: fatfs.h:246
int _bufl
Definition: fatfs.h:239
bool _cache_empty
Definition: fatfs.h:250
bool read_cache(DWORD sec, Buffer **bufptr)
int _bufents
Definition: fatfs.h:240
int * _CacheCnt
Definition: fatfs.h:247
int _Caches
Definition: fatfs.h:249
FATDrive(LPCTSTR path)
int get_cache_buffer()
int _SClus
Definition: fatfs.h:241
int _read_ahead
Definition: fatfs.h:251
BootSector _boot_sector
Definition: fatfs.h:238
void reset_cache()
HANDLE _hDrive
Definition: fatfs.h:237
bool * _CacheDty
Definition: fatfs.h:248
Cache * _FATCache
Definition: fatfs.h:244
DWORD read_FAT(DWORD Clus, bool &ok)
bool read_sector(DWORD sec, Buffer *buf, int len)
int _CacheCount
Definition: fatfs.h:245
void small_cache()
FAT file system file-entry.
Definition: fatfs.h:31
FATEntry(Entry *parent, unsigned cluster)
Definition: fatfs.h:32
virtual bool get_path(PTSTR path, size_t path_count) const
FATEntry()
Definition: fatfs.h:35
virtual ShellPath create_absolute_pidl() const
DWORD _cluster
Definition: fatfs.h:40
Definition: fatfs.h:206
union DEntry * Ent
Definition: fatfs.h:209
struct Kette * Rueck
Definition: fatfs.h:208
struct Kette * Vorw
Definition: fatfs.h:207
wrapper class for item ID lists
Definition: shellclasses.h:652
Definition: fatfs.h:198
union DEntry ent[1]
Definition: fatfs.h:199
Definition: fatfs.h:202
struct buffer far * buf
Definition: fatfs.h:180
DWORD sec
Definition: fatfs.h:178
WORD anz
Definition: fatfs.h:179
Definition: fatfs.h:133
unsigned deleted
Definition: fatfs.h:140
unsigned directory
Definition: fatfs.h:138
unsigned readonly
Definition: fatfs.h:134
unsigned hidden
Definition: fatfs.h:135
unsigned system
Definition: fatfs.h:136
unsigned archived
Definition: fatfs.h:139
unsigned volume
Definition: fatfs.h:137
WORD year
Definition: fatfs.h:130
WORD month
Definition: fatfs.h:129
WORD day
Definition: fatfs.h:128
WORD hour
Definition: fatfs.h:124
WORD sec2
Definition: fatfs.h:122
WORD min
Definition: fatfs.h:123
Definition: name.c:39
static unsigned int bufptr
Definition: tncon.cpp:77
Definition: fatfs.h:159
DEntry_E E
Definition: fatfs.h:160
fattr a
Definition: fatfs.h:145
char b
Definition: fatfs.h:144
#define far
Definition: windef.h:114
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
CHAR * PTSTR
Definition: xmlstorage.h:191
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
unsigned char BYTE
Definition: xxhash.c:193