From 17b6b4d72a478deb7e6a91d9dc126992128d13f8 Mon Sep 17 00:00:00 2001 From: jean Date: Mon, 4 Jan 1999 12:11:35 +0000 Subject: [PATCH] correct bug in write operations svn path=/trunk/; revision=149 --- reactos/drivers/fs/vfat/blockdev.c | 37 +++++++++++------------------- 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/reactos/drivers/fs/vfat/blockdev.c b/reactos/drivers/fs/vfat/blockdev.c index 6ecb42589f4..8e3019b56ae 100644 --- a/reactos/drivers/fs/vfat/blockdev.c +++ b/reactos/drivers/fs/vfat/blockdev.c @@ -1,3 +1,5 @@ + + /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -17,11 +19,11 @@ #include #include "vfat.h" - +//#include "dbgpool.c" /* FUNCTIONS ***************************************************************/ BOOLEAN VFATReadSectors(IN PDEVICE_OBJECT pDeviceObject, - IN ULONG DiskSector, + IN ULONG DiskSector, IN ULONG SectorCount, IN UCHAR* Buffer) { @@ -33,29 +35,22 @@ BOOLEAN VFATReadSectors(IN PDEVICE_OBJECT pDeviceObject, ULONG sectorSize; PULONG mbr; + DPRINT("VFATReadSector(pDeviceObject %x, DiskSector %d,count %d, Buffer %x)\n", + pDeviceObject,DiskSector,SectorCount,Buffer); + SET_LARGE_INTEGER_LOW_PART(sectorNumber, DiskSector << 9); SET_LARGE_INTEGER_HIGH_PART(sectorNumber, DiskSector >> 23); + KeInitializeEvent(&event, NotificationEvent, FALSE); - sectorSize = BLOCKSIZE * SectorCount; - /* FIXME: this routine does not need to alloc mem and copy */ + sectorSize = BLOCKSIZE*SectorCount; +DPRINT("SectorCount=%d,sectorSize=%d,BLOCKSIZE=%d\n",SectorCount,sectorSize,BLOCKSIZE); mbr = ExAllocatePool(NonPagedPool, sectorSize); - - DPRINT("VFATReadSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n", - pDeviceObject, - DiskSector, - Buffer); - DPRINT("sectorNumber %08lx:%08lx sectorSize %ld\n", - (unsigned long int)GET_LARGE_INTEGER_HIGH_PART(sectorNumber), - (unsigned long int)GET_LARGE_INTEGER_LOW_PART(sectorNumber), - sectorSize); - if (!mbr) { return FALSE; } - DPRINT("Building synchronous FSD Request...\n"); irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ, pDeviceObject, mbr, @@ -70,18 +65,15 @@ BOOLEAN VFATReadSectors(IN PDEVICE_OBJECT pDeviceObject, return FALSE; } - DPRINT("Calling IO Driver...\n"); status = IoCallDriver(pDeviceObject, irp); - DPRINT("Waiting for IO Operation...\n"); if (status == STATUS_PENDING) { KeWaitForSingleObject(&event, Suspended, KernelMode, FALSE, NULL); - DPRINT("Getting IO Status...\n"); status = ioStatus.Status; } @@ -97,11 +89,9 @@ BOOLEAN VFATReadSectors(IN PDEVICE_OBJECT pDeviceObject, return FALSE; } - DPRINT("Copying memory...\n"); RtlCopyMemory(Buffer,mbr,sectorSize); ExFreePool(mbr); - DPRINT("Block request succeeded\n"); return TRUE; } @@ -118,9 +108,8 @@ BOOLEAN VFATWriteSectors(IN PDEVICE_OBJECT pDeviceObject, ULONG sectorSize; PULONG mbr; - DPRINT("VFATWriteSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n", - pDeviceObject,DiskSector,Buffer); - + DPRINT("VFATWriteSector(pDeviceObject %x, DiskSector %d, count %d, Buffer %x)\n", + pDeviceObject,DiskSector,SectorCount,Buffer); SET_LARGE_INTEGER_LOW_PART(sectorNumber, DiskSector << 9); SET_LARGE_INTEGER_HIGH_PART(sectorNumber, DiskSector >> 23); @@ -133,7 +122,7 @@ BOOLEAN VFATWriteSectors(IN PDEVICE_OBJECT pDeviceObject, if (!mbr) { return FALSE; } - + memcpy(mbr,Buffer,sectorSize); DPRINT("Building synchronous FSD Request...\n"); irp = IoBuildSynchronousFsdRequest(IRP_MJ_WRITE,