[BTRFS] Fix booting with runtime checks
[reactos.git] / drivers / filesystems / npfs / 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 // File ID number for NPFS bugchecking support
14 #define NPFS_BUGCHECK_FILE_ID (NPFS_BUGCHECK_CLEANUP)
15
16 /* FUNCTIONS ******************************************************************/
17
18 NTSTATUS
19 NTAPI
20 NpCommonCleanup(IN PDEVICE_OBJECT DeviceObject,
21 IN PIRP Irp)
22 {
23 PIO_STACK_LOCATION IoStack;
24 NODE_TYPE_CODE NodeTypeCode;
25 LIST_ENTRY DeferredList;
26 PNP_FCB Fcb;
27 PNP_CCB Ccb;
28 ULONG NamedPipeEnd;
29 PAGED_CODE();
30
31 IoStack = IoGetCurrentIrpStackLocation(Irp);
32 InitializeListHead(&DeferredList);
33
34 NpAcquireExclusiveVcb();
35 NodeTypeCode = NpDecodeFileObject(IoStack->FileObject,
36 (PVOID*)&Fcb,
37 &Ccb,
38 &NamedPipeEnd);
39 if (NodeTypeCode == NPFS_NTC_CCB)
40 {
41 if (NamedPipeEnd == FILE_PIPE_SERVER_END)
42 {
43 ASSERT(Ccb->Fcb->ServerOpenCount != 0);
44 --Ccb->Fcb->ServerOpenCount;
45 }
46
47 NpSetClosingPipeState(Ccb, Irp, NamedPipeEnd, &DeferredList);
48 }
49
50 NpReleaseVcb();
51 NpCompleteDeferredIrps(&DeferredList);
52
53 return STATUS_SUCCESS;
54 }
55
56 NTSTATUS
57 NTAPI
58 NpFsdCleanup(IN PDEVICE_OBJECT DeviceObject,
59 IN PIRP Irp)
60 {
61 NTSTATUS Status;
62 PAGED_CODE();
63
64 FsRtlEnterFileSystem();
65
66 Status = NpCommonCleanup(DeviceObject, Irp);
67
68 FsRtlExitFileSystem();
69
70 if (Status != STATUS_PENDING)
71 {
72 Irp->IoStatus.Status = Status;
73 IoCompleteRequest(Irp, IO_NAMED_PIPE_INCREMENT);
74 }
75
76 return Status;
77 }
78
79 /* EOF */