mirror of
https://github.com/reactos/reactos.git
synced 2025-04-18 19:47:14 +00:00
Fragmented directories and crosslinking related fixes.
svn path=/trunk/; revision=1658
This commit is contained in:
parent
d3e61a64dd
commit
afe0e9f601
4 changed files with 65 additions and 10 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $Id: create.c,v 1.16 2001/02/14 02:53:54 dwelch Exp $
|
||||
/* $Id: create.c,v 1.17 2001/03/02 15:59:16 cnettel Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -93,7 +93,8 @@ GetEntryName (PVOID Block, PULONG _Offset, PWSTR Name, PULONG _jloop,
|
|||
if (Offset == ENTRIES_PER_SECTOR)
|
||||
{
|
||||
Offset = 0;
|
||||
StartingSector++; //FIXME : nor always the next sector
|
||||
/* FIXME: Check status */
|
||||
GetNextSector (DeviceExt, StartingSector, &StartingSector, FALSE);
|
||||
jloop++;
|
||||
/* FIXME: Check status */
|
||||
VfatReadSectors (DeviceExt->StorageDevice,
|
||||
|
@ -186,8 +187,9 @@ ReadVolumeLabel (PDEVICE_EXTENSION DeviceExt, PVPB Vpb)
|
|||
/* not found in this sector, try next : */
|
||||
|
||||
/* directory can be fragmented although it is best to keep them
|
||||
unfragmented */
|
||||
unfragmented.*/
|
||||
StartingSector++;
|
||||
|
||||
if (DeviceExt->FatType == FAT32)
|
||||
{
|
||||
if (StartingSector == ClusterToSector (DeviceExt, NextCluster + 1))
|
||||
|
@ -313,9 +315,9 @@ FindFile (PDEVICE_EXTENSION DeviceExt, PVFATFCB Fcb,
|
|||
i++;
|
||||
if (i == (ENTRIES_PER_SECTOR))
|
||||
{
|
||||
/* entry is in next sector */
|
||||
StartingSector++;
|
||||
/* FIXME : treat case of next sector fragmented */
|
||||
/* FIXME: Check status */
|
||||
GetNextSector (DeviceExt, StartingSector, &StartingSector, FALSE);
|
||||
|
||||
/* FIXME: Check status */
|
||||
VfatReadSectors (DeviceExt->StorageDevice,
|
||||
StartingSector, 1, block);
|
||||
|
@ -336,7 +338,8 @@ FindFile (PDEVICE_EXTENSION DeviceExt, PVFATFCB Fcb,
|
|||
/* not found in this sector, try next : */
|
||||
|
||||
/* directory can be fragmented although it is best to keep them
|
||||
unfragmented */
|
||||
unfragmented. Should we change this to also use GetNextSector?
|
||||
GetNextSector was originally implemented to handle the case above */
|
||||
if (Entry)
|
||||
*Entry = 0;
|
||||
StartingSector++;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Id: fat.c,v 1.19 2001/03/01 07:48:17 dwelch Exp $
|
||||
* $Id: fat.c,v 1.20 2001/03/02 15:59:16 cnettel Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -786,6 +786,7 @@ GetNextCluster (PDEVICE_EXTENSION DeviceExt,
|
|||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
|
||||
// DPRINT ("GetNextCluster(DeviceExt %x, CurrentCluster %x)\n",
|
||||
// DeviceExt, CurrentCluster);
|
||||
|
||||
|
@ -897,3 +898,39 @@ GetNextCluster (PDEVICE_EXTENSION DeviceExt,
|
|||
return (Status);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
GetNextSector (PDEVICE_EXTENSION DeviceExt,
|
||||
ULONG CurrentSector,
|
||||
PULONG NextSector,
|
||||
BOOLEAN Extend)
|
||||
/* Some functions don't have access to the cluster they're really reading from.
|
||||
Maybe this is a dirty solution, but it will allow them to handle fragmentation. */
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT ("GetNextSector(DeviceExt %x, CurrentSector %x)\n",DeviceExt, CurrentSector);
|
||||
if (CurrentSector<DeviceExt->dataStart || ((CurrentSector - DeviceExt->dataStart + 1) % DeviceExt -> Boot -> SectorsPerCluster))
|
||||
/* Basically, if the next sequential sector would be on a cluster border, then we'll need to check in the FAT */
|
||||
{
|
||||
(*NextSector)=CurrentSector+1;
|
||||
return (STATUS_SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentSector = (CurrentSector - DeviceExt->dataStart) / DeviceExt -> Boot -> SectorsPerCluster + 2;
|
||||
|
||||
Status = GetNextCluster(DeviceExt, CurrentSector, NextSector, Extend);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
if ((*NextSector) == 0 || (*NextSector) == 0xffffffff)
|
||||
{
|
||||
/* The caller wants to know a sector. These FAT codes don't correspond to any sector. */
|
||||
return (STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
(*NextSector)=ClusterToSector(DeviceExt,(*NextSector));
|
||||
return (STATUS_SUCCESS);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
/* $Id: rw.c,v 1.20 2001/01/16 15:43:42 dwelch Exp $
|
||||
/* $Id: rw.c,v 1.21 2001/03/02 15:59:16 cnettel Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -42,6 +42,16 @@ NextCluster(PDEVICE_EXTENSION DeviceExt,
|
|||
(*CurrentCluster) += DeviceExt->Boot->SectorsPerCluster;
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
else
|
||||
/* CN: FIXME: Real bug here or in dirwr, where CurrentCluster isn't initialized when 0*/
|
||||
if (FirstCluster == 0)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
Status = GetNextCluster(DeviceExt, 0, CurrentCluster,
|
||||
Extend);
|
||||
return(Status);
|
||||
}
|
||||
else
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: vfat.h,v 1.25 2001/02/10 22:51:11 dwelch Exp $ */
|
||||
/* $Id: vfat.h,v 1.26 2001/03/02 15:59:16 cnettel Exp $ */
|
||||
|
||||
#include <ddk/ntifs.h>
|
||||
|
||||
|
@ -251,6 +251,11 @@ GetNextCluster(PDEVICE_EXTENSION DeviceExt,
|
|||
PULONG NextCluster,
|
||||
BOOLEAN Extend);
|
||||
NTSTATUS
|
||||
GetNextSector (PDEVICE_EXTENSION DeviceExt,
|
||||
ULONG CurrentSector,
|
||||
PULONG NextSector,
|
||||
BOOLEAN Extend);
|
||||
NTSTATUS
|
||||
VfatRawReadCluster (PDEVICE_EXTENSION DeviceExt,
|
||||
ULONG FirstCluster,
|
||||
PVOID Buffer,
|
||||
|
|
Loading…
Reference in a new issue