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 18 NTSTATUS 19 NTAPI 20 NpCommonFlushBuffers(IN PDEVICE_OBJECT DeviceObject, 21 IN PIRP Irp) 22 { 23 NODE_TYPE_CODE NodeTypeCode; 24 PNP_CCB Ccb; 25 ULONG NamedPipeEnd; 26 NTSTATUS Status; 27 PNP_DATA_QUEUE FlushQueue; 28 PAGED_CODE(); 29 30 NodeTypeCode = NpDecodeFileObject(IoGetCurrentIrpStackLocation(Irp)->FileObject, 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, 52 WriteEntries, 53 2, 54 0, 55 Irp, 56 NULL, 57 0); 58 } 59 else 60 { 61 Status = STATUS_SUCCESS; 62 } 63 64 ExReleaseResourceLite(&Ccb->NonPagedCcb->Lock); 65 return Status; 66 } 67 68 NTSTATUS 69 NTAPI 70 NpFsdFlushBuffers(IN PDEVICE_OBJECT DeviceObject, 71 IN PIRP Irp) 72 { 73 NTSTATUS Status; 74 PAGED_CODE(); 75 76 FsRtlEnterFileSystem(); 77 NpAcquireSharedVcb(); 78 79 Status = NpCommonFlushBuffers(DeviceObject, Irp); 80 81 NpReleaseVcb(); 82 FsRtlExitFileSystem(); 83 84 if (Status != STATUS_PENDING) 85 { 86 Irp->IoStatus.Status = Status; 87 IoCompleteRequest(Irp, IO_NAMED_PIPE_INCREMENT); 88 } 89 90 return Status; 91 } 92 93 /* EOF */ 94