Author: tkreuzer
Date: Tue Aug 17 16:04:46 2010
New Revision: 48559
URL:
http://svn.reactos.org/svn/reactos?rev=48559&view=rev
Log:
[NTOSKRNL]
- Simplified IopGetRelatedTargetDevice implementation
- Added notification in case of success in NtSetVolumeInformationFile()
Patch by Pierre Schweitzer
Modified:
trunk/reactos/ntoskrnl/io/iomgr/device.c
trunk/reactos/ntoskrnl/io/iomgr/iofunc.c
Modified: trunk/reactos/ntoskrnl/io/iomgr/device.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/device.c…
==============================================================================
--- trunk/reactos/ntoskrnl/io/iomgr/device.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/io/iomgr/device.c [iso-8859-1] Tue Aug 17 16:04:46 2010
@@ -671,7 +671,6 @@
{
NTSTATUS Status;
IO_STACK_LOCATION Stack = {0};
- IO_STATUS_BLOCK IoStatusBlock;
PDEVICE_RELATIONS DeviceRelations;
PDEVICE_OBJECT DeviceObject = NULL;
@@ -682,18 +681,16 @@
if (!DeviceObject) return STATUS_NO_SUCH_DEVICE;
/* Define input parameters */
+ Stack.MajorFunction = IRP_MJ_PNP;
+ Stack.MinorFunction = IRP_MN_QUERY_DEVICE_RELATIONS;
Stack.Parameters.QueryDeviceRelations.Type = TargetDeviceRelation;
Stack.FileObject = FileObject;
/* Call the driver to query all relations (IRP_MJ_PNP) */
- Status = IopInitiatePnpIrp(DeviceObject,
- &IoStatusBlock,
- IRP_MN_QUERY_DEVICE_RELATIONS,
- &Stack);
+ Status = IopSynchronousCall(DeviceObject,
+ &Stack,
+ (PVOID)&DeviceRelations);
if (!NT_SUCCESS(Status)) return Status;
-
- /* Get returned pointer to DEVICE_RELATIONS */
- DeviceRelations = (PDEVICE_RELATIONS)IoStatusBlock.Information;
/* Make sure it's not NULL and contains only one object */
ASSERT(DeviceRelations);
Modified: trunk/reactos/ntoskrnl/io/iomgr/iofunc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/iofunc.c…
==============================================================================
--- trunk/reactos/ntoskrnl/io/iomgr/iofunc.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/io/iomgr/iofunc.c [iso-8859-1] Tue Aug 17 16:04:46 2010
@@ -11,6 +11,7 @@
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
+#include <ioevent.h>
#define NDEBUG
#include <debug.h>
#include "internal/io_i.h"
@@ -3223,12 +3224,13 @@
PFILE_OBJECT FileObject;
PIRP Irp;
PIO_STACK_LOCATION StackPtr;
- PDEVICE_OBJECT DeviceObject;
+ PDEVICE_OBJECT DeviceObject, TargetDeviceObject;
PKEVENT Event = NULL;
BOOLEAN LocalEvent = FALSE;
KPROCESSOR_MODE PreviousMode = KeGetPreviousMode();
NTSTATUS Status;
IO_STATUS_BLOCK KernelIosb;
+ TARGET_DEVICE_CUSTOM_NOTIFICATION NotificationStructure;
PAGED_CODE();
IOTRACE(IO_API_DEBUG, "FileHandle: %p\n", FileHandle);
@@ -3277,6 +3279,10 @@
NULL);
if (!NT_SUCCESS(Status)) return Status;
+ /* Get target device for notification */
+ Status = IoGetRelatedTargetDevice(FileObject, &TargetDeviceObject);
+ if (!NT_SUCCESS(Status)) TargetDeviceObject = NULL;
+
/* Check if we should use Sync IO or not */
if (FileObject->Flags & FO_SYNCHRONOUS_IO)
{
@@ -3290,6 +3296,7 @@
if (!Event)
{
ObDereferenceObject(FileObject);
+ if (TargetDeviceObject) ObDereferenceObject(TargetDeviceObject);
return STATUS_INSUFFICIENT_RESOURCES;
}
KeInitializeEvent(Event, SynchronizationEvent, FALSE);
@@ -3304,7 +3311,11 @@
/* Allocate the IRP */
Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE);
- if (!Irp) return IopCleanupFailedIrp(FileObject, NULL, Event);
+ if (!Irp)
+ {
+ if (TargetDeviceObject) ObDereferenceObject(TargetDeviceObject);
+ return IopCleanupFailedIrp(FileObject, NULL, Event);
+ }
/* Set up the IRP */
Irp->RequestorMode = PreviousMode;
@@ -3339,6 +3350,7 @@
{
/* Allocating failed, clean up and return the exception code */
IopCleanupAfterException(FileObject, Irp, NULL, Event);
+ if (TargetDeviceObject) ObDereferenceObject(TargetDeviceObject);
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
@@ -3369,6 +3381,17 @@
PreviousMode,
&KernelIosb,
IoStatusBlock);
+ }
+
+ if (TargetDeviceObject && NT_SUCCESS(Status))
+ {
+ /* Time to report change */
+ NotificationStructure.Version = 1;
+ NotificationStructure.Size = sizeof(TARGET_DEVICE_CUSTOM_NOTIFICATION);
+ NotificationStructure.Event = GUID_IO_VOLUME_NAME_CHANGE;
+ NotificationStructure.FileObject = NULL;
+ NotificationStructure.NameBufferOffset = - 1;
+ Status = IoReportTargetDeviceChange(TargetDeviceObject,
&NotificationStructure);
}
/* Return status */