Author: pschweitzer
Date: Fri Feb 17 22:25:03 2017
New Revision: 73822

URL: http://svn.reactos.org/svn/reactos?rev=73822&view=rev
Log:
[FASTFAT]
Generalize the usage of functions pointers for FatX vs Fat specific code 
(direntry).
This should also help speeding up FastFAT.

Modified:
    trunk/reactos/drivers/filesystems/fastfat/cleanup.c
    trunk/reactos/drivers/filesystems/fastfat/create.c
    trunk/reactos/drivers/filesystems/fastfat/direntry.c
    trunk/reactos/drivers/filesystems/fastfat/dirwr.c
    trunk/reactos/drivers/filesystems/fastfat/fcb.c
    trunk/reactos/drivers/filesystems/fastfat/finfo.c
    trunk/reactos/drivers/filesystems/fastfat/fsctl.c
    trunk/reactos/drivers/filesystems/fastfat/vfat.h

Modified: trunk/reactos/drivers/filesystems/fastfat/cleanup.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat/cleanup.c?rev=73822&r1=73821&r2=73822&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/cleanup.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/cleanup.c [iso-8859-1] Fri Feb 17 
22:25:03 2017
@@ -85,7 +85,7 @@
             pFcb->OpenHandleCount == 0)
         {
             if (vfatFCBIsDirectory(pFcb) &&
-                !VfatIsDirectoryEmpty(pFcb, vfatVolumeIsFatX(DeviceExt)))
+                !VfatIsDirectoryEmpty(DeviceExt, pFcb))
             {
                 pFcb->Flags &= ~FCB_DELETE_PENDING;
             }

Modified: trunk/reactos/drivers/filesystems/fastfat/create.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat/create.c?rev=73822&r1=73821&r2=73822&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/create.c  [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/create.c  [iso-8859-1] Fri Feb 17 
22:25:03 2017
@@ -296,7 +296,7 @@
 
     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)
         {

Modified: trunk/reactos/drivers/filesystems/fastfat/direntry.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat/direntry.c?rev=73822&r1=73821&r2=73822&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/direntry.c        [iso-8859-1] 
(original)
+++ trunk/reactos/drivers/filesystems/fastfat/direntry.c        [iso-8859-1] 
Fri Feb 17 22:25:03 2017
@@ -39,7 +39,6 @@
     return  cluster;
 }
 
-static
 BOOLEAN
 FATIsDirectoryEmpty(
     PVFATFCB Fcb)
@@ -108,7 +107,6 @@
     return TRUE;
 }
 
-static
 BOOLEAN
 FATXIsDirectoryEmpty(
     PVFATFCB Fcb)
@@ -166,17 +164,6 @@
     }
 
     return TRUE;
-}
-
-BOOLEAN
-VfatIsDirectoryEmpty(
-    PVFATFCB Fcb,
-    BOOLEAN IsFatX)
-{
-    if (IsFatX)
-        return FATXIsDirectoryEmpty(Fcb);
-    else
-        return FATIsDirectoryEmpty(Fcb);
 }
 
 NTSTATUS

Modified: trunk/reactos/drivers/filesystems/fastfat/dirwr.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat/dirwr.c?rev=73822&r1=73821&r2=73822&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/dirwr.c   [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/dirwr.c   [iso-8859-1] Fri Feb 17 
22:25:03 2017
@@ -815,22 +815,6 @@
     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 @@
     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 @@
     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 */

Modified: trunk/reactos/drivers/filesystems/fastfat/fcb.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat/fcb.c?rev=73822&r1=73821&r2=73822&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/fcb.c     [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/fcb.c     [iso-8859-1] Fri Feb 17 
22:25:03 2017
@@ -797,7 +797,8 @@
 
     while (TRUE)
     {
-        status = pDeviceExt->GetNextDirEntry(&Context,
+        status = VfatGetNextDirEntry(pDeviceExt,
+            &Context,
             &Page,
             pDirectoryFCB,
             &DirContext,

Modified: trunk/reactos/drivers/filesystems/fastfat/finfo.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat/finfo.c?rev=73822&r1=73821&r2=73822&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/finfo.c   [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/finfo.c   [iso-8859-1] Fri Feb 17 
22:25:03 2017
@@ -357,7 +357,7 @@
         return STATUS_CANNOT_DELETE;
     }
 
-    if (vfatFCBIsDirectory(FCB) && !VfatIsDirectoryEmpty(FCB, 
vfatVolumeIsFatX(DeviceExt)))
+    if (vfatFCBIsDirectory(FCB) && !VfatIsDirectoryEmpty(DeviceExt, FCB))
     {
         /* can't delete a non-empty directory */
 

Modified: trunk/reactos/drivers/filesystems/fastfat/fsctl.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat/fsctl.c?rev=73822&r1=73821&r2=73822&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/fsctl.c   [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/fsctl.c   [iso-8859-1] Fri Feb 17 
22:25:03 2017
@@ -29,6 +29,9 @@
 
 #define NDEBUG
 #include <debug.h>
+
+extern VFAT_DISPATCH FatXDispatch;
+extern VFAT_DISPATCH FatDispatch;
 
 /* FUNCTIONS ****************************************************************/
 
@@ -465,13 +468,13 @@
         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;

Modified: trunk/reactos/drivers/filesystems/fastfat/vfat.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat/vfat.h?rev=73822&r1=73821&r2=73822&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/vfat.h    [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/vfat.h    [iso-8859-1] Fri Feb 17 
22:25:03 2017
@@ -260,6 +260,7 @@
 
 struct _VFATFCB;
 struct _VFAT_DIRENTRY_CONTEXT;
+struct _VFAT_MOVE_CONTEXT;
 
 typedef struct _HASHENTRY
 {
@@ -275,7 +276,18 @@
 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
 {
@@ -303,9 +315,6 @@
     PWRITE_CLUSTER WriteCluster;
     ULONG CleanShutBitMask;
 
-    /* Pointers to functions for manipulating directory entries. */
-    PGET_NEXT_DIR_ENTRY GetNextDirEntry;
-
     ULONG BaseDateYear;
 
     LIST_ENTRY VolumeListEntry;
@@ -320,7 +329,52 @@
     /* 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
 
@@ -640,49 +694,12 @@
     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(


Reply via email to