Set filesystem characteristics.
[reactos.git] / reactos / drivers / filesystems / fastfat / fsctl.c
index 1684175..8b47aa8 100644 (file)
@@ -12,9 +12,9 @@
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
  *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 /*
  * COPYRIGHT:        See COPYING in the top level directory
@@ -241,7 +241,6 @@ VfatHasFileSystem(PDEVICE_OBJECT DeviceToMount,
             if (PartitionInfoIsValid &&
                 FatInfo.Sectors > PartitionInfo.PartitionLength.QuadPart / FatInfo.BytesPerSector)
             {
-               CHECKPOINT1;
                *RecognizedFS = FALSE;
             }
 
@@ -373,6 +372,7 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext)
    PVFATFCB VolumeFcb = NULL;
    PVFATCCB Ccb = NULL;
    PDEVICE_OBJECT DeviceToMount;
+   PVPB Vpb;
    UNICODE_STRING NameU = RTL_CONSTANT_STRING(L"\\$$Fat$$");
    UNICODE_STRING VolumeNameU = RTL_CONSTANT_STRING(L"\\$$Volume$$");
    ULONG HashTableSize;
@@ -390,6 +390,7 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext)
    }
 
    DeviceToMount = IrpContext->Stack->Parameters.MountVolume.DeviceObject;
+   Vpb = IrpContext->Stack->Parameters.MountVolume.Vpb;
 
    Status = VfatHasFileSystem (DeviceToMount, &RecognizedFS, &FatInfo);
    if (!NT_SUCCESS(Status))
@@ -423,8 +424,8 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext)
    Status = IoCreateDevice(VfatGlobalData->DriverObject,
                            ROUND_UP(sizeof (DEVICE_EXTENSION), sizeof(ULONG)) + sizeof(HASHENTRY*) * HashTableSize,
                            NULL,
-                           FILE_DEVICE_FILE_SYSTEM,
-                           0,
+                           FILE_DEVICE_DISK_FILE_SYSTEM,
+                           DeviceToMount->Characteristics,
                            FALSE,
                            &DeviceObject);
    if (!NT_SUCCESS(Status))
@@ -439,7 +440,9 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext)
    DeviceExt->HashTableSize = HashTableSize;
 
    /* use same vpb as device disk */
-   DeviceObject->Vpb = DeviceToMount->Vpb;
+   DeviceObject->Vpb = Vpb;
+   DeviceToMount->Vpb = Vpb;
+
    Status = VfatMountDevice(DeviceExt, DeviceToMount);
    if (!NT_SUCCESS(Status))
    {
@@ -506,6 +509,9 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext)
 
    DPRINT("FsDeviceObject %p\n", DeviceObject);
 
+   /* Initialize this resource early ... it's used in VfatCleanup */
+   ExInitializeResourceLite(&DeviceExt->DirResource);
+
    DeviceExt->FATFileObject = IoCreateStreamFileObject(NULL, DeviceExt->StorageDevice);
    Fcb = vfatNewFCB(DeviceExt, &NameU);
    if (Fcb == NULL)
@@ -534,30 +540,13 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext)
    Fcb->RFCB.ValidDataLength = Fcb->RFCB.FileSize;
    Fcb->RFCB.AllocationSize = Fcb->RFCB.FileSize;
 
-#ifdef USE_ROS_CC_AND_FS
-   if (DeviceExt->FatInfo.FatType != FAT12)
-   {
-      Status = CcRosInitializeFileCache(DeviceExt->FATFileObject, CACHEPAGESIZE(DeviceExt));
-   }
-   else
-   {
-      Status = CcRosInitializeFileCache(DeviceExt->FATFileObject, 2 * PAGE_SIZE);
-   }
-   if (!NT_SUCCESS (Status))
-   {
-      DPRINT1 ("CcRosInitializeFileCache failed\n");
-      goto ByeBye;
-   }
-#else
-   /* FIXME: Guard by SEH. */
    CcInitializeCacheMap(DeviceExt->FATFileObject,
                         (PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize),
-                        FALSE,
+                        TRUE,
                         &VfatGlobalData->CacheMgrCallbacks,
                         Fcb);
-#endif
+
    DeviceExt->LastAvailableCluster = 2;
-   ExInitializeResourceLite(&DeviceExt->DirResource);
    ExInitializeResourceLite(&DeviceExt->FatResource);
 
    InitializeListHead(&DeviceExt->FcbListHead);
@@ -784,30 +773,6 @@ VfatMoveFile(PVFAT_IRP_CONTEXT IrpContext)
    return STATUS_INVALID_DEVICE_REQUEST;
 }
 
-#ifdef USE_ROS_CC_AND_FS
-static NTSTATUS
-VfatRosQueryLcnMapping(PVFAT_IRP_CONTEXT IrpContext)
-{
-   PDEVICE_EXTENSION DeviceExt;
-   PROS_QUERY_LCN_MAPPING LcnQuery;
-   PIO_STACK_LOCATION Stack;
-
-   DPRINT("VfatRosQueryLcnMapping(IrpContext %p)\n", IrpContext);
-
-   DeviceExt = IrpContext->DeviceExt;
-   Stack = IrpContext->Stack;
-   if (IrpContext->Irp->AssociatedIrp.SystemBuffer == NULL ||
-       Stack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(ROS_QUERY_LCN_MAPPING))
-   {
-      return STATUS_BUFFER_TOO_SMALL;
-   }
-   LcnQuery = (PROS_QUERY_LCN_MAPPING)(IrpContext->Irp->AssociatedIrp.SystemBuffer);
-   LcnQuery->LcnDiskOffset.QuadPart = DeviceExt->FatInfo.dataStart * DeviceExt->FatInfo.BytesPerSector;
-   IrpContext->Irp->IoStatus.Information = sizeof(ROS_QUERY_LCN_MAPPING);
-   return(STATUS_SUCCESS);
-}
-#endif
-
 static NTSTATUS
 VfatIsVolumeDirty(PVFAT_IRP_CONTEXT IrpContext)
 {
@@ -888,11 +853,6 @@ NTSTATUS VfatFileSystemControl(PVFAT_IRP_CONTEXT IrpContext)
             case FSCTL_MOVE_FILE:
                Status = VfatMoveFile(IrpContext);
                break;
-#ifdef USE_ROS_CC_AND_FS
-            case FSCTL_ROS_QUERY_LCN_MAPPING:
-               Status = VfatRosQueryLcnMapping(IrpContext);
-               break;
-#endif
             case FSCTL_IS_VOLUME_DIRTY:
                Status = VfatIsVolumeDirty(IrpContext);
                break;