ReactOS 0.4.15-dev-8102-g108db8f
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 12 of file shutdown.c.

Function Documentation

◆ VfatDiskShutDown()

static NTSTATUS VfatDiskShutDown ( PVCB  Vcb)
static

Definition at line 19 of file shutdown.c.

21{
22 PIRP Irp;
26
29 NULL, 0, NULL, &Event, &IoStatus);
30 if (Irp)
31 {
32 Status = IoCallDriver(Vcb->StorageDevice, Irp);
34 {
36 Status = IoStatus.Status;
37 }
38 }
39 else
40 {
42 }
43
44 return Status;
45}
LONG NTSTATUS
Definition: precomp.h:26
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
Status
Definition: gdiplustypes.h:25
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:159
#define KernelMode
Definition: asm.h:34
@ NotificationEvent
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 IoCallDriver
Definition: irp.c:1225
#define STATUS_PENDING
Definition: ntstatus.h:82
#define Vcb
Definition: cdprocs.h:1415
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define IRP_MJ_SHUTDOWN
@ Executive
Definition: ketypes.h:415

Referenced by VfatShutdown().

◆ VfatShutdown()

NTSTATUS NTAPI VfatShutdown ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 50 of file shutdown.c.

53{
55 PLIST_ENTRY ListEntry;
56 PDEVICE_EXTENSION DeviceExt;
57
58 DPRINT("VfatShutdown(DeviceObject %p, Irp %p)\n",DeviceObject, Irp);
59
61
62 /* FIXME: block new mount requests */
64
66 {
67 Irp->IoStatus.Status = STATUS_SUCCESS;
70 while (ListEntry != &VfatGlobalData->VolumeListHead)
71 {
72 DeviceExt = CONTAINING_RECORD(ListEntry, VCB, VolumeListEntry);
73 ListEntry = ListEntry->Flink;
74
75 ExAcquireResourceExclusiveLite(&DeviceExt->DirResource, TRUE);
76
77 /* Flush volume & files */
78 Status = VfatFlushVolume(DeviceExt, DeviceExt->VolumeFcb);
79
80 /* We're performing a clean shutdown */
81 if (BooleanFlagOn(DeviceExt->VolumeFcb->Flags, VCB_CLEAR_DIRTY) &&
82 BooleanFlagOn(DeviceExt->VolumeFcb->Flags, VCB_IS_DIRTY))
83 {
84 /* Drop the dirty bit */
85 if (NT_SUCCESS(SetDirtyStatus(DeviceExt, FALSE)))
86 DeviceExt->VolumeFcb->Flags &= ~VCB_IS_DIRTY;
87 }
88
89 if (NT_SUCCESS(Status))
90 {
91 Status = VfatDiskShutDown(DeviceExt);
92 if (!NT_SUCCESS(Status))
93 {
94 DPRINT1("VfatDiskShutDown failed, status = %x\n", Status);
95 }
96 }
97 else
98 {
99 DPRINT1("VfatFlushVolume failed, status = %x\n", Status);
100 }
101 ExReleaseResourceLite(&DeviceExt->DirResource);
102
103 /* Unmount the logical volume */
104#ifdef ENABLE_SWAPOUT
105 VfatCheckForDismount(DeviceExt, FALSE);
106#endif
107
108 if (!NT_SUCCESS(Status))
109 Irp->IoStatus.Status = Status;
110 }
112
113 /* FIXME: Free all global acquired resources */
114
115 Status = Irp->IoStatus.Status;
116 }
117 else
118 {
119 Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
121 }
122
123 Irp->IoStatus.Information = 0;
125
127
128 return Status;
129}
#define DPRINT1
Definition: precomp.h:8
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS SetDirtyStatus(PDEVICE_EXTENSION DeviceExt, BOOLEAN DirtyStatus)
Definition: fat.c:1017
BOOLEAN VfatCheckForDismount(IN PDEVICE_EXTENSION DeviceExt, IN BOOLEAN Force)
Definition: misc.c:495
static NTSTATUS VfatDiskShutDown(PVCB Vcb)
Definition: shutdown.c:19
#define ExAcquireResourceExclusiveLite(res, wait)
Definition: env_spec_w32.h:615
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
PVFAT_GLOBAL_DATA VfatGlobalData
Definition: iface.c:18
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1822
#define IoCompleteRequest
Definition: irp.c:1240
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
ERESOURCE VolumeListLock
Definition: vfat.h:415
LIST_ENTRY VolumeListHead
Definition: vfat.h:416
PDEVICE_OBJECT DeviceObject
Definition: vfat.h:412
BOOLEAN ShutdownStarted
Definition: vfat.h:428
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
Definition: cdstruc.h:498
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define VCB_CLEAR_DIRTY
Definition: vfat.h:245
#define VCB_IS_DIRTY
Definition: vfat.h:244
NTSTATUS VfatFlushVolume(PDEVICE_EXTENSION DeviceExt, PVFATFCB VolumeFcb)
Definition: flush.c:51
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define IO_NO_INCREMENT
Definition: iotypes.h:598