[ros-diffs] [cgutman] 52374: [FASTFAT] - Move verification code to the BlockDev* functions (like CDFS does) so functions that call those directly will have verification handled for them - Add verification hand...

cgutman at svn.reactos.org cgutman at svn.reactos.org
Sun Jun 19 20:03:50 UTC 2011


Author: cgutman
Date: Sun Jun 19 20:03:49 2011
New Revision: 52374

URL: http://svn.reactos.org/svn/reactos?rev=52374&view=rev
Log:
[FASTFAT]
- Move verification code to the BlockDev* functions (like CDFS does) so functions that call those directly will have verification handled for them
- Add verification handling for IOCTL requests

Modified:
    trunk/reactos/drivers/filesystems/fastfat/blockdev.c
    trunk/reactos/drivers/filesystems/fastfat/create.c
    trunk/reactos/drivers/filesystems/fastfat/rw.c

Modified: trunk/reactos/drivers/filesystems/fastfat/blockdev.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat/blockdev.c?rev=52374&r1=52373&r2=52374&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/blockdev.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/blockdev.c [iso-8859-1] Sun Jun 19 20:03:49 2011
@@ -37,6 +37,10 @@
   if (Irp->PendingReturned)
     {
       IrpContext->Flags |= IRPCONTEXT_PENDINGRETURNED;
+    }
+  else
+    {
+      IrpContext->Flags &= ~IRPCONTEXT_PENDINGRETURNED;
     }
   if (!NT_SUCCESS(Irp->IoStatus.Status))
     {
@@ -67,6 +71,7 @@
   KEVENT event;
   NTSTATUS Status;
 
+again:
   KeInitializeEvent (&event, NotificationEvent, FALSE);
 
   DPRINT ("VfatReadDisk(pDeviceObject %p, Offset %I64x, Length %d, Buffer %p)\n",
@@ -102,6 +107,25 @@
       KeWaitForSingleObject (&event, Suspended, KernelMode, FALSE, NULL);
       DPRINT ("Getting IO Status... for %p\n", Irp);
       Status = IoStatus.Status;
+    }
+
+  if (Status == STATUS_VERIFY_REQUIRED)
+    {
+      PDEVICE_OBJECT DeviceToVerify;
+
+      DPRINT1 ("Media change detected!\n");
+
+      /* Find the device to verify and reset the thread field to empty value again. */
+      DeviceToVerify = IoGetDeviceToVerify (PsGetCurrentThread ());
+      IoSetDeviceToVerify (PsGetCurrentThread (), NULL);
+      Status = IoVerifyVolume (DeviceToVerify,
+                               FALSE);
+
+      if (NT_SUCCESS(Status))
+        {
+          DPRINT1 ("Volume verification successful; Reissuing read request\n");
+          goto again;
+        }
     }
 
   if (!NT_SUCCESS (Status))
@@ -134,6 +158,7 @@
 
   Buffer = (PCHAR)MmGetMdlVirtualAddress(IrpContext->Irp->MdlAddress) + BufferOffset;
 
+again:
   Irp = IoAllocateIrp(IrpContext->DeviceExt->StorageDevice->StackSize, TRUE);
   if (Irp == NULL)
     {
@@ -188,6 +213,25 @@
     {
       KeWaitForSingleObject(&IrpContext->Event, Executive, KernelMode, FALSE, NULL);
       Status = IrpContext->Irp->IoStatus.Status;
+    }
+
+  if (Status == STATUS_VERIFY_REQUIRED)
+    {
+      PDEVICE_OBJECT DeviceToVerify;
+
+      DPRINT1 ("Media change detected!\n");
+
+      /* Find the device to verify and reset the thread field to empty value again. */
+      DeviceToVerify = IoGetDeviceToVerify (PsGetCurrentThread ());
+      IoSetDeviceToVerify (PsGetCurrentThread (), NULL);
+      Status = IoVerifyVolume (DeviceToVerify,
+                               FALSE);
+
+      if (NT_SUCCESS(Status))
+        {
+          DPRINT1 ("Volume verification successful; Reissuing read request\n");
+          goto again;
+        }
     }
 
   DPRINT("%x\n", Status);
@@ -212,6 +256,7 @@
 
   Buffer = (PCHAR)MmGetMdlVirtualAddress(IrpContext->Irp->MdlAddress) + BufferOffset;
 
+again:
   DPRINT ("Building asynchronous FSD Request...\n");
   Irp = IoAllocateIrp(IrpContext->DeviceExt->StorageDevice->StackSize, TRUE);
   if (Irp == NULL)
@@ -266,6 +311,25 @@
     {
       KeWaitForSingleObject(&IrpContext->Event, Executive, KernelMode, FALSE, NULL);
       Status = IrpContext->Irp->IoStatus.Status;
+    }
+
+  if (Status == STATUS_VERIFY_REQUIRED)
+    {
+      PDEVICE_OBJECT DeviceToVerify;
+
+      DPRINT1 ("Media change detected!\n");
+
+      /* Find the device to verify and reset the thread field to empty value again. */
+      DeviceToVerify = IoGetDeviceToVerify (PsGetCurrentThread ());
+      IoSetDeviceToVerify (PsGetCurrentThread (), NULL);
+      Status = IoVerifyVolume (DeviceToVerify,
+                               FALSE);
+
+      if (NT_SUCCESS(Status))
+        {
+          DPRINT1 ("Volume verification successful; Reissuing write request\n");
+          goto again;
+        }
     }
 
   return Status;
@@ -292,6 +356,7 @@
          InputBuffer, InputBufferSize, OutputBuffer, OutputBufferSize,
          OutputBufferSize ? *OutputBufferSize : 0);
 
+again:
   KeInitializeEvent (&Event, NotificationEvent, FALSE);
 
   DPRINT("Building device I/O control request ...\n");
@@ -328,6 +393,25 @@
 
       Status = IoStatus.Status;
     }
