mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[FASTFAT]
Generalize the usage of functions pointers for FatX vs Fat specific code (direntry). This should also help speeding up FastFAT. svn path=/trunk/; revision=73822
This commit is contained in:
parent
41f23cace3
commit
1f58ae3a5d
8 changed files with 86 additions and 87 deletions
|
@ -85,7 +85,7 @@ VfatCleanupFile(
|
|||
pFcb->OpenHandleCount == 0)
|
||||
{
|
||||
if (vfatFCBIsDirectory(pFcb) &&
|
||||
!VfatIsDirectoryEmpty(pFcb, vfatVolumeIsFatX(DeviceExt)))
|
||||
!VfatIsDirectoryEmpty(DeviceExt, pFcb))
|
||||
{
|
||||
pFcb->Flags &= ~FCB_DELETE_PENDING;
|
||||
}
|
||||
|
|
|
@ -296,7 +296,7 @@ FindFile(
|
|||
|
||||
while (TRUE)
|
||||
{
|
||||
Status = DeviceExt->GetNextDirEntry(&Context, &Page, Parent, DirContext, First);
|
||||
Status = VfatGetNextDirEntry(DeviceExt, &Context, &Page, Parent, DirContext, First);
|
||||
First = FALSE;
|
||||
if (Status == STATUS_NO_MORE_ENTRIES)
|
||||
{
|
||||
|
|
|
@ -39,7 +39,6 @@ vfatDirEntryGetFirstCluster(
|
|||
return cluster;
|
||||
}
|
||||
|
||||
static
|
||||
BOOLEAN
|
||||
FATIsDirectoryEmpty(
|
||||
PVFATFCB Fcb)
|
||||
|
@ -108,7 +107,6 @@ FATIsDirectoryEmpty(
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static
|
||||
BOOLEAN
|
||||
FATXIsDirectoryEmpty(
|
||||
PVFATFCB Fcb)
|
||||
|
@ -168,17 +166,6 @@ FATXIsDirectoryEmpty(
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
VfatIsDirectoryEmpty(
|
||||
PVFATFCB Fcb,
|
||||
BOOLEAN IsFatX)
|
||||
{
|
||||
if (IsFatX)
|
||||
return FATXIsDirectoryEmpty(Fcb);
|
||||
else
|
||||
return FATIsDirectoryEmpty(Fcb);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
FATGetNextDirEntry(
|
||||
PVOID *pContext,
|
||||
|
|
|
@ -815,22 +815,6 @@ FATXAddEntry(
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
VfatAddEntry(
|
||||
IN PDEVICE_EXTENSION DeviceExt,
|
||||
IN PUNICODE_STRING NameU,
|
||||
IN PVFATFCB *Fcb,
|
||||
IN PVFATFCB ParentFcb,
|
||||
IN ULONG RequestedOptions,
|
||||
IN UCHAR ReqAttr,
|
||||
IN PVFAT_MOVE_CONTEXT MoveContext)
|
||||
{
|
||||
if (vfatVolumeIsFatX(DeviceExt))
|
||||
return FATXAddEntry(DeviceExt, NameU, Fcb, ParentFcb, RequestedOptions, ReqAttr, MoveContext);
|
||||
else
|
||||
return FATAddEntry(DeviceExt, NameU, Fcb, ParentFcb, RequestedOptions, ReqAttr, MoveContext);
|
||||
}
|
||||
|
||||
/*
|
||||
* deleting an existing FAT entry
|
||||
*/
|
||||
|
@ -978,18 +962,6 @@ FATXDelEntry(
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
VfatDelEntry(
|
||||
IN PDEVICE_EXTENSION DeviceExt,
|
||||
IN PVFATFCB pFcb,
|
||||
OUT PVFAT_MOVE_CONTEXT MoveContext)
|
||||
{
|
||||
if (vfatVolumeIsFatX(DeviceExt))
|
||||
return FATXDelEntry(DeviceExt, pFcb, MoveContext);
|
||||
else
|
||||
return FATDelEntry(DeviceExt, pFcb, MoveContext);
|
||||
}
|
||||
|
||||
/*
|
||||
* move an existing FAT entry
|
||||
*/
|
||||
|
@ -1031,4 +1003,23 @@ VfatMoveEntry(
|
|||
return Status;
|
||||
}
|
||||
|
||||
extern BOOLEAN FATXIsDirectoryEmpty(PVFATFCB Fcb);
|
||||
extern BOOLEAN FATIsDirectoryEmpty(PVFATFCB Fcb);
|
||||
extern NTSTATUS FATGetNextDirEntry(PVOID *pContext, PVOID *pPage, PVFATFCB pDirFcb, PVFAT_DIRENTRY_CONTEXT DirContext, BOOLEAN First);
|
||||
extern NTSTATUS FATXGetNextDirEntry(PVOID *pContext, PVOID *pPage, PVFATFCB pDirFcb, PVFAT_DIRENTRY_CONTEXT DirContext, BOOLEAN First);
|
||||
|
||||
VFAT_DISPATCH FatXDispatch = {
|
||||
.IsDirectoryEmpty = FATXIsDirectoryEmpty,
|
||||
.AddEntry = FATXAddEntry,
|
||||
.DelEntry = FATXDelEntry,
|
||||
.GetNextDirEntry = FATXGetNextDirEntry,
|
||||
};
|
||||
|
||||
VFAT_DISPATCH FatDispatch = {
|
||||
.IsDirectoryEmpty = FATIsDirectoryEmpty,
|
||||
.AddEntry = FATAddEntry,
|
||||
.DelEntry = FATDelEntry,
|
||||
.GetNextDirEntry = FATGetNextDirEntry,
|
||||
};
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -797,7 +797,8 @@ vfatDirFindFile(
|
|||
|
||||
while (TRUE)
|
||||
{
|
||||
status = pDeviceExt->GetNextDirEntry(&Context,
|
||||
status = VfatGetNextDirEntry(pDeviceExt,
|
||||
&Context,
|
||||
&Page,
|
||||
pDirectoryFCB,
|
||||
&DirContext,
|
||||
|
|
|
@ -357,7 +357,7 @@ VfatSetDispositionInformation(
|
|||
return STATUS_CANNOT_DELETE;
|
||||
}
|
||||
|
||||
if (vfatFCBIsDirectory(FCB) && !VfatIsDirectoryEmpty(FCB, vfatVolumeIsFatX(DeviceExt)))
|
||||
if (vfatFCBIsDirectory(FCB) && !VfatIsDirectoryEmpty(DeviceExt, FCB))
|
||||
{
|
||||
/* can't delete a non-empty directory */
|
||||
|
||||
|
|
|
@ -30,6 +30,9 @@
|
|||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
extern VFAT_DISPATCH FatXDispatch;
|
||||
extern VFAT_DISPATCH FatDispatch;
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
#define CACHEPAGESIZE(pDeviceExt) ((pDeviceExt)->FatInfo.BytesPerCluster > PAGE_SIZE ? \
|
||||
|
@ -465,13 +468,13 @@ VfatMount(
|
|||
DeviceExt->FatInfo.FatType == FATX32)
|
||||
{
|
||||
DeviceExt->Flags |= VCB_IS_FATX;
|
||||
DeviceExt->GetNextDirEntry = FATXGetNextDirEntry;
|
||||
DeviceExt->BaseDateYear = 2000;
|
||||
RtlCopyMemory(&DeviceExt->Dispatch, &FatXDispatch, sizeof(VFAT_DISPATCH));
|
||||
}
|
||||
else
|
||||
{
|
||||
DeviceExt->GetNextDirEntry = FATGetNextDirEntry;
|
||||
DeviceExt->BaseDateYear = 1980;
|
||||
RtlCopyMemory(&DeviceExt->Dispatch, &FatDispatch, sizeof(VFAT_DISPATCH));
|
||||
}
|
||||
|
||||
DeviceExt->StorageDevice = DeviceToMount;
|
||||
|
|
|
@ -260,6 +260,7 @@ typedef struct
|
|||
|
||||
struct _VFATFCB;
|
||||
struct _VFAT_DIRENTRY_CONTEXT;
|
||||
struct _VFAT_MOVE_CONTEXT;
|
||||
|
||||
typedef struct _HASHENTRY
|
||||
{
|
||||
|
@ -275,8 +276,19 @@ typedef NTSTATUS (*PGET_NEXT_CLUSTER)(PDEVICE_EXTENSION,ULONG,PULONG);
|
|||
typedef NTSTATUS (*PFIND_AND_MARK_AVAILABLE_CLUSTER)(PDEVICE_EXTENSION,PULONG);
|
||||
typedef NTSTATUS (*PWRITE_CLUSTER)(PDEVICE_EXTENSION,ULONG,ULONG,PULONG);
|
||||
|
||||
typedef BOOLEAN (*PIS_DIRECTORY_EMPTY)(struct _VFATFCB*);
|
||||
typedef NTSTATUS (*PADD_ENTRY)(PDEVICE_EXTENSION,PUNICODE_STRING,struct _VFATFCB**,struct _VFATFCB*,ULONG,UCHAR,struct _VFAT_MOVE_CONTEXT*);
|
||||
typedef NTSTATUS (*PDEL_ENTRY)(PDEVICE_EXTENSION,struct _VFATFCB*,struct _VFAT_MOVE_CONTEXT*);
|
||||
typedef NTSTATUS (*PGET_NEXT_DIR_ENTRY)(PVOID*,PVOID*,struct _VFATFCB*,struct _VFAT_DIRENTRY_CONTEXT*,BOOLEAN);
|
||||
|
||||
typedef struct _VFAT_DISPATCH
|
||||
{
|
||||
PIS_DIRECTORY_EMPTY IsDirectoryEmpty;
|
||||
PADD_ENTRY AddEntry;
|
||||
PDEL_ENTRY DelEntry;
|
||||
PGET_NEXT_DIR_ENTRY GetNextDirEntry;
|
||||
} VFAT_DISPATCH, *PVFAT_DISPATCH;
|
||||
|
||||
typedef struct DEVICE_EXTENSION
|
||||
{
|
||||
ERESOURCE DirResource;
|
||||
|
@ -303,9 +315,6 @@ typedef struct DEVICE_EXTENSION
|
|||
PWRITE_CLUSTER WriteCluster;
|
||||
ULONG CleanShutBitMask;
|
||||
|
||||
/* Pointers to functions for manipulating directory entries. */
|
||||
PGET_NEXT_DIR_ENTRY GetNextDirEntry;
|
||||
|
||||
ULONG BaseDateYear;
|
||||
|
||||
LIST_ENTRY VolumeListEntry;
|
||||
|
@ -320,8 +329,53 @@ typedef struct DEVICE_EXTENSION
|
|||
/* VPBs for dismount */
|
||||
PVPB IoVPB;
|
||||
PVPB SpareVPB;
|
||||
|
||||
/* Pointers to functions for manipulating directory entries. */
|
||||
VFAT_DISPATCH Dispatch;
|
||||
} DEVICE_EXTENSION, VCB, *PVCB;
|
||||
|
||||
FORCEINLINE
|
||||
BOOLEAN
|
||||
VfatIsDirectoryEmpty(PDEVICE_EXTENSION DeviceExt,
|
||||
struct _VFATFCB* Fcb)
|
||||
{
|
||||
return DeviceExt->Dispatch.IsDirectoryEmpty(Fcb);
|
||||
}
|
||||
|
||||
FORCEINLINE
|
||||
NTSTATUS
|
||||
VfatAddEntry(PDEVICE_EXTENSION DeviceExt,
|
||||
PUNICODE_STRING NameU,
|
||||
struct _VFATFCB** Fcb,
|
||||
struct _VFATFCB* ParentFcb,
|
||||
ULONG RequestedOptions,
|
||||
UCHAR ReqAttr,
|
||||
struct _VFAT_MOVE_CONTEXT* MoveContext)
|
||||
{
|
||||
return DeviceExt->Dispatch.AddEntry(DeviceExt, NameU, Fcb, ParentFcb, RequestedOptions, ReqAttr, MoveContext);
|
||||
}
|
||||
|
||||
FORCEINLINE
|
||||
NTSTATUS
|
||||
VfatDelEntry(PDEVICE_EXTENSION DeviceExt,
|
||||
struct _VFATFCB* Fcb,
|
||||
struct _VFAT_MOVE_CONTEXT* MoveContext)
|
||||
{
|
||||
return DeviceExt->Dispatch.DelEntry(DeviceExt, Fcb, MoveContext);
|
||||
}
|
||||
|
||||
FORCEINLINE
|
||||
NTSTATUS
|
||||
VfatGetNextDirEntry(PDEVICE_EXTENSION DeviceExt,
|
||||
PVOID *pContext,
|
||||
PVOID *pPage,
|
||||
struct _VFATFCB* pDirFcb,
|
||||
struct _VFAT_DIRENTRY_CONTEXT* DirContext,
|
||||
BOOLEAN First)
|
||||
{
|
||||
return DeviceExt->Dispatch.GetNextDirEntry(pContext, pPage, pDirFcb, DirContext, First);
|
||||
}
|
||||
|
||||
#define VFAT_BREAK_ON_CORRUPTION 1
|
||||
|
||||
typedef struct
|
||||
|
@ -640,50 +694,13 @@ vfatDirEntryGetFirstCluster(
|
|||
PDEVICE_EXTENSION pDeviceExt,
|
||||
PDIR_ENTRY pDirEntry);
|
||||
|
||||
BOOLEAN
|
||||
VfatIsDirectoryEmpty(
|
||||
PVFATFCB Fcb,
|
||||
BOOLEAN IsFatX);
|
||||
|
||||
NTSTATUS
|
||||
FATGetNextDirEntry(
|
||||
PVOID *pContext,
|
||||
PVOID *pPage,
|
||||
IN PVFATFCB pDirFcb,
|
||||
IN PVFAT_DIRENTRY_CONTEXT DirContext,
|
||||
BOOLEAN First);
|
||||
|
||||
NTSTATUS
|
||||
FATXGetNextDirEntry(
|
||||
PVOID *pContext,
|
||||
PVOID *pPage,
|
||||
IN PVFATFCB pDirFcb,
|
||||
IN PVFAT_DIRENTRY_CONTEXT DirContext,
|
||||
BOOLEAN First);
|
||||
|
||||
/* dirwr.c */
|
||||
|
||||
NTSTATUS
|
||||
VfatAddEntry(
|
||||
PDEVICE_EXTENSION DeviceExt,
|
||||
PUNICODE_STRING PathNameU,
|
||||
PVFATFCB* Fcb,
|
||||
PVFATFCB ParentFcb,
|
||||
ULONG RequestedOptions,
|
||||
UCHAR ReqAttr,
|
||||
PVFAT_MOVE_CONTEXT MoveContext);
|
||||
|
||||
NTSTATUS
|
||||
VfatUpdateEntry(
|
||||
PVFATFCB pFcb,
|
||||
IN BOOLEAN IsFatX);
|
||||
|
||||
NTSTATUS
|
||||
VfatDelEntry(
|
||||
PDEVICE_EXTENSION,
|
||||
PVFATFCB,
|
||||
PVFAT_MOVE_CONTEXT);
|
||||
|
||||
BOOLEAN
|
||||
vfatFindDirSpace(
|
||||
PDEVICE_EXTENSION DeviceExt,
|
||||
|
|
Loading…
Reference in a new issue