xref: /reactos/drivers/filesystems/npfs/close.c (revision c2c66aff)
1 /*
2  * PROJECT:     ReactOS Named Pipe FileSystem
3  * LICENSE:     BSD - See COPYING.ARM in the top level directory
4  * FILE:        drivers/filesystems/npfs/close.c
5  * PURPOSE:     Pipes Closing
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_CLOSE)
15 
16 /* FUNCTIONS ******************************************************************/
17 
18 NTSTATUS
19 NTAPI
NpCommonClose(IN PDEVICE_OBJECT DeviceObject,IN PIRP Irp)20 NpCommonClose(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_ROOT_DCB)
40     {
41         --Fcb->CurrentInstances;
42         NpDeleteCcb(Ccb, &DeferredList);
43     }
44     else if (NodeTypeCode == NPFS_NTC_VCB)
45     {
46         --NpVcb->ReferenceCount;
47     }
48 
49     NpReleaseVcb();
50     NpCompleteDeferredIrps(&DeferredList);
51 
52     Irp->IoStatus.Status = STATUS_SUCCESS;
53     IoCompleteRequest(Irp, IO_NAMED_PIPE_INCREMENT);
54     return STATUS_SUCCESS;
55 }
56 
57 NTSTATUS
58 NTAPI
NpFsdClose(IN PDEVICE_OBJECT DeviceObject,IN PIRP Irp)59 NpFsdClose(IN PDEVICE_OBJECT DeviceObject,
60            IN PIRP Irp)
61 {
62     NTSTATUS Status;
63     PAGED_CODE();
64 
65     FsRtlEnterFileSystem();
66 
67     Status = NpCommonClose(DeviceObject, Irp);
68 
69     FsRtlExitFileSystem();
70 
71     return Status;
72 }
73 
74 /* EOF */
75