[fastfat_new]
[reactos.git] / reactos / drivers / filesystems / fastfat_new / rw.c
index 3e543f8..10aa8f9 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;
@@ -38,9 +40,35 @@ FatiRead(PFAT_IRP_CONTEXT IrpContext)
     
     OpenType = FatDecodeFileObject(FileObject, &Vcb, &Fcb, &Ccb);
 
-    DPRINT1("FatiRead() Fcb %p, Name %wZ, Offset %d, Length %d\n",
-        Fcb, &FileObject->FileName, ByteOffset.LowPart, NumberOfBytes);
-    return STATUS_NOT_IMPLEMENTED;
+    DPRINT1("FatiRead() Fcb %p, Name %wZ, Offset %d, Length %d, Handle %p\n",
+        Fcb, &FileObject->FileName, ByteOffset.LowPart, NumberOfBytes, Fcb->FatHandle);
+
+    /* 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");
+
+        /* Set offset */
+        FF_Seek(Fcb->FatHandle, ByteOffset.LowPart, FF_SEEK_SET);
+
+        /* Read */
+        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