ReactOS  0.4.15-dev-1384-g878186b
shutdown.c File Reference
#include "vfat.h"
#include <debug.h>
Include dependency graph for shutdown.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static NTSTATUS VfatDiskShutDown (PVCB Vcb)
 
NTSTATUS NTAPI VfatShutdown (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file shutdown.c.

Function Documentation

◆ VfatDiskShutDown()

static NTSTATUS VfatDiskShutDown ( PVCB  Vcb)
static

Definition at line 20 of file shutdown.c.

22 {
23  PIRP Irp;
24  KEVENT Event;
27 
30  NULL, 0, NULL, &Event, &IoStatus);
31  if (Irp)
32  {
33  Status = IoCallDriver(Vcb->StorageDevice, Irp);
34  if (Status == STATUS_PENDING)
35  {
37  Status = IoStatus.Status;
38  }
39  }
40  else
41  {
43  }
44 
45  return Status;
46 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
PIRP NTAPI IoBuildSynchronousFsdRequest(IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN PVOID Buffer, IN ULONG Length, IN PLARGE_INTEGER StartingOffset, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:1069
#define IRP_MJ_SHUTDOWN
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:450
Status
Definition: gdiplustypes.h:24
#define STATUS_PENDING
Definition: ntstatus.h:82
#define Vcb
Definition: cdprocs.h:1415
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define NULL
Definition: types.h:112
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:155

Referenced by VfatShutdown().

◆ VfatShutdown()

NTSTATUS NTAPI VfatShutdown ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 51 of file shutdown.c.

54 {
56  PLIST_ENTRY ListEntry;
57  PDEVICE_EXTENSION DeviceExt;
58 
59  DPRINT("VfatShutdown(DeviceObject %p, Irp %p)\n",DeviceObject, Irp);
60 
62 
63  /* FIXME: block new mount requests */
65 
67  {
68  Irp->IoStatus.Status = STATUS_SUCCESS;
70  ListEntry = VfatGlobalData->VolumeListHead.Flink;
71  while (ListEntry != &VfatGlobalData->VolumeListHead)
72  {
73  DeviceExt = CONTAINING_RECORD(ListEntry, VCB, VolumeListEntry);
74  ListEntry = ListEntry->Flink;
75 
76  ExAcquireResourceExclusiveLite(&DeviceExt->DirResource, TRUE);
77 
78  /* Flush volume & files */
79  Status = VfatFlushVolume(DeviceExt, DeviceExt->VolumeFcb);
80 
81  /* We're performing a clean shutdown */
82  if (BooleanFlagOn(DeviceExt->VolumeFcb->Flags, VCB_CLEAR_DIRTY) &&
83  BooleanFlagOn(DeviceExt->VolumeFcb->Flags, VCB_IS_DIRTY))
84  {
85  /* Drop the dirty bit */
86  if (NT_SUCCESS(SetDirtyStatus(DeviceExt, FALSE)))
87  DeviceExt->VolumeFcb->Flags &= ~VCB_IS_DIRTY;
88  }
89 
90  if (NT_SUCCESS(Status))
91  {
92  Status = VfatDiskShutDown(DeviceExt);
93  if (!NT_SUCCESS(Status))
94  {
95  DPRINT1("VfatDiskShutDown failed, status = %x\n", Status);
96  }
97  }
98  else
99  {
100  DPRINT1("VfatFlushVolume failed, status = %x\n", Status);
101  }
102  ExReleaseResourceLite(&DeviceExt->DirResource);
103 
104  /* Unmount the logical volume */
105 #ifdef ENABLE_SWAPOUT
106  VfatCheckForDismount(DeviceExt, FALSE);
107 #endif
108 
109  if (!NT_SUCCESS(Status))
110  Irp->IoStatus.Status = Status;
111  }
113 
114  /* FIXME: Free all global acquired resources */
115 
116  Status = Irp->IoStatus.Status;
117  }
118  else
119  {
120  Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
122  }
123 
124  Irp->IoStatus.Information = 0;
126 
128 
129  return Status;
130 }
LIST_ENTRY VolumeListHead
Definition: vfat.h:416
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
#define TRUE
Definition: types.h:120
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
#define VCB_IS_DIRTY
Definition: vfat.h:244
LONG NTSTATUS
Definition: precomp.h:26
#define VCB_CLEAR_DIRTY
Definition: vfat.h:245
NTSTATUS VfatFlushVolume(PDEVICE_EXTENSION DeviceExt, PVFATFCB VolumeFcb)
Definition: flush.c:51
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
Definition: cdstruc.h:498
static NTSTATUS VfatDiskShutDown(PVCB Vcb)
Definition: shutdown.c:20
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
Status
Definition: gdiplustypes.h:24
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
PDEVICE_OBJECT DeviceObject
Definition: vfat.h:412
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
Definition: typedefs.h:119
BOOLEAN VfatCheckForDismount(IN PDEVICE_EXTENSION DeviceExt, IN BOOLEAN Force)
Definition: misc.c:496
PVFAT_GLOBAL_DATA VfatGlobalData
Definition: iface.c:36
BOOLEAN ShutdownStarted
Definition: vfat.h:428
#define DPRINT1
Definition: precomp.h:8
ERESOURCE VolumeListLock
Definition: vfat.h:415
#define IO_NO_INCREMENT
Definition: iotypes.h:581
#define STATUS_SUCCESS
Definition: shellext.h:65
NTSTATUS SetDirtyStatus(PDEVICE_EXTENSION DeviceExt, BOOLEAN DirtyStatus)
Definition: fat.c:1015