correct bug in write operations

svn path=/trunk/; revision=149
This commit is contained in:
jean 1999-01-04 12:11:35 +00:00
parent 66658f3d1a
commit 17b6b4d72a

View file

@ -1,3 +1,5 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -17,11 +19,11 @@
#include <internal/debug.h>
#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,