mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 02:46:57 +00:00
[NTOSKRNL]
- Simplified IopGetRelatedTargetDevice implementation - Added notification in case of success in NtSetVolumeInformationFile() Patch by Pierre Schweitzer svn path=/trunk/; revision=48559
This commit is contained in:
parent
2ded5adf7c
commit
3d5db91752
2 changed files with 30 additions and 10 deletions
|
@ -671,7 +671,6 @@ IopGetRelatedTargetDevice(IN PFILE_OBJECT FileObject,
|
|||
{
|
||||
NTSTATUS Status;
|
||||
IO_STACK_LOCATION Stack = {0};
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
PDEVICE_RELATIONS DeviceRelations;
|
||||
PDEVICE_OBJECT DeviceObject = NULL;
|
||||
|
||||
|
@ -682,19 +681,17 @@ IopGetRelatedTargetDevice(IN PFILE_OBJECT FileObject,
|
|||
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);
|
||||
ASSERT(DeviceRelations->Count == 1);
|
||||
|
|
|
@ -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 @@ NtSetVolumeInformationFile(IN HANDLE FileHandle,
|
|||
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 @@ NtSetVolumeInformationFile(IN HANDLE FileHandle,
|
|||
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 @@ NtSetVolumeInformationFile(IN HANDLE FileHandle,
|
|||
if (!Event)
|
||||
{
|
||||
ObDereferenceObject(FileObject);
|
||||
if (TargetDeviceObject) ObDereferenceObject(TargetDeviceObject);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
KeInitializeEvent(Event, SynchronizationEvent, FALSE);
|
||||
|
@ -3304,7 +3311,11 @@ NtSetVolumeInformationFile(IN HANDLE FileHandle,
|
|||
|
||||
/* 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 @@ NtSetVolumeInformationFile(IN HANDLE FileHandle,
|
|||
{
|
||||
/* 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;
|
||||
|
@ -3371,6 +3383,17 @@ NtSetVolumeInformationFile(IN HANDLE FileHandle,
|
|||
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 */
|
||||
return Status;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue