2003-07-17 13:31:39 +00:00
|
|
|
/*
|
|
|
|
* ReactOS kernel
|
|
|
|
* Copyright (C) 2002 ReactOS Team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2008-03-08 21:45:51 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
2003-07-17 13:31:39 +00:00
|
|
|
*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
2008-02-10 11:20:29 +00:00
|
|
|
* FILE: drivers/filesystem/ntfs/close.c
|
2003-07-17 13:31:39 +00:00
|
|
|
* PURPOSE: NTFS filesystem driver
|
|
|
|
* PROGRAMMER: Art Yerkes
|
2005-05-08 02:16:32 +00:00
|
|
|
* UPDATE HISTORY:
|
2003-07-17 13:31:39 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
2005-07-20 02:52:52 +00:00
|
|
|
#include "ntfs.h"
|
2003-07-17 13:31:39 +00:00
|
|
|
|
2004-06-05 08:28:37 +00:00
|
|
|
#define NDEBUG
|
2003-07-17 13:31:39 +00:00
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
/* FUNCTIONS ****************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: Closes a file
|
|
|
|
*/
|
2013-06-16 12:15:06 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsCloseFile(PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PFILE_OBJECT FileObject)
|
2003-07-17 13:31:39 +00:00
|
|
|
{
|
2013-06-16 12:15:06 +00:00
|
|
|
PNTFS_CCB Ccb;
|
2014-10-12 11:43:10 +00:00
|
|
|
PNTFS_FCB Fcb;
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2013-06-16 12:15:06 +00:00
|
|
|
DPRINT("NtfsCloseFile(DeviceExt %p, FileObject %p)\n",
|
|
|
|
DeviceExt,
|
|
|
|
FileObject);
|
2003-07-17 13:31:39 +00:00
|
|
|
|
2013-06-16 12:15:06 +00:00
|
|
|
Ccb = (PNTFS_CCB)(FileObject->FsContext2);
|
2014-10-12 11:43:10 +00:00
|
|
|
Fcb = (PNTFS_FCB)(FileObject->FsContext);
|
2003-07-17 13:31:39 +00:00
|
|
|
|
2013-06-16 12:15:06 +00:00
|
|
|
DPRINT("Ccb %p\n", Ccb);
|
|
|
|
if (Ccb == NULL)
|
2003-07-17 13:31:39 +00:00
|
|
|
{
|
2013-06-16 12:15:06 +00:00
|
|
|
return STATUS_SUCCESS;
|
2003-07-17 13:31:39 +00:00
|
|
|
}
|
|
|
|
|
2013-06-16 12:15:06 +00:00
|
|
|
FileObject->FsContext2 = NULL;
|
2014-10-12 11:43:10 +00:00
|
|
|
FileObject->FsContext = NULL;
|
|
|
|
FileObject->SectionObjectPointer = NULL;
|
2016-02-22 22:20:54 +00:00
|
|
|
DeviceExt->OpenHandleCount--;
|
2003-07-17 13:31:39 +00:00
|
|
|
|
2013-06-16 12:15:06 +00:00
|
|
|
if (FileObject->FileName.Buffer)
|
2003-07-17 13:31:39 +00:00
|
|
|
{
|
2013-06-16 12:15:06 +00:00
|
|
|
// This a FO, that was created outside from FSD.
|
|
|
|
// Some FO's are created with IoCreateStreamFileObject() insid from FSD.
|
|
|
|
// This FO's don't have a FileName.
|
2014-10-12 11:43:10 +00:00
|
|
|
NtfsReleaseFCB(DeviceExt, Fcb);
|
2003-07-17 13:31:39 +00:00
|
|
|
}
|
|
|
|
|
2013-06-16 12:15:06 +00:00
|
|
|
if (Ccb->DirectorySearchPattern)
|
2003-07-17 13:31:39 +00:00
|
|
|
{
|
2013-06-16 12:15:06 +00:00
|
|
|
ExFreePool(Ccb->DirectorySearchPattern);
|
2003-07-17 13:31:39 +00:00
|
|
|
}
|
|
|
|
|
2013-06-16 12:15:06 +00:00
|
|
|
ExFreePool(Ccb);
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
2003-07-17 13:31:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-24 21:29:34 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsClose(PNTFS_IRP_CONTEXT IrpContext)
|
2003-07-17 13:31:39 +00:00
|
|
|
{
|
2013-06-16 12:15:06 +00:00
|
|
|
PDEVICE_EXTENSION DeviceExtension;
|
|
|
|
PFILE_OBJECT FileObject;
|
|
|
|
NTSTATUS Status;
|
2015-05-24 21:29:34 +00:00
|
|
|
PDEVICE_OBJECT DeviceObject;
|
2003-07-17 13:31:39 +00:00
|
|
|
|
2013-06-16 12:15:06 +00:00
|
|
|
DPRINT("NtfsClose() called\n");
|
2003-07-17 13:31:39 +00:00
|
|
|
|
2015-05-24 21:29:34 +00:00
|
|
|
DeviceObject = IrpContext->DeviceObject;
|
2013-06-16 12:15:06 +00:00
|
|
|
if (DeviceObject == NtfsGlobalData->DeviceObject)
|
2003-07-17 13:31:39 +00:00
|
|
|
{
|
2013-06-16 12:15:06 +00:00
|
|
|
DPRINT("Closing file system\n");
|
2015-05-24 21:29:34 +00:00
|
|
|
IrpContext->Irp->IoStatus.Information = 0;
|
|
|
|
return STATUS_SUCCESS;
|
2003-07-17 13:31:39 +00:00
|
|
|
}
|
|
|
|
|
2015-05-24 21:29:34 +00:00
|
|
|
FileObject = IrpContext->FileObject;
|
2013-06-16 12:15:06 +00:00
|
|
|
DeviceExtension = DeviceObject->DeviceExtension;
|
2003-07-17 13:31:39 +00:00
|
|
|
|
2016-02-23 20:45:11 +00:00
|
|
|
if (!ExAcquireResourceExclusiveLite(&DeviceExtension->DirResource,
|
|
|
|
BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_CANWAIT)))
|
|
|
|
{
|
|
|
|
return NtfsMarkIrpContextForQueue(IrpContext);
|
|
|
|
}
|
|
|
|
|
2015-05-24 21:29:34 +00:00
|
|
|
Status = NtfsCloseFile(DeviceExtension, FileObject);
|
2003-07-17 13:31:39 +00:00
|
|
|
|
2016-02-23 20:45:11 +00:00
|
|
|
ExReleaseResourceLite(&DeviceExtension->DirResource);
|
|
|
|
|
|
|
|
if (Status == STATUS_PENDING)
|
|
|
|
{
|
|
|
|
return NtfsMarkIrpContextForQueue(IrpContext);
|
|
|
|
}
|
|
|
|
|
2015-05-24 21:29:34 +00:00
|
|
|
IrpContext->Irp->IoStatus.Information = 0;
|
2013-06-16 12:15:06 +00:00
|
|
|
return Status;
|
2003-07-17 13:31:39 +00:00
|
|
|
}
|
2013-06-16 12:15:06 +00:00
|
|
|
|
|
|
|
/* EOF */
|