ReactOS  0.4.15-dev-3177-gd6a0299
flushbuf.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Named Pipe FileSystem
3  * LICENSE: BSD - See COPYING.ARM in the top level directory
4  * FILE: drivers/filesystems/npfs/flushbuf.c
5  * PURPOSE: Buffers Flushing Support
6  * PROGRAMMERS: ReactOS Portable Systems Group
7  */
8 
9 /* INCLUDES *******************************************************************/
10 
11 #include "npfs.h"
12 
13 // File ID number for NPFS bugchecking support
14 #define NPFS_BUGCHECK_FILE_ID (NPFS_BUGCHECK_FLUSHBUF)
15 
16 /* FUNCTIONS ******************************************************************/
17 
19 NTAPI
21  IN PIRP Irp)
22 {
23  NODE_TYPE_CODE NodeTypeCode;
24  PNP_CCB Ccb;
25  ULONG NamedPipeEnd;
27  PNP_DATA_QUEUE FlushQueue;
28  PAGED_CODE();
29 
31  NULL,
32  &Ccb,
33  &NamedPipeEnd);
34  if (NodeTypeCode != NPFS_NTC_CCB) return STATUS_PIPE_DISCONNECTED;
35 
36  ExAcquireResourceExclusiveLite(&Ccb->NonPagedCcb->Lock, TRUE);
37 
38  if (NamedPipeEnd == FILE_PIPE_SERVER_END)
39  {
40  FlushQueue = &Ccb->DataQueue[FILE_PIPE_OUTBOUND];
41  }
42  else
43  {
44  FlushQueue = &Ccb->DataQueue[FILE_PIPE_INBOUND];
45  }
46 
47  if (FlushQueue->QueueState == WriteEntries)
48  {
49  Status = NpAddDataQueueEntry(NamedPipeEnd,
50  Ccb,
51  FlushQueue,
53  2,
54  0,
55  Irp,
56  NULL,
57  0);
58  }
59  else
60  {
62  }
63 
64  ExReleaseResourceLite(&Ccb->NonPagedCcb->Lock);
65  return Status;
66 }
67 
69 NTAPI
71  IN PIRP Irp)
72 {
74  PAGED_CODE();
75 
78 
80 
81  NpReleaseVcb();
83 
84  if (Status != STATUS_PENDING)
85  {
86  Irp->IoStatus.Status = Status;
88  }
89 
90  return Status;
91 }
92 
93 /* EOF */
#define IN
Definition: typedefs.h:39
FORCEINLINE VOID NpAcquireSharedVcb(VOID)
Definition: npfs.h:328
#define FsRtlEnterFileSystem
#define STATUS_PIPE_DISCONNECTED
Definition: ntstatus.h:412
#define FsRtlExitFileSystem
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define NPFS_NTC_CCB
Definition: npfs.h:115
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
NTSTATUS NTAPI NpCommonFlushBuffers(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: flushbuf.c:20
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
Definition: npfs.h:258
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
ULONG QueueState
Definition: npfs.h:139
Status
Definition: gdiplustypes.h:24
#define STATUS_PENDING
Definition: ntstatus.h:82
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define FILE_PIPE_SERVER_END
Definition: iotypes.h:85
#define IO_NAMED_PIPE_INCREMENT
Definition: iotypes.h:604
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:588
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
NTSTATUS NTAPI NpFsdFlushBuffers(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: flushbuf.c:70
FORCEINLINE VOID NpReleaseVcb(VOID)
Definition: npfs.h:344
#define FILE_PIPE_OUTBOUND
Definition: iotypes.h:82
NTSTATUS NTAPI NpAddDataQueueEntry(IN ULONG NamedPipeEnd, IN PNP_CCB Ccb, IN PNP_DATA_QUEUE DataQueue, IN ULONG Who, IN ULONG Type, IN ULONG DataSize, IN PIRP Irp, IN PVOID Buffer, IN ULONG ByteOffset)
Definition: datasup.c:295
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
NODE_TYPE_CODE NTAPI NpDecodeFileObject(IN PFILE_OBJECT FileObject, OUT PVOID *PrimaryContext OPTIONAL, OUT PNP_CCB *Ccb, OUT PULONG NamedPipeEnd OPTIONAL)
Definition: fileobsup.c:20
#define FILE_PIPE_INBOUND
Definition: iotypes.h:81
USHORT NODE_TYPE_CODE
Definition: nodetype.h:22
#define STATUS_SUCCESS
Definition: shellext.h:65
#define PAGED_CODE()