2003-05-11 09:51:26 +00:00
|
|
|
/* $Id: vfat.h,v 1.57 2003/05/11 09:51:26 hbirr Exp $ */
|
2000-12-29 23:17:12 +00:00
|
|
|
|
2002-09-08 10:23:54 +00:00
|
|
|
#include <ddk/ntifs.h>
|
1999-01-04 11:59:25 +00:00
|
|
|
|
2002-08-14 20:58:39 +00:00
|
|
|
#define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
|
|
|
|
#define ROUND_DOWN(N, S) ((N) - ((N) % (S)))
|
|
|
|
|
2001-07-20 08:00:21 +00:00
|
|
|
struct _BootSector
|
|
|
|
{
|
1998-10-05 04:00:59 +00:00
|
|
|
unsigned char magic0, res0, magic1;
|
|
|
|
unsigned char OEMName[8];
|
|
|
|
unsigned short BytesPerSector;
|
|
|
|
unsigned char SectorsPerCluster;
|
|
|
|
unsigned short ReservedSectors;
|
|
|
|
unsigned char FATCount;
|
|
|
|
unsigned short RootEntries, Sectors;
|
|
|
|
unsigned char Media;
|
|
|
|
unsigned short FATSectors, SectorsPerTrack, Heads;
|
|
|
|
unsigned long HiddenSectors, SectorsHuge;
|
|
|
|
unsigned char Drive, Res1, Sig;
|
|
|
|
unsigned long VolumeID;
|
|
|
|
unsigned char VolumeLabel[11], SysType[8];
|
2002-08-17 15:15:50 +00:00
|
|
|
unsigned char Res2[446];
|
|
|
|
unsigned long Signatur1;
|
1998-10-05 04:00:59 +00:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
2001-07-20 08:00:21 +00:00
|
|
|
struct _BootSector32
|
|
|
|
{
|
|
|
|
unsigned char magic0, res0, magic1; // 0
|
|
|
|
unsigned char OEMName[8]; // 3
|
|
|
|
unsigned short BytesPerSector; // 11
|
|
|
|
unsigned char SectorsPerCluster; // 13
|
|
|
|
unsigned short ReservedSectors; // 14
|
|
|
|
unsigned char FATCount; // 16
|
|
|
|
unsigned short RootEntries, Sectors; // 17
|
|
|
|
unsigned char Media; // 21
|
|
|
|
unsigned short FATSectors, SectorsPerTrack, Heads; // 22
|
|
|
|
unsigned long HiddenSectors, SectorsHuge; // 28
|
|
|
|
unsigned long FATSectors32; // 36
|
|
|
|
unsigned short ExtFlag; // 40
|
|
|
|
unsigned short FSVersion; // 42
|
|
|
|
unsigned long RootCluster; // 44
|
|
|
|
unsigned short FSInfoSector; // 48
|
2003-01-24 13:42:43 +00:00
|
|
|
unsigned short BootBackup; // 50
|
|
|
|
unsigned char Res3[12]; // 52
|
2001-07-20 08:00:21 +00:00
|
|
|
unsigned char Drive; // 64
|
|
|
|
unsigned char Res4; // 65
|
|
|
|
unsigned char ExtBootSignature; // 66
|
|
|
|
unsigned long VolumeID; // 67
|
|
|
|
unsigned char VolumeLabel[11], SysType[8]; // 71
|
|
|
|
unsigned char Res2[418]; // 90
|
|
|
|
unsigned long Signature1; // 508
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2003-01-31 15:55:18 +00:00
|
|
|
struct _FsInfoSector
|
2001-07-20 08:00:21 +00:00
|
|
|
{
|
|
|
|
unsigned long ExtBootSignature2; // 0
|
|
|
|
unsigned char Res6[480]; // 4
|
|
|
|
unsigned long FSINFOSignature; // 484
|
|
|
|
unsigned long FreeCluster; // 488
|
|
|
|
unsigned long NextCluster; // 492
|
|
|
|
unsigned char Res7[12]; // 496
|
|
|
|
unsigned long Signatur2; // 508
|
1998-12-20 19:41:39 +00:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
1998-10-05 04:00:59 +00:00
|
|
|
typedef struct _BootSector BootSector;
|
|
|
|
|
2002-12-03 01:14:49 +00:00
|
|
|
#define VFAT_CASE_LOWER_BASE 8 // base is lower case
|
|
|
|
#define VFAT_CASE_LOWER_EXT 16 // extension is lower case
|
|
|
|
|
2002-03-18 22:37:13 +00:00
|
|
|
struct _FATDirEntry
|
|
|
|
{
|
2002-12-03 01:14:49 +00:00
|
|
|
unsigned char Filename[8], Ext[3];
|
|
|
|
unsigned char Attrib;
|
|
|
|
unsigned char lCase;
|
|
|
|
unsigned char CreationTimeMs;
|
1998-12-30 18:43:27 +00:00
|
|
|
unsigned short CreationTime,CreationDate,AccessDate;
|
2002-03-18 22:37:13 +00:00
|
|
|
unsigned short FirstClusterHigh; // higher
|
|
|
|
unsigned short UpdateTime; //time create/update
|
|
|
|
unsigned short UpdateDate; //date create/update
|
1998-10-05 04:00:59 +00:00
|
|
|
unsigned short FirstCluster;
|
|
|
|
unsigned long FileSize;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2001-07-05 01:51:53 +00:00
|
|
|
typedef struct _FATDirEntry FATDirEntry, FAT_DIR_ENTRY, *PFAT_DIR_ENTRY;
|
1998-10-05 04:00:59 +00:00
|
|
|
|
|
|
|
struct _slot
|
|
|
|
{
|
|
|
|
unsigned char id; // sequence number for slot
|
2002-03-18 22:37:13 +00:00
|
|
|
WCHAR name0_4[5]; // first 5 characters in name
|
1998-10-05 04:00:59 +00:00
|
|
|
unsigned char attr; // attribute byte
|
|
|
|
unsigned char reserved; // always 0
|
|
|
|
unsigned char alias_checksum; // checksum for 8.3 alias
|
2002-03-18 22:37:13 +00:00
|
|
|
WCHAR name5_10[6]; // 6 more characters in name
|
1998-10-05 04:00:59 +00:00
|
|
|
unsigned char start[2]; // starting cluster number
|
2002-03-18 22:37:13 +00:00
|
|
|
WCHAR name11_12[2]; // last 2 characters in name
|
1998-10-05 04:00:59 +00:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct _slot slot;
|
|
|
|
|
|
|
|
#define BLOCKSIZE 512
|
1998-12-20 19:41:39 +00:00
|
|
|
|
1998-12-30 18:43:27 +00:00
|
|
|
#define FAT16 (1)
|
|
|
|
#define FAT12 (2)
|
|
|
|
#define FAT32 (3)
|
|
|
|
|
2002-03-18 22:37:13 +00:00
|
|
|
#define VCB_VOLUME_LOCKED 0x0001
|
|
|
|
#define VCB_DISMOUNT_PENDING 0x0002
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
ULONG VolumeID;
|
|
|
|
ULONG FATStart;
|
|
|
|
ULONG FATCount;
|
|
|
|
ULONG FATSectors;
|
|
|
|
ULONG rootDirectorySectors;
|
|
|
|
ULONG rootStart;
|
|
|
|
ULONG dataStart;
|
|
|
|
ULONG RootCluster;
|
|
|
|
ULONG SectorsPerCluster;
|
|
|
|
ULONG BytesPerSector;
|
|
|
|
ULONG BytesPerCluster;
|
|
|
|
ULONG NumberOfClusters;
|
|
|
|
ULONG FatType;
|
2002-05-05 20:18:33 +00:00
|
|
|
ULONG Sectors;
|
2002-08-14 20:58:39 +00:00
|
|
|
} FATINFO, *PFATINFO;
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2002-05-05 20:18:33 +00:00
|
|
|
struct _VFATFCB;
|
|
|
|
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
typedef struct _HASHENTRY
|
|
|
|
{
|
|
|
|
ULONG Hash;
|
|
|
|
struct _VFATFCB* self;
|
|
|
|
struct _HASHENTRY* next;
|
|
|
|
}
|
|
|
|
HASHENTRY;
|
|
|
|
|
|
|
|
#define FCB_HASH_TABLE_SIZE 1024
|
|
|
|
|
1998-12-30 18:43:27 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2001-01-08 02:14:06 +00:00
|
|
|
ERESOURCE DirResource;
|
|
|
|
ERESOURCE FatResource;
|
2001-11-02 22:57:14 +00:00
|
|
|
|
2001-01-08 02:14:06 +00:00
|
|
|
KSPIN_LOCK FcbListLock;
|
|
|
|
LIST_ENTRY FcbListHead;
|
2001-10-10 22:20:48 +00:00
|
|
|
|
2001-01-08 02:14:06 +00:00
|
|
|
PDEVICE_OBJECT StorageDevice;
|
2001-10-10 22:20:48 +00:00
|
|
|
PFILE_OBJECT FATFileObject;
|
2002-03-18 22:37:13 +00:00
|
|
|
FATINFO FatInfo;
|
2001-11-02 22:57:14 +00:00
|
|
|
ULONG LastAvailableCluster;
|
2002-03-18 22:37:13 +00:00
|
|
|
ULONG AvailableClusters;
|
|
|
|
BOOLEAN AvailableClustersValid;
|
2002-08-14 20:58:39 +00:00
|
|
|
ULONG Flags;
|
2002-05-05 20:18:33 +00:00
|
|
|
struct _VFATFCB * VolumeFcb;
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
struct _HASHENTRY* FcbHashTable[FCB_HASH_TABLE_SIZE];
|
2003-02-09 18:02:56 +00:00
|
|
|
|
|
|
|
LIST_ENTRY VolumeListEntry;
|
2002-08-14 20:58:39 +00:00
|
|
|
} DEVICE_EXTENSION, *PDEVICE_EXTENSION, VCB, *PVCB;
|
2002-03-18 22:37:13 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
PDRIVER_OBJECT DriverObject;
|
|
|
|
PDEVICE_OBJECT DeviceObject;
|
|
|
|
ULONG Flags;
|
2003-02-09 18:02:56 +00:00
|
|
|
ERESOURCE VolumeListLock;
|
|
|
|
LIST_ENTRY VolumeListHead;
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
NPAGED_LOOKASIDE_LIST FcbLookasideList;
|
|
|
|
NPAGED_LOOKASIDE_LIST CcbLookasideList;
|
|
|
|
NPAGED_LOOKASIDE_LIST IrpContextLookasideList;
|
2002-08-14 20:58:39 +00:00
|
|
|
} VFAT_GLOBAL_DATA, *PVFAT_GLOBAL_DATA;
|
2002-03-18 22:37:13 +00:00
|
|
|
|
|
|
|
extern PVFAT_GLOBAL_DATA VfatGlobalData;
|
1998-12-30 18:43:27 +00:00
|
|
|
|
2001-08-14 20:47:30 +00:00
|
|
|
#define FCB_CACHE_INITIALIZED 0x0001
|
|
|
|
#define FCB_DELETE_PENDING 0x0002
|
2001-10-10 22:20:48 +00:00
|
|
|
#define FCB_IS_FAT 0x0004
|
2001-11-02 22:57:14 +00:00
|
|
|
#define FCB_IS_PAGE_FILE 0x0008
|
2002-05-05 20:18:33 +00:00
|
|
|
#define FCB_IS_VOLUME 0x0010
|
2001-08-14 20:47:30 +00:00
|
|
|
|
1999-12-11 21:14:49 +00:00
|
|
|
typedef struct _VFATFCB
|
1998-12-30 18:43:27 +00:00
|
|
|
{
|
2003-02-13 22:24:19 +00:00
|
|
|
/* FCB header required by ROS/NT */
|
2000-12-29 23:17:12 +00:00
|
|
|
REACTOS_COMMON_FCB_HEADER RFCB;
|
2001-02-10 22:51:11 +00:00
|
|
|
SECTION_OBJECT_POINTERS SectionObjectPointers;
|
2003-02-13 22:24:19 +00:00
|
|
|
ERESOURCE MainResource;
|
|
|
|
ERESOURCE PagingIoResource;
|
|
|
|
/* end FCB header required by ROS/NT */
|
|
|
|
|
|
|
|
/* */
|
2000-12-29 23:17:12 +00:00
|
|
|
FATDirEntry entry;
|
2003-02-13 22:24:19 +00:00
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
/* point on filename (250 chars max) in PathName */
|
2001-08-14 20:47:30 +00:00
|
|
|
WCHAR *ObjectName;
|
2003-02-13 22:24:19 +00:00
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
/* path+filename 260 max */
|
2001-08-14 20:47:30 +00:00
|
|
|
WCHAR PathName[MAX_PATH];
|
2003-02-13 22:24:19 +00:00
|
|
|
|
|
|
|
/* short file name */
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
WCHAR ShortName[14];
|
2003-02-13 22:24:19 +00:00
|
|
|
|
|
|
|
/* */
|
2000-12-29 23:17:12 +00:00
|
|
|
LONG RefCount;
|
2003-02-13 22:24:19 +00:00
|
|
|
|
|
|
|
/* List of FCB's for this volume */
|
2000-12-29 23:17:12 +00:00
|
|
|
LIST_ENTRY FcbListEntry;
|
2003-02-13 22:24:19 +00:00
|
|
|
|
|
|
|
/* pointer to the parent fcb */
|
2000-12-29 23:17:12 +00:00
|
|
|
struct _VFATFCB* parentFcb;
|
2003-02-13 22:24:19 +00:00
|
|
|
|
|
|
|
/* Flags for the fcb */
|
2001-08-14 20:47:30 +00:00
|
|
|
ULONG Flags;
|
2003-02-13 22:24:19 +00:00
|
|
|
|
|
|
|
/* pointer to the file object which has initialized the fcb */
|
2001-10-10 22:20:48 +00:00
|
|
|
PFILE_OBJECT FileObject;
|
2003-02-13 22:24:19 +00:00
|
|
|
|
|
|
|
/* Directory index for the short name entry */
|
2001-10-10 22:20:48 +00:00
|
|
|
ULONG dirIndex;
|
2003-02-13 22:24:19 +00:00
|
|
|
|
|
|
|
/* Directory index where the long name starts */
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
ULONG startIndex;
|
2003-02-13 22:24:19 +00:00
|
|
|
|
|
|
|
/* Share access for the file object */
|
2002-08-14 20:58:39 +00:00
|
|
|
SHARE_ACCESS FCBShareAccess;
|
2003-02-13 22:24:19 +00:00
|
|
|
|
|
|
|
/* Entry into the hash table for the path + long name */
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
HASHENTRY Hash;
|
2003-02-13 22:24:19 +00:00
|
|
|
|
|
|
|
/* Entry into the hash table for the path + short name */
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
HASHENTRY ShortHash;
|
2003-02-13 22:24:19 +00:00
|
|
|
|
|
|
|
/* List of byte-range locks for this file */
|
2003-01-25 15:55:08 +00:00
|
|
|
FILE_LOCK FileLock;
|
2002-01-08 00:49:02 +00:00
|
|
|
|
2002-08-14 20:58:39 +00:00
|
|
|
} VFATFCB, *PVFATFCB;
|
1999-01-04 11:59:25 +00:00
|
|
|
|
1999-12-11 21:14:49 +00:00
|
|
|
typedef struct _VFATCCB
|
1999-01-04 11:59:25 +00:00
|
|
|
{
|
|
|
|
LARGE_INTEGER CurrentByteOffset;
|
2000-12-29 23:17:12 +00:00
|
|
|
/* for DirectoryControl */
|
2002-02-05 21:31:03 +00:00
|
|
|
ULONG Entry;
|
2000-12-29 23:17:12 +00:00
|
|
|
/* for DirectoryControl */
|
2002-02-05 21:31:03 +00:00
|
|
|
PWCHAR DirectorySearchPattern;
|
2001-10-10 22:20:48 +00:00
|
|
|
ULONG LastCluster;
|
|
|
|
ULONG LastOffset;
|
|
|
|
|
2002-08-14 20:58:39 +00:00
|
|
|
} VFATCCB, *PVFATCCB;
|
1998-12-30 18:43:27 +00:00
|
|
|
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
#ifndef TAG
|
2001-07-05 01:51:53 +00:00
|
|
|
#define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
#endif
|
2001-07-05 01:51:53 +00:00
|
|
|
|
|
|
|
#define TAG_CCB TAG('V', 'C', 'C', 'B')
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
#define TAG_FCB TAG('V', 'F', 'C', 'B')
|
|
|
|
#define TAG_IRP TAG('V', 'I', 'R', 'P')
|
1998-12-30 18:43:27 +00:00
|
|
|
|
|
|
|
#define ENTRIES_PER_SECTOR (BLOCKSIZE / sizeof(FATDirEntry))
|
|
|
|
|
1999-05-15 17:25:02 +00:00
|
|
|
typedef struct __DOSTIME
|
|
|
|
{
|
2001-11-02 22:57:14 +00:00
|
|
|
WORD Second:5;
|
1999-05-15 17:25:02 +00:00
|
|
|
WORD Minute:6;
|
|
|
|
WORD Hour:5;
|
2002-03-18 22:37:13 +00:00
|
|
|
}
|
|
|
|
DOSTIME, *PDOSTIME;
|
1999-05-15 17:25:02 +00:00
|
|
|
|
|
|
|
typedef struct __DOSDATE
|
|
|
|
{
|
2001-11-02 22:57:14 +00:00
|
|
|
WORD Day:5;
|
1999-05-15 17:25:02 +00:00
|
|
|
WORD Month:4;
|
|
|
|
WORD Year:5;
|
2002-03-18 22:37:13 +00:00
|
|
|
}
|
|
|
|
DOSDATE, *PDOSDATE;
|
1999-05-15 17:25:02 +00:00
|
|
|
|
2001-11-02 22:57:14 +00:00
|
|
|
#define IRPCONTEXT_CANWAIT 0x0001
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
PIRP Irp;
|
|
|
|
PDEVICE_OBJECT DeviceObject;
|
|
|
|
PDEVICE_EXTENSION DeviceExt;
|
|
|
|
ULONG Flags;
|
|
|
|
WORK_QUEUE_ITEM WorkQueueItem;
|
|
|
|
PIO_STACK_LOCATION Stack;
|
|
|
|
UCHAR MajorFunction;
|
|
|
|
UCHAR MinorFunction;
|
|
|
|
PFILE_OBJECT FileObject;
|
2002-08-14 20:58:39 +00:00
|
|
|
} VFAT_IRP_CONTEXT, *PVFAT_IRP_CONTEXT;
|
2001-11-02 22:57:14 +00:00
|
|
|
|
2002-03-18 22:37:13 +00:00
|
|
|
/* ------------------------------------------------------ shutdown.c */
|
|
|
|
|
|
|
|
NTSTATUS STDCALL VfatShutdown (PDEVICE_OBJECT DeviceObject,
|
|
|
|
PIRP Irp);
|
|
|
|
|
|
|
|
/* -------------------------------------------------------- volume.c */
|
|
|
|
|
|
|
|
NTSTATUS VfatQueryVolumeInformation (PVFAT_IRP_CONTEXT IrpContext);
|
|
|
|
|
|
|
|
NTSTATUS VfatSetVolumeInformation (PVFAT_IRP_CONTEXT IrpContext);
|
|
|
|
|
|
|
|
/* ------------------------------------------------------ blockdev.c */
|
|
|
|
|
2002-06-26 18:36:41 +00:00
|
|
|
NTSTATUS VfatReadDisk(IN PDEVICE_OBJECT pDeviceObject,
|
|
|
|
IN PLARGE_INTEGER ReadOffset,
|
|
|
|
IN ULONG ReadLength,
|
|
|
|
IN PUCHAR Buffer);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2002-06-26 18:36:41 +00:00
|
|
|
NTSTATUS VfatWriteDisk(IN PDEVICE_OBJECT pDeviceObject,
|
|
|
|
IN PLARGE_INTEGER WriteOffset,
|
|
|
|
IN ULONG WriteLength,
|
|
|
|
IN PUCHAR Buffer);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
|
|
|
NTSTATUS VfatBlockDeviceIoControl (IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN ULONG CtlCode,
|
|
|
|
IN PVOID InputBuffer,
|
|
|
|
IN ULONG InputBufferSize,
|
|
|
|
IN OUT PVOID OutputBuffer,
|
|
|
|
IN OUT PULONG pOutputBufferSize);
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------- dir.c */
|
2001-11-02 22:57:14 +00:00
|
|
|
|
|
|
|
NTSTATUS VfatDirectoryControl (PVFAT_IRP_CONTEXT);
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2002-03-18 22:37:13 +00:00
|
|
|
BOOL FsdDosDateTimeToFileTime (WORD wDosDate,
|
|
|
|
WORD wDosTime,
|
2002-09-08 10:23:54 +00:00
|
|
|
TIME *FileTime);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2002-09-08 10:23:54 +00:00
|
|
|
BOOL FsdFileTimeToDosDateTime (TIME *FileTime,
|
2002-03-18 22:37:13 +00:00
|
|
|
WORD *pwDosDate,
|
|
|
|
WORD *pwDosTime);
|
|
|
|
|
|
|
|
/* -------------------------------------------------------- create.c */
|
|
|
|
|
|
|
|
NTSTATUS VfatCreate (PVFAT_IRP_CONTEXT IrpContext);
|
|
|
|
|
|
|
|
NTSTATUS VfatOpenFile (PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PFILE_OBJECT FileObject,
|
|
|
|
PWSTR FileName);
|
|
|
|
|
|
|
|
NTSTATUS FindFile (PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PVFATFCB Fcb,
|
|
|
|
PVFATFCB Parent,
|
|
|
|
PWSTR FileToFind,
|
|
|
|
PULONG pDirIndex,
|
|
|
|
PULONG pDirIndex2);
|
|
|
|
|
2002-12-03 01:14:49 +00:00
|
|
|
VOID vfat8Dot3ToString (PFAT_DIR_ENTRY pEntry,
|
2002-03-18 22:37:13 +00:00
|
|
|
PWSTR pName);
|
|
|
|
|
|
|
|
NTSTATUS ReadVolumeLabel(PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PVPB Vpb);
|
|
|
|
|
|
|
|
BOOLEAN IsDeletedEntry (PVOID Block,
|
|
|
|
ULONG Offset);
|
|
|
|
|
|
|
|
BOOLEAN IsLastEntry (PVOID Block,
|
|
|
|
ULONG Offset);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------- close.c */
|
|
|
|
|
|
|
|
NTSTATUS VfatClose (PVFAT_IRP_CONTEXT IrpContext);
|
|
|
|
|
|
|
|
NTSTATUS VfatCloseFile(PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PFILE_OBJECT FileObject);
|
|
|
|
|
|
|
|
/* ------------------------------------------------------- cleanup.c */
|
|
|
|
|
|
|
|
NTSTATUS VfatCleanup (PVFAT_IRP_CONTEXT IrpContext);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------- fsctl.c */
|
|
|
|
|
|
|
|
NTSTATUS VfatFileSystemControl (PVFAT_IRP_CONTEXT IrpContext);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------- finfo.c */
|
|
|
|
|
|
|
|
NTSTATUS VfatQueryInformation (PVFAT_IRP_CONTEXT IrpContext);
|
|
|
|
|
|
|
|
NTSTATUS VfatSetInformation (PVFAT_IRP_CONTEXT IrpContext);
|
|
|
|
|
2002-08-14 20:58:39 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatSetAllocationSizeInformation(PFILE_OBJECT FileObject,
|
|
|
|
PVFATFCB Fcb,
|
2002-08-17 15:15:50 +00:00
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
2002-08-14 20:58:39 +00:00
|
|
|
PLARGE_INTEGER AllocationSize);
|
|
|
|
|
2002-03-18 22:37:13 +00:00
|
|
|
/* --------------------------------------------------------- iface.c */
|
|
|
|
|
|
|
|
NTSTATUS STDCALL DriverEntry (PDRIVER_OBJECT DriverObject,
|
|
|
|
PUNICODE_STRING RegistryPath);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------- dirwr.c */
|
|
|
|
|
2002-08-14 20:58:39 +00:00
|
|
|
NTSTATUS VfatAddEntry (PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PFILE_OBJECT pFileObject,
|
|
|
|
ULONG RequestedOptions,UCHAR ReqAttr);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2002-08-14 20:58:39 +00:00
|
|
|
NTSTATUS VfatUpdateEntry (PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PFILE_OBJECT pFileObject);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
|
|
|
NTSTATUS delEntry(PDEVICE_EXTENSION,
|
|
|
|
PFILE_OBJECT);
|
|
|
|
|
|
|
|
/* -------------------------------------------------------- string.c */
|
|
|
|
|
|
|
|
BOOLEAN wstrcmpjoki (PWSTR s1,
|
|
|
|
PWSTR s2);
|
|
|
|
|
|
|
|
PWCHAR vfatGetNextPathElement (PWCHAR pFileName);
|
|
|
|
|
|
|
|
VOID vfatWSubString (PWCHAR pTarget,
|
|
|
|
const PWCHAR pSource,
|
|
|
|
size_t pLength);
|
|
|
|
|
2001-05-10 04:02:21 +00:00
|
|
|
BOOL vfatIsFileNameValid (PWCHAR pFileName);
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2002-03-18 22:37:13 +00:00
|
|
|
/* ----------------------------------------------------------- fat.c */
|
|
|
|
|
|
|
|
NTSTATUS OffsetToCluster (PDEVICE_EXTENSION DeviceExt,
|
|
|
|
ULONG FirstCluster,
|
|
|
|
ULONG FileOffset,
|
|
|
|
PULONG Cluster,
|
|
|
|
BOOLEAN Extend);
|
|
|
|
|
2003-01-04 02:07:18 +00:00
|
|
|
ULONGLONG ClusterToSector (PDEVICE_EXTENSION DeviceExt,
|
|
|
|
ULONG Cluster);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
|
|
|
NTSTATUS GetNextCluster (PDEVICE_EXTENSION DeviceExt,
|
|
|
|
ULONG CurrentCluster,
|
|
|
|
PULONG NextCluster,
|
|
|
|
BOOLEAN Extend);
|
|
|
|
|
|
|
|
NTSTATUS CountAvailableClusters (PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PLARGE_INTEGER Clusters);
|
|
|
|
|
|
|
|
/* ------------------------------------------------------ direntry.c */
|
2001-07-05 01:51:53 +00:00
|
|
|
|
|
|
|
ULONG vfatDirEntryGetFirstCluster (PDEVICE_EXTENSION pDeviceExt,
|
|
|
|
PFAT_DIR_ENTRY pDirEntry);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2001-07-05 01:51:53 +00:00
|
|
|
BOOL vfatIsDirEntryDeleted (FATDirEntry * pFatDirEntry);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2001-07-28 07:05:56 +00:00
|
|
|
BOOL vfatIsDirEntryVolume (FATDirEntry * pFatDirEntry);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2001-08-14 20:47:30 +00:00
|
|
|
BOOL vfatIsDirEntryEndMarker (FATDirEntry * pFatDirEntry);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
|
|
|
VOID vfatGetDirEntryName (PFAT_DIR_ENTRY pDirEntry,
|
|
|
|
PWSTR pEntryName);
|
|
|
|
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
NTSTATUS vfatGetNextDirEntry(PVOID * pContext,
|
|
|
|
PVOID * pPage,
|
|
|
|
IN PVFATFCB pDirFcb,
|
|
|
|
IN OUT PULONG pDirIndex,
|
|
|
|
OUT PWSTR pFileName,
|
|
|
|
OUT PFAT_DIR_ENTRY pDirEntry,
|
|
|
|
OUT PULONG pStartIndex);
|
2001-07-05 01:51:53 +00:00
|
|
|
|
2002-03-18 22:37:13 +00:00
|
|
|
/* ----------------------------------------------------------- fcb.c */
|
|
|
|
|
|
|
|
PVFATFCB vfatNewFCB (PWCHAR pFileName);
|
|
|
|
|
|
|
|
VOID vfatDestroyFCB (PVFATFCB pFCB);
|
|
|
|
|
|
|
|
VOID vfatGrabFCB (PDEVICE_EXTENSION pVCB,
|
|
|
|
PVFATFCB pFCB);
|
|
|
|
|
|
|
|
VOID vfatReleaseFCB (PDEVICE_EXTENSION pVCB,
|
|
|
|
PVFATFCB pFCB);
|
|
|
|
|
|
|
|
VOID vfatAddFCBToTable (PDEVICE_EXTENSION pVCB,
|
|
|
|
PVFATFCB pFCB);
|
|
|
|
|
|
|
|
PVFATFCB vfatGrabFCBFromTable (PDEVICE_EXTENSION pDeviceExt,
|
|
|
|
PWSTR pFileName);
|
|
|
|
|
|
|
|
PVFATFCB vfatMakeRootFCB (PDEVICE_EXTENSION pVCB);
|
|
|
|
|
|
|
|
PVFATFCB vfatOpenRootFCB (PDEVICE_EXTENSION pVCB);
|
|
|
|
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
BOOL vfatFCBIsDirectory (PVFATFCB FCB);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
|
|
|
NTSTATUS vfatAttachFCBToFileObject (PDEVICE_EXTENSION vcb,
|
|
|
|
PVFATFCB fcb,
|
|
|
|
PFILE_OBJECT fileObject);
|
|
|
|
|
|
|
|
NTSTATUS vfatDirFindFile (PDEVICE_EXTENSION pVCB,
|
|
|
|
PVFATFCB parentFCB,
|
|
|
|
PWSTR elementName,
|
|
|
|
PVFATFCB * fileFCB);
|
|
|
|
|
|
|
|
NTSTATUS vfatGetFCBForFile (PDEVICE_EXTENSION pVCB,
|
|
|
|
PVFATFCB *pParentFCB,
|
|
|
|
PVFATFCB *pFCB,
|
|
|
|
const PWSTR pFileName);
|
|
|
|
|
|
|
|
NTSTATUS vfatMakeFCBFromDirEntry (PVCB vcb,
|
|
|
|
PVFATFCB directoryFCB,
|
|
|
|
PWSTR longName,
|
|
|
|
PFAT_DIR_ENTRY dirEntry,
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
ULONG startIndex,
|
2002-03-18 22:37:13 +00:00
|
|
|
ULONG dirIndex,
|
|
|
|
PVFATFCB * fileFCB);
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------ rw.c */
|
|
|
|
|
|
|
|
NTSTATUS VfatRead (PVFAT_IRP_CONTEXT IrpContext);
|
|
|
|
|
|
|
|
NTSTATUS VfatWrite (PVFAT_IRP_CONTEXT IrpContext);
|
|
|
|
|
|
|
|
NTSTATUS NextCluster(PDEVICE_EXTENSION DeviceExt,
|
|
|
|
ULONG FirstCluster,
|
|
|
|
PULONG CurrentCluster,
|
|
|
|
BOOLEAN Extend);
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------- misc.c */
|
|
|
|
|
2001-11-02 22:57:14 +00:00
|
|
|
NTSTATUS VfatQueueRequest(PVFAT_IRP_CONTEXT IrpContext);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
|
|
|
PVFAT_IRP_CONTEXT VfatAllocateIrpContext(PDEVICE_OBJECT DeviceObject,
|
|
|
|
PIRP Irp);
|
|
|
|
|
2001-11-02 22:57:14 +00:00
|
|
|
VOID VfatFreeIrpContext(PVFAT_IRP_CONTEXT IrpContext);
|
2001-05-02 03:18:03 +00:00
|
|
|
|
2002-03-18 22:37:13 +00:00
|
|
|
NTSTATUS STDCALL VfatBuildRequest (PDEVICE_OBJECT DeviceObject,
|
|
|
|
PIRP Irp);
|
2002-05-05 20:18:33 +00:00
|
|
|
|
2002-03-18 22:37:13 +00:00
|
|
|
PVOID VfatGetUserBuffer(IN PIRP);
|
|
|
|
|
|
|
|
NTSTATUS VfatLockUserBuffer(IN PIRP, IN ULONG,
|
|
|
|
IN LOCK_OPERATION);
|
2002-05-05 20:18:33 +00:00
|
|
|
|
2002-08-14 20:58:39 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatSetExtendedAttributes(PFILE_OBJECT FileObject,
|
|
|
|
PVOID Ea,
|
|
|
|
ULONG EaLength);
|
2003-02-09 18:02:56 +00:00
|
|
|
/* ------------------------------------------------------------- flush.c */
|
|
|
|
|
|
|
|
NTSTATUS VfatFlush(PVFAT_IRP_CONTEXT IrpContext);
|
|
|
|
|
|
|
|
NTSTATUS VfatFlushVolume(PDEVICE_EXTENSION DeviceExt, PVFATFCB VolumeFcb);
|
|
|
|
|
2002-03-18 22:37:13 +00:00
|
|
|
/* EOF */
|