/*
- * $Id: fat.c,v 1.25 2001/05/04 01:21:45 rex Exp $
+ * $Id: fat.c,v 1.26 2001/06/14 10:02:59 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
}
-ULONG
-FAT12CountAvailableClusters (PDEVICE_EXTENSION DeviceExt)
+NTSTATUS
+FAT12CountAvailableClusters(PDEVICE_EXTENSION DeviceExt,
+ PLARGE_INTEGER Clusters)
/*
* FUNCTION: Counts free cluster in a FAT12 table
*/
if (!NT_SUCCESS(Status))
{
ExReleaseResourceLite (&DeviceExt->FatResource);
- return 0; // Will the caller understand NTSTATUS values?
+ return(Status);
}
if (!Valid)
{
if (!NT_SUCCESS(Status))
{
CcRosReleaseCacheSegment(DeviceExt->Fat12StorageBcb, CacheSeg, FALSE);
- ExReleaseResourceLite (&DeviceExt->FatResource);
- return 0; // Will the caller understand NTSTATUS values?
+ ExReleaseResourceLite (&DeviceExt->FatResource);
+ return(Status);
}
}
CBlock = (PUCHAR)BaseAddress;
CcRosReleaseCacheSegment(DeviceExt->Fat12StorageBcb, CacheSeg, FALSE);
ExReleaseResourceLite (&DeviceExt->FatResource);
- return ulCount;
+ Clusters->QuadPart = ulCount;
+
+ return(STATUS_SUCCESS);
}
#if 0
-ULONG
-FAT16CountAvailableClusters (PDEVICE_EXTENSION DeviceExt)
+NTSTATUS
+FAT16CountAvailableClusters(PDEVICE_EXTENSION DeviceExt,
+ PLARGE_INTEGER Clusters)
/*
* FUNCTION: Counts free clusters in a FAT16 table
*/
ExReleaseResourceLite (&DeviceExt->FatResource);
- return ulCount;
+ Clusters->QuadPart = ulCount;
+
+ return(STATUS_SUCCESS);
}
#endif
-ULONG
-FAT32CountAvailableClusters (PDEVICE_EXTENSION DeviceExt)
+NTSTATUS
+FAT32CountAvailableClusters(PDEVICE_EXTENSION DeviceExt,
+ PLARGE_INTEGER Clusters)
/*
* FUNCTION: Counts free clusters in a FAT32 table
*/
ULONG ulCount = 0;
ULONG i,forto;
ULONG numberofclusters;
+ NTSTATUS Status;
ExAcquireResourceSharedLite (&DeviceExt->FatResource, TRUE);
sector < ((struct _BootSector32 *) (DeviceExt->Boot))->FATSectors32;
sector++)
{
- /* FIXME: Check status */
- VfatReadSectors (DeviceExt->StorageDevice,
- (ULONG) (DeviceExt->FATStart + sector), 1,
- (UCHAR *) Block);
+ Status = VfatReadSectors(DeviceExt->StorageDevice,
+ (ULONG) (DeviceExt->FATStart + sector), 1,
+ (UCHAR *) Block);
+ if (!NT_SUCCESS(Status))
+ {
+ ExFreePool(Block);
+ ExReleaseResourceLite(&DeviceExt->FatResource);
+ return(Status);
+ }
if (sector==((struct _BootSector32 *) (DeviceExt->Boot))->FATSectors32-1)
forto=numberofclusters;
}
ExFreePool (Block);
ExReleaseResourceLite (&DeviceExt->FatResource);
- return ulCount;
+
+ Clusters->QuadPart = ulCount;
+
+ return(STATUS_SUCCESS);
}
NTSTATUS
-FAT12WriteCluster (PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
- ULONG NewValue)
+FAT12WriteCluster(PDEVICE_EXTENSION DeviceExt,
+ ULONG ClusterToWrite,
+ ULONG NewValue)
/*
* FUNCTION: Writes a cluster to the FAT12 physical and in-memory tables
*/
}
NTSTATUS
-FAT16WriteCluster (PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
- ULONG NewValue)
+FAT16WriteCluster(PDEVICE_EXTENSION DeviceExt,
+ ULONG ClusterToWrite,
+ ULONG NewValue)
/*
* FUNCTION: Writes a cluster to the FAT16 physical and in-memory tables
*/
return (STATUS_SUCCESS);
}
-VOID
-FAT32WriteCluster (PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
- ULONG NewValue)
+NTSTATUS
+FAT32WriteCluster(PDEVICE_EXTENSION DeviceExt,
+ ULONG ClusterToWrite,
+ ULONG NewValue)
/*
* FUNCTION: Writes a cluster to the FAT32 physical tables
*/
ExFreePool (Block);
#endif
KeBugCheck(0);
+ return(STATUS_SUCCESS);
}
NTSTATUS
-WriteCluster (PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
- ULONG NewValue)
+WriteCluster(PDEVICE_EXTENSION DeviceExt,
+ ULONG ClusterToWrite,
+ ULONG NewValue)
/*
* FUNCTION: Write a changed FAT entry
*/
}
else if (DeviceExt->FatType == FAT32)
{
- FAT32WriteCluster (DeviceExt, ClusterToWrite, NewValue);
- Status = STATUS_SUCCESS;
+ Status = FAT32WriteCluster (DeviceExt, ClusterToWrite, NewValue);
}
else
{
}
NTSTATUS
-VfatRawReadCluster (PDEVICE_EXTENSION DeviceExt,
- ULONG FirstCluster,
- PVOID Buffer,
- ULONG Cluster)
+VfatRawReadCluster(PDEVICE_EXTENSION DeviceExt,
+ ULONG FirstCluster,
+ PVOID Buffer,
+ ULONG Cluster)
/*
* FUNCTION: Load a cluster from the physical device
*/
}
NTSTATUS
-VfatRawWriteCluster (PDEVICE_EXTENSION DeviceExt,
- ULONG FirstCluster,
- PVOID Buffer,
- ULONG Cluster)
+VfatRawWriteCluster(PDEVICE_EXTENSION DeviceExt,
+ ULONG FirstCluster,
+ PVOID Buffer,
+ ULONG Cluster)
/*
* FUNCTION: Write a cluster to the physical device
*/
if (FirstCluster == 1)
{
- Status = VfatWriteSectors (DeviceExt->StorageDevice,
+ Status = VfatWriteSectors(DeviceExt->StorageDevice,
Cluster,
- DeviceExt->Boot->SectorsPerCluster, Buffer);
+ DeviceExt->Boot->SectorsPerCluster,
+ Buffer);
}
else
{
- Sector = ClusterToSector (DeviceExt, Cluster);
+ Sector = ClusterToSector(DeviceExt,
+ Cluster);
- Status = VfatWriteSectors (DeviceExt->StorageDevice,
- Sector, DeviceExt->Boot->SectorsPerCluster,
- Buffer);
+ Status = VfatWriteSectors(DeviceExt->StorageDevice,
+ Sector,
+ DeviceExt->Boot->SectorsPerCluster,
+ Buffer);
}
return(Status);
}
-/* $Id: vfat.h,v 1.30 2001/06/11 19:52:22 ekohl Exp $ */
+/* $Id: vfat.h,v 1.31 2001/06/14 10:02:59 ekohl Exp $ */
#include <ddk/ntifs.h>
/*
* functions from fat.c
*/
-ULONG
-ClusterToSector(PDEVICE_EXTENSION DeviceExt, ULONG Cluster);
+ULONG
+ClusterToSector(PDEVICE_EXTENSION DeviceExt,
+ ULONG Cluster);
NTSTATUS
-GetNextCluster(PDEVICE_EXTENSION DeviceExt,
+GetNextCluster(PDEVICE_EXTENSION DeviceExt,
ULONG CurrentCluster,
PULONG NextCluster,
BOOLEAN Extend);
NTSTATUS
-GetNextSector (PDEVICE_EXTENSION DeviceExt,
- ULONG CurrentSector,
- PULONG NextSector,
- BOOLEAN Extend);
+GetNextSector(PDEVICE_EXTENSION DeviceExt,
+ ULONG CurrentSector,
+ PULONG NextSector,
+ BOOLEAN Extend);
NTSTATUS
-VfatRawReadCluster (PDEVICE_EXTENSION DeviceExt,
+VfatRawReadCluster(PDEVICE_EXTENSION DeviceExt,
+ ULONG FirstCluster,
+ PVOID Buffer,
+ ULONG Cluster);
+NTSTATUS
+VfatRawWriteCluster(PDEVICE_EXTENSION DeviceExt,
ULONG FirstCluster,
- PVOID Buffer,
+ PVOID Buffer,
ULONG Cluster);
-ULONG
-FAT12CountAvailableClusters(PDEVICE_EXTENSION DeviceExt);
-ULONG
-FAT16CountAvailableClusters(PDEVICE_EXTENSION DeviceExt);
-ULONG
-FAT32CountAvailableClusters(PDEVICE_EXTENSION DeviceExt);
NTSTATUS
-WriteCluster (PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
- ULONG NewValue);
+FAT12CountAvailableClusters(PDEVICE_EXTENSION DeviceExt,
+ PLARGE_INTEGER Clusters);
+NTSTATUS
+FAT16CountAvailableClusters(PDEVICE_EXTENSION DeviceExt,
+ PLARGE_INTEGER Clusters);
+NTSTATUS
+FAT32CountAvailableClusters(PDEVICE_EXTENSION DeviceExt,
+ PLARGE_INTEGER Clusters);
+NTSTATUS
+WriteCluster(PDEVICE_EXTENSION DeviceExt,
+ ULONG ClusterToWrite,
+ ULONG NewValue);
/*
* From create.c
*/
-NTSTATUS
+NTSTATUS
ReadVolumeLabel(PDEVICE_EXTENSION DeviceExt, PVPB Vpb);
NTSTATUS
-VfatOpenFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
- PWSTR FileName);
+VfatOpenFile(PDEVICE_EXTENSION DeviceExt,
+ PFILE_OBJECT FileObject,
+ PWSTR FileName);
/* ----------------------------------------------------- FCB Functions */
-/* $Id: volume.c,v 1.9 2001/06/12 12:35:42 ekohl Exp $
+/* $Id: volume.c,v 1.10 2001/06/14 10:02:59 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
PULONG BufferLength)
{
PDEVICE_EXTENSION DeviceExt;
+ NTSTATUS Status;
DPRINT("FsdGetFsSizeInformation()\n");
DPRINT("FsSizeInfo = %p\n", FsSizeInfo);
FsSizeInfo->TotalAllocationUnits.QuadPart = ((BootSect->Sectors ? BootSect->Sectors : BootSect->SectorsHuge)-DeviceExt->dataStart)/BootSect->SectorsPerCluster;
-
-
- FsSizeInfo->AvailableAllocationUnits.QuadPart = FAT32CountAvailableClusters (DeviceExt);
+ Status = FAT32CountAvailableClusters(DeviceExt,
+ &FsSizeInfo->AvailableAllocationUnits);
FsSizeInfo->SectorsPerAllocationUnit = BootSect->SectorsPerCluster;
FsSizeInfo->BytesPerSector = BootSect->BytesPerSector;
FsSizeInfo->TotalAllocationUnits.QuadPart = ((BootSect->Sectors ? BootSect->Sectors : BootSect->SectorsHuge)-DeviceExt->dataStart)/BootSect->SectorsPerCluster;
if (DeviceExt->FatType == FAT16)
- FsSizeInfo->AvailableAllocationUnits.QuadPart =
#if 0
- FAT16CountAvailableClusters (DeviceExt);
+ Status = FAT16CountAvailableClusters(DeviceExt,
+ &FsSizeInfo->AvailableAllocationUnits);
#else
-0;
+ {
+ FsSizeInfo->AvailableAllocationUnits.QuadPart = 0;
+ Status = STATUS_SUCCESS;
+ }
#endif
else
- FsSizeInfo->AvailableAllocationUnits.QuadPart =
- FAT12CountAvailableClusters (DeviceExt);
+ Status = FAT12CountAvailableClusters(DeviceExt,
+ &FsSizeInfo->AvailableAllocationUnits);
FsSizeInfo->SectorsPerAllocationUnit = BootSect->SectorsPerCluster;
FsSizeInfo->BytesPerSector = BootSect->BytesPerSector;
}
DPRINT("Finished FsdGetFsSizeInformation()\n");
+ if (NT_SUCCESS(Status))
+ *BufferLength -= sizeof(FILE_FS_SIZE_INFORMATION);
- *BufferLength -= sizeof(FILE_FS_SIZE_INFORMATION);
-
- return(STATUS_SUCCESS);
+ return(Status);
}