From 6c733856258ebfac4b62ffb7733202dddb74a4be Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Sun, 12 Nov 2017 18:36:20 +0100 Subject: [PATCH] [CDFS_NEW] Restore the ability to restore installing from disk image. CORE-13184 --- drivers/filesystems/cdfs_new/cdinit.c | 58 +++++++++++++++++++++++++ drivers/filesystems/cdfs_new/cdstruc.h | 4 ++ drivers/filesystems/cdfs_new/fsctrl.c | 44 +++++++++++++++++++ drivers/filesystems/cdfs_new/strucsup.c | 10 +++++ 4 files changed, 116 insertions(+) diff --git a/drivers/filesystems/cdfs_new/cdinit.c b/drivers/filesystems/cdfs_new/cdinit.c index e66bd75377b..aac879a2359 100755 --- a/drivers/filesystems/cdfs_new/cdinit.c +++ b/drivers/filesystems/cdfs_new/cdinit.c @@ -38,6 +38,10 @@ NTSTATUS CdInitializeGlobalData ( IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT FileSystemDeviceObject +#ifdef __REACTOS__ + , + IN PDEVICE_OBJECT HddFileSystemDeviceObject +#endif ); NTSTATUS @@ -89,6 +93,9 @@ Return Value: NTSTATUS Status; UNICODE_STRING UnicodeString; PDEVICE_OBJECT CdfsFileSystemDeviceObject; +#ifdef __REACTOS__ + PDEVICE_OBJECT HddFileSystemDeviceObject; +#endif // // Create the device object. @@ -107,6 +114,27 @@ Return Value: if (!NT_SUCCESS( Status )) { return Status; } + +#ifdef __REACTOS__ + // + // Create the HDD device object. + // + + RtlInitUnicodeString( &UnicodeString, L"\\CdfsHdd" ); + + Status = IoCreateDevice( DriverObject, + 0, + &UnicodeString, + FILE_DEVICE_DISK_FILE_SYSTEM, + 0, + FALSE, + &HddFileSystemDeviceObject ); + + if (!NT_SUCCESS( Status )) { + IoDeleteDevice (CdfsFileSystemDeviceObject); + return Status; + } +#endif DriverObject->DriverUnload = CdUnload; // // Note that because of the way data caching is done, we set neither @@ -141,6 +169,9 @@ Return Value: Status = IoRegisterShutdownNotification (CdfsFileSystemDeviceObject); if (!NT_SUCCESS (Status)) { IoDeleteDevice (CdfsFileSystemDeviceObject); +#ifdef __REACTOS__ + IoDeleteDevice (HddFileSystemDeviceObject); +#endif return Status; } @@ -148,9 +179,16 @@ Return Value: // Initialize the global data structures // +#ifndef __REACTOS__ Status = CdInitializeGlobalData( DriverObject, CdfsFileSystemDeviceObject ); +#else + Status = CdInitializeGlobalData( DriverObject, CdfsFileSystemDeviceObject, HddFileSystemDeviceObject ); +#endif if (!NT_SUCCESS (Status)) { IoDeleteDevice (CdfsFileSystemDeviceObject); +#ifdef __REACTOS__ + IoDeleteDevice (HddFileSystemDeviceObject); +#endif return Status; } @@ -161,9 +199,16 @@ Return Value: // CdfsFileSystemDeviceObject->Flags |= DO_LOW_PRIORITY_FILESYSTEM; +#ifdef __REACTOS__ + HddFileSystemDeviceObject->Flags |= DO_LOW_PRIORITY_FILESYSTEM; +#endif IoRegisterFileSystem( CdfsFileSystemDeviceObject ); ObReferenceObject (CdfsFileSystemDeviceObject); +#ifdef __REACTOS__ + IoRegisterFileSystem( HddFileSystemDeviceObject ); + ObReferenceObject (HddFileSystemDeviceObject); +#endif // // And return to our caller @@ -198,6 +243,9 @@ Return Value: { IoUnregisterFileSystem (DeviceObject); IoDeleteDevice (CdData.FileSystemDeviceObject); +#ifdef __REACTOS__ + IoDeleteDevice (CdData.HddFileSystemDeviceObject); +#endif CdCompleteRequest( NULL, Irp, STATUS_SUCCESS ); return STATUS_SUCCESS; @@ -241,6 +289,9 @@ Return Value: IoFreeWorkItem (CdData.CloseItem); ExDeleteResourceLite( &CdData.DataResource ); ObDereferenceObject (CdData.FileSystemDeviceObject); +#ifdef __REACTOS__ + ObDereferenceObject (CdData.HddFileSystemDeviceObject); +#endif } // @@ -251,6 +302,10 @@ NTSTATUS CdInitializeGlobalData ( IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT FileSystemDeviceObject +#ifdef __REACTOS__ + , + IN PDEVICE_OBJECT HddFileSystemDeviceObject +#endif ) /*++ @@ -307,6 +362,9 @@ Return Value: CdData.DriverObject = DriverObject; CdData.FileSystemDeviceObject = FileSystemDeviceObject; +#ifdef __REACTOS__ + CdData.HddFileSystemDeviceObject = HddFileSystemDeviceObject; +#endif InitializeListHead( &CdData.VcbQueue ); diff --git a/drivers/filesystems/cdfs_new/cdstruc.h b/drivers/filesystems/cdfs_new/cdstruc.h index e120ee27d0f..1259349db28 100755 --- a/drivers/filesystems/cdfs_new/cdstruc.h +++ b/drivers/filesystems/cdfs_new/cdstruc.h @@ -349,6 +349,10 @@ typedef struct _CD_DATA { PDEVICE_OBJECT FileSystemDeviceObject; +#ifdef __REACTOS__ + PDEVICE_OBJECT HddFileSystemDeviceObject; +#endif + // // Following are used to manage the async and delayed close queue. // diff --git a/drivers/filesystems/cdfs_new/fsctrl.c b/drivers/filesystems/cdfs_new/fsctrl.c index 31c4965f9f1..74b6c63839d 100755 --- a/drivers/filesystems/cdfs_new/fsctrl.c +++ b/drivers/filesystems/cdfs_new/fsctrl.c @@ -596,6 +596,10 @@ Return Value: ULONG TocDiskFlags = 0; ULONG MediaChangeCount = 0; +#ifdef __REACTOS__ + DEVICE_TYPE FilesystemDeviceType; +#endif + PAGED_CODE(); // @@ -603,7 +607,16 @@ Return Value: // always be waitable. // +#ifdef __REACTOS__ + if (IrpSp->DeviceObject == CdData.HddFileSystemDeviceObject) { + FilesystemDeviceType = FILE_DEVICE_DISK_FILE_SYSTEM; + } else { +#endif ASSERT( Vpb->RealDevice->DeviceType == FILE_DEVICE_CD_ROM ); +#ifdef __REACTOS__ + FilesystemDeviceType = FILE_DEVICE_CD_ROM_FILE_SYSTEM; + } +#endif ASSERT( FlagOn( IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT )); // @@ -630,7 +643,11 @@ Return Value: // Status = CdPerformDevIoCtrl( IrpContext, +#ifndef __REACTOS__ IOCTL_CDROM_CHECK_VERIFY, +#else + (FilesystemDeviceType == FILE_DEVICE_DISK_FILE_SYSTEM ? IOCTL_DISK_CHECK_VERIFY : IOCTL_CDROM_CHECK_VERIFY), +#endif DeviceObjectWeTalkTo, &MediaChangeCount, sizeof(ULONG), @@ -659,7 +676,11 @@ Return Value: // Status = CdPerformDevIoCtrl( IrpContext, +#ifndef __REACTOS__ IOCTL_CDROM_GET_DRIVE_GEOMETRY, +#else + (FilesystemDeviceType == FILE_DEVICE_DISK_FILE_SYSTEM ? IOCTL_DISK_GET_DRIVE_GEOMETRY : IOCTL_CDROM_GET_DRIVE_GEOMETRY), +#endif DeviceObjectWeTalkTo, &DiskGeometry, sizeof( DISK_GEOMETRY ), @@ -727,7 +748,11 @@ Return Value: Status = IoCreateDevice( CdData.DriverObject, sizeof( VOLUME_DEVICE_OBJECT ) - sizeof( DEVICE_OBJECT ), NULL, +#ifndef __REACTOS__ FILE_DEVICE_CD_ROM_FILE_SYSTEM, +#else + FilesystemDeviceType, +#endif 0, FALSE, (PDEVICE_OBJECT *) &VolDo ); @@ -780,7 +805,21 @@ Return Value: if (Status != STATUS_SUCCESS) { +#ifdef __REACTOS__ + + // + // Don't bail out if that was a disk based ISO image, it is legit + // + + if (FilesystemDeviceType == FILE_DEVICE_DISK_FILE_SYSTEM) { + CdFreePool( &CdromToc ); + Status = STATUS_SUCCESS; + } else { +#endif try_leave( Status ); +#ifdef __REACTOS__ + } +#endif } // @@ -2247,7 +2286,12 @@ Return Value: // We only allow the invalidate call to come in on our file system devices. // +#ifndef __REACTOS__ if (IrpSp->DeviceObject != CdData.FileSystemDeviceObject) { +#else + if (IrpSp->DeviceObject != CdData.FileSystemDeviceObject && + IrpSp->DeviceObject != CdData.HddFileSystemDeviceObject) { +#endif CdCompleteRequest( IrpContext, Irp, STATUS_INVALID_DEVICE_REQUEST ); diff --git a/drivers/filesystems/cdfs_new/strucsup.c b/drivers/filesystems/cdfs_new/strucsup.c index 58210ad7a1f..3439b730002 100755 --- a/drivers/filesystems/cdfs_new/strucsup.c +++ b/drivers/filesystems/cdfs_new/strucsup.c @@ -1570,7 +1570,12 @@ Return Value: // occur in the context of fileobjects (i.e., mount). // +#ifndef __REACTOS__ if (IrpSp->DeviceObject == CdData.FileSystemDeviceObject) { +#else + if (IrpSp->DeviceObject == CdData.FileSystemDeviceObject || + IrpSp->DeviceObject == CdData.HddFileSystemDeviceObject) { +#endif if (IrpSp->FileObject != NULL && IrpSp->MajorFunction != IRP_MJ_CREATE && @@ -1648,7 +1653,12 @@ Return Value: // the Vcb field. // +#ifndef __REACTOS__ if (IrpSp->DeviceObject != CdData.FileSystemDeviceObject) { +#else + if (IrpSp->DeviceObject != CdData.FileSystemDeviceObject && + IrpSp->DeviceObject != CdData.HddFileSystemDeviceObject) { +#endif NewIrpContext->Vcb = &((PVOLUME_DEVICE_OBJECT) IrpSp->DeviceObject)->Vcb; -- 2.17.1