Author: pschweitzer
Date: Sun Mar 9 08:58:25 2008
New Revision: 32621
URL:
http://svn.reactos.org/svn/reactos?rev=3D32621&view=3Drev
Log:
- Reworked NtfsAllocateIrpContext to avoid working with null IRP....
- Rewritten NtfsFsdDirectoryControl (using IrpContext, etc)
Modified:
trunk/reactos/drivers/filesystems/ntfs/dirctl.c
trunk/reactos/drivers/filesystems/ntfs/misc.c
Modified: trunk/reactos/drivers/filesystems/ntfs/dirctl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/n=
tfs/dirctl.c?rev=3D32621&r1=3D32620&r2=3D32621&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/drivers/filesystems/ntfs/dirctl.c (original)
+++ trunk/reactos/drivers/filesystems/ntfs/dirctl.c Sun Mar 9 08:58:25 2008
@@ -477,10 +477,11 @@
}
#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 =3D 0;
PUNICODE_STRING SearchPattern =3D NULL;
@@ -498,6 +499,10 @@
=
DPRINT1("NtfsQueryDirectory() called\n");
=
+ ASSERT(IrpContext);
+ Irp =3D IrpContext->Irp;
+ DeviceObject =3D IrpContext->DeviceObject;
+
DeviceExtension =3D DeviceObject->DeviceExtension;
Stack =3D IoGetCurrentIrpStackLocation(Irp);
FileObject =3D Stack->FileObject;
@@ -672,37 +677,49 @@
NtfsFsdDirectoryControl(PDEVICE_OBJECT DeviceObject,
PIRP Irp)
{
- PIO_STACK_LOCATION Stack;
- NTSTATUS Status;
+ PNTFS_IRP_CONTEXT IrpContext =3D NULL;
+ NTSTATUS Status =3D STATUS_UNSUCCESSFUL;
=
DPRINT1("NtfsDirectoryControl() called\n");
=
- Stack =3D IoGetCurrentIrpStackLocation(Irp);
-
- switch (Stack->MinorFunction)
- {
- case IRP_MN_QUERY_DIRECTORY:
- Status =3D NtfsQueryDirectory(DeviceObject,
- Irp);
- break;
-
- case IRP_MN_NOTIFY_CHANGE_DIRECTORY:
- DPRINT1("IRP_MN_NOTIFY_CHANGE_DIRECTORY\n");
- Status =3D STATUS_NOT_IMPLEMENTED;
- break;
-
- default:
- DPRINT1("NTFS: MinorFunction %d\n", Stack->MinorFunction);
- Status =3D STATUS_INVALID_DEVICE_REQUEST;
- break;
- }
-
+ FsRtlEnterFileSystem();
+ ASSERT(DeviceObject);
+ ASSERT(Irp);
+
+ NtfsIsIrpTopLevel(Irp);
+
+ IrpContext =3D NtfsAllocateIrpContext(DeviceObject, Irp);
+ if (IrpContext)
+ {
+ switch (IrpContext->MinorFunction)
+ {
+ case IRP_MN_QUERY_DIRECTORY:
+ Status =3D NtfsQueryDirectory(IrpContext);
+ break;
+ =
+ case IRP_MN_NOTIFY_CHANGE_DIRECTORY:
+ DPRINT1("IRP_MN_NOTIFY_CHANGE_DIRECTORY\n");
+ Status =3D STATUS_NOT_IMPLEMENTED;
+ break;
+ =
+ default:
+ Status =3D STATUS_INVALID_DEVICE_REQUEST;
+ break;
+ }
+ }
+ else
+ Status =3D STATUS_INSUFFICIENT_RESOURCES;
+ =
Irp->IoStatus.Status =3D Status;
Irp->IoStatus.Information =3D 0;
-
IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
- return(Status);
+ =
+ if (IrpContext)
+ ExFreePoolWithTag(IrpContext, TAG('N', 'I', 'R',
'P'));
+ =
+ IoSetTopLevelIrp(NULL);
+ FsRtlExitFileSystem();
+ return Status;
}
=
/* EOF */
Modified: trunk/reactos/drivers/filesystems/ntfs/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/n=
tfs/misc.c?rev=3D32621&r1=3D32620&r2=3D32621&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/drivers/filesystems/ntfs/misc.c (original)
+++ trunk/reactos/drivers/filesystems/ntfs/misc.c Sun Mar 9 08:58:25 2008
@@ -74,20 +74,24 @@
=
TRACE_(NTFS, "NtfsAllocateIrpContext()\n");
=
- IoStackLocation =3D IoGetCurrentIrpStackLocation(Irp);
- =
IrpContext =3D (PNTFS_IRP_CONTEXT)ExAllocatePoolWithTag(NonPagedPool, si=
zeof(NTFS_IRP_CONTEXT), TAG('N', 'I', 'R', 'P'));
if (IrpContext =3D=3D NULL)
return NULL;
- =
RtlZeroMemory(IrpContext, sizeof(NTFS_IRP_CONTEXT));
+
IrpContext->Identifier.Type =3D NTFS_TYPE_IRP_CONTEST;
IrpContext->Identifier.Size =3D sizeof(NTFS_IRP_CONTEXT);
IrpContext->Irp =3D Irp;
- IrpContext->MajorFunction =3D IoStackLocation->MajorFunction;
- IrpContext->MinorFunction =3D IoStackLocation->MinorFunction;
IrpContext->DeviceObject =3D DeviceObject;
- IrpContext->IsTopLevel =3D (IoGetTopLevelIrp() =3D=3D Irp);
+ if (Irp)
+ {
+ IoStackLocation =3D IoGetCurrentIrpStackLocation(Irp);
+ ASSERT(IoStackLocation);
+
+ IrpContext->MajorFunction =3D IoStackLocation->MajorFunction;
+ IrpContext->MinorFunction =3D IoStackLocation->MinorFunction;
+ IrpContext->IsTopLevel =3D (IoGetTopLevelIrp() =3D=3D Irp);
+ }
=
return IrpContext;
}