reactos/reactos/drivers/fs/vfat/cleanup.c

92 lines
2.4 KiB
C
Raw Normal View History

/* $Id: cleanup.c,v 1.13 2003/07/24 20:52:58 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: services/fs/vfat/cleanup.c
* PURPOSE: VFAT Filesystem
* PROGRAMMER: Jason Filby (jasonfilby@yahoo.com)
*/
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
#define NDEBUG
#include <debug.h>
#include "vfat.h"
/* FUNCTIONS ****************************************************************/
static NTSTATUS
VfatCleanupFile(PVFAT_IRP_CONTEXT IrpContext)
/*
* FUNCTION: Cleans up after a file has been closed.
*/
{
2002-08-08 David Welch <welch@computer2.darkstar.org> * ntoskrnl/mm/section (NtQuerySection): Return the right result length. 2002-08-08 David Welch <welch@computer2.darkstar.org> * ntoskrnl/ke/usertrap.c (print_user_address): Check for a NULL LDR structure in the PEB; copy the LDR pointer in safely. 2002-08-08 David Welch <welch@computer2.darkstar.org> * ntoskrnl/ke/apc.c (KiDeliverUserApc): Deliver all present APCs; release the APC spinlock while acccessing user memory. 2002-08-08 David Welch <welch@computer2.darkstar.org> * include/internal/ps.h: Adjusted offsets into the ETHREAD structure. * include/internal/ps.h: Removed redundant members from the KTHREAD structure. * ntoskrnl/ke/kthread.c (KeInitializeThread): Removed redundant members from the KTHREAD structure. 2002-08-08 David Welch <welch@computer2.darkstar.org> * ntoskrnl/dbg/kdb.c (KdbEnterDebuggerException): New function to enter the debugger on an exception. * ntoskrnl/kd/kdebug.c (KdInitSystem): Initialize the local kernel debugger if enabled. * ntoskrnl/ke/catch.c (KiDispatchException): Enter the local kernel debugger on an exception. 2002-08-08 David Welch <welch@computer2.darkstar.org> * include/ntdll/ldr.h: Added definition for a DLL entrypoint. * lib/kernel32/process/create.c (KlCreateFirstThread): Put the argument to the NtProcessStartup function on the stack. * lib/kernel32/process/create.c (KlInitPeb): Read the base address of the new image from the PEB. * lib/kernel32/process/create.c (CreateProcessW): Start the first thread at the entrypoint of the new image. * lib/ntdll/ldr/startup.c (LdrInitializeThunk): If the function is called after the initial startup then just call the entrypoints for the loaded DLLs with DLL_THREAD_ATTACH. Don't call the entrypoint of the image. * lib/ntdll/rtl/process.c (RtlpCreateFirstThread): Put the argument to the NtProcessStartup function on the stack. * lib/ntdll/rtl/process.c (KlInitPeb): Read the base address of the new image from the PEB. * lib/ntdll/rtl/process.c (RtlCreateUserProcess): Start the first thread at the entrypoint of the new image. * ntoskrnl/ke/i386/bthread.S (PsBeginThreadWithContextInternal): Use the system call path to begin a usermode thread. * ntoskrnl/ke/i386/thread.c (Ke386InitThreadWithContext): Convert the supplied context into a trap frame. * ntoskrnl/ldr/init.c (LdrLoadInitialProcess): Put the PEB argument to the NtProcessStartup function on the new stack; start the first thread at the entrypoint of the image. * ntoskrnl/ps/create.c (NtCreateThread): Create an APC to call LdrInitializeThunk in the context of a new thread before its entrypoint. 2002-08-08 David Welch <welch@computer2.darkstar.org> * drivers/fs/vfat/cleanup.c (VfatCleanupFile): Uninitialise the cache on file cleanup. * drivers/fs/vfat/fcb.c (vfatReleaseFcb): Don't uninitialise the cache on file close. * ntoskrnl/cc/copy.c: Renamed zero page global variable. * ntoskrnl/cc/view.c: Added cache delete function. svn path=/trunk/; revision=3323
2002-08-08 17:54:16 +00:00
PVFATFCB pFcb;
PDEVICE_EXTENSION DeviceExt = IrpContext->DeviceExt;
PFILE_OBJECT FileObject = IrpContext->FileObject;
2002-08-08 David Welch <welch@computer2.darkstar.org> * ntoskrnl/mm/section (NtQuerySection): Return the right result length. 2002-08-08 David Welch <welch@computer2.darkstar.org> * ntoskrnl/ke/usertrap.c (print_user_address): Check for a NULL LDR structure in the PEB; copy the LDR pointer in safely. 2002-08-08 David Welch <welch@computer2.darkstar.org> * ntoskrnl/ke/apc.c (KiDeliverUserApc): Deliver all present APCs; release the APC spinlock while acccessing user memory. 2002-08-08 David Welch <welch@computer2.darkstar.org> * include/internal/ps.h: Adjusted offsets into the ETHREAD structure. * include/internal/ps.h: Removed redundant members from the KTHREAD structure. * ntoskrnl/ke/kthread.c (KeInitializeThread): Removed redundant members from the KTHREAD structure. 2002-08-08 David Welch <welch@computer2.darkstar.org> * ntoskrnl/dbg/kdb.c (KdbEnterDebuggerException): New function to enter the debugger on an exception. * ntoskrnl/kd/kdebug.c (KdInitSystem): Initialize the local kernel debugger if enabled. * ntoskrnl/ke/catch.c (KiDispatchException): Enter the local kernel debugger on an exception. 2002-08-08 David Welch <welch@computer2.darkstar.org> * include/ntdll/ldr.h: Added definition for a DLL entrypoint. * lib/kernel32/process/create.c (KlCreateFirstThread): Put the argument to the NtProcessStartup function on the stack. * lib/kernel32/process/create.c (KlInitPeb): Read the base address of the new image from the PEB. * lib/kernel32/process/create.c (CreateProcessW): Start the first thread at the entrypoint of the new image. * lib/ntdll/ldr/startup.c (LdrInitializeThunk): If the function is called after the initial startup then just call the entrypoints for the loaded DLLs with DLL_THREAD_ATTACH. Don't call the entrypoint of the image. * lib/ntdll/rtl/process.c (RtlpCreateFirstThread): Put the argument to the NtProcessStartup function on the stack. * lib/ntdll/rtl/process.c (KlInitPeb): Read the base address of the new image from the PEB. * lib/ntdll/rtl/process.c (RtlCreateUserProcess): Start the first thread at the entrypoint of the new image. * ntoskrnl/ke/i386/bthread.S (PsBeginThreadWithContextInternal): Use the system call path to begin a usermode thread. * ntoskrnl/ke/i386/thread.c (Ke386InitThreadWithContext): Convert the supplied context into a trap frame. * ntoskrnl/ldr/init.c (LdrLoadInitialProcess): Put the PEB argument to the NtProcessStartup function on the new stack; start the first thread at the entrypoint of the image. * ntoskrnl/ps/create.c (NtCreateThread): Create an APC to call LdrInitializeThunk in the context of a new thread before its entrypoint. 2002-08-08 David Welch <welch@computer2.darkstar.org> * drivers/fs/vfat/cleanup.c (VfatCleanupFile): Uninitialise the cache on file cleanup. * drivers/fs/vfat/fcb.c (vfatReleaseFcb): Don't uninitialise the cache on file close. * ntoskrnl/cc/copy.c: Renamed zero page global variable. * ntoskrnl/cc/view.c: Added cache delete function. svn path=/trunk/; revision=3323
2002-08-08 17:54:16 +00:00
DPRINT("VfatCleanupFile(DeviceExt %x, FileObject %x)\n",
DeviceExt, FileObject);
2002-08-08 David Welch <welch@computer2.darkstar.org> * ntoskrnl/mm/section (NtQuerySection): Return the right result length. 2002-08-08 David Welch <welch@computer2.darkstar.org> * ntoskrnl/ke/usertrap.c (print_user_address): Check for a NULL LDR structure in the PEB; copy the LDR pointer in safely. 2002-08-08 David Welch <welch@computer2.darkstar.org> * ntoskrnl/ke/apc.c (KiDeliverUserApc): Deliver all present APCs; release the APC spinlock while acccessing user memory. 2002-08-08 David Welch <welch@computer2.darkstar.org> * include/internal/ps.h: Adjusted offsets into the ETHREAD structure. * include/internal/ps.h: Removed redundant members from the KTHREAD structure. * ntoskrnl/ke/kthread.c (KeInitializeThread): Removed redundant members from the KTHREAD structure. 2002-08-08 David Welch <welch@computer2.darkstar.org> * ntoskrnl/dbg/kdb.c (KdbEnterDebuggerException): New function to enter the debugger on an exception. * ntoskrnl/kd/kdebug.c (KdInitSystem): Initialize the local kernel debugger if enabled. * ntoskrnl/ke/catch.c (KiDispatchException): Enter the local kernel debugger on an exception. 2002-08-08 David Welch <welch@computer2.darkstar.org> * include/ntdll/ldr.h: Added definition for a DLL entrypoint. * lib/kernel32/process/create.c (KlCreateFirstThread): Put the argument to the NtProcessStartup function on the stack. * lib/kernel32/process/create.c (KlInitPeb): Read the base address of the new image from the PEB. * lib/kernel32/process/create.c (CreateProcessW): Start the first thread at the entrypoint of the new image. * lib/ntdll/ldr/startup.c (LdrInitializeThunk): If the function is called after the initial startup then just call the entrypoints for the loaded DLLs with DLL_THREAD_ATTACH. Don't call the entrypoint of the image. * lib/ntdll/rtl/process.c (RtlpCreateFirstThread): Put the argument to the NtProcessStartup function on the stack. * lib/ntdll/rtl/process.c (KlInitPeb): Read the base address of the new image from the PEB. * lib/ntdll/rtl/process.c (RtlCreateUserProcess): Start the first thread at the entrypoint of the new image. * ntoskrnl/ke/i386/bthread.S (PsBeginThreadWithContextInternal): Use the system call path to begin a usermode thread. * ntoskrnl/ke/i386/thread.c (Ke386InitThreadWithContext): Convert the supplied context into a trap frame. * ntoskrnl/ldr/init.c (LdrLoadInitialProcess): Put the PEB argument to the NtProcessStartup function on the new stack; start the first thread at the entrypoint of the image. * ntoskrnl/ps/create.c (NtCreateThread): Create an APC to call LdrInitializeThunk in the context of a new thread before its entrypoint. 2002-08-08 David Welch <welch@computer2.darkstar.org> * drivers/fs/vfat/cleanup.c (VfatCleanupFile): Uninitialise the cache on file cleanup. * drivers/fs/vfat/fcb.c (vfatReleaseFcb): Don't uninitialise the cache on file close. * ntoskrnl/cc/copy.c: Renamed zero page global variable. * ntoskrnl/cc/view.c: Added cache delete function. svn path=/trunk/; revision=3323
2002-08-08 17:54:16 +00:00
/* FIXME: handle file/directory deletion here */
pFcb = (PVFATFCB) FileObject->FsContext;
if (pFcb)
{
if (!(pFcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY) &&
FsRtlAreThereCurrentFileLocks(&pFcb->FileLock))
{
/* remove all locks this process have on this file */
FsRtlFastUnlockAll(&pFcb->FileLock,
FileObject,
IoGetRequestorProcess(IrpContext->Irp),
NULL);
}
/* Uninitialize file cache if initialized for this file object. */
if (FileObject->PrivateCacheMap)
{
CcRosReleaseFileCache (FileObject);
}
}
return STATUS_SUCCESS;
}
NTSTATUS VfatCleanup (PVFAT_IRP_CONTEXT IrpContext)
/*
* FUNCTION: Cleans up after a file has been closed.
*/
{
NTSTATUS Status;
DPRINT("VfatCleanup(DeviceObject %x, Irp %x)\n", IrpContext->DeviceObject, IrpContext->Irp);
if (IrpContext->DeviceObject == VfatGlobalData->DeviceObject)
{
Status = STATUS_SUCCESS;
goto ByeBye;
}
if (!ExAcquireResourceExclusiveLite (&IrpContext->DeviceExt->DirResource,
(BOOLEAN)(IrpContext->Flags & IRPCONTEXT_CANWAIT)))
{
return VfatQueueRequest (IrpContext);
}
Status = VfatCleanupFile(IrpContext);
ExReleaseResourceLite (&IrpContext->DeviceExt->DirResource);
ByeBye:
IrpContext->Irp->IoStatus.Status = Status;
IrpContext->Irp->IoStatus.Information = 0;
IoCompleteRequest (IrpContext->Irp, IO_NO_INCREMENT);
VfatFreeIrpContext(IrpContext);
return (Status);
}
/* EOF */