[ros-diffs] [fireball] 43222: [fastfat_new] - Start integrating FullFAT library. - Current state is that it's able to mount a FAT volume.

fireball at svn.reactos.org fireball at svn.reactos.org
Tue Sep 29 12:08:43 CEST 2009


Author: fireball
Date: Tue Sep 29 12:08:43 2009
New Revision: 43222

URL: http://svn.reactos.org/svn/reactos?rev=43222&view=rev
Log:
[fastfat_new]
- Start integrating FullFAT library.
- Current state is that it's able to mount a FAT volume.

Added:
    trunk/reactos/drivers/filesystems/fastfat_new/fullfat.c   (with props)
Modified:
    trunk/reactos/drivers/filesystems/fastfat_new/fastfat.h
    trunk/reactos/drivers/filesystems/fastfat_new/fastfat.rbuild
    trunk/reactos/drivers/filesystems/fastfat_new/fatstruc.h
    trunk/reactos/drivers/filesystems/fastfat_new/fcb.c
    trunk/reactos/drivers/filesystems/fastfat_new/fsctl.c

Modified: trunk/reactos/drivers/filesystems/fastfat_new/fastfat.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat_new/fastfat.h?rev=43222&r1=43221&r2=43222&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat_new/fastfat.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat_new/fastfat.h [iso-8859-1] Tue Sep 29 12:08:43 2009
@@ -2,6 +2,8 @@
 #include <ntdddisk.h>
 #include <debug.h>
 #include <pseh/pseh2.h>
+
+#include "fullfat.h"
 
 #include <fat.h>
 #include <fatstruc.h>
@@ -150,6 +152,14 @@
                     OUT PVCB *Vcb,
                     OUT PFCB *FcbOrDcb,
                     OUT PCCB *Ccb);
+
+/* --------------------------------------------------------- fullfat.c */
+
+FF_T_SINT32
+FatWriteBlocks(FF_T_UINT8 *pBuffer, FF_T_UINT32 SectorAddress, FF_T_UINT32 Count, void *pParam);
+
+FF_T_SINT32
+FatReadBlocks(FF_T_UINT8 *pBuffer, FF_T_UINT32 SectorAddress, FF_T_UINT32 Count, void *pParam);
 
 /* ---------------------------------------------------------  lock.c */
 

Modified: trunk/reactos/drivers/filesystems/fastfat_new/fastfat.rbuild
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat_new/fastfat.rbuild?rev=43222&r1=43221&r2=43222&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat_new/fastfat.rbuild [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat_new/fastfat.rbuild [iso-8859-1] Tue Sep 29 12:08:43 2009
@@ -3,9 +3,11 @@
 <module name="fastfatn" type="kernelmodedriver" installbase="system32/drivers" installname="fastfatn.sys">
 	<bootstrap installbase="$(CDOUTPUT)" />
 	<include base="fastfatn">.</include>
+	<include base="ReactOS">include/reactos/libs/fullfat</include>
 	<library>ntoskrnl</library>
 	<library>hal</library>
 	<library>pseh</library>
+	<library>fullfat</library>
 	<file>blockdev.c</file>
 	<file>cleanup.c</file>
 	<file>close.c</file>
@@ -21,6 +23,7 @@
 	<file>finfo.c</file>
 	<file>flush.c</file>
 	<file>fsctl.c</file>
+	<file>fullfat.c</file>
 	<file>lock.c</file>
 	<file>rw.c</file>
 	<file>shutdown.c</file>

Modified: trunk/reactos/drivers/filesystems/fastfat_new/fatstruc.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat_new/fatstruc.h?rev=43222&r1=43221&r2=43222&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat_new/fatstruc.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat_new/fatstruc.h [iso-8859-1] Tue Sep 29 12:08:43 2009
@@ -35,6 +35,10 @@
     BOOLEAN Win31FileSystem;
     /* Jan 1, 1980 System Time */
     LARGE_INTEGER DefaultFileTime;
+
+    /* FullFAT integration */
+    FF_IOMAN *Ioman;
+    FF_ERROR FF_Error;
 } FAT_GLOBAL_DATA;
 
 typedef struct _FAT_PAGE_CONTEXT
