[NPFS_NEW]: Add file header info.
[reactos.git] / reactos / drivers / filesystems / npfs_new / cleanup.c
1 /*
2 * PROJECT: ReactOS Named Pipe FileSystem
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: drivers/filesystems/npfs/cleanup.c
5 * PURPOSE: Pipes Cleanup
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9 /* INCLUDES *******************************************************************/
10
11 #include "npfs.h"
12
13 /* FUNCTIONS ******************************************************************/
14
15 NTSTATUS
16 NTAPI
17 NpCommonCleanup(IN PDEVICE_OBJECT DeviceObject,
18 IN PIRP Irp)
19 {
20 PIO_STACK_LOCATION IoStack;
21 NODE_TYPE_CODE NodeTypeCode;
22 LIST_ENTRY DeferredList;
23 PNP_FCB Fcb;
24 PNP_CCB Ccb;
25 ULONG NamedPipeEnd;
26 PAGED_CODE();
27
28 IoStack = IoGetCurrentIrpStackLocation(Irp);
29 InitializeListHead(&DeferredList);
30
31 NpAcquireExclusiveVcb();
32 NodeTypeCode = NpDecodeFileObject(IoStack->FileObject,
33 (PVOID*)&Fcb,
34 &Ccb,
35 &NamedPipeEnd);
36 if (NodeTypeCode == NPFS_NTC_CCB)
37 {
38 if (NamedPipeEnd == FILE_PIPE_SERVER_END)
39 {
40 ASSERT(Ccb->Fcb->ServerOpenCount != 0);
41 --Ccb->Fcb->ServerOpenCount;
42 }
43
44 NpSetClosingPipeState(Ccb, Irp, NamedPipeEnd, &DeferredList);
45 }
46
47 NpReleaseVcb();
48 NpCompleteDeferredIrps(&DeferredList);
49
50 return STATUS_SUCCESS;
51 }
52
53 NTSTATUS
54 NTAPI
55 NpFsdCleanup(IN PDEVICE_OBJECT DeviceObject,
56 IN PIRP Irp)
57 {
58 NTSTATUS Status;
59 PAGED_CODE();
60
61 FsRtlEnterFileSystem();
62
63 Status = NpCommonCleanup(DeviceObject, Irp);
64
65 FsRtlExitFileSystem();
66
67 if (Status != STATUS_PENDING)
68 {
69 Irp->IoStatus.Status = Status;
70 IoCompleteRequest(Irp, IO_NAMED_PIPE_INCREMENT);
71 }
72
73 return Status;
74 }
75
76 /* EOF */