summaryrefslogtreecommitdiffstats
path: root/private/ntos/npfs/close.c
diff options
context:
space:
mode:
authorAdam <you@example.com>2020-05-17 05:51:50 +0200
committerAdam <you@example.com>2020-05-17 05:51:50 +0200
commite611b132f9b8abe35b362e5870b74bce94a1e58e (patch)
treea5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/ntos/npfs/close.c
downloadNT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip
Diffstat (limited to 'private/ntos/npfs/close.c')
-rw-r--r--private/ntos/npfs/close.c236
1 files changed, 236 insertions, 0 deletions
diff --git a/private/ntos/npfs/close.c b/private/ntos/npfs/close.c
new file mode 100644
index 000000000..8b169d3b5
--- /dev/null
+++ b/private/ntos/npfs/close.c
@@ -0,0 +1,236 @@
+/*++
+
+Copyright (c) 1989 Microsoft Corporation
+
+Module Name:
+
+ Close.c
+
+Abstract:
+
+ This module implements the File Close routine for NPFS called by the
+ dispatch driver.
+
+Author:
+
+ Gary Kimura [GaryKi] 21-Aug-1990
+
+Revision History:
+
+--*/
+
+#include "NpProcs.h"
+
+//
+// The debug trace level
+//
+
+#define Dbg (DEBUG_TRACE_CLOSE)
+
+//
+// local procedure prototypes
+//
+
+NTSTATUS
+NpCommonClose (
+ IN PNPFS_DEVICE_OBJECT NpfsDeviceObject,
+ IN PIRP Irp
+ );
+
+#ifdef ALLOC_PRAGMA
+#pragma alloc_text(PAGE, NpCommonClose)
+#pragma alloc_text(PAGE, NpFsdClose)
+#endif
+
+
+NTSTATUS
+NpFsdClose (
+ IN PNPFS_DEVICE_OBJECT NpfsDeviceObject,
+ IN PIRP Irp
+ )
+
+/*++
+
+Routine Description:
+
+ This routine implements the FSD part of the NtCloseFile API calls.
+
+Arguments:
+
+ NpfsDeviceObject - Supplies the device object to use.
+
+ Irp - Supplies the Irp being processed
+
+Return Value:
+
+ NTSTATUS - The Fsd status for the Irp
+
+--*/
+
+{
+ NTSTATUS Status;
+
+ PAGED_CODE();
+
+ DebugTrace(+1, Dbg, "NpFsdClose\n", 0);
+
+ //
+ // Call the common Close routine.
+ //
+
+ FsRtlEnterFileSystem();
+
+ try {
+
+ Status = NpCommonClose( NpfsDeviceObject, Irp );
+
+ } except(NpExceptionFilter( GetExceptionCode() )) {
+
+ //
+ // We had some trouble trying to perform the requested
+ // operation, so we'll abort the I/O request with
+ // the error status that we get back from the
+ // execption code
+ //
+
+ Status = NpProcessException( NpfsDeviceObject, Irp, GetExceptionCode() );
+ }
+
+ FsRtlExitFileSystem();
+
+ //
+ // And return to our caller
+ //
+
+ DebugTrace(-1, Dbg, "NpFsdClose -> %08lx\n", Status );
+
+ return Status;
+}
+
+//
+// Internal support routine
+//
+
+NTSTATUS
+NpCommonClose (
+ IN PNPFS_DEVICE_OBJECT NpfsDeviceObject,
+ IN PIRP Irp
+ )
+
+/*++
+
+Routine Description:
+
+ This is the common routine for creating/opening a file.
+
+Arguments:
+
+ Irp - Supplies the Irp to process
+
+Return Value:
+
+ NTSTATUS - the return status for the operation
+
+--*/
+
+{
+ NTSTATUS Status;
+
+ PIO_STACK_LOCATION IrpSp;
+
+ NODE_TYPE_CODE NodeTypeCode;
+ PFCB Fcb;
+ PCCB Ccb;
+
+ PAGED_CODE();
+
+ //
+ // Get the current stack location
+ //
+
+ IrpSp = IoGetCurrentIrpStackLocation( Irp );
+
+ DebugTrace(+1, Dbg, "NpCommonClose...\n", 0);
+ DebugTrace( 0, Dbg, " Irp = %08lx\n", Irp);
+
+ //
+ // Now acquire exclusive access to the vcb
+ //
+
+ NpAcquireExclusiveVcb();
+
+ try {
+
+ //
+ // Decode the file object to figure out who we are. If the result
+ // is null then the pipe has been disconnected.
+ //
+
+ if ((NodeTypeCode = NpDecodeFileObject( IrpSp->FileObject,
+ &Fcb,
+ &Ccb,
+ NULL )) == NTC_UNDEFINED) {
+
+ DebugTrace(0, Dbg, "Pipe is disconnected from us\n", 0);
+
+ NpCompleteRequest( Irp, STATUS_PIPE_DISCONNECTED );
+ try_return( Status = STATUS_PIPE_DISCONNECTED );
+ }
+
+ //
+ // Now case on the type of file object we're closing
+ //
+
+ switch (NodeTypeCode) {
+
+ case NPFS_NTC_VCB:
+
+ //
+ // Decrement the Open count and clear our fields in the file object
+ //
+
+ NpVcb->OpenCount -= 1;
+ NpSetFileObject( IrpSp->FileObject, NULL, NULL, FILE_PIPE_SERVER_END );
+
+ break;
+
+ case NPFS_NTC_ROOT_DCB:
+
+ //
+ // Decrement the Open count and clear our fields in the file object
+ //
+
+ Fcb->OpenCount -= 1;
+ NpSetFileObject( IrpSp->FileObject, NULL, NULL, FILE_PIPE_SERVER_END );
+
+ //
+ // Remove the root dcb ccb.
+ //
+
+ NpDeleteCcb( Ccb );
+
+ break;
+
+ case NPFS_NTC_CCB:
+
+ break;
+ }
+
+ //
+ // Complete the close irp
+ //
+
+ NpCompleteRequest( Irp, STATUS_SUCCESS );
+
+ Status = STATUS_SUCCESS;
+
+ try_exit: NOTHING;
+ } finally {
+
+ NpReleaseVcb( );
+ }
+
+ DebugTrace(-1, Dbg, "NpCommonClose -> %08lx\n", Status);
+ return Status;
+}
+