@@ -175,6 +179,9 @@
     struct _FCB *RootDcb;
 
     ULONG MediaChangeCount;
+
+    /* FullFAT integration */
+    FF_IOMAN *Ioman;
 } VCB, *PVCB;
 
 #define VcbToVolumeDeviceObject(xVcb) \

Modified: trunk/reactos/drivers/filesystems/fastfat_new/fcb.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat_new/fcb.c?rev=43222&r1=43221&r2=43222&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat_new/fcb.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat_new/fcb.c [iso-8859-1] Tue Sep 29 12:08:43 2009
@@ -12,7 +12,7 @@
 #include "fastfat.h"
 
 /* FUNCTIONS ****************************************************************/
-
+#if 0
 /**
  * Locates FCB by the supplied name in the cache trie of fcbs.
  *
@@ -325,4 +325,5 @@
         &Context.ShortName, &LongFileName);
     return Status;
 }
+#endif
 /* EOF */

Modified: trunk/reactos/drivers/filesystems/fastfat_new/fsctl.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat_new/fsctl.c?rev=43222&r1=43221&r2=43222&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat_new/fsctl.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat_new/fsctl.c [iso-8859-1] Tue Sep 29 12:08:43 2009
@@ -58,6 +58,8 @@
     DISK_GEOMETRY DiskGeometry;
     ULONG MediaChangeCount = 0;
     PVOLUME_DEVICE_OBJECT VolumeDevice;
+    VCB *Vcb;
+    FF_ERROR Error;
 
     DPRINT1("FatMountVolume()\n");
 
@@ -81,6 +83,9 @@
     /* Remove unmounted VCBs */
     FatiCleanVcbs(IrpContext);
 
+    /* Acquire the global exclusive lock */
+    FatAcquireExclusiveGlobal(IrpContext);
+
     /* Create a new volume device object */
     Status = IoCreateDevice(FatGlobalData.DriverObject,
                             sizeof(VOLUME_DEVICE_OBJECT) - sizeof(DEVICE_OBJECT),
@@ -90,7 +95,13 @@
                             FALSE,
                             (PDEVICE_OBJECT *)&VolumeDevice);
 
-    if (!NT_SUCCESS(Status)) return Status;
+    if (!NT_SUCCESS(Status))
+    {
+        /* Release the global lock */
+        FatReleaseGlobal(IrpContext);
+
+        return Status;
+    }
 
     /* Match alignment requirements */
     if (TargetDeviceObject->AlignmentRequirement > VolumeDevice->DeviceObject.AlignmentRequirement)
@@ -124,14 +135,53 @@
     Status = FatInitializeVcb(IrpContext, &VolumeDevice->Vcb, TargetDeviceObject, Vpb);
     if (!NT_SUCCESS(Status)) goto FatMountVolumeCleanup;
 
+    Vcb = &VolumeDevice->Vcb;
+
+    /* Initialize FullFAT library */
+    Vcb->Ioman = FF_CreateIOMAN(NULL,
+                                8192,
+                                VolumeDevice->DeviceObject.SectorSize,
+                                &Error);
+
+    ASSERT(Vcb->Ioman);
+
+    /* Register block device read/write functions */
+    Error = FF_RegisterBlkDevice(Vcb->Ioman,
+                                 VolumeDevice->DeviceObject.SectorSize,
+                                 (FF_WRITE_BLOCKS)FatWriteBlocks,
+                                 (FF_READ_BLOCKS)FatReadBlocks,
+                                 Vcb);
+
+    if (Error)
+    {
+        DPRINT1("Registering block device with FullFAT failed with error %d\n", Error);
+        FF_DestroyIOMAN(Vcb->Ioman);
+        goto FatMountVolumeCleanup;
+    }
+
+    /* Mount the volume using FullFAT */
+    if(FF_MountPartition(Vcb->Ioman, 0))
+    {
+        DPRINT1("Partition mounting failed\n");
+        FF_DestroyIOMAN(Vcb->Ioman);
+        goto FatMountVolumeCleanup;
+    }
+
+    // TODO: Read BPB and store it in Vcb->Bpb
+
     /* Create root DCB for it */
     FatCreateRootDcb(IrpContext, &VolumeDevice->Vcb);
 
     /* Keep trace of media changes */
     VolumeDevice->Vcb.MediaChangeCount = MediaChangeCount;
 
