[ros-diffs] [cgutman] 52435: [VFATLIB] - Lock the volume before formatting to prevent concurrent access during formatting - This should (in theory) fix our formatting issue on mounted devices but currently we ...

cgutman at svn.reactos.org cgutman at svn.reactos.org
Thu Jun 23 22:34:04 UTC 2011


Author: cgutman
Date: Thu Jun 23 22:34:03 2011
New Revision: 52435

URL: http://svn.reactos.org/svn/reactos?rev=52435&view=rev
Log:
[VFATLIB]
- Lock the volume before formatting to prevent concurrent access during formatting
- This should (in theory) fix our formatting issue on mounted devices but currently we don't support FSCTL_LOCK_VOLUME in our FS drivers

Modified:
    trunk/reactos/lib/fslib/vfatlib/vfatlib.c

Modified: trunk/reactos/lib/fslib/vfatlib/vfatlib.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fslib/vfatlib/vfatlib.c?rev=52435&r1=52434&r2=52435&view=diff
==============================================================================
--- trunk/reactos/lib/fslib/vfatlib/vfatlib.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fslib/vfatlib/vfatlib.c [iso-8859-1] Thu Jun 23 22:34:03 2011
@@ -194,6 +194,21 @@
         Context.Percent = 0;
         Callback (PROGRESS, 0, (PVOID)&Context.Percent);
     }
+    
+    Status = NtFsControlFile(FileHandle,
+                             NULL,
+                             NULL,
+                             NULL,
+                             &Iosb,
+                             FSCTL_LOCK_VOLUME,
+                             NULL,
+                             0,
+                             NULL,
+                             0);
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("WARNING: Failed to lock volume for formatting! Format may fail! (Status: 0x%x)\n", Status);
+    }
 
     if (PartitionInfo.PartitionType == PARTITION_FAT_12)
     {
@@ -234,6 +249,21 @@
     else
     {
         Status = STATUS_INVALID_PARAMETER;
+    }
+    
+    Status = NtFsControlFile(FileHandle,
+                             NULL,
+                             NULL,
+                             NULL,
+                             &Iosb,
+                             FSCTL_UNLOCK_VOLUME,
+                             NULL,
+                             0,
+                             NULL,
+                             0);
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("Failed to unlock volume (Status: 0x%x)\n", Status);
     }
 
     NtClose(FileHandle);




More information about the Ros-diffs mailing list