+    
+  if (Status == STATUS_VERIFY_REQUIRED)
+    {
+      PDEVICE_OBJECT DeviceToVerify;
+
+      DPRINT1 ("Media change detected!\n");
+
+      /* Find the device to verify and reset the thread field to empty value again. */
+      DeviceToVerify = IoGetDeviceToVerify (PsGetCurrentThread ());
+      IoSetDeviceToVerify (PsGetCurrentThread (), NULL);
+      Status = IoVerifyVolume (DeviceToVerify,
+                               FALSE);
+
+      if (NT_SUCCESS(Status))
+        {
+          DPRINT1 ("Volume verification successful; Reissuing IOCTL request\n");
+          goto again;
+        }
+    }
 
   if (OutputBufferSize)
     {

Modified: trunk/reactos/drivers/filesystems/fastfat/create.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat/create.c?rev=52374&r1=52373&r2=52374&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/create.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/create.c [iso-8859-1] Sun Jun 19 20:03:49 2011
@@ -372,20 +372,6 @@
 			0,
 			FALSE);
 
-		if (Status == STATUS_VERIFY_REQUIRED)
-
-		{
-			PDEVICE_OBJECT DeviceToVerify;
-
-			DPRINT ("Media change detected!\n");
-			DPRINT ("Device %p\n", DeviceExt->StorageDevice);
-
-                        /* Find the device to verify and reset the thread field to empty value again. */
-			DeviceToVerify = IoGetDeviceToVerify (PsGetCurrentThread ());
-			IoSetDeviceToVerify (PsGetCurrentThread (), NULL);
-			Status = IoVerifyVolume (DeviceToVerify,
-				FALSE);
-		}
 		if (!NT_SUCCESS(Status))
 		{
 			DPRINT ("Status %lx\n", Status);

Modified: trunk/reactos/drivers/filesystems/fastfat/rw.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat/rw.c?rev=52374&r1=52373&r2=52374&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/rw.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/rw.c [iso-8859-1] Sun Jun 19 20:03:49 2011
@@ -537,7 +537,6 @@
    PERESOURCE Resource = NULL;
    LARGE_INTEGER ByteOffset;
    PVOID Buffer;
-   PDEVICE_OBJECT DeviceToVerify;
    ULONG BytesPerSector;
 
    ASSERT(IrpContext);
@@ -697,20 +696,6 @@
         }
 
       Status = VfatReadFileData(IrpContext, Length, ByteOffset, &ReturnedLength);
-      if (Status == STATUS_VERIFY_REQUIRED)
-      {
-         DPRINT("VfatReadFileData returned STATUS_VERIFY_REQUIRED\n");
-         DeviceToVerify = IoGetDeviceToVerify(PsGetCurrentThread());
-         IoSetDeviceToVerify(PsGetCurrentThread(), NULL);
-         Status = IoVerifyVolume (DeviceToVerify, FALSE);
-
-         if (NT_SUCCESS(Status))
-         {
-            Status = VfatReadFileData(IrpContext, Length,
-                                      ByteOffset, &ReturnedLength);
-         }
-      }
-
       if (NT_SUCCESS(Status))
       {
          IrpContext->Irp->IoStatus.Information = ReturnedLength;
@@ -767,7 +752,6 @@
    ULONG OldAllocationSize;
    PVOID Buffer;
    ULONG BytesPerSector;
-   PDEVICE_OBJECT DeviceToVerify;
 
    ASSERT(IrpContext);
 
@@ -989,19 +973,6 @@
 	}
 
       Status = VfatWriteFileData(IrpContext, Length, ByteOffset);
-      if (Status == STATUS_VERIFY_REQUIRED)
-      {
-          DPRINT("VfatWriteFileData returned STATUS_VERIFY_REQUIRED\n");
-          DeviceToVerify = IoGetDeviceToVerify(PsGetCurrentThread());
-          IoSetDeviceToVerify(PsGetCurrentThread(), NULL);
-          Status = IoVerifyVolume (DeviceToVerify, FALSE);
-           
-          if (NT_SUCCESS(Status))
-          {
-              Status = VfatWriteFileData(IrpContext, Length, ByteOffset);
-          }
-      }
-
       if (NT_SUCCESS(Status))
       {
          IrpContext->Irp->IoStatus.Information = Length;




More information about the Ros-diffs mailing list