From 43ef29d7ef505b91571c2ee74e0fef93cdcc7aba Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Thu, 1 Oct 2009 16:08:11 +0000 Subject: [PATCH] [fastfat_new] - Implement simple read support. - Rewrite FatMapUserBuffer, no exception raising necessary at this stage. - Silence FatReadBlocks dbgprint. svn path=/trunk/; revision=43250 --- .../filesystems/fastfat_new/blockdev.c | 24 ----------------- .../drivers/filesystems/fastfat_new/fastfat.c | 9 +++++++ .../drivers/filesystems/fastfat_new/fastfat.h | 7 +++-- .../drivers/filesystems/fastfat_new/fullfat.c | 2 +- reactos/drivers/filesystems/fastfat_new/rw.c | 26 ++++++++++++++++++- 5 files changed, 38 insertions(+), 30 deletions(-) diff --git a/reactos/drivers/filesystems/fastfat_new/blockdev.c b/reactos/drivers/filesystems/fastfat_new/blockdev.c index c91ae3a6701..8e1d0fbe8c0 100644 --- a/reactos/drivers/filesystems/fastfat_new/blockdev.c +++ b/reactos/drivers/filesystems/fastfat_new/blockdev.c @@ -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, diff --git a/reactos/drivers/filesystems/fastfat_new/fastfat.c b/reactos/drivers/filesystems/fastfat_new/fastfat.c index f1bb21d1b88..db45392caba 100644 --- a/reactos/drivers/filesystems/fastfat_new/fastfat.c +++ b/reactos/drivers/filesystems/fastfat_new/fastfat.c @@ -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 */ diff --git a/reactos/drivers/filesystems/fastfat_new/fastfat.h b/reactos/drivers/filesystems/fastfat_new/fastfat.h index fdc7c8728ec..2c2a6b673cc 100644 --- a/reactos/drivers/filesystems/fastfat_new/fastfat.h +++ b/reactos/drivers/filesystems/fastfat_new/fastfat.h @@ -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 diff --git a/reactos/drivers/filesystems/fastfat_new/fullfat.c b/reactos/drivers/filesystems/fastfat_new/fullfat.c index cb1b8351c83..fdbd2a6845c 100644 --- a/reactos/drivers/filesystems/fastfat_new/fullfat.c +++ b/reactos/drivers/filesystems/fastfat_new/fullfat.c @@ -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); diff --git a/reactos/drivers/filesystems/fastfat_new/rw.c b/reactos/drivers/filesystems/fastfat_new/rw.c index d3693d897c2..3d54129eda8 100644 --- a/reactos/drivers/filesystems/fastfat_new/rw.c +++ b/reactos/drivers/filesystems/fastfat_new/rw.c @@ -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