- Reworked NtfsAllocateIrpContext to avoid working with null IRP....

- Rewritten NtfsFsdDirectoryControl (using IrpContext, etc)

svn path=/trunk/; revision=32621
This commit is contained in:
Pierre Schweitzer 2008-03-09 13:58:25 +00:00
parent 8083445324
commit 7d27fdf54b
2 changed files with 52 additions and 31 deletions

View file

@ -477,10 +477,11 @@ CdfsGetBothDirectoryInformation(PFCB Fcb,
}
#endif
static NTSTATUS
NtfsQueryDirectory(PDEVICE_OBJECT DeviceObject,
PIRP Irp)
NTSTATUS
NtfsQueryDirectory(PNTFS_IRP_CONTEXT IrpContext)
{
PIRP Irp;
PDEVICE_OBJECT DeviceObject;
PDEVICE_EXTENSION DeviceExtension;
LONG BufferLength = 0;
PUNICODE_STRING SearchPattern = NULL;
@ -498,6 +499,10 @@ NtfsQueryDirectory(PDEVICE_OBJECT DeviceObject,
DPRINT1("NtfsQueryDirectory() called\n");
ASSERT(IrpContext);
Irp = IrpContext->Irp;
DeviceObject = IrpContext->DeviceObject;
DeviceExtension = DeviceObject->DeviceExtension;
Stack = IoGetCurrentIrpStackLocation(Irp);
FileObject = Stack->FileObject;
@ -672,37 +677,49 @@ NTSTATUS NTAPI
NtfsFsdDirectoryControl(PDEVICE_OBJECT DeviceObject,
PIRP Irp)
{
PIO_STACK_LOCATION Stack;
NTSTATUS Status;
PNTFS_IRP_CONTEXT IrpContext = NULL;
NTSTATUS Status = STATUS_UNSUCCESSFUL;
DPRINT1("NtfsDirectoryControl() called\n");
Stack = IoGetCurrentIrpStackLocation(Irp);
FsRtlEnterFileSystem();
ASSERT(DeviceObject);
ASSERT(Irp);
switch (Stack->MinorFunction)
NtfsIsIrpTopLevel(Irp);
IrpContext = NtfsAllocateIrpContext(DeviceObject, Irp);
if (IrpContext)
{
case IRP_MN_QUERY_DIRECTORY:
Status = NtfsQueryDirectory(DeviceObject,
Irp);
break;
case IRP_MN_NOTIFY_CHANGE_DIRECTORY:
DPRINT1("IRP_MN_NOTIFY_CHANGE_DIRECTORY\n");
Status = STATUS_NOT_IMPLEMENTED;
break;
default:
DPRINT1("NTFS: MinorFunction %d\n", Stack->MinorFunction);
Status = STATUS_INVALID_DEVICE_REQUEST;
break;
switch (IrpContext->MinorFunction)
{
case IRP_MN_QUERY_DIRECTORY:
Status = NtfsQueryDirectory(IrpContext);
break;
case IRP_MN_NOTIFY_CHANGE_DIRECTORY:
DPRINT1("IRP_MN_NOTIFY_CHANGE_DIRECTORY\n");
Status = STATUS_NOT_IMPLEMENTED;
break;
default:
Status = STATUS_INVALID_DEVICE_REQUEST;
break;
}
}
else
Status = STATUS_INSUFFICIENT_RESOURCES;
Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return(Status);
if (IrpContext)
ExFreePoolWithTag(IrpContext, TAG('N', 'I', 'R', 'P'));
IoSetTopLevelIrp(NULL);
FsRtlExitFileSystem();
return Status;
}
/* EOF */

View file

@ -74,20 +74,24 @@ NtfsAllocateIrpContext(PDEVICE_OBJECT DeviceObject,
TRACE_(NTFS, "NtfsAllocateIrpContext()\n");
IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
IrpContext = (PNTFS_IRP_CONTEXT)ExAllocatePoolWithTag(NonPagedPool, sizeof(NTFS_IRP_CONTEXT), TAG('N', 'I', 'R', 'P'));
if (IrpContext == NULL)
return NULL;
RtlZeroMemory(IrpContext, sizeof(NTFS_IRP_CONTEXT));
IrpContext->Identifier.Type = NTFS_TYPE_IRP_CONTEST;
IrpContext->Identifier.Size = sizeof(NTFS_IRP_CONTEXT);
IrpContext->Irp = Irp;
IrpContext->MajorFunction = IoStackLocation->MajorFunction;
IrpContext->MinorFunction = IoStackLocation->MinorFunction;
IrpContext->DeviceObject = DeviceObject;
IrpContext->IsTopLevel = (IoGetTopLevelIrp() == Irp);
if (Irp)
{
IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
ASSERT(IoStackLocation);
IrpContext->MajorFunction = IoStackLocation->MajorFunction;
IrpContext->MinorFunction = IoStackLocation->MinorFunction;
IrpContext->IsTopLevel = (IoGetTopLevelIrp() == Irp);
}
return IrpContext;
}