Author: ekohl
Date: Mon Jun 1 13:13:18 2015
New Revision: 67988
URL:
http://svn.reactos.org/svn/reactos?rev=67988&view=rev
Log:
[CDFS]
- Move the fastio code to a separate file.
- Add Pierres IRP-Queue code and use it for IRP_MJ_QUERY_VOLUME_INFORMATION,
IRP_MJ_SET_VOLUME_INFORMATION, IRP_MJ_QUERY_INFORMATION, IRP_MJ_SET_INFORMATION,
IRP_MJ_DEVICE_CONTROL and IRP_MJ_FILE_SYSTEM_CONTROL requests.
Added:
trunk/reactos/drivers/filesystems/cdfs/dispatch.c (with props)
trunk/reactos/drivers/filesystems/cdfs/fastio.c (with props)
Modified:
trunk/reactos/drivers/filesystems/cdfs/CMakeLists.txt
trunk/reactos/drivers/filesystems/cdfs/cdfs.c
trunk/reactos/drivers/filesystems/cdfs/cdfs.h
trunk/reactos/drivers/filesystems/cdfs/devctrl.c
trunk/reactos/drivers/filesystems/cdfs/finfo.c
trunk/reactos/drivers/filesystems/cdfs/fsctl.c
trunk/reactos/drivers/filesystems/cdfs/misc.c
trunk/reactos/drivers/filesystems/cdfs/volinfo.c
Modified: trunk/reactos/drivers/filesystems/cdfs/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/cdfs/C…
==============================================================================
--- trunk/reactos/drivers/filesystems/cdfs/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/cdfs/CMakeLists.txt [iso-8859-1] Mon Jun 1 13:13:18
2015
@@ -9,6 +9,8 @@
create.c
devctrl.c
dirctl.c
+ dispatch.c
+ fastio.c
fcb.c
finfo.c
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] Mon Jun 1 13:13:18 2015
@@ -84,26 +84,24 @@
DriverObject->MajorFunction[IRP_MJ_CREATE] = CdfsCreate;
DriverObject->MajorFunction[IRP_MJ_READ] = CdfsRead;
DriverObject->MajorFunction[IRP_MJ_WRITE] = CdfsWrite;
- DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] =
- CdfsFileSystemControl;
+ DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = CdfsFsdDispatch;
DriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] =
CdfsDirectoryControl;
- DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] =
- CdfsQueryInformation;
- DriverObject->MajorFunction[IRP_MJ_SET_INFORMATION] =
- CdfsSetInformation;
- DriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] =
- CdfsQueryVolumeInformation;
- DriverObject->MajorFunction[IRP_MJ_SET_VOLUME_INFORMATION] =
- CdfsSetVolumeInformation;
- DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] =
- CdfsDeviceControl;
+ DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] = CdfsFsdDispatch;
+ DriverObject->MajorFunction[IRP_MJ_SET_INFORMATION] = CdfsFsdDispatch;
+ DriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] = CdfsFsdDispatch;
+ DriverObject->MajorFunction[IRP_MJ_SET_VOLUME_INFORMATION] = CdfsFsdDispatch;
+ DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = CdfsFsdDispatch;
CdfsGlobalData->FastIoDispatch.SizeOfFastIoDispatch = sizeof(FAST_IO_DISPATCH);
CdfsGlobalData->FastIoDispatch.FastIoCheckIfPossible = CdfsFastIoCheckIfPossible;
CdfsGlobalData->FastIoDispatch.FastIoRead = CdfsFastIoRead;
CdfsGlobalData->FastIoDispatch.FastIoWrite = CdfsFastIoWrite;
DriverObject->FastIoDispatch = &CdfsGlobalData->FastIoDispatch;
+
+ /* Initialize lookaside list for IRP contexts */
+ ExInitializeNPagedLookasideList(&CdfsGlobalData->IrpContextLookasideList,
+ NULL, NULL, 0, sizeof(CDFS_IRP_CONTEXT),
'PRIC', 0);
DriverObject->DriverUnload = NULL;
@@ -122,98 +120,3 @@
}
-BOOLEAN NTAPI
-CdfsAcquireForLazyWrite(IN PVOID Context,
- IN BOOLEAN Wait)
-{
- PFCB Fcb = (PFCB)Context;
- ASSERT(Fcb);
- DPRINT("CdfsAcquireForLazyWrite(): Fcb %p\n", Fcb);
-
- if (!ExAcquireResourceExclusiveLite(&(Fcb->MainResource), Wait))
- {
- DPRINT("CdfsAcquireForLazyWrite(): ExReleaseResourceLite failed.\n");
- return FALSE;
- }
- return TRUE;
-}
-
-VOID NTAPI
-CdfsReleaseFromLazyWrite(IN PVOID Context)
-{
- PFCB Fcb = (PFCB)Context;
- ASSERT(Fcb);
- DPRINT("CdfsReleaseFromLazyWrite(): Fcb %p\n", Fcb);
-
- ExReleaseResourceLite(&(Fcb->MainResource));
-}
-
-BOOLEAN
-NTAPI
-CdfsFastIoCheckIfPossible(
- _In_ PFILE_OBJECT FileObject,
- _In_ PLARGE_INTEGER FileOffset,
- _In_ ULONG Length,
- _In_ BOOLEAN Wait,
- _In_ ULONG LockKey,
- _In_ BOOLEAN CheckForReadOperation,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject)
-{
- /* Deny FastIo */
- UNREFERENCED_PARAMETER(FileObject);
- UNREFERENCED_PARAMETER(FileOffset);
- UNREFERENCED_PARAMETER(Length);
- UNREFERENCED_PARAMETER(Wait);
- UNREFERENCED_PARAMETER(LockKey);
- UNREFERENCED_PARAMETER(CheckForReadOperation);
- UNREFERENCED_PARAMETER(IoStatus);
- UNREFERENCED_PARAMETER(DeviceObject);
- return FALSE;
-}
-
-BOOLEAN
-NTAPI
-CdfsFastIoRead(
- _In_ PFILE_OBJECT FileObject,
- _In_ PLARGE_INTEGER FileOffset,
- _In_ ULONG Length,
- _In_ BOOLEAN Wait,
- _In_ ULONG LockKey,
- _Out_ PVOID Buffer,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject)
-{
- DBG_UNREFERENCED_PARAMETER(FileObject);
- DBG_UNREFERENCED_PARAMETER(FileOffset);
- DBG_UNREFERENCED_PARAMETER(Length);
- DBG_UNREFERENCED_PARAMETER(Wait);
- DBG_UNREFERENCED_PARAMETER(LockKey);
- DBG_UNREFERENCED_PARAMETER(Buffer);
- DBG_UNREFERENCED_PARAMETER(IoStatus);
- DBG_UNREFERENCED_PARAMETER(DeviceObject);
- return FALSE;
-}
-
-BOOLEAN
-NTAPI
-CdfsFastIoWrite(
- _In_ PFILE_OBJECT FileObject,
- _In_ PLARGE_INTEGER FileOffset,
- _In_ ULONG Length,
- _In_ BOOLEAN Wait,
- _In_ ULONG LockKey,
- _In_ PVOID Buffer,
- _Out_ PIO_STATUS_BLOCK IoStatus,
- _In_ PDEVICE_OBJECT DeviceObject)
-{
- DBG_UNREFERENCED_PARAMETER(FileObject);
- DBG_UNREFERENCED_PARAMETER(FileOffset);
- DBG_UNREFERENCED_PARAMETER(Length);
- DBG_UNREFERENCED_PARAMETER(Wait);
- DBG_UNREFERENCED_PARAMETER(LockKey);
- DBG_UNREFERENCED_PARAMETER(Buffer);
- DBG_UNREFERENCED_PARAMETER(IoStatus);
- DBG_UNREFERENCED_PARAMETER(DeviceObject);
- return FALSE;
-}
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] Mon Jun 1 13:13:18 2015
@@ -238,17 +238,46 @@
#define CDFS_SEARCH_PATTERN_TAG 'eedC'
#define CDFS_FILENAME_TAG 'nFdC'
-typedef struct
+typedef struct _CDFS_GLOBAL_DATA
{
PDRIVER_OBJECT DriverObject;
PDEVICE_OBJECT DeviceObject;
ULONG Flags;
CACHE_MANAGER_CALLBACKS CacheMgrCallbacks;
FAST_IO_DISPATCH FastIoDispatch;
+ NPAGED_LOOKASIDE_LIST IrpContextLookasideList;
} CDFS_GLOBAL_DATA, *PCDFS_GLOBAL_DATA;
+#define IRPCONTEXT_CANWAIT 0x1
+#define IRPCONTEXT_COMPLETE 0x2
+#define IRPCONTEXT_QUEUE 0x4
+
+typedef struct _CDFS_IRP_CONTEXT
+{
+// NTFSIDENTIFIER Identifier;
+ ULONG Flags;
+ PIO_STACK_LOCATION Stack;
+ UCHAR MajorFunction;
+ UCHAR MinorFunction;
+ WORK_QUEUE_ITEM WorkQueueItem;
+ PIRP Irp;
+ BOOLEAN IsTopLevel;
+ PDEVICE_OBJECT DeviceObject;
+ PFILE_OBJECT FileObject;
+ NTSTATUS SavedExceptionCode;
+ CCHAR PriorityBoost;
+} CDFS_IRP_CONTEXT, *PCDFS_IRP_CONTEXT;
+
+
extern PCDFS_GLOBAL_DATA CdfsGlobalData;
+/* cdfs.c */
+
+NTSTATUS
+NTAPI
+DriverEntry(
+ PDRIVER_OBJECT DriverObject,
+ PUNICODE_STRING RegistryPath);
/* cleanup.c */
@@ -303,11 +332,9 @@
/* devctrl.c */
-DRIVER_DISPATCH CdfsDeviceControl;
-
NTSTATUS NTAPI
-CdfsDeviceControl(PDEVICE_OBJECT DeviceObject,
- PIRP Irp);
+CdfsDeviceControl(
+ PCDFS_IRP_CONTEXT IrpContext);
/* dirctl.c */
@@ -318,6 +345,29 @@
CdfsDirectoryControl(PDEVICE_OBJECT DeviceObject,
PIRP Irp);
+/* dispatch.c */
+
+DRIVER_DISPATCH CdfsFsdDispatch;
+NTSTATUS
+NTAPI
+CdfsFsdDispatch(
+ PDEVICE_OBJECT DeviceObject,
+ PIRP Irp);
+
+/* fastio.c */
+
+BOOLEAN
+NTAPI
+CdfsAcquireForLazyWrite(IN PVOID Context,
+ IN BOOLEAN Wait);
+
+VOID
+NTAPI
+CdfsReleaseFromLazyWrite(IN PVOID Context);
+
+FAST_IO_CHECK_IF_POSSIBLE CdfsFastIoCheckIfPossible;
+FAST_IO_READ CdfsFastIoRead;
+FAST_IO_WRITE CdfsFastIoWrite;
/* fcb.c */
@@ -389,31 +439,38 @@
/* finfo.c */
-DRIVER_DISPATCH CdfsQueryInformation;
-
-NTSTATUS
-NTAPI
-CdfsQueryInformation(PDEVICE_OBJECT DeviceObject,
- PIRP Irp);
-
-DRIVER_DISPATCH CdfsSetInformation;
-
-NTSTATUS
-NTAPI
-CdfsSetInformation(PDEVICE_OBJECT DeviceObject,
- PIRP Irp);
+NTSTATUS
+NTAPI
+CdfsQueryInformation(
+ PCDFS_IRP_CONTEXT IrpContext);
+
+NTSTATUS
+NTAPI
+CdfsSetInformation(
+ PCDFS_IRP_CONTEXT IrpContext);
/* fsctl.c */
-DRIVER_DISPATCH CdfsFileSystemControl;
+//DRIVER_DISPATCH CdfsFileSystemControl;
NTSTATUS NTAPI
-CdfsFileSystemControl(PDEVICE_OBJECT DeviceObject,
- PIRP Irp);
+CdfsFileSystemControl(
+ PCDFS_IRP_CONTEXT IrpContext);
+// PDEVICE_OBJECT DeviceObject,
+// PIRP Irp);
/* misc.c */
+
+BOOLEAN
+CdfsIsIrpTopLevel(
+ PIRP Irp);
+
+PCDFS_IRP_CONTEXT
+CdfsAllocateIrpContext(
+ PDEVICE_OBJECT DeviceObject,
+ PIRP Irp);
VOID
CdfsSwapString(PWCHAR Out,
@@ -454,35 +511,14 @@
/* volinfo.c */
-DRIVER_DISPATCH CdfsQueryVolumeInformation;
-
-NTSTATUS
-NTAPI
-CdfsQueryVolumeInformation(PDEVICE_OBJECT DeviceObject,
- PIRP Irp);
-
-DRIVER_DISPATCH CdfsSetVolumeInformation;
-
-NTSTATUS
-NTAPI
-CdfsSetVolumeInformation(PDEVICE_OBJECT DeviceObject,
- PIRP Irp);
-
-/* cdfs.c */
-
-NTSTATUS NTAPI
-DriverEntry(PDRIVER_OBJECT DriverObject,
- PUNICODE_STRING RegistryPath);
-
-BOOLEAN NTAPI
-CdfsAcquireForLazyWrite(IN PVOID Context,
- IN BOOLEAN Wait);
-
-VOID NTAPI
-CdfsReleaseFromLazyWrite(IN PVOID Context);
-
-FAST_IO_CHECK_IF_POSSIBLE CdfsFastIoCheckIfPossible;
-FAST_IO_READ CdfsFastIoRead;
-FAST_IO_WRITE CdfsFastIoWrite;
+NTSTATUS
+NTAPI
+CdfsQueryVolumeInformation(
+ PCDFS_IRP_CONTEXT IrpContext);
+
+NTSTATUS
+NTAPI
+CdfsSetVolumeInformation(
+ PCDFS_IRP_CONTEXT IrpContext);
#endif /* CDFS_H */
Modified: trunk/reactos/drivers/filesystems/cdfs/devctrl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/cdfs/d…
==============================================================================
--- trunk/reactos/drivers/filesystems/cdfs/devctrl.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/cdfs/devctrl.c [iso-8859-1] Mon Jun 1 13:13:18
2015
@@ -17,16 +17,19 @@
/* FUNCTIONS ****************************************************************/
NTSTATUS NTAPI
-CdfsDeviceControl(PDEVICE_OBJECT DeviceObject,
- PIRP Irp)
+CdfsDeviceControl(
+ PCDFS_IRP_CONTEXT IrpContext)
{
+ PIRP Irp;
NTSTATUS Status;
PVCB Vcb = NULL;
PFILE_OBJECT FileObject;
- PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
+ PIO_STACK_LOCATION Stack;
- UNREFERENCED_PARAMETER(DeviceObject);
+ ASSERT(IrpContext);
+ Irp = IrpContext->Irp;
+ Stack = IrpContext->Stack;
FileObject = Stack->FileObject;
Irp->IoStatus.Information = 0;
@@ -35,7 +38,6 @@
{
DPRINT1("FIXME: CdfsDeviceControl called without FileObject!\n");
Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_INVALID_DEVICE_REQUEST;
}
@@ -43,7 +45,6 @@
if (!(FileObject->RelatedFileObject == NULL ||
FileObject->RelatedFileObject->FsContext2 != NULL))
{
Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_INVALID_PARAMETER;
}
@@ -52,7 +53,6 @@
/* We should handle this one, but we don't! */
Status = STATUS_NOT_IMPLEMENTED;
Irp->IoStatus.Status = Status;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
}
else
{
Added: 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 (added)
+++ trunk/reactos/drivers/filesystems/cdfs/dispatch.c [iso-8859-1] Mon Jun 1 13:13:18
2015
@@ -0,0 +1,186 @@
+/*
+ * ReactOS kernel
+ * Copyright (C) 2008 ReactOS Team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS kernel
+ * FILE: drivers/filesystem/cdfs/dispatch.c
+ * PURPOSE: CDROM (ISO 9660) filesystem driver
+ * PROGRAMMER: Pierre Schweitzer
+ */
+
+/* INCLUDES *****************************************************************/
+
+#include "cdfs.h"
+
+#define NDEBUG
+#include <debug.h>
+
+static LONG QueueCount = 0;
+
+/* FUNCTIONS ****************************************************************/
+
+static WORKER_THREAD_ROUTINE CdfsDoRequest;
+
+static
+NTSTATUS
+CdfsQueueRequest(PCDFS_IRP_CONTEXT IrpContext)
+{
+ InterlockedIncrement(&QueueCount);
+ DPRINT("CdfsQueueRequest(IrpContext %p), %d\n", IrpContext, QueueCount);
+
+ ASSERT(!(IrpContext->Flags & IRPCONTEXT_QUEUE) &&
+ (IrpContext->Flags & IRPCONTEXT_COMPLETE));
+ IrpContext->Flags |= IRPCONTEXT_CANWAIT;
+ IoMarkIrpPending(IrpContext->Irp);
+ ExInitializeWorkItem(&IrpContext->WorkQueueItem, CdfsDoRequest, IrpContext);
+ ExQueueWorkItem(&IrpContext->WorkQueueItem, CriticalWorkQueue);
+
+ return STATUS_PENDING;
+}
+
+static
+NTSTATUS
+CdfsDispatch(PCDFS_IRP_CONTEXT IrpContext)
+{
+ PIRP Irp = IrpContext->Irp;
+ NTSTATUS Status = STATUS_UNSUCCESSFUL;
+
+ DPRINT("CdfsDispatch()\n");
+
+ FsRtlEnterFileSystem();
+
+ CdfsIsIrpTopLevel(Irp);
+
+ switch (IrpContext->MajorFunction)
+ {
+ case IRP_MJ_QUERY_VOLUME_INFORMATION:
+ Status = CdfsQueryVolumeInformation(IrpContext);
+ break;
+
+ case IRP_MJ_SET_VOLUME_INFORMATION:
+ Status = CdfsSetVolumeInformation(IrpContext);
+ break;
+
+ case IRP_MJ_QUERY_INFORMATION:
+ Status = CdfsQueryInformation(IrpContext);
+ break;
+
+ case IRP_MJ_SET_INFORMATION:
+ Status = CdfsSetInformation(IrpContext);
+ break;
+
+ case IRP_MJ_DIRECTORY_CONTROL:
+// Status = CdfsDirectoryControl(IrpContext);
+ break;
+
+ case IRP_MJ_READ:
+// Status = CdfsRead(IrpContext);
+ break;
+
+ case IRP_MJ_DEVICE_CONTROL:
+ Status = CdfsDeviceControl(IrpContext);
+ break;
+
+ case IRP_MJ_WRITE:
+// Status = CdfsWrite(IrpContext);
+ break;
+
+ case IRP_MJ_CLOSE:
+// Status = CdfsClose(IrpContext);
+ break;
+
+ case IRP_MJ_CREATE:
+// Status = CdfsCreate(IrpContext);
+ break;
+
+ case IRP_MJ_FILE_SYSTEM_CONTROL:
+ Status = CdfsFileSystemControl(IrpContext);
+ break;
+ }
+
+ ASSERT((!(IrpContext->Flags & IRPCONTEXT_COMPLETE) &&
!(IrpContext->Flags & IRPCONTEXT_QUEUE)) ||
+ ((IrpContext->Flags & IRPCONTEXT_COMPLETE) &&
!(IrpContext->Flags & IRPCONTEXT_QUEUE)) ||
+ (!(IrpContext->Flags & IRPCONTEXT_COMPLETE) &&
(IrpContext->Flags & IRPCONTEXT_QUEUE)));
+
+ if (IrpContext->Flags & IRPCONTEXT_COMPLETE)
+ {
+ Irp->IoStatus.Status = Status;
+ IoCompleteRequest(Irp, IrpContext->PriorityBoost);
+ }
+
+ if (IrpContext->Flags & IRPCONTEXT_QUEUE)
+ {
+ /* Reset our status flags before queueing the IRP */
+ IrpContext->Flags |= IRPCONTEXT_COMPLETE;
+ IrpContext->Flags &= ~IRPCONTEXT_QUEUE;
+ Status = CdfsQueueRequest(IrpContext);
+ }
+ else
+ {
+ ExFreeToNPagedLookasideList(&CdfsGlobalData->IrpContextLookasideList,
IrpContext);
+ }
+
+ IoSetTopLevelIrp(NULL);
+ FsRtlExitFileSystem();
+
+ return Status;
+}
+
+static
+VOID
+NTAPI
+CdfsDoRequest(PVOID IrpContext)
+{
+ InterlockedDecrement(&QueueCount);
+ DPRINT("CdfsDoRequest(IrpContext %p), MajorFunction %x, %d\n",
+ IrpContext, ((PCDFS_IRP_CONTEXT)IrpContext)->MajorFunction, QueueCount);
+ CdfsDispatch((PCDFS_IRP_CONTEXT)IrpContext);
+}
+
+/*
+ * FUNCTION: This function manages IRP for various major functions
+ * ARGUMENTS:
+ * DriverObject = object describing this driver
+ * Irp = IRP to be passed to internal functions
+ * RETURNS: Status of I/O Request
+ */
+NTSTATUS
+NTAPI
+CdfsFsdDispatch(
+ PDEVICE_OBJECT DeviceObject,
+ PIRP Irp)
+{
+ PCDFS_IRP_CONTEXT IrpContext = NULL;
+ NTSTATUS Status;
+
+ DPRINT("CdfsFsdDispatch()\n");
+
+ IrpContext = CdfsAllocateIrpContext(DeviceObject, Irp);
+ if (IrpContext == NULL)
+ {
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ Irp->IoStatus.Status = Status;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ }
+ else
+ {
+ Status = CdfsDispatch(IrpContext);
+ }
+
+ return Status;
+}
Propchange: trunk/reactos/drivers/filesystems/cdfs/dispatch.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/drivers/filesystems/cdfs/fastio.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/cdfs/f…
==============================================================================
--- trunk/reactos/drivers/filesystems/cdfs/fastio.c (added)
+++ trunk/reactos/drivers/filesystems/cdfs/fastio.c [iso-8859-1] Mon Jun 1 13:13:18 2015
@@ -0,0 +1,116 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS kernel
+ * FILE: drivers/filesystems/cdfs/fastio.c
+ * PURPOSE: CDROM (ISO 9660) filesystem driver
+ * PROGRAMMER: Pierre Schweitzer
+ */
+
+/* INCLUDES *****************************************************************/
+
+#include "cdfs.h"
+
+#define NDEBUG
+#include <debug.h>
+
+/* FUNCTIONS ****************************************************************/
+
+BOOLEAN
+NTAPI
+CdfsAcquireForLazyWrite(
+ _In_ PVOID Context,
+ _In_ BOOLEAN Wait)
+{
+ PFCB Fcb = (PFCB)Context;
+ ASSERT(Fcb);
+ DPRINT("CdfsAcquireForLazyWrite(): Fcb %p\n", Fcb);
+
+ if (!ExAcquireResourceExclusiveLite(&(Fcb->MainResource), Wait))
+ {
+ DPRINT("CdfsAcquireForLazyWrite(): ExReleaseResourceLite failed.\n");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+VOID
+NTAPI
+CdfsReleaseFromLazyWrite(
+ _In_ PVOID Context)
+{
+ PFCB Fcb = (PFCB)Context;
+ ASSERT(Fcb);
+ DPRINT("CdfsReleaseFromLazyWrite(): Fcb %p\n", Fcb);
+
+ ExReleaseResourceLite(&(Fcb->MainResource));
+}
+
+BOOLEAN
+NTAPI
+CdfsFastIoCheckIfPossible(
+ _In_ PFILE_OBJECT FileObject,
+ _In_ PLARGE_INTEGER FileOffset,
+ _In_ ULONG Length,
+ _In_ BOOLEAN Wait,
+ _In_ ULONG LockKey,
+ _In_ BOOLEAN CheckForReadOperation,
+ _Out_ PIO_STATUS_BLOCK IoStatus,
+ _In_ PDEVICE_OBJECT DeviceObject)
+{
+ /* Deny FastIo */
+ UNREFERENCED_PARAMETER(FileObject);
+ UNREFERENCED_PARAMETER(FileOffset);
+ UNREFERENCED_PARAMETER(Length);
+ UNREFERENCED_PARAMETER(Wait);
+ UNREFERENCED_PARAMETER(LockKey);
+ UNREFERENCED_PARAMETER(CheckForReadOperation);
+ UNREFERENCED_PARAMETER(IoStatus);
+ UNREFERENCED_PARAMETER(DeviceObject);
+ return FALSE;
+}
+
+BOOLEAN
+NTAPI
+CdfsFastIoRead(
+ _In_ PFILE_OBJECT FileObject,
+ _In_ PLARGE_INTEGER FileOffset,
+ _In_ ULONG Length,
+ _In_ BOOLEAN Wait,
+ _In_ ULONG LockKey,
+ _Out_ PVOID Buffer,
+ _Out_ PIO_STATUS_BLOCK IoStatus,
+ _In_ PDEVICE_OBJECT DeviceObject)
+{
+ DBG_UNREFERENCED_PARAMETER(FileObject);
+ DBG_UNREFERENCED_PARAMETER(FileOffset);
+ DBG_UNREFERENCED_PARAMETER(Length);
+ DBG_UNREFERENCED_PARAMETER(Wait);
+ DBG_UNREFERENCED_PARAMETER(LockKey);
+ DBG_UNREFERENCED_PARAMETER(Buffer);
+ DBG_UNREFERENCED_PARAMETER(IoStatus);
+ DBG_UNREFERENCED_PARAMETER(DeviceObject);
+ return FALSE;
+}
+
+BOOLEAN
+NTAPI
+CdfsFastIoWrite(
+ _In_ PFILE_OBJECT FileObject,
+ _In_ PLARGE_INTEGER FileOffset,
+ _In_ ULONG Length,
+ _In_ BOOLEAN Wait,
+ _In_ ULONG LockKey,
+ _In_ PVOID Buffer,
+ _Out_ PIO_STATUS_BLOCK IoStatus,
+ _In_ PDEVICE_OBJECT DeviceObject)
+{
+ DBG_UNREFERENCED_PARAMETER(FileObject);
+ DBG_UNREFERENCED_PARAMETER(FileOffset);
+ DBG_UNREFERENCED_PARAMETER(Length);
+ DBG_UNREFERENCED_PARAMETER(Wait);
+ DBG_UNREFERENCED_PARAMETER(LockKey);
+ DBG_UNREFERENCED_PARAMETER(Buffer);
+ DBG_UNREFERENCED_PARAMETER(IoStatus);
+ DBG_UNREFERENCED_PARAMETER(DeviceObject);
+ return FALSE;
+}
Propchange: trunk/reactos/drivers/filesystems/cdfs/fastio.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/drivers/filesystems/cdfs/finfo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/cdfs/f…
==============================================================================
--- trunk/reactos/drivers/filesystems/cdfs/finfo.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/cdfs/finfo.c [iso-8859-1] Mon Jun 1 13:13:18 2015
@@ -334,9 +334,11 @@
* FUNCTION: Retrieve the specified file information
*/
NTSTATUS NTAPI
-CdfsQueryInformation(PDEVICE_OBJECT DeviceObject,
- PIRP Irp)
-{
+CdfsQueryInformation(
+ PCDFS_IRP_CONTEXT IrpContext)
+{
+ PIRP Irp;
+ PDEVICE_OBJECT DeviceObject;
FILE_INFORMATION_CLASS FileInformationClass;
PIO_STACK_LOCATION Stack;
PFILE_OBJECT FileObject;
@@ -348,7 +350,9 @@
DPRINT("CdfsQueryInformation() called\n");
- Stack = IoGetCurrentIrpStackLocation(Irp);
+ Irp = IrpContext->Irp;
+ DeviceObject = IrpContext->DeviceObject;
+ Stack = IrpContext->Stack;
FileInformationClass = Stack->Parameters.QueryFile.FileInformationClass;
FileObject = Stack->FileObject;
Fcb = FileObject->FsContext;
@@ -423,8 +427,6 @@
else
Irp->IoStatus.Information = 0;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
return(Status);
}
@@ -452,9 +454,10 @@
* FUNCTION: Set the specified file information
*/
NTSTATUS NTAPI
-CdfsSetInformation(PDEVICE_OBJECT DeviceObject,
- PIRP Irp)
-{
+CdfsSetInformation(
+ PCDFS_IRP_CONTEXT IrpContext)
+{
+ PIRP Irp;
FILE_INFORMATION_CLASS FileInformationClass;
PIO_STACK_LOCATION Stack;
PFILE_OBJECT FileObject;
@@ -462,11 +465,10 @@
NTSTATUS Status = STATUS_SUCCESS;
- UNREFERENCED_PARAMETER(DeviceObject);
-
DPRINT("CdfsSetInformation() called\n");
- Stack = IoGetCurrentIrpStackLocation(Irp);
+ Irp = IrpContext->Irp;
+ Stack = IrpContext->Stack;
FileInformationClass = Stack->Parameters.SetFile.FileInformationClass;
FileObject = Stack->FileObject;
@@ -492,8 +494,6 @@
Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = 0;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
return Status;
}
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] Mon Jun 1 13:13:18 2015
@@ -550,17 +550,25 @@
NTSTATUS NTAPI
-CdfsFileSystemControl(PDEVICE_OBJECT DeviceObject,
- PIRP Irp)
-{
+CdfsFileSystemControl(
+ PCDFS_IRP_CONTEXT IrpContext)
+{
+ PIRP Irp;
+ PDEVICE_OBJECT DeviceObject;
PIO_STACK_LOCATION Stack;
NTSTATUS Status;
DPRINT("CdfsFileSystemControl() called\n");
- Stack = IoGetCurrentIrpStackLocation(Irp);
-
- switch (Stack->MinorFunction)
+ ASSERT(IrpContext);
+
+ DeviceObject = IrpContext->DeviceObject;
+ Irp = IrpContext->Irp;
+ Stack = IrpContext->Stack;
+
+ Irp->IoStatus.Information = 0;
+
+ switch (IrpContext->MinorFunction)
{
case IRP_MN_KERNEL_CALL:
case IRP_MN_USER_FS_REQUEST:
@@ -594,11 +602,6 @@
break;
}
- Irp->IoStatus.Status = Status;
- Irp->IoStatus.Information = 0;
-
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
return(Status);
}
Modified: trunk/reactos/drivers/filesystems/cdfs/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/cdfs/m…
==============================================================================
--- trunk/reactos/drivers/filesystems/cdfs/misc.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/cdfs/misc.c [iso-8859-1] Mon Jun 1 13:13:18 2015
@@ -34,6 +34,78 @@
/* FUNCTIONS ****************************************************************/
+/*
+ * FUNCTION: Used with IRP to set them to TopLevelIrp field
+ * ARGUMENTS:
+ * Irp = The IRP to set
+ * RETURNS: TRUE if top level was null, else FALSE
+ */
+BOOLEAN
+CdfsIsIrpTopLevel(
+ PIRP Irp)
+{
+ BOOLEAN ReturnCode = FALSE;
+
+ DPRINT("CdfsIsIrpTopLevel()\n");
+
+ if (IoGetTopLevelIrp() == NULL)
+ {
+ IoSetTopLevelIrp(Irp);
+ ReturnCode = TRUE;
+ }
+
+ return ReturnCode;
+}
+
+
+/*
+ * FUNCTION: Allocate and fill a CDFS_IRP_CONTEXT struct in order to use it for IRP
+ * ARGUMENTS:
+ * DeviceObject = Used to fill in struct
+ * Irp = The IRP that need IRP_CONTEXT struct
+ * RETURNS: NULL or PCDFS_IRP_CONTEXT
+ */
+PCDFS_IRP_CONTEXT
+CdfsAllocateIrpContext(
+ PDEVICE_OBJECT DeviceObject,
+ PIRP Irp)
+{
+ PCDFS_IRP_CONTEXT IrpContext;
+
+ DPRINT("CdfsAllocateIrpContext()\n");
+
+ IrpContext =
(PCDFS_IRP_CONTEXT)ExAllocateFromNPagedLookasideList(&CdfsGlobalData->IrpContextLookasideList);
+ if (IrpContext == NULL)
+ return NULL;
+
+ RtlZeroMemory(IrpContext, sizeof(CDFS_IRP_CONTEXT));
+
+// IrpContext->Identifier.Type = NTFS_TYPE_IRP_CONTEST;
+// IrpContext->Identifier.Size = sizeof(NTFS_IRP_CONTEXT);
+ IrpContext->Irp = Irp;
+ IrpContext->DeviceObject = DeviceObject;
+ IrpContext->Stack = IoGetCurrentIrpStackLocation(Irp);
+ IrpContext->MajorFunction = IrpContext->Stack->MajorFunction;
+ IrpContext->MinorFunction = IrpContext->Stack->MinorFunction;
+ IrpContext->FileObject = IrpContext->Stack->FileObject;
+ IrpContext->IsTopLevel = (IoGetTopLevelIrp() == Irp);
+ IrpContext->PriorityBoost = IO_NO_INCREMENT;
+ IrpContext->Flags = IRPCONTEXT_COMPLETE;
+
+ if (IrpContext->MajorFunction == IRP_MJ_FILE_SYSTEM_CONTROL ||
+ IrpContext->MajorFunction == IRP_MJ_DEVICE_CONTROL ||
+ IrpContext->MajorFunction == IRP_MJ_SHUTDOWN ||
+ (IrpContext->MajorFunction != IRP_MJ_CLEANUP &&
+ IrpContext->MajorFunction != IRP_MJ_CLOSE &&
+ IoIsOperationSynchronous(Irp)))
+ {
+ IrpContext->Flags |= IRPCONTEXT_CANWAIT;
+ }
+
+ return IrpContext;
+}
+
+
VOID
CdfsSwapString(PWCHAR Out,
PUCHAR In,
Modified: trunk/reactos/drivers/filesystems/cdfs/volinfo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/cdfs/v…
==============================================================================
--- trunk/reactos/drivers/filesystems/cdfs/volinfo.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/cdfs/volinfo.c [iso-8859-1] Mon Jun 1 13:13:18
2015
@@ -168,9 +168,11 @@
NTSTATUS NTAPI
-CdfsQueryVolumeInformation(PDEVICE_OBJECT DeviceObject,
- PIRP Irp)
-{
+CdfsQueryVolumeInformation(
+ PCDFS_IRP_CONTEXT IrpContext)
+{
+ PIRP Irp;
+ PDEVICE_OBJECT DeviceObject;
FS_INFORMATION_CLASS FsInformationClass;
PIO_STACK_LOCATION Stack;
NTSTATUS Status = STATUS_SUCCESS;
@@ -179,7 +181,11 @@
DPRINT("CdfsQueryVolumeInformation() called\n");
- Stack = IoGetCurrentIrpStackLocation(Irp);
+ ASSERT(IrpContext);
+
+ Irp = IrpContext->Irp;
+ DeviceObject = IrpContext->DeviceObject;
+ Stack = IrpContext->Stack;
FsInformationClass = Stack->Parameters.QueryVolume.FsInformationClass;
BufferLength = Stack->Parameters.QueryVolume.Length;
SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
@@ -223,23 +229,24 @@
Stack->Parameters.QueryVolume.Length - BufferLength;
else
Irp->IoStatus.Information = 0;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
return(Status);
}
NTSTATUS NTAPI
-CdfsSetVolumeInformation(PDEVICE_OBJECT DeviceObject,
- PIRP Irp)
-{
+CdfsSetVolumeInformation(
+ PCDFS_IRP_CONTEXT IrpContext)
+{
+ PIRP Irp;
+
DPRINT("CdfsSetVolumeInformation() called\n");
- UNREFERENCED_PARAMETER(DeviceObject);
-
+ ASSERT(IrpContext);
+
+ Irp = IrpContext->Irp;
Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
Irp->IoStatus.Information = 0;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
return(STATUS_NOT_SUPPORTED);
}