2005-08-24 18:29:45 +00:00
|
|
|
/*
|
2000-07-07 02:14:14 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
2003-10-11 17:51:56 +00:00
|
|
|
* FILE: drivers/fs/vfat/close.c
|
2000-07-07 02:14:14 +00:00
|
|
|
* PURPOSE: VFAT Filesystem
|
|
|
|
* PROGRAMMER: Jason Filby (jasonfilby@yahoo.com)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#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
|
|
|
|
2007-11-21 16:50:07 +00:00
|
|
|
DPRINT ("VfatCloseFile(DeviceExt %p, FileObject %p)\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;
|
|
|
|
}
|
2005-04-01 18:35:34 +00:00
|
|
|
else
|
2001-08-14 20:47:30 +00:00
|
|
|
{
|
2006-12-30 01:11:14 +00:00
|
|
|
if (FileObject->DeletePending)
|
2001-08-14 20:47:30 +00:00
|
|
|
{
|
|
|
|
if (pFcb->Flags & FCB_DELETE_PENDING)
|
|
|
|
{
|
2003-10-11 17:51:56 +00:00
|
|
|
VfatDelEntry (DeviceExt, pFcb);
|
2001-08-14 20:47:30 +00:00
|
|
|
}
|
|
|
|
else
|
2003-02-13 22:24:19 +00:00
|
|
|
{
|
|
|
|
Status = STATUS_DELETE_PENDING;
|
|
|
|
}
|
2001-08-14 20:47:30 +00:00
|
|
|
}
|
|
|
|
vfatReleaseFCB (DeviceExt, pFcb);
|
|
|
|
}
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2006-12-30 01:11:14 +00:00
|
|
|
FileObject->FsContext2 = NULL;
|
2003-02-13 22:24:19 +00:00
|
|
|
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);
|
|
|
|
}
|
2005-05-08 02:16:32 +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;
|
|
|
|
|
2007-11-21 16:50:07 +00:00
|
|
|
DPRINT ("VfatClose(DeviceObject %p, Irp %p)\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
|
2005-05-08 02:16:32 +00:00
|
|
|
/* There occurs a dead look at the call to CcRosDeleteFileCache/ObDereferenceObject/VfatClose
|
2003-01-11 15:56:43 +00:00
|
|
|
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 */
|