[FASTFAT] Deny dismounting system volume or a volume with a pagefile
authorPierre Schweitzer <pierre@reactos.org>
Wed, 16 May 2018 19:44:47 +0000 (21:44 +0200)
committerPierre Schweitzer <pierre@reactos.org>
Wed, 16 May 2018 19:45:35 +0000 (21:45 +0200)
drivers/filesystems/fastfat/create.c
drivers/filesystems/fastfat/fsctl.c
drivers/filesystems/fastfat/vfat.h

index 7ecc0ff..d9efa96 100644 (file)
@@ -778,6 +778,7 @@ VfatCreateFile(
                 if (PagingFileCreate)
                 {
                     pFcb->Flags |= FCB_IS_PAGE_FILE;
+                    SetFlag(DeviceExt->Flags, VCB_IS_SYS_OR_HAS_PAGE);
                 }
             }
             else
@@ -897,6 +898,7 @@ VfatCreateFile(
             else
             {
                 pFcb->Flags |= FCB_IS_PAGE_FILE;
+                SetFlag(DeviceExt->Flags, VCB_IS_SYS_OR_HAS_PAGE);
             }
         }
         else
index abd7726..778a2bc 100644 (file)
@@ -777,6 +777,10 @@ VfatMount(
     }
 
     VolumeFcb->Flags |= VCB_IS_DIRTY;
+    if (BooleanFlagOn(Vpb->RealDevice->Flags, DO_SYSTEM_BOOT_PARTITION))
+    {
+        SetFlag(DeviceExt->Flags, VCB_IS_SYS_OR_HAS_PAGE);
+    }
 
     FsRtlNotifyVolumeEvent(DeviceExt->FATFileObject, FSRTL_VOLUME_MOUNT);
     FsRtlNotifyInitializeSync(&DeviceExt->NotifySync);
@@ -1174,6 +1178,12 @@ VfatDismountVolume(
         return STATUS_ACCESS_DENIED;
     }
 
+    /* Deny dismount of boot volume */
+    if (BooleanFlagOn(DeviceExt->Flags, VCB_IS_SYS_OR_HAS_PAGE))
+    {
+        return STATUS_ACCESS_DENIED;
+    }
+
     /* Race condition? */
     if (BooleanFlagOn(DeviceExt->Flags, VCB_DISMOUNT_PENDING))
     {
index cb38b16..e58b61b 100644 (file)
@@ -239,6 +239,7 @@ typedef union _DIR_ENTRY DIR_ENTRY, *PDIR_ENTRY;
 #define VCB_VOLUME_LOCKED       0x0001
 #define VCB_DISMOUNT_PENDING    0x0002
 #define VCB_IS_FATX             0x0004
+#define VCB_IS_SYS_OR_HAS_PAGE  0x0008
 #define VCB_IS_DIRTY            0x4000 /* Volume is dirty */
 #define VCB_CLEAR_DIRTY         0x8000 /* Clean dirty flag at shutdown */