ReactOS 0.4.15-dev-7928-g68a8619
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
19{
21
22 Fcb = CONTAINING_RECORD(Csq, MSFS_FCB, CancelSafeQueue);
23 InsertTailList(&Fcb->PendingIrpQueue, &Irp->Tail.Overlay.ListEntry);
24}
25
28{
30
31 RemoveEntryList(&Irp->Tail.Overlay.ListEntry);
32}
33
36{
38 PIRP NextIrp = NULL;
39 PLIST_ENTRY NextEntry, ListHead;
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
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
81{
83
84 Fcb = CONTAINING_RECORD(Csq, MSFS_FCB, CancelSafeQueue);
85 KeAcquireSpinLock(&Fcb->QueueLock, Irql);
86}
87
88
91{
93
94 Fcb = CONTAINING_RECORD(Csq, MSFS_FCB, CancelSafeQueue);
95 KeReleaseSpinLock(&Fcb->QueueLock, Irql);
96}
97
100{
101
103
104 Irp->IoStatus.Status = STATUS_CANCELLED;
105 Irp->IoStatus.Information = 0;
107}
108
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 */
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
_In_ PFCB Fcb
Definition: cdprocs.h:159
_In_ PIRP Irp
Definition: csq.h:116
_In_opt_ PIRP _In_opt_ PVOID PeekContext
Definition: csq.h:160
_Out_ PKIRQL Irql
Definition: csq.h:179
NTKERNELAPI PIRP NTAPI IoCsqRemoveIrp(_Inout_ PIO_CSQ Csq, _Inout_ PIO_CSQ_IRP_CONTEXT Context)
Remove anb IRP from the queue.
Definition: csq.c:326
IO_CSQ Csq
Definition: csqrtns.c:46
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define InsertTailList(ListHead, Entry)
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
KIRQL * PKIRQL
Definition: env_spec_w32.h:592
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
IO_CSQ_REMOVE_IRP MsfsRemoveIrp
Definition: msfs.h:109
IO_CSQ_ACQUIRE_LOCK MsfsAcquireLock
Definition: msfs.h:117
KDEFERRED_ROUTINE MsfsTimeout
Definition: msfs.h:129
struct _MSFS_DPC_CTX * PMSFS_DPC_CTX
IO_CSQ_RELEASE_LOCK MsfsReleaseLock
Definition: msfs.h:121
IO_CSQ_COMPLETE_CANCELED_IRP MsfsCompleteCanceledIrp
Definition: msfs.h:125
IO_CSQ_PEEK_NEXT_IRP MsfsPeekNextIrp
Definition: msfs.h:113
IO_CSQ_INSERT_IRP MsfsInsertIrp
Definition: msfs.h:105
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define IoCompleteRequest
Definition: irp.c:1240
Definition: csq.h:222
Definition: ketypes.h:699
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
Definition: msfs.h:25
#define NTAPI
Definition: typedefs.h:36
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define STATUS_IO_TIMEOUT
Definition: udferr_usr.h:163
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
_Must_inspect_result_ _In_ PWDF_DPC_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFDPC * Dpc
Definition: wdfdpc.h:112
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:639
#define IO_NO_INCREMENT
Definition: iotypes.h:598
* PFILE_OBJECT
Definition: iotypes.h:1998
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
Definition: ketypes.h:688
_In_opt_ PVOID DeferredContext
Definition: ketypes.h:687
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
Definition: ketypes.h:689