ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

pnp.c
Go to the documentation of this file.
00001 /*
00002  * PROJECT:         ReactOS Kernel
00003  * LICENSE:         GPL - See COPYING in the top level directory
00004  * FILE:            ntoskrnl/fsrtl/pnp.c
00005  * PURPOSE:         Manages PnP support routines for file system drivers.
00006  * PROGRAMMERS:     Pierre Schweitzer
00007  */
00008 
00009 /* INCLUDES ******************************************************************/
00010 
00011 #include <ntoskrnl.h>
00012 #include <ioevent.h>
00013 #define NDEBUG
00014 #include <debug.h>
00015 
00016 /* PUBLIC FUNCTIONS **********************************************************/
00017 
00018 /*++
00019  * @name FsRtlNotifyVolumeEvent
00020  * @implemented
00021  *
00022  * Notifies system (and applications) that something changed on volume.
00023  * FSD should call it each time volume status changes.
00024  *
00025  * @param FileObject
00026  *        FileObject for the volume
00027  *
00028  * @param EventCode
00029  *        Event that occurs one the volume
00030  *
00031  * @return STATUS_SUCCESS if notification went well
00032  *
00033  * @remarks Only present in NT 5+.
00034  *
00035  *--*/
00036 NTSTATUS
00037 NTAPI
00038 FsRtlNotifyVolumeEvent(IN PFILE_OBJECT FileObject,
00039                        IN ULONG EventCode)
00040 {
00041     NTSTATUS Status;
00042     LPGUID Guid = NULL;
00043     PDEVICE_OBJECT DeviceObject = NULL;
00044     TARGET_DEVICE_CUSTOM_NOTIFICATION Notification;
00045 
00046     Status = IoGetRelatedTargetDevice(FileObject, &DeviceObject);
00047     if (!NT_SUCCESS(Status))
00048     {
00049         return Status;
00050     }
00051 
00052     Status = STATUS_INVALID_PARAMETER;
00053 
00054     Notification.Version = 1;
00055     Notification.Size = sizeof(TARGET_DEVICE_CUSTOM_NOTIFICATION);
00056     /* MSDN says that FileObject must be null
00057        when calling IoReportTargetDeviceChangeAsynchronous */
00058     Notification.FileObject = NULL;
00059     Notification.NameBufferOffset = -1;
00060     /* Find the good GUID associated with the event */
00061     switch (EventCode)
00062     {
00063         case FSRTL_VOLUME_DISMOUNT:
00064         {
00065             Guid = (LPGUID)&GUID_IO_VOLUME_DISMOUNT;
00066             break;
00067         }
00068         case FSRTL_VOLUME_DISMOUNT_FAILED:
00069         {
00070             Guid = (LPGUID)&GUID_IO_VOLUME_DISMOUNT_FAILED;
00071             break;
00072         }
00073         case FSRTL_VOLUME_LOCK:
00074         {
00075             Guid = (LPGUID)&GUID_IO_VOLUME_LOCK;
00076             break;
00077         }
00078         case FSRTL_VOLUME_LOCK_FAILED:
00079         {
00080             Guid = (LPGUID)&GUID_IO_VOLUME_LOCK_FAILED;
00081             break;
00082         }
00083         case FSRTL_VOLUME_MOUNT:
00084         {
00085             Guid = (LPGUID)&GUID_IO_VOLUME_MOUNT;
00086             break;
00087         }
00088         case FSRTL_VOLUME_UNLOCK:
00089         {
00090             Guid = (LPGUID)&GUID_IO_VOLUME_UNLOCK;
00091             break;
00092         }
00093     }
00094     if (Guid)
00095     {
00096         /* Copy GUID to notification structure and then report the change */
00097         RtlCopyMemory(&(Notification.Event), Guid, sizeof(GUID));
00098 
00099         if (EventCode == FSRTL_VOLUME_MOUNT)
00100         {
00101             IoReportTargetDeviceChangeAsynchronous(DeviceObject,
00102                                                    &Notification,
00103                                                    NULL,
00104                                                    NULL);
00105         }
00106         else
00107         {
00108             IoReportTargetDeviceChange(DeviceObject,
00109                                        &Notification);
00110         }
00111 
00112         Status = STATUS_SUCCESS;
00113     }
00114     ObDereferenceObject(DeviceObject);
00115 
00116     return Status;
00117 }

Generated on Fri May 25 2012 04:15:59 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.