ReactOS  0.4.14-dev-98-gb0d4763
pnp.c
Go to the documentation of this file.
1 /*
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
7  */
8 
9 /* INCLUDES ******************************************************************/
10 
11 #include <ntoskrnl.h>
12 #include <ioevent.h>
13 #define NDEBUG
14 #include <debug.h>
15 
16 /* PUBLIC FUNCTIONS **********************************************************/
17 
18 /*++
19  * @name FsRtlNotifyVolumeEvent
20  * @implemented
21  *
22  * Notifies system (and applications) that something changed on volume.
23  * FSD should call it each time volume status changes.
24  *
25  * @param FileObject
26  * FileObject for the volume
27  *
28  * @param EventCode
29  * Event that occurs one the volume
30  *
31  * @return STATUS_SUCCESS if notification went well
32  *
33  * @remarks Only present in NT 5+.
34  *
35  *--*/
37 NTAPI
40 {
42  LPGUID Guid = NULL;
45 
47  if (!NT_SUCCESS(Status))
48  {
49  return Status;
50  }
51 
53 
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 */
61  switch (EventCode)
62  {
64  {
65  Guid = (LPGUID)&GUID_IO_VOLUME_DISMOUNT;
66  break;
67  }
69  {
70  Guid = (LPGUID)&GUID_IO_VOLUME_DISMOUNT_FAILED;
71  break;
72  }
73  case FSRTL_VOLUME_LOCK:
74  {
75  Guid = (LPGUID)&GUID_IO_VOLUME_LOCK;
76  break;
77  }
79  {
80  Guid = (LPGUID)&GUID_IO_VOLUME_LOCK_FAILED;
81  break;
82  }
83  case FSRTL_VOLUME_MOUNT:
84  {
85  Guid = (LPGUID)&GUID_IO_VOLUME_MOUNT;
86  break;
87  }
89  {
90  Guid = (LPGUID)&GUID_IO_VOLUME_UNLOCK;
91  break;
92  }
93  }
94  if (Guid)
95  {
96  /* Copy GUID to notification structure and then report the change */
97  RtlCopyMemory(&(Notification.Event), Guid, sizeof(GUID));
98 
100  {
102  &Notification,
103  NULL,
104  NULL);
105  }
106  else
107  {
109  &Notification);
110  }
111 
113  }
115 
116  return Status;
117 }
#define IN
Definition: typedefs.h:38
#define FSRTL_VOLUME_DISMOUNT
Definition: ntifs_ex.h:439
NTSTATUS NTAPI IoGetRelatedTargetDevice(IN PFILE_OBJECT FileObject, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1607
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
struct _TARGET_DEVICE_CUSTOM_NOTIFICATION TARGET_DEVICE_CUSTOM_NOTIFICATION
_In_ NDIS_STATUS EventCode
Definition: ndis.h:4751
#define FSRTL_VOLUME_DISMOUNT_FAILED
Definition: ntifs_ex.h:440
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define FSRTL_VOLUME_UNLOCK
Definition: ntifs_ex.h:443
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
#define FSRTL_VOLUME_LOCK_FAILED
Definition: ntifs_ex.h:442
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
static GUID * Guid
Definition: apphelp.c:93
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI IoReportTargetDeviceChange(IN PDEVICE_OBJECT PhysicalDeviceObject, IN PVOID NotificationStructure)
Definition: pnpreport.c:469
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
NTSTATUS NTAPI FsRtlNotifyVolumeEvent(IN PFILE_OBJECT FileObject, IN ULONG EventCode)
Definition: pnp.c:38
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
* PFILE_OBJECT
Definition: iotypes.h:1955
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define FSRTL_VOLUME_LOCK
Definition: ntifs_ex.h:441
#define FSRTL_VOLUME_MOUNT
Definition: ntifs_ex.h:444
unsigned int ULONG
Definition: retypes.h:1
struct _FILE_OBJECT * FileObject
Definition: iotypes.h:975
return STATUS_SUCCESS
Definition: btrfs.c:2966
NTSTATUS NTAPI IoReportTargetDeviceChangeAsynchronous(IN PDEVICE_OBJECT PhysicalDeviceObject, IN PVOID NotificationStructure, IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback OPTIONAL, IN PVOID Context OPTIONAL)
Definition: pnpreport.c:519
GUID * LPGUID
Definition: guiddef.h:81