[fastfat_new]
authorAleksey Bragin <aleksey@reactos.org>
Thu, 1 Oct 2009 16:08:11 +0000 (16:08 +0000)
committerAleksey Bragin <aleksey@reactos.org>
Thu, 1 Oct 2009 16:08:11 +0000 (16:08 +0000)
- Implement simple read support.
- Rewrite FatMapUserBuffer, no exception raising necessary at this stage.
- Silence FatReadBlocks dbgprint.

svn path=/trunk/; revision=43250

reactos/drivers/filesystems/fastfat_new/blockdev.c
reactos/drivers/filesystems/fastfat_new/fastfat.c
reactos/drivers/filesystems/fastfat_new/fastfat.h
reactos/drivers/filesystems/fastfat_new/fullfat.c
reactos/drivers/filesystems/fastfat_new/rw.c

index c91ae3a..8e1d0fb 100644 (file)
@@ -56,30 +56,6 @@ FatDiskIoControl_(
     return Status;
 }
 
-PVOID
-FatMapUserBuffer(
-    IN OUT PIRP Irp)
-/*
- * FUNCTION:
- *      
- *      
- * ARGUMENTS:
- *      IrpContext = Pointer to FCB structure for the file.
- *      Irp = Pointer to the IRP structure
- * RETURNS: Status Value.
- * NOTES:
- */
-{
-    PVOID Address;
-
-    if (Irp->MdlAddress == NULL)
-        return Irp->UserBuffer;
-    Address = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);
-    if (Address == NULL)
-        ExRaiseStatus( STATUS_INVALID_USER_BUFFER );
-    return Address;
-}
-
 NTSTATUS
 FatLockUserBuffer (
     IN PFAT_IRP_CONTEXT IrpContext,
index f1bb21d..db45392 100644 (file)
@@ -394,5 +394,14 @@ FatReleaseVcb(IN PFAT_IRP_CONTEXT IrpContext,
     ExReleaseResourceLite(&Vcb->Resource);
 }
 
+PVOID
+FASTCALL
+FatMapUserBuffer(PIRP Irp)
+{
+    if (!Irp->MdlAddress)
+        return Irp->UserBuffer;
+    else
+        return MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);
+}
 
 /* EOF */
index fdc7c87..2c2a6b6 100644 (file)
@@ -65,10 +65,6 @@ FatPerformVirtualNonCachedIo(
     IN PLARGE_INTEGER Offset,
     IN SIZE_T Length);
 
-PVOID
-FatMapUserBuffer(
-    IN OUT PIRP Irp);
-
 /*  -----------------------------------------------------------  dir.c  */
 
 NTSTATUS NTAPI
@@ -159,6 +155,9 @@ FatSetFileObject(PFILE_OBJECT FileObject,
                  PVOID Fcb,
                  PCCB Ccb);
 
+PVOID FASTCALL
+FatMapUserBuffer(PIRP Irp);
+
 /* --------------------------------------------------------- fullfat.c */
 
 FF_T_SINT32
index cb1b835..fdbd2a6 100644 (file)
@@ -46,7 +46,7 @@ FatReadBlocks(FF_T_UINT8 *DestBuffer, FF_T_UINT32 SectorAddress, FF_T_UINT32 Cou
     PBCB Bcb;
     ULONG SectorSize = 512; // FIXME: hardcoding 512 is bad
 
-    DPRINT1("FatReadBlocks %p %d %d %p\n", DestBuffer, SectorAddress, Count, pParam);
+    DPRINT("FatReadBlocks %p %d %d %p\n", DestBuffer, SectorAddress, Count, pParam);
 
     /* Calculate the offset */
     Offset.QuadPart = Int32x32To64(SectorAddress, SectorSize);
index d3693d8..3d54129 100644 (file)
@@ -26,6 +26,8 @@ FatiRead(PFAT_IRP_CONTEXT IrpContext)
     PFCB Fcb;
     PVCB Vcb;
     PCCB Ccb;
+    PVOID Buffer;
+    LONG BytesRead;
 
     FileObject = IrpSp->FileObject;
     NumberOfBytes = IrpSp->Parameters.Read.Length;
@@ -40,7 +42,29 @@ FatiRead(PFAT_IRP_CONTEXT IrpContext)
 
     DPRINT1("FatiRead() Fcb %p, Name %wZ, Offset %d, Length %d, Handle %p\n",
         Fcb, &FileObject->FileName, ByteOffset.LowPart, NumberOfBytes, Fcb->FatHandle);
-    return STATUS_NOT_IMPLEMENTED;
+
+    /* Perform actual read */
+
+    if (IrpContext->MinorFunction & IRP_MN_MDL)
+    {
+        DPRINT1("MDL read\n");
+    }
+    else
+    {
+        Buffer = FatMapUserBuffer(IrpContext->Irp);
+        DPRINT1("Normal cached read, buffer %p\n");
+
+        BytesRead = FF_Read(Fcb->FatHandle, NumberOfBytes, 1, Buffer);
+        DPRINT1("Read %d bytes\n", BytesRead);
+
+        /* Indicate we read requested amount of bytes */
+        IrpContext->Irp->IoStatus.Information = BytesRead;
+        IrpContext->Irp->IoStatus.Status = STATUS_SUCCESS;
+    }
+
+    /* Complete the request */
+    FatCompleteRequest(IrpContext, IrpContext->Irp, STATUS_SUCCESS);
+    return STATUS_SUCCESS;
 }
 
 NTSTATUS