ReactOS 0.4.15-dev-7934-g1dc8d80
dispatch.c File Reference
#include "ext2fs.h"
Include dependency graph for dispatch.c:

Go to the source code of this file.

Functions

VOID Ext2OplockComplete (IN PVOID Context, IN PIRP Irp)
 
VOID Ext2LockIrp (IN PVOID Context, IN PIRP Irp)
 
NTSTATUS Ext2QueueRequest (IN PEXT2_IRP_CONTEXT IrpContext)
 
VOID Ext2DeQueueRequest (IN PVOID Context)
 
NTSTATUS Ext2DispatchRequest (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2BuildRequest (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 

Variables

PEXT2_GLOBAL Ext2Global
 

Function Documentation

◆ Ext2BuildRequest()

NTSTATUS Ext2BuildRequest ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 308 of file dispatch.c.

309{
310 BOOLEAN AtIrqlPassiveLevel = FALSE;
311 BOOLEAN IsTopLevelIrp = FALSE;
312 PEXT2_IRP_CONTEXT IrpContext = NULL;
314
315 _SEH2_TRY {
316
317 _SEH2_TRY {
318
319#if EXT2_DEBUG
321#endif
322
323 AtIrqlPassiveLevel = (KeGetCurrentIrql() == PASSIVE_LEVEL);
324
325 if (AtIrqlPassiveLevel) {
327 }
328
329 if (!IoGetTopLevelIrp()) {
330 IsTopLevelIrp = TRUE;
332 }
333
335
336 if (!IrpContext) {
337
339 Irp->IoStatus.Status = Status;
340
342
343 } else {
344
345 if ((IrpContext->MajorFunction == IRP_MJ_CREATE) &&
346 !AtIrqlPassiveLevel) {
347
348 DbgBreak();
349 }
350
351 Status = Ext2DispatchRequest(IrpContext);
352 }
354
355 Status = Ext2ExceptionHandler(IrpContext);
356 } _SEH2_END;
357
358 } _SEH2_FINALLY {
359
360 if (IsTopLevelIrp) {
362 }
363
364 if (AtIrqlPassiveLevel) {
366 }
367 } _SEH2_END;
368
369 return Status;
370}
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
NTSTATUS Ext2DispatchRequest(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: dispatch.c:228
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
NTSTATUS Ext2ExceptionHandler(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: except.c:112
NTSTATUS Ext2ExceptionFilter(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXCEPTION_POINTERS ExceptionPointer)
Definition: except.c:21
PEXT2_IRP_CONTEXT Ext2AllocateIrpContext(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: memory.c:35
#define Ext2CompleteRequest(Irp, bPrint, PriorityBoost)
Definition: ext2fs.h:1475
#define DbgBreak()
Definition: ext2fs.h:46
VOID Ext2DbgPrintCall(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
#define _SEH2_FINALLY
Definition: filesup.c:21
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
Status
Definition: gdiplustypes.h:25
PIRP NTAPI IoGetTopLevelIrp(VOID)
Definition: irp.c:1843
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:2000
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:158
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
UCHAR MajorFunction
Definition: ext2fs.h:1056
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define IO_NO_INCREMENT
Definition: iotypes.h:598

◆ Ext2DeQueueRequest()

VOID Ext2DeQueueRequest ( IN PVOID  Context)

Definition at line 190 of file dispatch.c.

191{
192 PEXT2_IRP_CONTEXT IrpContext;
193
194 IrpContext = (PEXT2_IRP_CONTEXT) Context;
195
196 ASSERT(IrpContext);
197
198 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
199 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
200
201 _SEH2_TRY {
202
203 _SEH2_TRY {
204
206
207 if (!IrpContext->IsTopLevel) {
209 }
210
211 Ext2DispatchRequest(IrpContext);
212
214
215 Ext2ExceptionHandler(IrpContext);
216 } _SEH2_END;
217
218 } _SEH2_FINALLY {
219
221
223 } _SEH2_END;
224}
@ EXT2ICX
Definition: ext2fs.h:465
struct ext2_icb * PEXT2_IRP_CONTEXT
#define FSRTL_FSP_TOP_LEVEL_IRP
Definition: fsrtltypes.h:59
#define ASSERT(a)
Definition: mode.c:44
EXT2_IDENTIFIER_TYPE Type
Definition: ext2fs.h:477
EXT2_IDENTIFIER Identifier
Definition: ext2fs.h:1047
BOOLEAN IsTopLevel
Definition: ext2fs.h:1072

Referenced by Ext2QueueRequest().

◆ Ext2DispatchRequest()

NTSTATUS Ext2DispatchRequest ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 228 of file dispatch.c.

229{
230 ASSERT(IrpContext);
231
232 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
233 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
234
235 switch (IrpContext->MajorFunction) {
236
237 case IRP_MJ_CREATE:
238 return Ext2Create(IrpContext);
239
240 case IRP_MJ_CLOSE:
241 return Ext2Close(IrpContext);
242
243 case IRP_MJ_READ:
244 return Ext2Read(IrpContext);
245
246 case IRP_MJ_WRITE:
247 return Ext2Write(IrpContext);
248
250 return Ext2Flush(IrpContext);
251
253 return Ext2QueryFileInformation(IrpContext);
254
256 return Ext2SetFileInformation(IrpContext);
257
259 return Ext2QueryVolumeInformation(IrpContext);
260
262 return Ext2SetVolumeInformation(IrpContext);
263
265 return Ext2DirectoryControl(IrpContext);
266
268 return Ext2FileSystemControl(IrpContext);
269
271 return Ext2DeviceControl(IrpContext);
272
274 return Ext2LockControl(IrpContext);
275
276 case IRP_MJ_CLEANUP:
277 return Ext2Cleanup(IrpContext);
278
279 case IRP_MJ_SHUTDOWN:
280 return Ext2ShutDown(IrpContext);
281
282 case IRP_MJ_QUERY_EA:
283 return Ext2QueryEa(IrpContext);
284
285 case IRP_MJ_SET_EA:
286 return Ext2SetEa(IrpContext);
287
288#if (_WIN32_WINNT >= 0x0500)
289 case IRP_MJ_PNP:
290 return Ext2Pnp(IrpContext);
291#endif //(_WIN32_WINNT >= 0x0500)
292 default:
293 DEBUG(DL_ERR, ( "Ext2DispatchRequest: Unexpected major function: %xh\n",
294 IrpContext->MajorFunction));
295
297
299 }
300}
#define DEBUG(args)
Definition: rdesktop.h:129
ARC_STATUS Ext2Close(ULONG FileId)
Definition: ext2.c:1192
ARC_STATUS Ext2Read(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: ext2.c:1240
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
NTSTATUS Ext2QueryEa(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: ea.c:94
NTSTATUS Ext2Pnp(IN PEXT2_IRP_CONTEXT IrpContext)
NTSTATUS Ext2Flush(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: flush.c:148
NTSTATUS Ext2ShutDown(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: shutdown.c:25
NTSTATUS Ext2Cleanup(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: cleanup.c:21
NTSTATUS Ext2DirectoryControl(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: dirctl.c:1236
NTSTATUS Ext2Create(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: create.c:1951
NTSTATUS Ext2SetFileInformation(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fileinfo.c:514
NTSTATUS Ext2QueryVolumeInformation(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: volinfo.c:27
NTSTATUS Ext2LockControl(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: lock.c:25
NTSTATUS Ext2FileSystemControl(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fsctl.c:2848
NTSTATUS Ext2SetVolumeInformation(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: volinfo.c:292
NTSTATUS Ext2DeviceControl(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: devctl.c:783
NTSTATUS Ext2Write(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: write.c:1355
NTSTATUS Ext2QueryFileInformation(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fileinfo.c:48
#define DL_ERR
Definition: ext2fs.h:1434
NTSTATUS Ext2CompleteIrpContext(IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:32
NTSTATUS Ext2SetEa(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: ea.c:436
#define IRP_MJ_DIRECTORY_CONTROL
Definition: rdpdr.c:51
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define IRP_MJ_QUERY_VOLUME_INFORMATION
Definition: rdpdr.c:50
#define IRP_MJ_LOCK_CONTROL
Definition: rdpdr.c:53
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_SET_INFORMATION
Definition: rdpdr.c:49
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
#define STATUS_DRIVER_INTERNAL_ERROR
Definition: udferr_usr.h:177
#define IRP_MJ_QUERY_EA
#define IRP_MJ_FILE_SYSTEM_CONTROL
#define IRP_MJ_SET_VOLUME_INFORMATION
#define IRP_MJ_SET_EA
#define IRP_MJ_FLUSH_BUFFERS
#define IRP_MJ_SHUTDOWN
#define IRP_MJ_CLEANUP

Referenced by Ext2BuildRequest(), and Ext2DeQueueRequest().

◆ Ext2LockIrp()

VOID Ext2LockIrp ( IN PVOID  Context,
IN PIRP  Irp 
)

Definition at line 94 of file dispatch.c.

98{
100 PEXT2_IRP_CONTEXT IrpContext;
101
102 if (Irp == NULL) {
103 return;
104 }
105
107
108 IrpContext = (PEXT2_IRP_CONTEXT) Context;
109
110 if ( IrpContext->MajorFunction == IRP_MJ_READ ||
111 IrpContext->MajorFunction == IRP_MJ_WRITE ) {
112
113 //
114 // lock the user's buffer to MDL, if the I/O is bufferred
115 //
116
117 if (!IsFlagOn(IrpContext->MinorFunction, IRP_MN_MDL)) {
118
120 (IrpContext->MajorFunction == IRP_MJ_READ) ?
122 }
123
124 } else if (IrpContext->MajorFunction == IRP_MJ_DIRECTORY_CONTROL
125 && IrpContext->MinorFunction == IRP_MN_QUERY_DIRECTORY) {
126
127 ULONG Length = ((PEXTENDED_IO_STACK_LOCATION) IrpSp)->Parameters.QueryDirectory.Length;
129
130 } else if (IrpContext->MajorFunction == IRP_MJ_QUERY_EA) {
131
132 ULONG Length = ((PEXTENDED_IO_STACK_LOCATION) IrpSp)->Parameters.QueryEa.Length;
134
135 } else if (IrpContext->MajorFunction == IRP_MJ_SET_EA) {
136 ULONG Length = ((PEXTENDED_IO_STACK_LOCATION) IrpSp)->Parameters.SetEa.Length;
138
139 } else if ( (IrpContext->MajorFunction == IRP_MJ_FILE_SYSTEM_CONTROL) &&
140 (IrpContext->MinorFunction == IRP_MN_USER_FS_REQUEST) ) {
142 if ( (EIrpSp->Parameters.FileSystemControl.FsControlCode == FSCTL_GET_VOLUME_BITMAP) ||
143 (EIrpSp->Parameters.FileSystemControl.FsControlCode == FSCTL_GET_RETRIEVAL_POINTERS) ||
145 ULONG Length = EIrpSp->Parameters.FileSystemControl.OutputBufferLength;
147 }
148 }
149
150 // Mark the request as pending status
151
153
154 return;
155}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
NTSTATUS Ext2LockUserBuffer(IN PIRP Irp, IN ULONG Length, IN LOCK_OPERATION Operation)
Definition: block.c:113
#define FSCTL_GET_RETRIEVAL_POINTER_BASE
Definition: ext2fs.h:1132
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
IoMarkIrpPending(Irp)
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define FSCTL_GET_RETRIEVAL_POINTERS
Definition: winioctl.h:95
#define FSCTL_GET_VOLUME_BITMAP
Definition: winioctl.h:94
#define IRP_MN_QUERY_DIRECTORY
Definition: rdpdr.c:55
union _IO_STACK_LOCATION::@1564 Parameters
struct _IO_STACK_LOCATION::@3978::@3983 Write
struct _IO_STACK_LOCATION::@3978::@3993 FileSystemControl
UCHAR MinorFunction
Definition: ext2fs.h:1057
uint32_t ULONG
Definition: typedefs.h:59
#define PEXTENDED_IO_STACK_LOCATION
Definition: udffs.h:119
#define IRP_MN_USER_FS_REQUEST
Definition: iotypes.h:4403
#define IRP_MN_MDL
Definition: iotypes.h:4419
@ IoReadAccess
Definition: ketypes.h:863
@ IoWriteAccess
Definition: ketypes.h:864

Referenced by Ext2CreateFile(), Ext2QueueRequest(), Ext2ReadFile(), and Ext2WriteFile().

◆ Ext2OplockComplete()

VOID Ext2OplockComplete ( IN PVOID  Context,
IN PIRP  Irp 
)

Definition at line 45 of file dispatch.c.

49{
50 //
51 // Check on the return value in the Irp.
52 //
53
54 if (Irp->IoStatus.Status == STATUS_SUCCESS) {
55
56 //
57 // queue the Irp context in the workqueue.
58 //
59
61
62 } else {
63
64 //
65 // complete the request in case of failure
66 //
67
69 Irp->IoStatus.Status );
70 }
71
72 return;
73}
NTSTATUS Ext2QueueRequest(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: dispatch.c:158
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by Ext2CreateFile(), Ext2LockControl(), Ext2ReadFile(), and Ext2WriteFile().

◆ Ext2QueueRequest()

NTSTATUS Ext2QueueRequest ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 158 of file dispatch.c.

159{
160 ASSERT(IrpContext);
161
162 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
163 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
164
165 /* set the flags of "can wait" and "queued" */
166 SetFlag(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT);
167 SetFlag(IrpContext->Flags, IRP_CONTEXT_FLAG_REQUEUED);
168
169 /* make sure the buffer is kept valid in system context */
170 Ext2LockIrp(IrpContext, IrpContext->Irp);
171
172 /* initialize workite*/
174 &IrpContext->WorkQueueItem,
176 IrpContext );
177
178 /* dispatch it */
179 ExQueueWorkItem(&IrpContext->WorkQueueItem, CriticalWorkQueue);
180
181 return STATUS_PENDING;
182}
#define IRP_CONTEXT_FLAG_WAIT
Definition: cdstruc.h:1215
VOID Ext2LockIrp(IN PVOID Context, IN PIRP Irp)
Definition: dispatch.c:94
VOID Ext2DeQueueRequest(IN PVOID Context)
Definition: dispatch.c:190
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define IRP_CONTEXT_FLAG_REQUEUED
Definition: ext2fs.h:1094
#define STATUS_PENDING
Definition: ntstatus.h:82
VOID NTAPI ExQueueWorkItem(IN PWORK_QUEUE_ITEM WorkItem, IN WORK_QUEUE_TYPE QueueType)
Definition: work.c:723
#define ExInitializeWorkItem(Item, Routine, Context)
Definition: exfuncs.h:265
@ CriticalWorkQueue
Definition: extypes.h:189

Referenced by Ext2Cleanup(), Ext2Create(), Ext2DeferWrite(), Ext2DeleteReparsePoint(), Ext2ExceptionHandler(), Ext2GetReparsePoint(), Ext2GetRetrievalPointerBase(), Ext2GetRetrievalPointers(), Ext2NotifyChangeDirectory(), Ext2OplockComplete(), Ext2QueryDirectory(), Ext2QueryEa(), Ext2QueryFileInformation(), Ext2QueryRetrievalPointers(), Ext2QueryVolumeInformation(), Ext2ReadFile(), Ext2ReadVolume(), Ext2SetEa(), Ext2SetFileInformation(), Ext2SetReparsePoint(), Ext2SetVolumeInformation(), Ext2ShutDown(), Ext2WriteFile(), and Ext2WriteVolume().

Variable Documentation

◆ Ext2Global

PEXT2_GLOBAL Ext2Global
extern

Definition at line 16 of file init.c.