mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 19:11:55 +00:00
- 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:
parent
0004f90a07
commit
68a3b15468
6 changed files with 68 additions and 44 deletions
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* 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
|
||||
* FILE: drivers/fs/vfat/create.c
|
||||
|
@ -469,7 +469,7 @@ VfatSupersedeFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
|||
}
|
||||
while (Cluster != 0xffffffff && Cluster > 1)
|
||||
{
|
||||
Status = GetNextCluster (DeviceExt, Cluster, &NextCluster, FALSE);
|
||||
Status = GetNextCluster (DeviceExt, Cluster, &NextCluster);
|
||||
WriteCluster (DeviceExt, Cluster, 0);
|
||||
Cluster = NextCluster;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -558,7 +558,7 @@ VfatDelEntry (PDEVICE_EXTENSION DeviceExt, PVFATFCB pFcb)
|
|||
|
||||
while (CurrentCluster && CurrentCluster != 0xffffffff)
|
||||
{
|
||||
GetNextCluster (DeviceExt, CurrentCluster, &NextCluster, FALSE);
|
||||
GetNextCluster (DeviceExt, CurrentCluster, &NextCluster);
|
||||
/* FIXME: check status */
|
||||
WriteCluster(DeviceExt, CurrentCluster, 0);
|
||||
CurrentCluster = NextCluster;
|
||||
|
|
|
@ -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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -307,7 +307,6 @@ FAT32FindAndMarkAvailableCluster (PDEVICE_EXTENSION DeviceExt, PULONG Cluster)
|
|||
return (STATUS_DISK_FULL);
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
FAT12CountAvailableClusters(PDEVICE_EXTENSION DeviceExt)
|
||||
/*
|
||||
|
@ -631,8 +630,7 @@ ClusterToSector(PDEVICE_EXTENSION DeviceExt,
|
|||
NTSTATUS
|
||||
GetNextCluster(PDEVICE_EXTENSION DeviceExt,
|
||||
ULONG CurrentCluster,
|
||||
PULONG NextCluster,
|
||||
BOOLEAN Extend)
|
||||
PULONG NextCluster)
|
||||
/*
|
||||
* 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",
|
||||
DeviceExt, CurrentCluster);
|
||||
|
||||
if (!Extend)
|
||||
{
|
||||
ExAcquireResourceSharedLite(&DeviceExt->FatResource, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
ExAcquireResourceExclusiveLite(&DeviceExt->FatResource, TRUE);
|
||||
}
|
||||
if (CurrentCluster == 0)
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
|
||||
ExAcquireResourceSharedLite(&DeviceExt->FatResource, TRUE);
|
||||
Status = DeviceExt->GetNextCluster(DeviceExt, CurrentCluster, NextCluster);
|
||||
ExReleaseResourceLite(&DeviceExt->FatResource);
|
||||
|
||||
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;
|
||||
/*
|
||||
* If the file hasn't any clusters allocated then we need special
|
||||
* handling
|
||||
*/
|
||||
if (CurrentCluster == 0 && Extend)
|
||||
if (CurrentCluster == 0)
|
||||
{
|
||||
ULONG NewCluster;
|
||||
|
||||
|
@ -670,15 +684,10 @@ GetNextCluster(PDEVICE_EXTENSION DeviceExt,
|
|||
ExReleaseResourceLite(&DeviceExt->FatResource);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
else if (CurrentCluster == 0)
|
||||
{
|
||||
ExReleaseResourceLite(&DeviceExt->FatResource);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
Status = DeviceExt->GetNextCluster(DeviceExt, CurrentCluster, NextCluster);
|
||||
|
||||
if (Extend && (*NextCluster) == 0xFFFFFFFF)
|
||||
if ((*NextCluster) == 0xFFFFFFFF)
|
||||
{
|
||||
ULONG NewCluster;
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* 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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -164,7 +164,7 @@ VfatHasFileSystem(PDEVICE_OBJECT DeviceToMount,
|
|||
Boot->BytesPerSector != 512 &&
|
||||
Boot->BytesPerSector != 1024 &&
|
||||
Boot->BytesPerSector != 2048 &&
|
||||
Boot->BytesPerSector == 4096)
|
||||
Boot->BytesPerSector != 4096)
|
||||
{
|
||||
DPRINT1("BytesPerSector %d\n", Boot->BytesPerSector);
|
||||
*RecognizedFS=FALSE;
|
||||
|
|
|
@ -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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -50,8 +50,10 @@ NextCluster(PDEVICE_EXTENSION DeviceExt,
|
|||
}
|
||||
else
|
||||
{
|
||||
return GetNextCluster(DeviceExt, (*CurrentCluster), CurrentCluster,
|
||||
Extend);
|
||||
if (Extend)
|
||||
return GetNextClusterExtend(DeviceExt, (*CurrentCluster), CurrentCluster);
|
||||
else
|
||||
return GetNextCluster(DeviceExt, (*CurrentCluster), CurrentCluster);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,18 +92,28 @@ OffsetToCluster(PDEVICE_EXTENSION DeviceExt,
|
|||
else
|
||||
{
|
||||
CurrentCluster = FirstCluster;
|
||||
for (i = 0; i < FileOffset / DeviceExt->FatInfo.BytesPerCluster; i++)
|
||||
{
|
||||
Status = GetNextCluster (DeviceExt, CurrentCluster, &CurrentCluster,
|
||||
Extend);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
}
|
||||
*Cluster = CurrentCluster;
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
if (Extend)
|
||||
{
|
||||
for (i = 0; i < FileOffset / DeviceExt->FatInfo.BytesPerCluster; i++)
|
||||
{
|
||||
Status = GetNextClusterExtend (DeviceExt, CurrentCluster, &CurrentCluster);
|
||||
if (!NT_SUCCESS(Status))
|
||||
return(Status);
|
||||
}
|
||||
*Cluster = CurrentCluster;
|
||||
}
|
||||
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
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
@ -142,7 +142,7 @@ typedef struct _HASHENTRY
|
|||
}
|
||||
HASHENTRY;
|
||||
|
||||
#define FCB_HASH_TABLE_SIZE 1024
|
||||
#define FCB_HASH_TABLE_SIZE 65536
|
||||
|
||||
typedef struct DEVICE_EXTENSION *PDEVICE_EXTENSION;
|
||||
|
||||
|
@ -509,8 +509,11 @@ ULONGLONG ClusterToSector (PDEVICE_EXTENSION DeviceExt,
|
|||
|
||||
NTSTATUS GetNextCluster (PDEVICE_EXTENSION DeviceExt,
|
||||
ULONG CurrentCluster,
|
||||
PULONG NextCluster,
|
||||
BOOLEAN Extend);
|
||||
PULONG NextCluster);
|
||||
|
||||
NTSTATUS GetNextClusterExtend (PDEVICE_EXTENSION DeviceExt,
|
||||
ULONG CurrentCluster,
|
||||
PULONG NextCluster);
|
||||
|
||||
NTSTATUS CountAvailableClusters (PDEVICE_EXTENSION DeviceExt,
|
||||
PLARGE_INTEGER Clusters);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue