[FASTFAT]
[reactos.git] / reactos / drivers / filesystems / fastfat / rw.c
index 0f806fe..bbcae94 100644 (file)
@@ -69,7 +69,7 @@ OffsetToCluster(PDEVICE_EXTENSION DeviceExt,
   if (FirstCluster == 0)
   {
     DbgPrint("OffsetToCluster is called with FirstCluster = 0!\n");
-    KEBUGCHECK(0);
+    ASSERT(FALSE);
   }
 
   if (FirstCluster == 1)
@@ -123,7 +123,6 @@ VfatReadFileData (PVFAT_IRP_CONTEXT IrpContext,
   PDEVICE_EXTENSION DeviceExt;
   BOOLEAN First = TRUE;
   PVFATFCB Fcb;
-  PVFATCCB Ccb;
   NTSTATUS Status;
   ULONG BytesDone;
   ULONG BytesPerSector;
@@ -145,7 +144,6 @@ VfatReadFileData (PVFAT_IRP_CONTEXT IrpContext,
 
   *LengthRead = 0;
 
-  Ccb = (PVFATCCB)IrpContext->FileObject->FsContext2;
   Fcb = IrpContext->FileObject->FsContext;
   BytesPerSector = DeviceExt->FatInfo.BytesPerSector;
   BytesPerCluster = DeviceExt->FatInfo.BytesPerCluster;
@@ -194,7 +192,6 @@ VfatReadFileData (PVFAT_IRP_CONTEXT IrpContext,
   if (FirstCluster == 1)
   {
     // Directory of FAT12/16 needs a special handling
-    CHECKPOINT;
     if (ReadOffset.u.LowPart + Length > DeviceExt->FatInfo.rootDirectorySectors * BytesPerSector)
     {
       Length = DeviceExt->FatInfo.rootDirectorySectors * BytesPerSector - ReadOffset.u.LowPart;
@@ -233,7 +230,7 @@ VfatReadFileData (PVFAT_IRP_CONTEXT IrpContext,
                       ROUND_DOWN(ReadOffset.u.LowPart, BytesPerCluster),
                       &CorrectCluster, FALSE);
       if (CorrectCluster != CurrentCluster)
-        KEBUGCHECK(FAT_FILE_SYSTEM);
+        KeBugCheck(FAT_FILE_SYSTEM);
     }
 #endif
   }
@@ -329,7 +326,6 @@ VfatWriteFileData(PVFAT_IRP_CONTEXT IrpContext,
 {
    PDEVICE_EXTENSION DeviceExt;
    PVFATFCB Fcb;
-   PVFATCCB Ccb;
    ULONG Count;
    ULONG FirstCluster;
    ULONG CurrentCluster;
@@ -353,7 +349,6 @@ VfatWriteFileData(PVFAT_IRP_CONTEXT IrpContext,
    ASSERT(IrpContext->FileObject);
    ASSERT(IrpContext->FileObject->FsContext2 != NULL);
 
-   Ccb = (PVFATCCB)IrpContext->FileObject->FsContext2;
    Fcb = IrpContext->FileObject->FsContext;
    BytesPerCluster = DeviceExt->FatInfo.BytesPerCluster;
    BytesPerSector = DeviceExt->FatInfo.BytesPerSector;
@@ -442,7 +437,7 @@ VfatWriteFileData(PVFAT_IRP_CONTEXT IrpContext,
                          ROUND_DOWN(WriteOffset.u.LowPart, BytesPerCluster),
                          &CorrectCluster, FALSE);
          if (CorrectCluster != CurrentCluster)
-            KEBUGCHECK(FAT_FILE_SYSTEM);
+            KeBugCheck(FAT_FILE_SYSTEM);
       }
 #endif
    }
@@ -660,7 +655,6 @@ VfatRead(PVFAT_IRP_CONTEXT IrpContext)
      !(Fcb->Flags & (FCB_IS_PAGE_FILE|FCB_IS_VOLUME)))
    {
       // cached read
-      CHECKPOINT;
       Status = STATUS_SUCCESS;
       if (ByteOffset.u.LowPart + Length > Fcb->RFCB.FileSize.u.LowPart)
       {
@@ -668,31 +662,21 @@ VfatRead(PVFAT_IRP_CONTEXT IrpContext)
          Status = /*STATUS_END_OF_FILE*/STATUS_SUCCESS;
       }
 
-      CHECKPOINT;
       if (IrpContext->FileObject->PrivateCacheMap == NULL)
       {
-#ifdef USE_ROS_CC_AND_FS
-        ULONG CacheSize;
-        CacheSize = max(IrpContext->DeviceExt->FatInfo.BytesPerCluster,
-                        8 * PAGE_SIZE);
-        CcRosInitializeFileCache(IrpContext->FileObject, CacheSize);
-#else
-        /* FIXME: Guard by SEH. */
         CcInitializeCacheMap(IrpContext->FileObject,
                              (PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize),
                              FALSE,
                              &(VfatGlobalData->CacheMgrCallbacks),
                              Fcb);
-#endif
       }
       if (!CcCopyRead(IrpContext->FileObject, &ByteOffset, Length,
                       (BOOLEAN)(IrpContext->Flags & IRPCONTEXT_CANWAIT), Buffer,
                       &IrpContext->Irp->IoStatus))
       {
-         Status = IrpContext->Irp->IoStatus.Status;//STATUS_PENDING;
+         Status = STATUS_PENDING;
          goto ByeBye;
       }
-      CHECKPOINT;
       if (!NT_SUCCESS(IrpContext->Irp->IoStatus.Status))
       {
         Status = IrpContext->Irp->IoStatus.Status;
@@ -701,7 +685,6 @@ VfatRead(PVFAT_IRP_CONTEXT IrpContext)
    else
    {
       // non cached read
-      CHECKPOINT;
       if (ByteOffset.QuadPart + Length > ROUND_UP(Fcb->RFCB.FileSize.QuadPart, BytesPerSector))
       {
          Length = (ULONG)(ROUND_UP(Fcb->RFCB.FileSize.QuadPart, BytesPerSector) - ByteOffset.QuadPart);
@@ -959,7 +942,6 @@ NTSTATUS VfatWrite (PVFAT_IRP_CONTEXT IrpContext)
                                                IrpContext->DeviceExt, &AllocationSize);
       if (!NT_SUCCESS (Status))
       {
-         CHECKPOINT;
          goto ByeBye;
       }
    }
@@ -968,23 +950,14 @@ NTSTATUS VfatWrite (PVFAT_IRP_CONTEXT IrpContext)
       !(Fcb->Flags & (FCB_IS_PAGE_FILE|FCB_IS_VOLUME)))
    {
       // cached write
-      CHECKPOINT;
 
       if (IrpContext->FileObject->PrivateCacheMap == NULL)
       {
-#ifdef USE_ROS_CC_AND_FS
-         ULONG CacheSize;
-         CacheSize = max(IrpContext->DeviceExt->FatInfo.BytesPerCluster,
-                         8 * PAGE_SIZE);
-        CcRosInitializeFileCache(IrpContext->FileObject, CacheSize);
-#else
-         /* FIXME: Guard by SEH. */
          CcInitializeCacheMap(IrpContext->FileObject,
                               (PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize),
                               FALSE,
                               &VfatGlobalData->CacheMgrCallbacks,
                               Fcb);
-#endif
       }
       if (ByteOffset.QuadPart > OldFileSize.QuadPart)
       {
@@ -1000,12 +973,10 @@ NTSTATUS VfatWrite (PVFAT_IRP_CONTEXT IrpContext)
       {
          Status = STATUS_UNSUCCESSFUL;
       }
-      CHECKPOINT;
    }
    else
    {
       // non cached write
-      CHECKPOINT;
 
       if (ByteOffset.QuadPart > OldFileSize.QuadPart)
       {