ReactOS  0.4.13-dev-982-g9853eab
msfssup.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS kernel
4  * FILE: drivers/filesystems/msfs/msfssup.c
5  * PURPOSE: Mailslot filesystem
6  * PROGRAMMER: Nikita Pechenkin (n.pechenkin@mail.ru)
7  */
8 
9 /* INCLUDES ******************************************************************/
10 #include "msfs.h"
11 
12 #define NDEBUG
13 #include <debug.h>
14 
15 /* FUNCTIONS *****************************************************************/
16 
17 VOID NTAPI
19 {
20  PMSFS_FCB Fcb;
21 
22  Fcb = CONTAINING_RECORD(Csq, MSFS_FCB, CancelSafeQueue);
23  InsertTailList(&Fcb->PendingIrpQueue, &Irp->Tail.Overlay.ListEntry);
24 }
25 
26 VOID NTAPI
28 {
30 
31  RemoveEntryList(&Irp->Tail.Overlay.ListEntry);
32 }
33 
34 PIRP NTAPI
36 {
37  PMSFS_FCB Fcb;
38  PIRP NextIrp = NULL;
39  PLIST_ENTRY NextEntry, ListHead;
40  PIO_STACK_LOCATION Stack;
41 
42  Fcb = CONTAINING_RECORD(Csq, MSFS_FCB, CancelSafeQueue);
43 
44  ListHead = &Fcb->PendingIrpQueue;
45 
46  if (Irp == NULL)
47  {
48  NextEntry = ListHead->Flink;
49  }
50  else
51  {
52  NextEntry = Irp->Tail.Overlay.ListEntry.Flink;
53  }
54 
55  for (; NextEntry != ListHead; NextEntry = NextEntry->Flink)
56  {
57  NextIrp = CONTAINING_RECORD(NextEntry, IRP, Tail.Overlay.ListEntry);
58 
59  Stack = IoGetCurrentIrpStackLocation(NextIrp);
60 
61  if (PeekContext)
62  {
63  if (Stack->FileObject == (PFILE_OBJECT)PeekContext)
64  {
65  break;
66  }
67  }
68  else
69  {
70  break;
71  }
72 
73  NextIrp = NULL;
74  }
75 
76  return NextIrp;
77 }
78 
79 VOID NTAPI
81 {
82  PMSFS_FCB Fcb;
83 
84  Fcb = CONTAINING_RECORD(Csq, MSFS_FCB, CancelSafeQueue);
85  KeAcquireSpinLock(&Fcb->QueueLock, Irql);
86 }
87 
88 
89 VOID NTAPI
91 {
92  PMSFS_FCB Fcb;
93 
94  Fcb = CONTAINING_RECORD(Csq, MSFS_FCB, CancelSafeQueue);
95  KeReleaseSpinLock(&Fcb->QueueLock, Irql);
96 }
97 
98 VOID NTAPI
100 {
101 
103 
104  Irp->IoStatus.Status = STATUS_CANCELLED;
105  Irp->IoStatus.Information = 0;
107 }
108 
109 VOID NTAPI
114 {
116  PIRP Irp;
117 
119 
120  /* Try to get the IRP */
121  Irp = IoCsqRemoveIrp(Context->Csq, &Context->CsqContext);
122  if (Irp != NULL)
123  {
124  /* It timed out, complete it (it's ours) and free context */
125  Irp->IoStatus.Status = STATUS_IO_TIMEOUT;
127  ExFreePoolWithTag(Context, 'NFsM');
128  }
129  else
130  {
131  /* We were racing with writing and failed, signal we're done */
133  }
134 }
135 
136 /* EOF */
VOID NTAPI MsfsReleaseLock(PIO_CSQ Csq, KIRQL Irql)
Definition: msfssup.c:90
VOID NTAPI MsfsTimeout(PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2)
Definition: msfssup.c:110
VOID NTAPI MsfsRemoveIrp(PIO_CSQ Csq, PIRP Irp)
Definition: msfssup.c:27
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
VOID NTAPI MsfsCompleteCanceledIrp(PIO_CSQ Csq, PIRP Irp)
Definition: msfssup.c:99
IRP
Definition: iotypes.h:2462
#define InsertTailList(ListHead, Entry)
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
_Out_ PKIRQL Irql
Definition: csq.h:179
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
PIRP NTAPI MsfsPeekNextIrp(PIO_CSQ Csq, PIRP Irp, PVOID PeekContext)
Definition: msfssup.c:35
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
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
Definition: ketypes.h:675
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
_In_ LARGE_INTEGER _In_opt_ PKDPC Dpc
Definition: kefuncs.h:524
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
* PFILE_OBJECT
Definition: iotypes.h:1954
Definition: ketypes.h:687
KIRQL * PKIRQL
Definition: env_spec_w32.h:592
Definition: typedefs.h:117
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
Definition: ketypes.h:675
Definition: csq.h:222
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2812
VOID NTAPI MsfsInsertIrp(PIO_CSQ Csq, PIRP Irp)
Definition: msfssup.c:18
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define STATUS_IO_TIMEOUT
Definition: udferr_usr.h:163
_In_opt_ PIRP _In_opt_ PVOID PeekContext
Definition: csq.h:159
IO_CSQ Csq
Definition: csqrtns.c:46
struct _MSFS_DPC_CTX * PMSFS_DPC_CTX
struct tagContext Context
Definition: acpixf.h:1012
#define IO_NO_INCREMENT
Definition: iotypes.h:565
VOID NTAPI MsfsAcquireLock(PIO_CSQ Csq, PKIRQL Irql)
Definition: msfssup.c:80
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
Definition: msfs.h:24
_In_ PFCB Fcb
Definition: cdprocs.h:151
NTKERNELAPI PIRP NTAPI IoCsqRemoveIrp(_Inout_ PIO_CSQ Csq, _Inout_ PIO_CSQ_IRP_CONTEXT Context)
Remove anb IRP from the queue.
Definition: csq.c:326
_In_opt_ PVOID DeferredContext
Definition: ketypes.h:675