ReactOS 0.4.16-dev-340-g0540c21
shutdown.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYRIGHT.TXT
3 * PROJECT: Ext2 File System Driver for WinNT/2K/XP
4 * FILE: shutdown.c
5 * PROGRAMMER: Matt Wu <mattwu@163.com>
6 * HOMEPAGE: http://www.ext2fsd.com
7 * UPDATE HISTORY:
8 */
9
10/* INCLUDES *****************************************************************/
11
12#include "ext2fs.h"
13
14/* GLOBALS ***************************************************************/
15
17
18/* DEFINITIONS *************************************************************/
19
20#ifdef ALLOC_PRAGMA
21#pragma alloc_text(PAGE, Ext2ShutDown)
22#endif
23
26{
28
29 PIRP Irp;
30
32 PLIST_ENTRY ListEntry;
33
34 BOOLEAN GlobalResourceAcquired = FALSE;
35
36 _SEH2_TRY {
37
39
40 ASSERT(IrpContext);
41 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
42 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
43
44 Irp = IrpContext->Irp;
45
48 IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT) )) {
51 }
52
53 GlobalResourceAcquired = TRUE;
54
55 for (ListEntry = Ext2Global->VcbList.Flink;
56 ListEntry != &(Ext2Global->VcbList);
57 ListEntry = ListEntry->Flink ) {
58
59 Vcb = CONTAINING_RECORD(ListEntry, EXT2_VCB, Next);
60
62 &Vcb->MainResource,
63 TRUE )) {
64
65 if (IsMounted(Vcb)) {
66
67 /* update mount count */
68 Vcb->SuperBlock->s_mnt_count++;
69 if (Vcb->SuperBlock->s_mnt_count >
70 Vcb->SuperBlock->s_max_mnt_count ) {
71 Vcb->SuperBlock->s_mnt_count =
72 Vcb->SuperBlock->s_max_mnt_count;
73 }
74 Ext2SaveSuper(IrpContext, Vcb);
75
76 /* flush dirty cache for all files */
77 Status = Ext2FlushFiles(IrpContext, Vcb, TRUE);
78 if (!NT_SUCCESS(Status)) {
79 DbgBreak();
80 }
81
82 /* flush volume stream's cache to disk */
83 Status = Ext2FlushVolume(IrpContext, Vcb, TRUE);
84
86 DbgBreak();
87 }
88
89 /* send shutdown request to underlying disk */
91 }
92
93 ExReleaseResourceLite(&Vcb->MainResource);
94 }
95 }
96
97 /*
98 IoUnregisterFileSystem(Ext2Global->DiskdevObject);
99 IoUnregisterFileSystem(Ext2Global->CdromdevObject);
100 */
101
102 } _SEH2_FINALLY {
103
104 if (GlobalResourceAcquired) {
106 }
107
108 if (!IrpContext->ExceptionInProgress) {
109 if (Status == STATUS_PENDING) {
110 Ext2QueueRequest(IrpContext);
111 } else {
112 Ext2CompleteIrpContext(IrpContext, Status);
113 }
114 }
115 } _SEH2_END;
116
117 return Status;
118}
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define IRP_CONTEXT_FLAG_WAIT
Definition: cdstruc.h:1215
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_PENDING
Definition: d3dkmdt.h:43
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
NTSTATUS Ext2ShutDown(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: shutdown.c:25
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
#define ExAcquireResourceExclusiveLite(res, wait)
Definition: env_spec_w32.h:615
@ EXT2ICX
Definition: ext2fs.h:465
#define IsMounted(Vcb)
Definition: ext2fs.h:812
NTSTATUS Ext2QueueRequest(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: dispatch.c:158
BOOLEAN Ext2SaveSuper(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
Definition: generic.c:67
NTSTATUS Ext2DiskShutDown(PEXT2_VCB Vcb)
Definition: block.c:748
#define DbgBreak()
Definition: ext2fs.h:46
NTSTATUS Ext2CompleteIrpContext(IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:32
NTSTATUS Ext2FlushFiles(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN BOOLEAN bShutDown)
Definition: flush.c:112
NTSTATUS Ext2FlushVolume(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN BOOLEAN bShutDown)
Definition: flush.c:43
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
Status
Definition: gdiplustypes.h:25
#define ASSERT(a)
Definition: mode.c:44
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1822
#define Vcb
Definition: cdprocs.h:1415
#define _SEH2_FINALLY
Definition: pseh2_64.h:114
#define _SEH2_END
Definition: pseh2_64.h:155
#define _SEH2_TRY
Definition: pseh2_64.h:55
#define _SEH2_LEAVE
Definition: pseh2_64.h:167
#define STATUS_SUCCESS
Definition: shellext.h:65
ERESOURCE Resource
Definition: ext2fs.h:519
LIST_ENTRY VcbList
Definition: ext2fs.h:545
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define IN
Definition: typedefs.h:39
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define STATUS_MEDIA_WRITE_PROTECTED
Definition: udferr_usr.h:161