2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/fsrtl/pnp.c
5 * PURPOSE: Manages PnP support routines for file system drivers.
6 * PROGRAMMERS: Pierre Schweitzer
9 /* INCLUDES ******************************************************************/
16 /* PUBLIC FUNCTIONS **********************************************************/
19 * @name FsRtlNotifyVolumeEvent
22 * Notifies system (and applications) that something changed on volume.
23 * FSD should call it each time volume status changes.
26 * FileObject for the volume
29 * Event that occurs one the volume
31 * @return STATUS_SUCCESS if notification went well
33 * @remarks Only present in NT 5+.
38 FsRtlNotifyVolumeEvent(IN PFILE_OBJECT FileObject
,
43 PDEVICE_OBJECT DeviceObject
= NULL
;
44 TARGET_DEVICE_CUSTOM_NOTIFICATION Notification
;
46 Status
= IoGetRelatedTargetDevice(FileObject
, &DeviceObject
);
47 if (!NT_SUCCESS(Status
))
52 Status
= STATUS_INVALID_PARAMETER
;
54 Notification
.Version
= 1;
55 Notification
.Size
= sizeof(TARGET_DEVICE_CUSTOM_NOTIFICATION
);
56 /* MSDN says that FileObject must be null
57 when calling IoReportTargetDeviceChangeAsynchronous */
58 Notification
.FileObject
= NULL
;
59 Notification
.NameBufferOffset
= -1;
60 /* Find the good GUID associated with the event */
63 case FSRTL_VOLUME_DISMOUNT
:
65 Guid
= (LPGUID
)&GUID_IO_VOLUME_DISMOUNT
;
68 case FSRTL_VOLUME_DISMOUNT_FAILED
:
70 Guid
= (LPGUID
)&GUID_IO_VOLUME_DISMOUNT_FAILED
;
73 case FSRTL_VOLUME_LOCK
:
75 Guid
= (LPGUID
)&GUID_IO_VOLUME_LOCK
;
78 case FSRTL_VOLUME_LOCK_FAILED
:
80 Guid
= (LPGUID
)&GUID_IO_VOLUME_LOCK_FAILED
;
83 case FSRTL_VOLUME_MOUNT
:
85 Guid
= (LPGUID
)&GUID_IO_VOLUME_MOUNT
;
88 case FSRTL_VOLUME_UNLOCK
:
90 Guid
= (LPGUID
)&GUID_IO_VOLUME_UNLOCK
;
96 /* Copy GUID to notification structure and then report the change */
97 RtlCopyMemory(&(Notification
.Event
), Guid
, sizeof(GUID
));
99 if (EventCode
== FSRTL_VOLUME_MOUNT
)
101 IoReportTargetDeviceChangeAsynchronous(DeviceObject
,
108 IoReportTargetDeviceChange(DeviceObject
,
112 Status
= STATUS_SUCCESS
;
114 ObDereferenceObject(DeviceObject
);