- Separate out cluster chain extending functionality from GetNextCluster to GetNextClusterExtend.

- Fix a typo in VfatHasFileSystem.

svn path=/trunk/; revision=10401
This commit is contained in:
Filip Navara 2004-08-05 02:48:18 +00:00
parent 0004f90a07
commit 68a3b15468
6 changed files with 68 additions and 44 deletions

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: create.c,v 1.71 2004/08/01 21:57:17 navaraf Exp $ /* $Id: create.c,v 1.72 2004/08/05 02:48:18 navaraf Exp $
* *
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: drivers/fs/vfat/create.c * FILE: drivers/fs/vfat/create.c
@ -469,7 +469,7 @@ VfatSupersedeFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
} }
while (Cluster != 0xffffffff && Cluster > 1) while (Cluster != 0xffffffff && Cluster > 1)
{ {
Status = GetNextCluster (DeviceExt, Cluster, &NextCluster, FALSE); Status = GetNextCluster (DeviceExt, Cluster, &NextCluster);
WriteCluster (DeviceExt, Cluster, 0); WriteCluster (DeviceExt, Cluster, 0);
Cluster = NextCluster; Cluster = NextCluster;
} }

View file

@ -1,4 +1,4 @@
/* $Id: dirwr.c,v 1.40 2004/08/01 21:57:17 navaraf Exp $ /* $Id: dirwr.c,v 1.41 2004/08/05 02:48:18 navaraf Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -558,7 +558,7 @@ VfatDelEntry (PDEVICE_EXTENSION DeviceExt, PVFATFCB pFcb)
while (CurrentCluster && CurrentCluster != 0xffffffff) while (CurrentCluster && CurrentCluster != 0xffffffff)
{ {
GetNextCluster (DeviceExt, CurrentCluster, &NextCluster, FALSE); GetNextCluster (DeviceExt, CurrentCluster, &NextCluster);
/* FIXME: check status */ /* FIXME: check status */
WriteCluster(DeviceExt, CurrentCluster, 0); WriteCluster(DeviceExt, CurrentCluster, 0);
CurrentCluster = NextCluster; CurrentCluster = NextCluster;

View file

@ -1,5 +1,5 @@
/* /*
* $Id: fat.c,v 1.45 2004/08/01 21:57:17 navaraf Exp $ * $Id: fat.c,v 1.46 2004/08/05 02:48:18 navaraf Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -307,7 +307,6 @@ FAT32FindAndMarkAvailableCluster (PDEVICE_EXTENSION DeviceExt, PULONG Cluster)
return (STATUS_DISK_FULL); return (STATUS_DISK_FULL);
} }
NTSTATUS NTSTATUS
FAT12CountAvailableClusters(PDEVICE_EXTENSION DeviceExt) FAT12CountAvailableClusters(PDEVICE_EXTENSION DeviceExt)
/* /*
@ -631,8 +630,7 @@ ClusterToSector(PDEVICE_EXTENSION DeviceExt,
NTSTATUS NTSTATUS
GetNextCluster(PDEVICE_EXTENSION DeviceExt, GetNextCluster(PDEVICE_EXTENSION DeviceExt,
ULONG CurrentCluster, ULONG CurrentCluster,
PULONG NextCluster, PULONG NextCluster)
BOOLEAN Extend)
/* /*
* FUNCTION: Retrieve the next cluster depending on the FAT type * FUNCTION: Retrieve the next cluster depending on the FAT type
*/ */
@ -642,20 +640,36 @@ GetNextCluster(PDEVICE_EXTENSION DeviceExt,
DPRINT ("GetNextCluster(DeviceExt %x, CurrentCluster %x)\n", DPRINT ("GetNextCluster(DeviceExt %x, CurrentCluster %x)\n",
DeviceExt, CurrentCluster); DeviceExt, CurrentCluster);
if (!Extend) if (CurrentCluster == 0)
{ return(STATUS_UNSUCCESSFUL);
ExAcquireResourceSharedLite(&DeviceExt->FatResource, TRUE);
} ExAcquireResourceSharedLite(&DeviceExt->FatResource, TRUE);
else Status = DeviceExt->GetNextCluster(DeviceExt, CurrentCluster, NextCluster);
{ ExReleaseResourceLite(&DeviceExt->FatResource);
ExAcquireResourceExclusiveLite(&DeviceExt->FatResource, TRUE);
} return(Status);
}
NTSTATUS
GetNextClusterExtend(PDEVICE_EXTENSION DeviceExt,
ULONG CurrentCluster,
PULONG NextCluster)
/*
* FUNCTION: Retrieve the next cluster depending on the FAT type
*/
{
NTSTATUS Status;
DPRINT ("GetNextClusterExtend(DeviceExt %x, CurrentCluster %x)\n",
DeviceExt, CurrentCluster);
ExAcquireResourceExclusiveLite(&DeviceExt->FatResource, TRUE);
CHECKPOINT; CHECKPOINT;
/* /*
* If the file hasn't any clusters allocated then we need special * If the file hasn't any clusters allocated then we need special
* handling * handling
*/ */
if (CurrentCluster == 0 && Extend) if (CurrentCluster == 0)
{ {
ULONG NewCluster; ULONG NewCluster;
@ -670,15 +684,10 @@ GetNextCluster(PDEVICE_EXTENSION DeviceExt,
ExReleaseResourceLite(&DeviceExt->FatResource); ExReleaseResourceLite(&DeviceExt->FatResource);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
else if (CurrentCluster == 0)
{
ExReleaseResourceLite(&DeviceExt->FatResource);
return(STATUS_UNSUCCESSFUL);
}
Status = DeviceExt->GetNextCluster(DeviceExt, CurrentCluster, NextCluster); Status = DeviceExt->GetNextCluster(DeviceExt, CurrentCluster, NextCluster);
if (Extend && (*NextCluster) == 0xFFFFFFFF) if ((*NextCluster) == 0xFFFFFFFF)
{ {
ULONG NewCluster; ULONG NewCluster;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: fsctl.c,v 1.34 2004/08/01 21:57:18 navaraf Exp $ /* $Id: fsctl.c,v 1.35 2004/08/05 02:48:18 navaraf Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -164,7 +164,7 @@ VfatHasFileSystem(PDEVICE_OBJECT DeviceToMount,
Boot->BytesPerSector != 512 && Boot->BytesPerSector != 512 &&
Boot->BytesPerSector != 1024 && Boot->BytesPerSector != 1024 &&
Boot->BytesPerSector != 2048 && Boot->BytesPerSector != 2048 &&
Boot->BytesPerSector == 4096) Boot->BytesPerSector != 4096)
{ {
DPRINT1("BytesPerSector %d\n", Boot->BytesPerSector); DPRINT1("BytesPerSector %d\n", Boot->BytesPerSector);
*RecognizedFS=FALSE; *RecognizedFS=FALSE;

View file

@ -1,5 +1,5 @@
/* $Id: rw.c,v 1.67 2004/08/01 21:57:18 navaraf Exp $ /* $Id: rw.c,v 1.68 2004/08/05 02:48:18 navaraf Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -50,8 +50,10 @@ NextCluster(PDEVICE_EXTENSION DeviceExt,
} }
else else
{ {
return GetNextCluster(DeviceExt, (*CurrentCluster), CurrentCluster, if (Extend)
Extend); return GetNextClusterExtend(DeviceExt, (*CurrentCluster), CurrentCluster);
else
return GetNextCluster(DeviceExt, (*CurrentCluster), CurrentCluster);
} }
} }
@ -90,18 +92,28 @@ OffsetToCluster(PDEVICE_EXTENSION DeviceExt,
else else
{ {
CurrentCluster = FirstCluster; CurrentCluster = FirstCluster;
for (i = 0; i < FileOffset / DeviceExt->FatInfo.BytesPerCluster; i++) if (Extend)
{ {
Status = GetNextCluster (DeviceExt, CurrentCluster, &CurrentCluster, for (i = 0; i < FileOffset / DeviceExt->FatInfo.BytesPerCluster; i++)
Extend); {
if (!NT_SUCCESS(Status)) Status = GetNextClusterExtend (DeviceExt, CurrentCluster, &CurrentCluster);
{ if (!NT_SUCCESS(Status))
return(Status); return(Status);
} }
} *Cluster = CurrentCluster;
*Cluster = CurrentCluster; }
return(STATUS_SUCCESS); else
} {
for (i = 0; i < FileOffset / DeviceExt->FatInfo.BytesPerCluster; i++)
{
Status = GetNextCluster (DeviceExt, CurrentCluster, &CurrentCluster);
if (!NT_SUCCESS(Status))
return(Status);
}
*Cluster = CurrentCluster;
}
return(STATUS_SUCCESS);
}
} }
NTSTATUS NTSTATUS

View file

@ -1,4 +1,4 @@
/* $Id: vfat.h,v 1.66 2004/08/01 21:57:18 navaraf Exp $ */ /* $Id: vfat.h,v 1.67 2004/08/05 02:48:18 navaraf Exp $ */
#include <ddk/ntifs.h> #include <ddk/ntifs.h>
@ -142,7 +142,7 @@ typedef struct _HASHENTRY
} }
HASHENTRY; HASHENTRY;
#define FCB_HASH_TABLE_SIZE 1024 #define FCB_HASH_TABLE_SIZE 65536
typedef struct DEVICE_EXTENSION *PDEVICE_EXTENSION; typedef struct DEVICE_EXTENSION *PDEVICE_EXTENSION;
@ -509,8 +509,11 @@ ULONGLONG ClusterToSector (PDEVICE_EXTENSION DeviceExt,
NTSTATUS GetNextCluster (PDEVICE_EXTENSION DeviceExt, NTSTATUS GetNextCluster (PDEVICE_EXTENSION DeviceExt,
ULONG CurrentCluster, ULONG CurrentCluster,
PULONG NextCluster, PULONG NextCluster);
BOOLEAN Extend);
NTSTATUS GetNextClusterExtend (PDEVICE_EXTENSION DeviceExt,
ULONG CurrentCluster,
PULONG NextCluster);
NTSTATUS CountAvailableClusters (PDEVICE_EXTENSION DeviceExt, NTSTATUS CountAvailableClusters (PDEVICE_EXTENSION DeviceExt,
PLARGE_INTEGER Clusters); PLARGE_INTEGER Clusters);