ReactOS 0.4.15-dev-5669-g09dde2c
shutdown.c File Reference
#include "cdprocs.h"
Include dependency graph for shutdown.c:

Go to the source code of this file.

Macros

#define BugCheckFileId   (CDFS_BUG_CHECK_SHUTDOWN)
 

Functions

 _Requires_lock_held_ (_Global_critical_region_)
 

Macro Definition Documentation

◆ BugCheckFileId

#define BugCheckFileId   (CDFS_BUG_CHECK_SHUTDOWN)

Definition at line 23 of file shutdown.c.

Function Documentation

◆ _Requires_lock_held_()

_Requires_lock_held_ ( _Global_critical_region_  )

Definition at line 29 of file shutdown.c.

53{
55 PLIST_ENTRY Links;
56 PVCB Vcb;
57 PIRP NewIrp;
59 BOOLEAN VcbPresent;
61
62 PAGED_CODE();
63
64 //
65 // Make sure we don't get any pop-ups.
66 //
67
68 SetFlag( IrpContext->Flags, IRP_CONTEXT_FLAG_DISABLE_POPUPS );
69
70 //
71 // Initialize an event for doing calls down to
72 // our target device objects.
73 //
74
76
77 //
78 // Indicate that shutdown has started.
79 //
80
82
83 //
84 // Get everyone else out of the way
85 //
86
87 CdAcquireCdData( IrpContext );
88
89 //
90 // Now walk through all the mounted Vcb's and shutdown the target
91 // device objects.
92 //
93
94 Links = CdData.VcbQueue.Flink;
95
96 while (Links != &CdData.VcbQueue) {
97
98 Vcb = CONTAINING_RECORD( Links, VCB, VcbLinks );
99
100 //
101 // Move to the next link now since the current Vcb may be deleted.
102 //
103
104 Links = Links->Flink;
105
106 //
107 // If we have already been called before for this volume
108 // (and yes this does happen), skip this volume as no writes
109 // have been allowed since the first shutdown.
110 //
111
112 if (FlagOn( Vcb->VcbState, VCB_STATE_SHUTDOWN ) ||
113 (Vcb->VcbCondition != VcbMounted)) {
114
115 continue;
116 }
117
118 CdAcquireVcbExclusive( IrpContext, Vcb, FALSE );
119
120 CdPurgeVolume( IrpContext, Vcb, FALSE );
121
122 //
123 // Build an irp for this volume stack - our own irp is probably too small and
124 // each stack may have a different stack size.
125 //
126
128 Vcb->TargetDeviceObject,
129 NULL,
130 0,
131 NULL,
132 &Event,
133 &Iosb );
134
135 if (NewIrp != NULL) {
136
137 Status = IoCallDriver( Vcb->TargetDeviceObject, NewIrp );
138
139 if (Status == STATUS_PENDING) {
140
142 Executive,
144 FALSE,
145 NULL );
146 }
147
149 }
150
151 SetFlag( Vcb->VcbState, VCB_STATE_SHUTDOWN );
152
153 //
154 // Attempt to punch the volume down.
155 //
156
157 VcbPresent = CdCheckForDismount( IrpContext, Vcb, FALSE );
158
159 if (VcbPresent) {
160
161 CdReleaseVcb( IrpContext, Vcb );
162 }
163 }
164
165
166 CdReleaseCdData( IrpContext );
167
170#ifdef __REACTOS__
171 IoUnregisterFileSystem( CdData.HddFileSystemDeviceObject );
172 IoDeleteDevice( CdData.HddFileSystemDeviceObject );
173#endif
174
175 CdCompleteRequest( IrpContext, Irp, STATUS_SUCCESS );
176 return STATUS_SUCCESS;
177}
#define PAGED_CODE()
unsigned char BOOLEAN
#define VOID
Definition: acefi.h:82
LONG NTSTATUS
Definition: precomp.h:26
VOID CdCompleteRequest(_Inout_opt_ PIRP_CONTEXT IrpContext, _Inout_opt_ PIRP Irp, _In_ NTSTATUS Status)
Definition: cddata.c:914
CD_DATA CdData
Definition: cddata.c:42
#define CdAcquireCdData(IC)
Definition: cdprocs.h:973
#define CdReleaseVcb(IC, V)
Definition: cdprocs.h:985
#define CdReleaseCdData(IC)
Definition: cdprocs.h:976
#define CdAcquireVcbExclusive(IC, V, I)
Definition: cdprocs.h:979
#define VCB_STATE_SHUTDOWN
Definition: cdstruc.h:715
#define CD_FLAGS_SHUTDOWN
Definition: cdstruc.h:422
#define IRP_CONTEXT_FLAG_DISABLE_POPUPS
Definition: cdstruc.h:1222
@ VcbMounted
Definition: cdstruc.h:492
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
return Iosb
Definition: create.c:4402
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
Status
Definition: gdiplustypes.h:25
#define KernelMode
Definition: asm.h:34
@ NotificationEvent
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
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
VOID NTAPI IoUnregisterFileSystem(IN PDEVICE_OBJECT DeviceObject)
Definition: volume.c:1056
#define STATUS_PENDING
Definition: ntstatus.h:82
#define Vcb
Definition: cdprocs.h:1415
#define STATUS_SUCCESS
Definition: shellext.h:65
USHORT Flags
Definition: cdstruc.h:380
LIST_ENTRY VcbQueue
Definition: cdstruc.h:334
PDEVICE_OBJECT FileSystemDeviceObject
Definition: cdstruc.h:350
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 IRP_MJ_SHUTDOWN
@ Executive
Definition: ketypes.h:403