corrected bug in writing files : extend files before needed

svn path=/trunk/; revision=1440
This commit is contained in:
jean 2000-12-01 12:41:08 +00:00
parent 7cdd9a1c62
commit 45fcd58321

View file

@ -1,4 +1,4 @@
/* $Id: rw.c,v 1.9 2000/11/23 15:53:37 jean Exp $ /* $Id: rw.c,v 1.10 2000/12/01 12:41:08 jean Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -255,6 +255,7 @@ NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
TempLength); TempLength);
/* Write the cluster back */ /* Write the cluster back */
Length2 -= TempLength;
if (FirstCluster==1) if (FirstCluster==1)
{ {
VFATWriteSectors(DeviceExt->StorageDevice, VFATWriteSectors(DeviceExt->StorageDevice,
@ -266,9 +267,9 @@ NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
else else
{ {
VFATWriteCluster(DeviceExt,Temp,CurrentCluster); VFATWriteCluster(DeviceExt,Temp,CurrentCluster);
CurrentCluster = GetNextWriteCluster(DeviceExt, CurrentCluster); if (Length2 >0)
CurrentCluster = GetNextWriteCluster(DeviceExt, CurrentCluster);
} }
Length2 -= TempLength;
Buffer = Buffer + TempLength; Buffer = Buffer + TempLength;
} }
CHECKPOINT; CHECKPOINT;
@ -283,6 +284,7 @@ NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
ExFreePool(Temp); ExFreePool(Temp);
return(STATUS_UNSUCCESSFUL); return(STATUS_UNSUCCESSFUL);
} }
Length2 -= DeviceExt->BytesPerCluster;
if (FirstCluster==1) if (FirstCluster==1)
{ {
VFATWriteSectors(DeviceExt->StorageDevice, VFATWriteSectors(DeviceExt->StorageDevice,
@ -294,10 +296,10 @@ NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
else else
{ {
VFATWriteCluster(DeviceExt,Buffer,CurrentCluster); VFATWriteCluster(DeviceExt,Buffer,CurrentCluster);
CurrentCluster = GetNextWriteCluster(DeviceExt, CurrentCluster); if (Length2 >0)
CurrentCluster = GetNextWriteCluster(DeviceExt, CurrentCluster);
} }
Buffer = Buffer + DeviceExt->BytesPerCluster; Buffer = Buffer + DeviceExt->BytesPerCluster;
Length2 -= DeviceExt->BytesPerCluster;
} }
CHECKPOINT; CHECKPOINT;