[VFATLIB]
authorPierre Schweitzer <pierre@reactos.org>
Wed, 20 Sep 2017 08:45:28 +0000 (08:45 +0000)
committerPierre Schweitzer <pierre@reactos.org>
Wed, 20 Sep 2017 08:45:28 +0000 (08:45 +0000)
Fix a really bad bug in VfatChkdsk(), the routine used to check a volume:
In case readwrite is enabled (ie, volume fixing is allowed), when the volume is opened, it is also locked.
If the volume has the clean shutdown bit and is to be checked only if that one is not set, then the volume lock is leaked.
This makes the volume then totally unusable later on (any later open will fail).

Because r75772 fixed volume locking on non-system partition, this totally broke (access denied) any secondary FAT volume in ROS.

Now, we just properly release the lock when required, also made a comment more explicit to avoid later bugs like that.

CORE-13805

svn path=/trunk/; revision=75911

reactos/sdk/lib/fslib/vfatlib/vfatlib.c

index d61b359..267d3a1 100644 (file)
@@ -402,11 +402,15 @@ VfatChkdsk(IN PUNICODE_STRING DriveRoot,
     verify = TRUE;
     salvage_files = TRUE;
 
     verify = TRUE;
     salvage_files = TRUE;
 
-    /* Open filesystem */
+    /* Open filesystem and lock it */
     fs_open(DriveRoot, FsCheckFlags & FSCHECK_READ_WRITE);
 
     if (CheckOnlyIfDirty && !fs_isdirty())
     {
     fs_open(DriveRoot, FsCheckFlags & FSCHECK_READ_WRITE);
 
     if (CheckOnlyIfDirty && !fs_isdirty())
     {
+        /* Unlock volume if required */
+        if (FsCheckFlags & FSCHECK_READ_WRITE)
+            fs_lock(FALSE);
+
         /* No need to check FS */
         return (fs_close(FALSE) == 0 ? STATUS_SUCCESS : STATUS_DISK_CORRUPT_ERROR);
     }
         /* No need to check FS */
         return (fs_close(FALSE) == 0 ? STATUS_SUCCESS : STATUS_DISK_CORRUPT_ERROR);
     }