ReactOS  0.4.14-dev-49-gfb4591c
shutdown.c File Reference
#include "ext2fs.h"
Include dependency graph for shutdown.c:

Go to the source code of this file.

Functions

NTSTATUS Ext2ShutDown (IN PEXT2_IRP_CONTEXT IrpContext)
 

Variables

PEXT2_GLOBAL Ext2Global
 

Function Documentation

◆ Ext2ShutDown()

NTSTATUS Ext2ShutDown ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 25 of file shutdown.c.

26 {
28 
29  PIRP Irp;
30 
31  PEXT2_VCB Vcb;
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 }
#define IsMounted(Vcb)
Definition: ext2fs.h:803
#define TRUE
Definition: types.h:120
#define IRP_CONTEXT_FLAG_WAIT
Definition: cdstruc.h:1221
NTSTATUS Ext2DiskShutDown(PEXT2_VCB Vcb)
Definition: block.c:724
BOOLEAN Ext2SaveSuper(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
Definition: generic.c:63
_In_ PIRP Irp
Definition: csq.h:116
ERESOURCE Resource
Definition: ext2fs.h:510
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS Ext2FlushVolume(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN BOOLEAN bShutDown)
Definition: flush.c:39
LIST_ENTRY VcbList
Definition: ext2fs.h:536
_SEH2_TRY
Definition: create.c:4250
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
NTSTATUS Ext2QueueRequest(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: dispatch.c:150
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
unsigned char BOOLEAN
#define STATUS_MEDIA_WRITE_PROTECTED
Definition: udferr_usr.h:161
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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define Vcb
Definition: cdprocs.h:1425
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
NTSTATUS Ext2CompleteIrpContext(IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:32
Definition: typedefs.h:117
Status
Definition: gdiplustypes.h:24
_SEH2_END
Definition: create.c:4424
NTSTATUS Ext2FlushFiles(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN BOOLEAN bShutDown)
Definition: flush.c:108
_SEH2_FINALLY
Definition: create.c:4395
#define DbgBreak()
Definition: ext2fs.h:46
#define _SEH2_LEAVE
Definition: filesup.c:20
return STATUS_SUCCESS
Definition: btrfs.c:2966
PEXT2_GLOBAL Ext2Global
Definition: init.c:16

Referenced by Ext2DispatchRequest().

Variable Documentation

◆ Ext2Global

PEXT2_GLOBAL Ext2Global

Definition at line 16 of file init.c.

Referenced by Ext2ShutDown().