1 /* $Id: vfat.h,v 1.25 2001/02/10 22:51:11 dwelch Exp $ */
6 unsigned char magic0
, res0
, magic1
;
7 unsigned char OEMName
[8];
8 unsigned short BytesPerSector
;
9 unsigned char SectorsPerCluster
;
10 unsigned short ReservedSectors
;
11 unsigned char FATCount
;
12 unsigned short RootEntries
, Sectors
;
14 unsigned short FATSectors
, SectorsPerTrack
, Heads
;
15 unsigned long HiddenSectors
, SectorsHuge
;
16 unsigned char Drive
, Res1
, Sig
;
17 unsigned long VolumeID
;
18 unsigned char VolumeLabel
[11], SysType
[8];
19 unsigned char Res2
[450];
20 } __attribute__((packed
));
22 struct _BootSector32
{
23 unsigned char magic0
, res0
, magic1
;
24 unsigned char OEMName
[8];
25 unsigned short BytesPerSector
;
26 unsigned char SectorsPerCluster
;
27 unsigned short ReservedSectors
;
28 unsigned char FATCount
;
29 unsigned short RootEntries
, Sectors
;
31 unsigned short FATSectors
, SectorsPerTrack
, Heads
;
32 unsigned long HiddenSectors
, SectorsHuge
;
33 unsigned long FATSectors32
;
35 unsigned long VolumeID
;
36 unsigned char VolumeLabel
[11], SysType
[8];
37 unsigned char Res2
[422];
38 } __attribute__((packed
));
40 typedef struct _BootSector BootSector
;
43 unsigned char Filename
[8], Ext
[3], Attrib
, Res
[2];
44 unsigned short CreationTime
,CreationDate
,AccessDate
;
45 unsigned short FirstClusterHigh
;// higher
46 unsigned short UpdateTime
;//time create/update
47 unsigned short UpdateDate
;//date create/update
48 unsigned short FirstCluster
;
49 unsigned long FileSize
;
50 } __attribute__((packed
));
52 typedef struct _FATDirEntry FATDirEntry
;
56 unsigned char id
; // sequence number for slot
57 WCHAR name0_4
[5]; // first 5 characters in name
58 unsigned char attr
; // attribute byte
59 unsigned char reserved
; // always 0
60 unsigned char alias_checksum
; // checksum for 8.3 alias
61 WCHAR name5_10
[6]; // 6 more characters in name
62 unsigned char start
[2]; // starting cluster number
63 WCHAR name11_12
[2]; // last 2 characters in name
64 } __attribute__((packed
));
67 typedef struct _slot slot
;
77 ERESOURCE DirResource
;
78 ERESOURCE FatResource
;
80 KSPIN_LOCK FcbListLock
;
81 LIST_ENTRY FcbListHead
;
83 PDEVICE_OBJECT StorageDevice
;
84 PFILE_OBJECT StreamStorageDevice
;
86 PFILE_OBJECT Fat12StorageDevice
;
89 int rootDirectorySectors
, FATStart
, rootStart
, dataStart
;
90 int FATEntriesPerSector
, FATUnit
;
91 ULONG BytesPerCluster
;
93 } DEVICE_EXTENSION
, *PDEVICE_EXTENSION
;
95 typedef struct _VFATFCB
97 REACTOS_COMMON_FCB_HEADER RFCB
;
98 SECTION_OBJECT_POINTERS SectionObjectPointers
;
100 /* point on filename (250 chars max) in PathName */
102 /* path+filename 260 max */
103 WCHAR PathName
[MAX_PATH
];
105 PDEVICE_EXTENSION pDevExt
;
106 LIST_ENTRY FcbListEntry
;
107 struct _VFATFCB
* parentFcb
;
108 } VFATFCB
, *PVFATFCB
;
110 typedef struct _VFATCCB
114 PFILE_OBJECT PtrFileObject
;
115 LARGE_INTEGER CurrentByteOffset
;
116 /* for DirectoryControl */
118 /* for DirectoryControl */
120 // PSTRING DirectorySearchPattern;// for DirectoryControl ?
121 } VFATCCB
, *PVFATCCB
;
124 #define ENTRIES_PER_SECTOR (BLOCKSIZE / sizeof(FATDirEntry))
126 typedef struct __DOSTIME
131 } DOSTIME
, *PDOSTIME
;
133 typedef struct __DOSDATE
138 } DOSDATE
, *PDOSDATE
;
140 /* functions called by i/o manager : */
142 DriverEntry(PDRIVER_OBJECT _DriverObject
,PUNICODE_STRING RegistryPath
);
144 VfatDirectoryControl(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
146 VfatRead(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
148 VfatWrite(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
150 VfatCreate(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
152 VfatClose(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
154 VfatFileSystemControl(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
156 VfatQueryInformation(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
160 NextCluster(PDEVICE_EXTENSION DeviceExt
,
162 PULONG CurrentCluster
,
165 /* internal functions in blockdev.c */
167 VfatReadSectors(IN PDEVICE_OBJECT pDeviceObject
,
169 IN ULONG SectorCount
,
173 VfatWriteSectors(IN PDEVICE_OBJECT pDeviceObject
,
175 IN ULONG SectorCount
,
178 /* internal functions in dir.c : */
179 BOOL
FsdDosDateTimeToFileTime(WORD wDosDate
,WORD wDosTime
, TIME
*FileTime
);
180 BOOL
FsdFileTimeToDosDateTime(TIME
*FileTime
,WORD
*pwDosDate
,WORD
*pwDosTime
);
182 /* internal functions in iface.c : */
184 FindFile(PDEVICE_EXTENSION DeviceExt
, PVFATFCB Fcb
,
185 PVFATFCB Parent
, PWSTR FileToFind
,ULONG
*StartSector
,ULONG
*Entry
);
187 VfatCloseFile(PDEVICE_EXTENSION DeviceExt
, PFILE_OBJECT FileObject
);
189 VfatGetStandardInformation(PVFATFCB FCB
, PDEVICE_OBJECT DeviceObject
,
190 PFILE_STANDARD_INFORMATION StandardInfo
);
192 VfatOpenFile(PDEVICE_EXTENSION DeviceExt
, PFILE_OBJECT FileObject
,
195 VfatReadFile(PDEVICE_EXTENSION DeviceExt
, PFILE_OBJECT FileObject
,
196 PVOID Buffer
, ULONG Length
, ULONG ReadOffset
,
197 PULONG LengthRead
, ULONG NoCache
);
199 VfatWriteFile(PDEVICE_EXTENSION DeviceExt
, PFILE_OBJECT FileObject
,
200 PVOID Buffer
, ULONG Length
, ULONG WriteOffset
, ULONG NoCache
);
202 GetNextWriteCluster(PDEVICE_EXTENSION DeviceExt
,
204 ULONG CurrentCluster
,
207 IsDeletedEntry(PVOID Block
, ULONG Offset
);
209 IsLastEntry(PVOID Block
, ULONG Offset
);
211 vfat_wcsncpy(wchar_t * dest
, const wchar_t *src
,size_t wcount
);
213 VfatRawWriteCluster(PDEVICE_EXTENSION DeviceExt
,
214 ULONG FirstCluster
, PVOID Buffer
, ULONG Cluster
);
216 /* internal functions in dirwr.c */
218 addEntry(PDEVICE_EXTENSION DeviceExt
,
219 PFILE_OBJECT pFileObject
,ULONG RequestedOptions
,UCHAR ReqAttr
);
221 updEntry(PDEVICE_EXTENSION DeviceExt
,PFILE_OBJECT pFileObject
);
227 RtlAnsiToUnicode(PWSTR Dest
, PCH Source
, ULONG Length
);
229 RtlCatAnsiToUnicode(PWSTR Dest
, PCH Source
, ULONG Length
);
231 vfat_initstr(wchar_t *wstr
, ULONG wsize
);
233 vfat_wcsncat(wchar_t * dest
, const wchar_t * src
,size_t wstart
, size_t wcount
);
235 vfat_wcsncpy(wchar_t * dest
, const wchar_t *src
,size_t wcount
);
237 vfat_movstr(wchar_t *src
, ULONG dpos
, ULONG spos
, ULONG len
);
239 wstrcmpi(PWSTR s1
, PWSTR s2
);
241 wstrcmpjoki(PWSTR s1
, PWSTR s2
);
244 * functions from fat.c
247 ClusterToSector(PDEVICE_EXTENSION DeviceExt
, ULONG Cluster
);
249 GetNextCluster(PDEVICE_EXTENSION DeviceExt
,
250 ULONG CurrentCluster
,
254 VfatRawReadCluster (PDEVICE_EXTENSION DeviceExt
,
259 FAT12CountAvailableClusters(PDEVICE_EXTENSION DeviceExt
);
261 FAT16CountAvailableClusters(PDEVICE_EXTENSION DeviceExt
);
263 FAT32CountAvailableClusters(PDEVICE_EXTENSION DeviceExt
);
265 WriteCluster (PDEVICE_EXTENSION DeviceExt
, ULONG ClusterToWrite
,
269 * functions from volume.c
272 VfatQueryVolumeInformation(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
275 * functions from finfo.c
278 VfatSetInformation(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
284 ReadVolumeLabel(PDEVICE_EXTENSION DeviceExt
, PVPB Vpb
);
286 VfatOpenFile (PDEVICE_EXTENSION DeviceExt
, PFILE_OBJECT FileObject
,
290 * functions from shutdown.c
292 NTSTATUS STDCALL
VfatShutdown(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);