1 /* $Id: vfat.h,v 1.23 2001/01/14 15:05:53 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
;
87 int rootDirectorySectors
, FATStart
, rootStart
, dataStart
;
88 int FATEntriesPerSector
, FATUnit
;
89 ULONG BytesPerCluster
;
91 } DEVICE_EXTENSION
, *PDEVICE_EXTENSION
;
93 typedef struct _VFATFCB
95 REACTOS_COMMON_FCB_HEADER RFCB
;
97 /* point on filename (250 chars max) in PathName */
99 /* path+filename 260 max */
100 WCHAR PathName
[MAX_PATH
];
102 PDEVICE_EXTENSION pDevExt
;
103 LIST_ENTRY FcbListEntry
;
104 struct _VFATFCB
* parentFcb
;
105 } VFATFCB
, *PVFATFCB
;
107 typedef struct _VFATCCB
111 PFILE_OBJECT PtrFileObject
;
112 LARGE_INTEGER CurrentByteOffset
;
113 /* for DirectoryControl */
115 /* for DirectoryControl */
117 // PSTRING DirectorySearchPattern;// for DirectoryControl ?
118 } VFATCCB
, *PVFATCCB
;
121 #define ENTRIES_PER_SECTOR (BLOCKSIZE / sizeof(FATDirEntry))
123 typedef struct __DOSTIME
128 } DOSTIME
, *PDOSTIME
;
130 typedef struct __DOSDATE
135 } DOSDATE
, *PDOSDATE
;
137 /* functions called by i/o manager : */
139 DriverEntry(PDRIVER_OBJECT _DriverObject
,PUNICODE_STRING RegistryPath
);
141 VfatDirectoryControl(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
143 VfatRead(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
145 VfatWrite(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
147 VfatCreate(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
149 VfatClose(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
151 VfatFileSystemControl(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
153 VfatQueryInformation(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
156 /* internal functions in blockdev.c */
158 VfatReadSectors(IN PDEVICE_OBJECT pDeviceObject
,
160 IN ULONG SectorCount
,
164 VfatWriteSectors(IN PDEVICE_OBJECT pDeviceObject
,
166 IN ULONG SectorCount
,
169 /* internal functions in dir.c : */
170 BOOL
FsdDosDateTimeToFileTime(WORD wDosDate
,WORD wDosTime
, TIME
*FileTime
);
171 BOOL
FsdFileTimeToDosDateTime(TIME
*FileTime
,WORD
*pwDosDate
,WORD
*pwDosTime
);
173 /* internal functions in iface.c : */
175 FindFile(PDEVICE_EXTENSION DeviceExt
, PVFATFCB Fcb
,
176 PVFATFCB Parent
, PWSTR FileToFind
,ULONG
*StartSector
,ULONG
*Entry
);
178 VfatCloseFile(PDEVICE_EXTENSION DeviceExt
, PFILE_OBJECT FileObject
);
180 VfatGetStandardInformation(PVFATFCB FCB
, PDEVICE_OBJECT DeviceObject
,
181 PFILE_STANDARD_INFORMATION StandardInfo
);
183 VfatOpenFile(PDEVICE_EXTENSION DeviceExt
, PFILE_OBJECT FileObject
,
186 VfatReadFile(PDEVICE_EXTENSION DeviceExt
, PFILE_OBJECT FileObject
,
187 PVOID Buffer
, ULONG Length
, ULONG ReadOffset
,
188 PULONG LengthRead
, ULONG NoCache
);
190 VfatWriteFile(PDEVICE_EXTENSION DeviceExt
, PFILE_OBJECT FileObject
,
191 PVOID Buffer
, ULONG Length
, ULONG WriteOffset
);
193 GetNextWriteCluster(PDEVICE_EXTENSION DeviceExt
, ULONG CurrentCluster
,
196 IsDeletedEntry(PVOID Block
, ULONG Offset
);
198 IsLastEntry(PVOID Block
, ULONG Offset
);
200 vfat_wcsncpy(wchar_t * dest
, const wchar_t *src
,size_t wcount
);
202 VfatWriteCluster(PDEVICE_EXTENSION DeviceExt
, PVOID Buffer
, ULONG Cluster
);
204 /* internal functions in dirwr.c */
206 addEntry(PDEVICE_EXTENSION DeviceExt
,
207 PFILE_OBJECT pFileObject
,ULONG RequestedOptions
,UCHAR ReqAttr
);
209 updEntry(PDEVICE_EXTENSION DeviceExt
,PFILE_OBJECT pFileObject
);
215 RtlAnsiToUnicode(PWSTR Dest
, PCH Source
, ULONG Length
);
217 RtlCatAnsiToUnicode(PWSTR Dest
, PCH Source
, ULONG Length
);
219 vfat_initstr(wchar_t *wstr
, ULONG wsize
);
221 vfat_wcsncat(wchar_t * dest
, const wchar_t * src
,size_t wstart
, size_t wcount
);
223 vfat_wcsncpy(wchar_t * dest
, const wchar_t *src
,size_t wcount
);
225 vfat_movstr(wchar_t *src
, ULONG dpos
, ULONG spos
, ULONG len
);
227 wstrcmpi(PWSTR s1
, PWSTR s2
);
229 wstrcmpjoki(PWSTR s1
, PWSTR s2
);
232 * functions from fat.c
235 ClusterToSector(PDEVICE_EXTENSION DeviceExt
, ULONG Cluster
);
237 GetNextCluster(PDEVICE_EXTENSION DeviceExt
,
238 ULONG CurrentCluster
,
241 VfatRawReadCluster (PDEVICE_EXTENSION DeviceExt
,
246 FAT12CountAvailableClusters(PDEVICE_EXTENSION DeviceExt
);
248 FAT16CountAvailableClusters(PDEVICE_EXTENSION DeviceExt
);
250 FAT32CountAvailableClusters(PDEVICE_EXTENSION DeviceExt
);
252 WriteCluster (PDEVICE_EXTENSION DeviceExt
, ULONG ClusterToWrite
,
256 * functions from volume.c
259 VfatQueryVolumeInformation(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
262 * functions from finfo.c
265 VfatSetInformation(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);
271 ReadVolumeLabel(PDEVICE_EXTENSION DeviceExt
, PVPB Vpb
);
274 * functions from shutdown.c
276 NTSTATUS STDCALL
VfatShutdown(PDEVICE_OBJECT DeviceObject
, PIRP Irp
);