1 /* $Id: vfat.h,v 1.24 2001/01/16 09:55:02 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
;
99 /* point on filename (250 chars max) in PathName */
101 /* path+filename 260 max */
102 WCHAR PathName
[MAX_PATH
];
104 PDEVICE_EXTENSION pDevExt
;
105 LIST_ENTRY FcbListEntry
;
106 struct _VFATFCB
* parentFcb
;
107 } VFATFCB
, *PVFATFCB
;
109 typedef struct _VFATCCB
113 PFILE_OBJECT PtrFileObject
;
114 LARGE_INTEGER CurrentByteOffset
;
115 /* for DirectoryControl */
117 /* for DirectoryControl */
119 // PSTRING DirectorySearchPattern;// for DirectoryControl ?
120 } VFATCCB
, *PVFATCCB
;
123 #define ENTRIES_PER_SECTOR (BLOCKSIZE / sizeof(FATDirEntry))
125 typedef struct __DOSTIME
130 } DOSTIME
, *PDOSTIME
;
132 typedef struct __DOSDATE
137 } DOSDATE
, *PDOSDATE
;
139 /* functions called by i/o manager : */
141 DriverEntry(PDRIVER_OBJECT _DriverObject
,PUNICODE_STRING RegistryPath
);
143 VfatDirectoryControl(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
145 VfatRead(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
147 VfatWrite(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
149 VfatCreate(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
151 VfatClose(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
153 VfatFileSystemControl(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
155 VfatQueryInformation(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
159 NextCluster(PDEVICE_EXTENSION DeviceExt
,
161 PULONG CurrentCluster
,
164 /* internal functions in blockdev.c */
166 VfatReadSectors(IN PDEVICE_OBJECT pDeviceObject
,
168 IN ULONG SectorCount
,
172 VfatWriteSectors(IN PDEVICE_OBJECT pDeviceObject
,
174 IN ULONG SectorCount
,
177 /* internal functions in dir.c : */
178 BOOL
FsdDosDateTimeToFileTime(WORD wDosDate
,WORD wDosTime
, TIME
*FileTime
);
179 BOOL
FsdFileTimeToDosDateTime(TIME
*FileTime
,WORD
*pwDosDate
,WORD
*pwDosTime
);
181 /* internal functions in iface.c : */
183 FindFile(PDEVICE_EXTENSION DeviceExt
, PVFATFCB Fcb
,
184 PVFATFCB Parent
, PWSTR FileToFind
,ULONG
*StartSector
,ULONG
*Entry
);
186 VfatCloseFile(PDEVICE_EXTENSION DeviceExt
, PFILE_OBJECT FileObject
);
188 VfatGetStandardInformation(PVFATFCB FCB
, PDEVICE_OBJECT DeviceObject
,
189 PFILE_STANDARD_INFORMATION StandardInfo
);
191 VfatOpenFile(PDEVICE_EXTENSION DeviceExt
, PFILE_OBJECT FileObject
,
194 VfatReadFile(PDEVICE_EXTENSION DeviceExt
, PFILE_OBJECT FileObject
,
195 PVOID Buffer
, ULONG Length
, ULONG ReadOffset
,
196 PULONG LengthRead
, ULONG NoCache
);
198 VfatWriteFile(PDEVICE_EXTENSION DeviceExt
, PFILE_OBJECT FileObject
,
199 PVOID Buffer
, ULONG Length
, ULONG WriteOffset
, ULONG NoCache
);
201 GetNextWriteCluster(PDEVICE_EXTENSION DeviceExt
,
203 ULONG CurrentCluster
,
206 IsDeletedEntry(PVOID Block
, ULONG Offset
);
208 IsLastEntry(PVOID Block
, ULONG Offset
);
210 vfat_wcsncpy(wchar_t * dest
, const wchar_t *src
,size_t wcount
);
212 VfatRawWriteCluster(PDEVICE_EXTENSION DeviceExt
,
213 ULONG FirstCluster
, PVOID Buffer
, ULONG Cluster
);
215 /* internal functions in dirwr.c */
217 addEntry(PDEVICE_EXTENSION DeviceExt
,
218 PFILE_OBJECT pFileObject
,ULONG RequestedOptions
,UCHAR ReqAttr
);
220 updEntry(PDEVICE_EXTENSION DeviceExt
,PFILE_OBJECT pFileObject
);
226 RtlAnsiToUnicode(PWSTR Dest
, PCH Source
, ULONG Length
);
228 RtlCatAnsiToUnicode(PWSTR Dest
, PCH Source
, ULONG Length
);
230 vfat_initstr(wchar_t *wstr
, ULONG wsize
);
232 vfat_wcsncat(wchar_t * dest
, const wchar_t * src
,size_t wstart
, size_t wcount
);
234 vfat_wcsncpy(wchar_t * dest
, const wchar_t *src
,size_t wcount
);
236 vfat_movstr(wchar_t *src
, ULONG dpos
, ULONG spos
, ULONG len
);
238 wstrcmpi(PWSTR s1
, PWSTR s2
);
240 wstrcmpjoki(PWSTR s1
, PWSTR s2
);
243 * functions from fat.c
246 ClusterToSector(PDEVICE_EXTENSION DeviceExt
, ULONG Cluster
);
248 GetNextCluster(PDEVICE_EXTENSION DeviceExt
,
249 ULONG CurrentCluster
,
253 VfatRawReadCluster (PDEVICE_EXTENSION DeviceExt
,
258 FAT12CountAvailableClusters(PDEVICE_EXTENSION DeviceExt
);
260 FAT16CountAvailableClusters(PDEVICE_EXTENSION DeviceExt
);
262 FAT32CountAvailableClusters(PDEVICE_EXTENSION DeviceExt
);
264 WriteCluster (PDEVICE_EXTENSION DeviceExt
, ULONG ClusterToWrite
,
268 * functions from volume.c
271 VfatQueryVolumeInformation(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
274 * functions from finfo.c
277 VfatSetInformation(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
283 ReadVolumeLabel(PDEVICE_EXTENSION DeviceExt
, PVPB Vpb
);
285 VfatOpenFile (PDEVICE_EXTENSION DeviceExt
, PFILE_OBJECT FileObject
,
289 * functions from shutdown.c
291 NTSTATUS STDCALL
VfatShutdown(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);