[USBOHCI_NEW][USBUHCI_NEW] Avoid unnecessary/incorrect status defines.
[reactos.git] / drivers / filesystems / ffs / src / shutdown.c
1 /*
2 * FFS File System Driver for Windows
3 *
4 * read.c
5 *
6 * 2004.5.6 ~
7 *
8 * Lee Jae-Hong, http://www.pyrasis.com
9 *
10 * See License.txt
11 *
12 */
13
14 #include "ntifs.h"
15 #include "ffsdrv.h"
16
17 /* Globals */
18
19 extern PFFS_GLOBAL FFSGlobal;
20
21
22 /* Definitions */
23
24 #ifdef ALLOC_PRAGMA
25 #pragma alloc_text(PAGE, FFSShutDown)
26 #endif
27
28
29 __drv_mustHoldCriticalRegion
30 NTSTATUS
31 FFSShutDown(
32 IN PFFS_IRP_CONTEXT IrpContext)
33 {
34 NTSTATUS Status;
35
36 #ifndef __REACTOS__
37 PKEVENT Event;
38 #endif
39
40 PIRP Irp;
41 PIO_STACK_LOCATION IrpSp;
42
43 PFFS_VCB Vcb;
44 PLIST_ENTRY ListEntry;
45
46 BOOLEAN GlobalResourceAcquired = FALSE;
47
48 PAGED_CODE();
49
50 _SEH2_TRY
51 {
52 ASSERT(IrpContext);
53
54 ASSERT((IrpContext->Identifier.Type == FFSICX) &&
55 (IrpContext->Identifier.Size == sizeof(FFS_IRP_CONTEXT)));
56
57 Status = STATUS_SUCCESS;
58
59 Irp = IrpContext->Irp;
60
61 IrpSp = IoGetCurrentIrpStackLocation(Irp);
62 #ifdef _MSC_VER
63 #pragma prefast( suppress: 28137, "by design" )
64 #endif
65 if (!ExAcquireResourceExclusiveLite(
66 &FFSGlobal->Resource,
67 IrpContext->IsSynchronous))
68 {
69 Status = STATUS_PENDING;
70 _SEH2_LEAVE;
71 }
72
73 GlobalResourceAcquired = TRUE;
74
75 #ifndef __REACTOS__
76 Event = ExAllocatePoolWithTag(NonPagedPool, sizeof(KEVENT), FFS_POOL_TAG);
77 KeInitializeEvent(Event, NotificationEvent, FALSE);
78 #endif
79
80 for (ListEntry = FFSGlobal->VcbList.Flink;
81 ListEntry != &(FFSGlobal->VcbList);
82 ListEntry = ListEntry->Flink)
83 {
84 Vcb = CONTAINING_RECORD(ListEntry, FFS_VCB, Next);
85
86 if (ExAcquireResourceExclusiveLite(
87 &Vcb->MainResource,
88 TRUE))
89 {
90
91 Status = FFSFlushFiles(Vcb, TRUE);
92 if(!NT_SUCCESS(Status))
93 {
94 FFSBreakPoint();
95 }
96
97 Status = FFSFlushVolume(Vcb, TRUE);
98
99 if(!NT_SUCCESS(Status))
100 {
101 FFSBreakPoint();
102 }
103
104 FFSDiskShutDown(Vcb);
105
106 ExReleaseResourceForThreadLite(
107 &Vcb->MainResource,
108 ExGetCurrentResourceThread());
109 }
110 }
111
112 /*
113 IoUnregisterFileSystem(FFSGlobal->DeviceObject);
114 */
115 }
116
117 _SEH2_FINALLY
118 {
119 if (GlobalResourceAcquired)
120 {
121 ExReleaseResourceForThreadLite(
122 &FFSGlobal->Resource,
123 ExGetCurrentResourceThread());
124 }
125
126 if (!IrpContext->ExceptionInProgress)
127 {
128 if (Status == STATUS_PENDING)
129 {
130 FFSQueueRequest(IrpContext);
131 }
132 else
133 {
134 FFSCompleteIrpContext(IrpContext, Status);
135 }
136 }
137 } _SEH2_END;
138
139 return Status;
140 }