Author: cfinck
Date: Wed Aug 16 20:04:55 2017
New Revision: 75579
URL:
http://svn.reactos.org/svn/reactos?rev=75579&view=rev
Log:
[CDFS]
Register CDFS as a disk filesystem too in order to flash our ISOs directly to USB drives
and boot from them. Also fix some DPRINTs in the course of that.
One step closer towards CORE-13184: This gets qemu -hda bootcd.iso to work.
What still doesn't work is qemu -hda livecd.iso and booting from a flashed USB drive
on real hardware.
Further changes are also required in fs_rec, but this code isn't ready yet and
doesn't seem to be the current blocker either.
Credits go to the entire Hackfest Team for helping on this!!
Modified:
trunk/reactos/drivers/filesystems/cdfs/cdfs.c
trunk/reactos/drivers/filesystems/cdfs/cdfs.h
trunk/reactos/drivers/filesystems/cdfs/cleanup.c
trunk/reactos/drivers/filesystems/cdfs/close.c
trunk/reactos/drivers/filesystems/cdfs/create.c
trunk/reactos/drivers/filesystems/cdfs/dispatch.c
trunk/reactos/drivers/filesystems/cdfs/fcb.c
trunk/reactos/drivers/filesystems/cdfs/fsctl.c
Modified: trunk/reactos/drivers/filesystems/cdfs/cdfs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/cdfs/c…
==============================================================================
--- trunk/reactos/drivers/filesystems/cdfs/cdfs.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/cdfs/cdfs.c [iso-8859-1] Wed Aug 16 20:04:55 2017
@@ -55,9 +55,11 @@
* RETURNS: Success or failure
*/
{
- PDEVICE_OBJECT DeviceObject;
NTSTATUS Status;
- UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Cdfs");
+ PDEVICE_OBJECT CdFsDeviceObject;
+ PDEVICE_OBJECT HddFsDeviceObject;
+ UNICODE_STRING CdFsDeviceName = RTL_CONSTANT_STRING(L"\\Cdfs");
+ UNICODE_STRING HddFsDeviceName = RTL_CONSTANT_STRING(L"\\CdfsHdd");
UNREFERENCED_PARAMETER(RegistryPath);
@@ -65,25 +67,38 @@
Status = IoCreateDevice(DriverObject,
sizeof(CDFS_GLOBAL_DATA),
- &DeviceName,
+ &CdFsDeviceName,
FILE_DEVICE_CD_ROM_FILE_SYSTEM,
0,
FALSE,
- &DeviceObject);
+ &CdFsDeviceObject);
+ if (!NT_SUCCESS(Status))
+ {
+ return(Status);
+ }
+
+ Status = IoCreateDevice(DriverObject,
+ 0,
+ &HddFsDeviceName,
+ FILE_DEVICE_DISK_FILE_SYSTEM,
+ 0,
+ FALSE,
+ &HddFsDeviceObject);
if (!NT_SUCCESS(Status))
{
return(Status);
}
/* Initialize global data */
- CdfsGlobalData = DeviceObject->DeviceExtension;
+ CdfsGlobalData = CdFsDeviceObject->DeviceExtension;
RtlZeroMemory(CdfsGlobalData,
sizeof(CDFS_GLOBAL_DATA));
CdfsGlobalData->DriverObject = DriverObject;
- CdfsGlobalData->DeviceObject = DeviceObject;
+ CdfsGlobalData->CdFsDeviceObject = CdFsDeviceObject;
+ CdfsGlobalData->HddFsDeviceObject = HddFsDeviceObject;
+ HddFsDeviceObject->DeviceExtension = CdfsGlobalData;
/* Initialize driver data */
- DeviceObject->Flags = DO_DIRECT_IO;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = CdfsFsdDispatch;
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = CdfsFsdDispatch;
DriverObject->MajorFunction[IRP_MJ_CREATE] = CdfsFsdDispatch;
@@ -116,12 +131,11 @@
CdfsGlobalData->CacheMgrCallbacks.AcquireForReadAhead = CdfsAcquireForLazyWrite;
CdfsGlobalData->CacheMgrCallbacks.ReleaseFromReadAhead =
CdfsReleaseFromLazyWrite;
- DeviceObject->Flags |= DO_LOW_PRIORITY_FILESYSTEM;
+ CdFsDeviceObject->Flags |= DO_DIRECT_IO | DO_LOW_PRIORITY_FILESYSTEM;
+ HddFsDeviceObject->Flags |= DO_DIRECT_IO | DO_LOW_PRIORITY_FILESYSTEM;
- IoRegisterFileSystem(DeviceObject);
- DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
+ IoRegisterFileSystem(CdFsDeviceObject);
+ IoRegisterFileSystem(HddFsDeviceObject);
return(STATUS_SUCCESS);
}
-
-
Modified: trunk/reactos/drivers/filesystems/cdfs/cdfs.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/cdfs/c…
==============================================================================
--- trunk/reactos/drivers/filesystems/cdfs/cdfs.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/cdfs/cdfs.h [iso-8859-1] Wed Aug 16 20:04:55 2017
@@ -248,7 +248,8 @@
typedef struct _CDFS_GLOBAL_DATA
{
PDRIVER_OBJECT DriverObject;
- PDEVICE_OBJECT DeviceObject;
+ PDEVICE_OBJECT CdFsDeviceObject;
+ PDEVICE_OBJECT HddFsDeviceObject;
ULONG Flags;
CACHE_MANAGER_CALLBACKS CacheMgrCallbacks;
FAST_IO_DISPATCH FastIoDispatch;
Modified: trunk/reactos/drivers/filesystems/cdfs/cleanup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/cdfs/c…
==============================================================================
--- trunk/reactos/drivers/filesystems/cdfs/cleanup.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/cdfs/cleanup.c [iso-8859-1] Wed Aug 16 20:04:55
2017
@@ -97,7 +97,7 @@
DeviceObject = IrpContext->DeviceObject;
Stack = IrpContext->Stack;
- if (DeviceObject == CdfsGlobalData->DeviceObject)
+ if (DeviceObject == CdfsGlobalData->CdFsDeviceObject || DeviceObject ==
CdfsGlobalData->HddFsDeviceObject)
{
DPRINT("Closing file system\n");
Status = STATUS_SUCCESS;
Modified: trunk/reactos/drivers/filesystems/cdfs/close.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/cdfs/c…
==============================================================================
--- trunk/reactos/drivers/filesystems/cdfs/close.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/cdfs/close.c [iso-8859-1] Wed Aug 16 20:04:55 2017
@@ -94,7 +94,7 @@
DeviceObject = IrpContext->DeviceObject;
Stack = IrpContext->Stack;
- if (DeviceObject == CdfsGlobalData->DeviceObject)
+ if (DeviceObject == CdfsGlobalData->CdFsDeviceObject || DeviceObject ==
CdfsGlobalData->HddFsDeviceObject)
{
DPRINT("Closing file system\n");
Status = STATUS_SUCCESS;
Modified: trunk/reactos/drivers/filesystems/cdfs/create.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/cdfs/c…
==============================================================================
--- trunk/reactos/drivers/filesystems/cdfs/create.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/cdfs/create.c [iso-8859-1] Wed Aug 16 20:04:55 2017
@@ -266,7 +266,7 @@
ASSERT(IrpContext);
DeviceObject = IrpContext->DeviceObject;
- if (DeviceObject == CdfsGlobalData->DeviceObject)
+ if (DeviceObject == CdfsGlobalData->CdFsDeviceObject || DeviceObject ==
CdfsGlobalData->HddFsDeviceObject)
{
/* DeviceObject represents FileSystem instead of logical volume */
DPRINT("Opening file system\n");
Modified: trunk/reactos/drivers/filesystems/cdfs/dispatch.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/cdfs/d…
==============================================================================
--- trunk/reactos/drivers/filesystems/cdfs/dispatch.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/cdfs/dispatch.c [iso-8859-1] Wed Aug 16 20:04:55
2017
@@ -63,7 +63,7 @@
DPRINT("CdfsLockControl(IrpContext %p)\n", IrpContext);
- if (IrpContext->DeviceObject == CdfsGlobalData->DeviceObject)
+ if (IrpContext->DeviceObject == CdfsGlobalData->CdFsDeviceObject ||
IrpContext->DeviceObject == CdfsGlobalData->HddFsDeviceObject)
{
return STATUS_INVALID_DEVICE_REQUEST;
}
Modified: trunk/reactos/drivers/filesystems/cdfs/fcb.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/cdfs/f…
==============================================================================
--- trunk/reactos/drivers/filesystems/cdfs/fcb.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/cdfs/fcb.c [iso-8859-1] Wed Aug 16 20:04:55 2017
@@ -138,9 +138,9 @@
{
KIRQL oldIrql;
- DPRINT("grabbing FCB at %p: %S, refCount:%d\n",
+ DPRINT("grabbing FCB at %p: %wZ, refCount:%d\n",
Fcb,
- Fcb->PathName,
+ &Fcb->PathName,
Fcb->RefCount);
KeAcquireSpinLock(&Vcb->FcbListLock, &oldIrql);
@@ -208,7 +208,8 @@
{
Fcb = CONTAINING_RECORD(current_entry, FCB, FcbListEntry);
- DPRINT("Comparing '%wZ' and '%wZ'\n", FileName,
&Fcb->PathName);
+ // Disabled the DPRINT! Can't be called at DISPATCH_LEVEL!
+ //DPRINT("Comparing '%wZ' and '%wZ'\n", FileName,
&Fcb->PathName);
if (RtlCompareUnicodeString(FileName, &Fcb->PathName, TRUE) == 0)
{
Fcb->RefCount++;
Modified: trunk/reactos/drivers/filesystems/cdfs/fsctl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/cdfs/f…
==============================================================================
--- trunk/reactos/drivers/filesystems/cdfs/fsctl.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/cdfs/fsctl.c [iso-8859-1] Wed Aug 16 20:04:55 2017
@@ -222,26 +222,29 @@
&Toc,
&Size,
TRUE);
- if (!NT_SUCCESS(Status))
- {
- ExFreePoolWithTag(Buffer, CDFS_TAG);
- return Status;
- }
-
- DPRINT("FirstTrack %u, LastTrack %u, TrackNumber %u\n",
- Toc.FirstTrack, Toc.LastTrack, Toc.TrackData[0].TrackNumber);
-
- Offset = Toc.TrackData[0].Address[1] * 60 * 75;
- Offset += Toc.TrackData[0].Address[2] * 75;
- Offset += Toc.TrackData[0].Address[3];
- if (Offset >= 150)
- {
- /* Remove MSF numbering offset of first frame */
- /* FIXME: should be done only for real cdroms? */
- Offset -= 150;
- }
- CdInfo->VolumeOffset = Offset;
-
+ if (NT_SUCCESS(Status))
+ {
+
+ DPRINT("FirstTrack %u, LastTrack %u, TrackNumber %u\n",
+ Toc.FirstTrack, Toc.LastTrack, Toc.TrackData[0].TrackNumber);
+
+ Offset = Toc.TrackData[0].Address[1] * 60 * 75;
+ Offset += Toc.TrackData[0].Address[2] * 75;
+ Offset += Toc.TrackData[0].Address[3];
+ if (Offset >= 150)
+ {
+ /* Remove MSF numbering offset of first frame */
+ /* FIXME: should be done only for real cdroms? */
+ Offset -= 150;
+ }
+ CdInfo->VolumeOffset = Offset;
+ }
+ else
+ {
+ DPRINT1("Allowing mount of CDFS volume on non-CD device\n");
+ CdInfo->VolumeOffset = 0;
+ }
+
DPRINT("Offset of first track in last session %u\n", Offset);
CdInfo->JolietLevel = 0;
@@ -325,10 +328,19 @@
PVPB Vpb;
NTSTATUS Status;
CDINFO CdInfo;
+ DEVICE_TYPE FilesystemDeviceType;
DPRINT("CdfsMountVolume() called\n");
- if (DeviceObject != CdfsGlobalData->DeviceObject)
+ if (DeviceObject == CdfsGlobalData->CdFsDeviceObject)
+ {
+ FilesystemDeviceType = FILE_DEVICE_CD_ROM_FILE_SYSTEM;
+ }
+ else if (DeviceObject == CdfsGlobalData->HddFsDeviceObject)
+ {
+ FilesystemDeviceType = FILE_DEVICE_DISK_FILE_SYSTEM;
+ }
+ else
{
Status = STATUS_INVALID_DEVICE_REQUEST;
goto ByeBye;
@@ -347,7 +359,7 @@
Status = IoCreateDevice(CdfsGlobalData->DriverObject,
sizeof(DEVICE_EXTENSION),
NULL,
- FILE_DEVICE_CD_ROM_FILE_SYSTEM,
+ FilesystemDeviceType,
DeviceToMount->Characteristics,
FALSE,
&NewDeviceObject);