mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
bug corrected in updating fat16
erase clusters before use. svn path=/trunk/; revision=1453
This commit is contained in:
parent
d8748695f2
commit
02d3c2cb72
1 changed files with 22 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* $Id: fat.c,v 1.6 2000/06/29 23:35:50 dwelch Exp $
|
* $Id: fat.c,v 1.7 2000/12/07 16:58:42 jean Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -356,7 +356,7 @@ void FAT16WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
|
||||||
VFATWriteSectors(DeviceExt->StorageDevice,
|
VFATWriteSectors(DeviceExt->StorageDevice,
|
||||||
Start,
|
Start,
|
||||||
1,
|
1,
|
||||||
(UCHAR *)Block);
|
((UCHAR *)Block)+FATsector*512);
|
||||||
Start += DeviceExt->Boot->FATSectors;
|
Start += DeviceExt->Boot->FATSectors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -370,6 +370,9 @@ void FAT32WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
|
||||||
ULONG FATsector;
|
ULONG FATsector;
|
||||||
ULONG FATeis;
|
ULONG FATeis;
|
||||||
PUSHORT Block;
|
PUSHORT Block;
|
||||||
|
ULONG Start;
|
||||||
|
int i;
|
||||||
|
struct _BootSector32 *pBoot;
|
||||||
DbgPrint("FAT32WriteCluster %u : %u\n",ClusterToWrite,NewValue);
|
DbgPrint("FAT32WriteCluster %u : %u\n",ClusterToWrite,NewValue);
|
||||||
Block = ExAllocatePool(NonPagedPool,BLOCKSIZE);
|
Block = ExAllocatePool(NonPagedPool,BLOCKSIZE);
|
||||||
FATsector=ClusterToWrite/128;
|
FATsector=ClusterToWrite/128;
|
||||||
|
@ -380,10 +383,17 @@ DbgPrint("FAT32WriteCluster %u : %u\n",ClusterToWrite,NewValue);
|
||||||
1,
|
1,
|
||||||
(UCHAR *)Block);
|
(UCHAR *)Block);
|
||||||
Block[FATeis] = NewValue;
|
Block[FATeis] = NewValue;
|
||||||
VFATWriteSectors(DeviceExt->StorageDevice,
|
/* Write the changed FAT sector to disk (all FAT's) */
|
||||||
DeviceExt->FATStart+FATsector,
|
Start = DeviceExt->FATStart + FATsector;
|
||||||
|
pBoot = (struct _BootSector32*) DeviceExt->Boot;
|
||||||
|
for (i = 0; i < pBoot->FATCount; i++)
|
||||||
|
{
|
||||||
|
VFATWriteSectors(DeviceExt->StorageDevice,
|
||||||
|
Start,
|
||||||
1,
|
1,
|
||||||
(UCHAR *)Block);
|
(UCHAR *)Block);
|
||||||
|
Start += pBoot->FATSectors;
|
||||||
|
}
|
||||||
ExFreePool(Block);
|
ExFreePool(Block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,9 +422,10 @@ ULONG GetNextWriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
|
||||||
* FUNCTION: Determines the next cluster to be written
|
* FUNCTION: Determines the next cluster to be written
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
ULONG LastCluster, NewCluster;
|
ULONG LastCluster, NewCluster;
|
||||||
|
UCHAR *Buffer2;
|
||||||
|
|
||||||
DPRINT1("GetNextWriteCluster(DeviceExt %x, CurrentCluster %x)\n",
|
DPRINT("GetNextWriteCluster(DeviceExt %x, CurrentCluster %x)\n",
|
||||||
DeviceExt,CurrentCluster);
|
DeviceExt,CurrentCluster);
|
||||||
|
|
||||||
/* Find out what was happening in the last cluster's AU */
|
/* Find out what was happening in the last cluster's AU */
|
||||||
|
@ -448,6 +459,11 @@ ULONG GetNextWriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
|
||||||
{
|
{
|
||||||
WriteCluster(DeviceExt, CurrentCluster, NewCluster);
|
WriteCluster(DeviceExt, CurrentCluster, NewCluster);
|
||||||
}
|
}
|
||||||
|
// fill cluster with zero
|
||||||
|
Buffer2=ExAllocatePool(NonPagedPool,DeviceExt->BytesPerCluster);
|
||||||
|
memset(Buffer2,0,DeviceExt->BytesPerCluster);
|
||||||
|
VFATWriteCluster(DeviceExt,Buffer2,NewCluster);
|
||||||
|
ExFreePool(Buffer2);
|
||||||
/* Return NewCluster as CurrentCluster */
|
/* Return NewCluster as CurrentCluster */
|
||||||
return NewCluster;
|
return NewCluster;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue