Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

pnp.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1989-1998 Microsoft Corporation 00004 00005 Module Name: 00006 00007 PnP.c 00008 00009 Abstract: 00010 00011 The PnP package provides a method for file systems to 00012 notify applications and services that a volume is being 00013 locked or unlocked, so handles to it can be closed and 00014 reopened. 00015 00016 This module exports routines which help file systems 00017 do this notification. 00018 00019 Author: 00020 00021 Keith Kaplan [KeithKa] 01-Apr-1998 00022 00023 Revision History: 00024 00025 --*/ 00026 00027 #include "FsRtlP.h" 00028 00029 #ifndef FAR 00030 #define FAR 00031 #endif 00032 #include <IoEvent.h> 00033 00034 #ifdef ALLOC_PRAGMA 00035 #pragma alloc_text(PAGE, FsRtlNotifyVolumeEvent) 00036 #endif 00037 00038 00039 NTKERNELAPI 00040 NTSTATUS 00041 FsRtlNotifyVolumeEvent ( 00042 IN PFILE_OBJECT FileObject, 00043 IN ULONG EventCode 00044 ) 00045 00046 /*++ 00047 00048 Routine Description: 00049 00050 This routine notifies any registered applications that a 00051 volume is being locked, unlocked, etc. 00052 00053 Arguments: 00054 00055 FileeObject - Supplies a file object for the volume being 00056 locked. 00057 00058 EventCode - Which event is occuring -- e.g. FSRTL_VOLUME_LOCK 00059 00060 Return Value: 00061 00062 Status of the notification. 00063 00064 --*/ 00065 00066 { 00067 NTSTATUS Status = STATUS_SUCCESS; 00068 00069 TARGET_DEVICE_CUSTOM_NOTIFICATION Event; 00070 PDEVICE_OBJECT Pdo; 00071 00072 // 00073 // Retrieve the device object associated with this file object. 00074 // 00075 00076 Status = IoGetRelatedTargetDevice( FileObject, &Pdo ); 00077 00078 if (NT_SUCCESS( Status )) { 00079 00080 ASSERT(Pdo != NULL); 00081 00082 Event.Version = 1; 00083 Event.FileObject = NULL; 00084 Event.NameBufferOffset = -1; 00085 Event.Size = (USHORT)FIELD_OFFSET( TARGET_DEVICE_CUSTOM_NOTIFICATION, CustomDataBuffer ); 00086 00087 switch (EventCode) { 00088 00089 case FSRTL_VOLUME_DISMOUNT: 00090 00091 RtlCopyMemory( &Event.Event, &GUID_IO_VOLUME_DISMOUNT, sizeof( GUID )); 00092 break; 00093 00094 case FSRTL_VOLUME_DISMOUNT_FAILED: 00095 00096 RtlCopyMemory( &Event.Event, &GUID_IO_VOLUME_DISMOUNT_FAILED, sizeof( GUID )); 00097 break; 00098 00099 case FSRTL_VOLUME_LOCK: 00100 00101 RtlCopyMemory( &Event.Event, &GUID_IO_VOLUME_LOCK, sizeof( GUID )); 00102 break; 00103 00104 case FSRTL_VOLUME_LOCK_FAILED: 00105 00106 RtlCopyMemory( &Event.Event, &GUID_IO_VOLUME_LOCK_FAILED, sizeof( GUID )); 00107 break; 00108 00109 case FSRTL_VOLUME_MOUNT: 00110 00111 // 00112 // Mount notification is asynchronous to avoid deadlocks when someone 00113 // unwittingly causes a mount in the course of handling some other 00114 // PnP notification, e.g. MountMgr's device arrival code. 00115 // 00116 00117 RtlCopyMemory( &Event.Event, &GUID_IO_VOLUME_MOUNT, sizeof( GUID )); 00118 IoReportTargetDeviceChangeAsynchronous( Pdo, &Event, NULL, NULL ); 00119 ObDereferenceObject( Pdo ); 00120 return STATUS_SUCCESS; 00121 break; 00122 00123 case FSRTL_VOLUME_UNLOCK: 00124 00125 RtlCopyMemory( &Event.Event, &GUID_IO_VOLUME_UNLOCK, sizeof( GUID )); 00126 break; 00127 00128 default: 00129 00130 ObDereferenceObject( Pdo ); 00131 return STATUS_INVALID_PARAMETER; 00132 } 00133 00134 IoReportTargetDeviceChange( Pdo, &Event ); 00135 ObDereferenceObject( Pdo ); 00136 } 00137 00138 return Status; 00139 } 00140 00141

Generated on Sat May 15 19:41:15 2004 for test by doxygen 1.3.7