2003-07-24 20:52:58 +00:00
|
|
|
/* $Id: close.c,v 1.20 2003/07/24 20:52:58 chorns Exp $
|
2000-07-07 02:14:14 +00:00
|
|
|
*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* FILE: services/fs/vfat/close.c
|
|
|
|
* PURPOSE: VFAT Filesystem
|
|
|
|
* PROGRAMMER: Jason Filby (jasonfilby@yahoo.com)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
|
|
|
#include <ddk/ntddk.h>
|
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
#include "vfat.h"
|
|
|
|
|
|
|
|
/* FUNCTIONS ****************************************************************/
|
|
|
|
|
2001-08-14 20:47:30 +00:00
|
|
|
NTSTATUS
|
2000-12-29 23:17:12 +00:00
|
|
|
VfatCloseFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
|
2000-07-07 02:14:14 +00:00
|
|
|
/*
|
|
|
|
* FUNCTION: Closes a file
|
|
|
|
*/
|
|
|
|
{
|
2000-12-29 23:17:12 +00:00
|
|
|
PVFATFCB pFcb;
|
|
|
|
PVFATCCB pCcb;
|
2001-08-14 20:47:30 +00:00
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
2000-12-29 23:17:12 +00:00
|
|
|
|
2001-01-16 09:55:02 +00:00
|
|
|
DPRINT ("VfatCloseFile(DeviceExt %x, FileObject %x)\n",
|
2000-12-29 23:17:12 +00:00
|
|
|
DeviceExt, FileObject);
|
|
|
|
|
2001-03-09 14:40:28 +00:00
|
|
|
/* FIXME : update entry in directory? */
|
2000-12-29 23:17:12 +00:00
|
|
|
pCcb = (PVFATCCB) (FileObject->FsContext2);
|
2003-02-13 22:24:19 +00:00
|
|
|
pFcb = (PVFATFCB) (FileObject->FsContext);
|
2000-12-29 23:17:12 +00:00
|
|
|
|
2003-02-13 22:24:19 +00:00
|
|
|
if (pFcb == NULL)
|
2001-05-10 04:02:21 +00:00
|
|
|
{
|
2003-02-13 22:24:19 +00:00
|
|
|
return STATUS_SUCCESS;
|
2001-05-10 04:02:21 +00:00
|
|
|
}
|
2003-02-13 22:24:19 +00:00
|
|
|
|
2002-05-05 20:18:33 +00:00
|
|
|
if (pFcb->Flags & FCB_IS_VOLUME)
|
|
|
|
{
|
|
|
|
DPRINT1("Volume\n");
|
|
|
|
pFcb->RefCount--;
|
|
|
|
FileObject->FsContext2 = NULL;
|
|
|
|
}
|
|
|
|
else if (FileObject->FileName.Buffer)
|
2001-08-14 20:47:30 +00:00
|
|
|
{
|
|
|
|
// This a FO, that was created outside from FSD.
|
|
|
|
// Some FO's are created with IoCreateStreamFileObject() insid from FSD.
|
|
|
|
// This FO's haven't a FileName.
|
|
|
|
if (FileObject->DeletePending)
|
|
|
|
{
|
|
|
|
if (pFcb->Flags & FCB_DELETE_PENDING)
|
|
|
|
{
|
|
|
|
delEntry (DeviceExt, FileObject);
|
|
|
|
}
|
|
|
|
else
|
2003-02-13 22:24:19 +00:00
|
|
|
{
|
|
|
|
Status = STATUS_DELETE_PENDING;
|
|
|
|
}
|
2001-08-14 20:47:30 +00:00
|
|
|
}
|
|
|
|
vfatReleaseFCB (DeviceExt, pFcb);
|
|
|
|
}
|
2003-02-13 22:24:19 +00:00
|
|
|
|
|
|
|
FileObject->FsContext2 = NULL;
|
|
|
|
FileObject->FsContext = NULL;
|
2003-06-07 Casper S. Hornstrup <chorns@users.sourceforge.net>
Changes for compiling with w32api
* include/ddk/cctypes.h (PREACTOS_COMMON_FCB_HEADER): Remove.
(FSRTL_COMMON_FCB_HEADER): Add.
* include/ddk/iotypes.h (FILE_OBJECT): Rename field
SectionObjectPointers to SectionObjectPointer.
* ntoskrnl/cc/copy.c, ntoskrnl/cc/misc.c, ntoskrnl/cc/pin.c,
ntoskrnl/cc/view.c, ntoskrnl/io/rawfs.c, ntoskrnl/mm/section.c,
drivers/fs/cdfs/cleanup.c, drivers/fs/cdfs/fcb.c,
drivers/fs/cdfs/fsctl.c, drivers/fs/ntfs/fcb.c, drivers/fs/ntfs/fsctl.c,
drivers/fs/vfat/close.c, drivers/fs/vfat/create.c,
drivers/fs/vfat/finfo.c, drivers/fs/vfat/fcb.c, drivers/fs/vfat/fsctl.c:
Use new FILE_OBJECT structure.
* drivers/fs/cdfs/cdfs.h, drivers/fs/ntfs/ntfs.h, drivers/fs/vfat/vfat.h:
Use new FSRTL_COMMON_FCB_HEADER structure.
* drivers/net/afd/include/afd.h (FSRTL_COMMON_FCB_HEADER): Remove.
* include/ddk/ketypes.h (KQUEUE): Match w32api structure.
* ntoskrnl/ke/queue.c, ntoskrnl/ke/wait.c: Use new structure.
* ntoskrnl/ke/spinlock.c (KeAcquireSpinLockAtDpcLevel,
KeReleaseSpinLockFromDpcLevel): Undefine before declaring.
svn path=/trunk/; revision=4865
2003-06-07 11:34:36 +00:00
|
|
|
FileObject->SectionObjectPointer = NULL;
|
2000-12-29 23:17:12 +00:00
|
|
|
|
2003-02-13 22:24:19 +00:00
|
|
|
if (pCcb)
|
|
|
|
{
|
|
|
|
vfatDestroyCCB(pCcb);
|
|
|
|
}
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
|
2001-08-14 20:47:30 +00:00
|
|
|
return Status;
|
2000-07-07 02:14:14 +00:00
|
|
|
}
|
|
|
|
|
2001-11-02 22:47:36 +00:00
|
|
|
NTSTATUS VfatClose (PVFAT_IRP_CONTEXT IrpContext)
|
2000-07-07 02:14:14 +00:00
|
|
|
/*
|
|
|
|
* FUNCTION: Closes a file
|
|
|
|
*/
|
|
|
|
{
|
2000-12-29 23:17:12 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
|
2003-07-24 19:00:42 +00:00
|
|
|
DPRINT ("VfatClose(DeviceObject %x, Irp %x)\n", IrpContext->DeviceObject, IrpContext->Irp);
|
2000-12-29 23:17:12 +00:00
|
|
|
|
2002-05-15 18:05:00 +00:00
|
|
|
if (IrpContext->DeviceObject == VfatGlobalData->DeviceObject)
|
|
|
|
{
|
|
|
|
DPRINT("Closing file system\n");
|
|
|
|
Status = STATUS_SUCCESS;
|
|
|
|
goto ByeBye;
|
|
|
|
}
|
2003-01-11 15:56:43 +00:00
|
|
|
#if 0
|
|
|
|
/* There occurs a dead look at the call to CcRosDeleteFileCache/ObDereferenceObject/VfatClose
|
|
|
|
in CmLazyCloseThreadMain if VfatClose is execute asynchronous in a worker thread. */
|
2001-11-02 22:47:36 +00:00
|
|
|
if (!ExAcquireResourceExclusiveLite (&IrpContext->DeviceExt->DirResource, IrpContext->Flags & IRPCONTEXT_CANWAIT))
|
2003-01-11 15:56:43 +00:00
|
|
|
#else
|
|
|
|
if (!ExAcquireResourceExclusiveLite (&IrpContext->DeviceExt->DirResource, TRUE))
|
|
|
|
#endif
|
2001-11-02 22:47:36 +00:00
|
|
|
{
|
|
|
|
return VfatQueueRequest (IrpContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = VfatCloseFile (IrpContext->DeviceExt, IrpContext->FileObject);
|
|
|
|
ExReleaseResourceLite (&IrpContext->DeviceExt->DirResource);
|
2000-12-29 23:17:12 +00:00
|
|
|
|
2002-05-15 18:05:00 +00:00
|
|
|
ByeBye:
|
2001-11-02 22:47:36 +00:00
|
|
|
IrpContext->Irp->IoStatus.Status = Status;
|
|
|
|
IrpContext->Irp->IoStatus.Information = 0;
|
|
|
|
IoCompleteRequest (IrpContext->Irp, IO_NO_INCREMENT);
|
|
|
|
VfatFreeIrpContext(IrpContext);
|
2000-12-29 23:17:12 +00:00
|
|
|
|
|
|
|
return (Status);
|
2000-07-07 02:14:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|