+    //ObDereferenceObject(TargetDeviceObject);
+
+    /* Release the global lock */
+    FatReleaseGlobal(IrpContext);
+
     /* Notify about volume mount */
-    FsRtlNotifyVolumeEvent(VolumeDevice->Vcb.StreamFileObject, FSRTL_VOLUME_MOUNT);
+    //FsRtlNotifyVolumeEvent(VolumeDevice->Vcb.StreamFileObject, FSRTL_VOLUME_MOUNT);
 
     /* Return success */
     return STATUS_SUCCESS;
@@ -141,6 +191,10 @@
 
     /* Unwind the routine actions */
     IoDeleteDevice((PDEVICE_OBJECT)VolumeDevice);
+
+    /* Release the global lock */
+    FatReleaseGlobal(IrpContext);
+
     return Status;
 }
 

Added: trunk/reactos/drivers/filesystems/fastfat_new/fullfat.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat_new/fullfat.c?rev=43222&view=auto
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat_new/fullfat.c (added)
+++ trunk/reactos/drivers/filesystems/fastfat_new/fullfat.c [iso-8859-1] Tue Sep 29 12:08:43 2009
@@ -1,0 +1,75 @@
+/*
+ * PROJECT:         ReactOS FAT file system driver
+ * LICENSE:         GPL - See COPYING in the top level directory
+ * FILE:            drivers/filesystems/fastfat/fullfat.c
+ * PURPOSE:         FullFAT integration routines
+ * PROGRAMMERS:     Aleksey Bragin (aleksey at reactos.org)
+ */
+
+/* INCLUDES *****************************************************************/
+
+#define NDEBUG
+#include "fastfat.h"
+
+/* GLOBALS ******************************************************************/
+
+#define TAG_FULLFAT 'FLUF'
+
+/* FUNCTIONS ****************************************************************/
+
+VOID *
+FF_Malloc(FF_T_UINT32 allocSize)
+{
+    return ExAllocatePoolWithTag(PagedPool, allocSize, TAG_FULLFAT);
+}
+
+VOID
+FF_Free(VOID *pBuffer)
+{
+    return ExFreePoolWithTag(pBuffer, TAG_FULLFAT);
+}
+
+FF_T_SINT32
+FatWriteBlocks(FF_T_UINT8 *pBuffer, FF_T_UINT32 SectorAddress, FF_T_UINT32 Count, void *pParam)
+{
+    DPRINT1("FatWriteBlocks %p %d %d %p\n", pBuffer, SectorAddress, Count, pParam);
+
+    return 0;
+}
+
+FF_T_SINT32
+FatReadBlocks(FF_T_UINT8 *DestBuffer, FF_T_UINT32 SectorAddress, FF_T_UINT32 Count, void *pParam)
+{
+    LARGE_INTEGER Offset;
+    PVOID Buffer;
+    PVCB Vcb = (PVCB)pParam;
+    PBCB Bcb;
+    ULONG SectorSize = 512; // FIXME: hardcoding 512 is bad
+
+    DPRINT1("FatReadBlocks %p %d %d %p\n", DestBuffer, SectorAddress, Count, pParam);
+
+    /* Calculate the offset */
+    Offset.QuadPart = Int32x32To64(SectorAddress, SectorSize);
+
+    if (!CcMapData(Vcb->StreamFileObject,
+                  &Offset,
+                  Count * SectorSize,
+                  TRUE,
+                  &Bcb,
+                  &Buffer))
+    {
+        /* Mapping failed */
+        return 0;
+    }
+
+    /* Copy data to the buffer */
+    RtlCopyMemory(DestBuffer, Buffer, Count * SectorSize);
+
+    /* Unpin unneeded data */
+    CcUnpinData(Bcb);
+
+    /* Return amount of read data in sectors */
+    return Count;
+}
+
+/* EOF */

Propchange: trunk/reactos/drivers/filesystems/fastfat_new/fullfat.c
------------------------------------------------------------------------------
    svn:eol-style = native




More information about the Ros-diffs mailing list