Enabled caching for FAT32 partitions.
[reactos.git] / reactos / drivers / fs / vfat / volume.c
index 59d9e22..907b9c2 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: volume.c,v 1.9 2001/06/12 12:35:42 ekohl Exp $
+/* $Id: volume.c,v 1.11 2001/07/20 08:00:21 ekohl Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -93,6 +93,7 @@ FsdGetFsSizeInformation(PDEVICE_OBJECT DeviceObject,
                        PULONG BufferLength)
 {
   PDEVICE_EXTENSION DeviceExt;
+  NTSTATUS Status;
   
   DPRINT("FsdGetFsSizeInformation()\n");
   DPRINT("FsSizeInfo = %p\n", FsSizeInfo);
@@ -110,9 +111,8 @@ FsdGetFsSizeInformation(PDEVICE_OBJECT DeviceObject,
 
       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;
@@ -124,24 +124,20 @@ FsdGetFsSizeInformation(PDEVICE_OBJECT DeviceObject,
       FsSizeInfo->TotalAllocationUnits.QuadPart = ((BootSect->Sectors ? BootSect->Sectors : BootSect->SectorsHuge)-DeviceExt->dataStart)/BootSect->SectorsPerCluster;
 
       if (DeviceExt->FatType == FAT16)
-       FsSizeInfo->AvailableAllocationUnits.QuadPart =
-#if 0
-         FAT16CountAvailableClusters (DeviceExt);
-#else
-0;
-#endif
+       Status = FAT16CountAvailableClusters(DeviceExt,
+                                            &FsSizeInfo->AvailableAllocationUnits);
       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);
 }
 
 
@@ -174,9 +170,9 @@ static NTSTATUS
 FsdSetFsLabelInformation(PDEVICE_OBJECT DeviceObject,
                         PFILE_FS_LABEL_INFORMATION FsLabelInfo)
 {
-   DPRINT("FsdSetFsLabelInformation()\n");
-   
-   return STATUS_NOT_IMPLEMENTED;
+  DPRINT("FsdSetFsLabelInformation()\n");
+  
+  return(STATUS_NOT_IMPLEMENTED);
 }
 
 
@@ -265,50 +261,50 @@ VfatSetVolumeInformation(PDEVICE_OBJECT DeviceObject,
  * FUNCTION: Set the specified volume information
  */
 {
-   PIO_STACK_LOCATION Stack;
-   FS_INFORMATION_CLASS FsInformationClass;
-//   PFILE_OBJECT FileObject = NULL;
-//   PVFATFCB FCB = NULL;
-   NTSTATUS Status = STATUS_SUCCESS;
-   PVOID SystemBuffer;
-   ULONG BufferLength;
-
-   /* PRECONDITION */
-   assert(DeviceObject != NULL);
-   assert(Irp != NULL);
-
-   DPRINT("FsdSetVolumeInformation(DeviceObject %x, Irp %x)\n",
-         DeviceObject,
-         Irp);
-
-   Stack = IoGetCurrentIrpStackLocation (Irp);
-   FsInformationClass = Stack->Parameters.SetVolume.FsInformationClass;
-   BufferLength = Stack->Parameters.SetVolume.Length;
-   SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
-//   FileObject = Stack->FileObject;
-//   FCB = ((PVFATCCB) (FileObject->FsContext2))->pFcb;
-
-   DPRINT("FsInformationClass %d\n", FsInformationClass);
-   DPRINT("BufferLength %d\n", BufferLength);
-   DPRINT("SystemBuffer %x\n", SystemBuffer);
-
-   switch (FsInformationClass)
-     {
-     case FileFsLabelInformation:
-       Status = FsdSetFsLabelInformation(DeviceObject,
-                                        SystemBuffer);
-       break;
-
-     default:
-       Status = STATUS_NOT_SUPPORTED;
-     }
-
-   Irp->IoStatus.Status = Status;
-   Irp->IoStatus.Information = 0;
-   IoCompleteRequest(Irp,
-                    IO_NO_INCREMENT);
-
-   return(Status);
+  PIO_STACK_LOCATION Stack;
+  FS_INFORMATION_CLASS FsInformationClass;
+//  PFILE_OBJECT FileObject = NULL;
+//  PVFATFCB FCB = NULL;
+  NTSTATUS Status = STATUS_SUCCESS;
+  PVOID SystemBuffer;
+  ULONG BufferLength;
+
+  /* PRECONDITION */
+  assert(DeviceObject != NULL);
+  assert(Irp != NULL);
+
+  DPRINT("FsdSetVolumeInformation(DeviceObject %x, Irp %x)\n",
+        DeviceObject,
+        Irp);
+
+  Stack = IoGetCurrentIrpStackLocation(Irp);
+  FsInformationClass = Stack->Parameters.SetVolume.FsInformationClass;
+  BufferLength = Stack->Parameters.SetVolume.Length;
+  SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
+//  FileObject = Stack->FileObject;
+//  FCB = ((PVFATCCB) (FileObject->FsContext2))->pFcb;
+
+  DPRINT("FsInformationClass %d\n", FsInformationClass);
+  DPRINT("BufferLength %d\n", BufferLength);
+  DPRINT("SystemBuffer %x\n", SystemBuffer);
+
+  switch(FsInformationClass)
+    {
+    case FileFsLabelInformation:
+      Status = FsdSetFsLabelInformation(DeviceObject,
+                                       SystemBuffer);
+      break;
+
+    default:
+      Status = STATUS_NOT_SUPPORTED;
+    }
+
+  Irp->IoStatus.Status = Status;
+  Irp->IoStatus.Information = 0;
+  IoCompleteRequest(Irp,
+                   IO_NO_INCREMENT);
+
+  return(Status);
 }
 
 /* EOF */