-/* $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
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,
/* 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))
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);
/* 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++;
/*
- * $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
{
NTSTATUS Status;
+
// DPRINT ("GetNextCluster(DeviceExt %x, CurrentCluster %x)\n",
// DeviceExt, CurrentCluster);
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);
+ }
+}
\ No newline at end of file
-/* $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
(*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;
-/* $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>
PULONG NextCluster,
BOOLEAN Extend);
NTSTATUS
+GetNextSector (PDEVICE_EXTENSION DeviceExt,
+ ULONG CurrentSector,
+ PULONG NextSector,
+ BOOLEAN Extend);
+NTSTATUS
VfatRawReadCluster (PDEVICE_EXTENSION DeviceExt,
ULONG FirstCluster,
PVOID Buffer,