mirror of
https://github.com/reactos/reactos.git
synced 2025-04-22 13:10:39 +00:00
[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. svn path=/trunk/; revision=67988
This commit is contained in:
parent
cf09e71a19
commit
2ae749ea34
10 changed files with 513 additions and 188 deletions
|
@ -9,6 +9,8 @@ list(APPEND SOURCE
|
|||
create.c
|
||||
devctrl.c
|
||||
dirctl.c
|
||||
dispatch.c
|
||||
fastio.c
|
||||
fcb.c
|
||||
finfo.c
|
||||
fsctl.c
|
||||
|
|
|
@ -84,20 +84,14 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
|
|||
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;
|
||||
|
@ -105,6 +99,10 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
|
|||
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;
|
||||
|
||||
/* Cache manager */
|
||||
|
@ -122,98 +120,3 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
|
|||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -238,17 +238,46 @@ typedef struct _CCB
|
|||
#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 @@ CdfsCreate(PDEVICE_OBJECT DeviceObject,
|
|||
|
||||
/* devctrl.c */
|
||||
|
||||
DRIVER_DISPATCH CdfsDeviceControl;
|
||||
|
||||
NTSTATUS NTAPI
|
||||
CdfsDeviceControl(PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp);
|
||||
CdfsDeviceControl(
|
||||
PCDFS_IRP_CONTEXT IrpContext);
|
||||
|
||||
/* dirctl.c */
|
||||
|
||||
|
@ -318,6 +345,29 @@ NTAPI
|
|||
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,32 +439,39 @@ CdfsGetFCBForFile(PDEVICE_EXTENSION Vcb,
|
|||
|
||||
/* finfo.c */
|
||||
|
||||
DRIVER_DISPATCH CdfsQueryInformation;
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CdfsQueryInformation(
|
||||
PCDFS_IRP_CONTEXT IrpContext);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CdfsQueryInformation(PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp);
|
||||
|
||||
DRIVER_DISPATCH CdfsSetInformation;
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CdfsSetInformation(PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp);
|
||||
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,
|
||||
PUCHAR In,
|
||||
|
@ -454,35 +511,14 @@ CdfsWrite(PDEVICE_OBJECT DeviceObject,
|
|||
|
||||
/* volinfo.c */
|
||||
|
||||
DRIVER_DISPATCH CdfsQueryVolumeInformation;
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CdfsQueryVolumeInformation(
|
||||
PCDFS_IRP_CONTEXT IrpContext);
|
||||
|
||||
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;
|
||||
CdfsSetVolumeInformation(
|
||||
PCDFS_IRP_CONTEXT IrpContext);
|
||||
|
||||
#endif /* CDFS_H */
|
||||
|
|
|
@ -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 @@ CdfsDeviceControl(PDEVICE_OBJECT DeviceObject,
|
|||
{
|
||||
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 @@ CdfsDeviceControl(PDEVICE_OBJECT DeviceObject,
|
|||
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 @@ CdfsDeviceControl(PDEVICE_OBJECT DeviceObject,
|
|||
/* We should handle this one, but we don't! */
|
||||
Status = STATUS_NOT_IMPLEMENTED;
|
||||
Irp->IoStatus.Status = Status;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
186
reactos/drivers/filesystems/cdfs/dispatch.c
Normal file
186
reactos/drivers/filesystems/cdfs/dispatch.c
Normal file
|
@ -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;
|
||||
}
|
116
reactos/drivers/filesystems/cdfs/fastio.c
Normal file
116
reactos/drivers/filesystems/cdfs/fastio.c
Normal file
|
@ -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;
|
||||
}
|
|
@ -334,9 +334,11 @@ CdfsGetAllInformation(PFILE_OBJECT FileObject,
|
|||
* 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 @@ CdfsQueryInformation(PDEVICE_OBJECT DeviceObject,
|
|||
|
||||
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 @@ CdfsQueryInformation(PDEVICE_OBJECT DeviceObject,
|
|||
else
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
return(Status);
|
||||
}
|
||||
|
||||
|
@ -452,9 +454,10 @@ CdfsSetPositionInformation(PFILE_OBJECT FileObject,
|
|||
* 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 @@ CdfsSetInformation(PDEVICE_OBJECT DeviceObject,
|
|||
|
||||
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 @@ CdfsSetInformation(PDEVICE_OBJECT DeviceObject,
|
|||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
|
|
@ -550,17 +550,25 @@ CdfsSetCompression(
|
|||
|
||||
|
||||
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);
|
||||
ASSERT(IrpContext);
|
||||
|
||||
switch (Stack->MinorFunction)
|
||||
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 @@ CdfsFileSystemControl(PDEVICE_OBJECT DeviceObject,
|
|||
break;
|
||||
}
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
return(Status);
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -168,9 +168,11 @@ CdfsGetFsDeviceInformation
|
|||
|
||||
|
||||
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 @@ CdfsQueryVolumeInformation(PDEVICE_OBJECT DeviceObject,
|
|||
|
||||
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 @@ CdfsQueryVolumeInformation(PDEVICE_OBJECT DeviceObject,
|
|||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue