From 4b6d4d065b0fa12000ed1f7c4aecb18bae5c269d Mon Sep 17 00:00:00 2001 From: Hartmut Birr Date: Mon, 9 Sep 2002 17:27:14 +0000 Subject: [PATCH] Added CdfsCleanup. svn path=/trunk/; revision=3480 --- reactos/drivers/fs/cdfs/cdfs.c | 3 +- reactos/drivers/fs/cdfs/cdfs.h | 4 ++ reactos/drivers/fs/cdfs/cleanup.c | 104 ++++++++++++++++++++++++++++++ reactos/drivers/fs/cdfs/makefile | 4 +- 4 files changed, 112 insertions(+), 3 deletions(-) create mode 100644 reactos/drivers/fs/cdfs/cleanup.c diff --git a/reactos/drivers/fs/cdfs/cdfs.c b/reactos/drivers/fs/cdfs/cdfs.c index b4ce78694dd..845a91b4330 100644 --- a/reactos/drivers/fs/cdfs/cdfs.c +++ b/reactos/drivers/fs/cdfs/cdfs.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: cdfs.c,v 1.6 2002/08/20 20:37:06 hyperion Exp $ +/* $Id: cdfs.c,v 1.7 2002/09/09 17:27:14 hbirr Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -82,6 +82,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject, /* Initialize driver data */ DeviceObject->Flags = DO_DIRECT_IO; DriverObject->MajorFunction[IRP_MJ_CLOSE] = CdfsClose; + DriverObject->MajorFunction[IRP_MJ_CLEANUP] = CdfsCleanup; DriverObject->MajorFunction[IRP_MJ_CREATE] = CdfsCreate; DriverObject->MajorFunction[IRP_MJ_READ] = CdfsRead; DriverObject->MajorFunction[IRP_MJ_WRITE] = CdfsWrite; diff --git a/reactos/drivers/fs/cdfs/cdfs.h b/reactos/drivers/fs/cdfs/cdfs.h index 11487f90072..ed63ca51d0f 100644 --- a/reactos/drivers/fs/cdfs/cdfs.h +++ b/reactos/drivers/fs/cdfs/cdfs.h @@ -227,7 +227,11 @@ CdfsReadSectors(IN PDEVICE_OBJECT DeviceObject, int CdfsStrcmpi( wchar_t *str1, wchar_t *str2 ); void CdfsWstrcpy( wchar_t *str1, wchar_t *str2, int max ); +/* cleanup.c */ +NTSTATUS STDCALL +CdfsCleanup(PDEVICE_OBJECT DeviceObject, + PIRP Irp); /* close.c */ diff --git a/reactos/drivers/fs/cdfs/cleanup.c b/reactos/drivers/fs/cdfs/cleanup.c new file mode 100644 index 00000000000..3a23a0c8b74 --- /dev/null +++ b/reactos/drivers/fs/cdfs/cleanup.c @@ -0,0 +1,104 @@ +/* + * 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 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* $Id: cleanup.c,v 1.1 2002/09/09 17:27:14 hbirr Exp $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: services/fs/cdfs/cleanup.c + * PURPOSE: CDROM (ISO 9660) filesystem driver + * PROGRAMMER: Hartmut Birr + * UPDATE HISTORY: + */ + +/* INCLUDES *****************************************************************/ + +#include + +#define NDEBUG +#include + +#include "cdfs.h" + + +/* FUNCTIONS ****************************************************************/ + +static NTSTATUS +CdfsCleanupFile(PDEVICE_EXTENSION DeviceExt, + PFILE_OBJECT FileObject) +/* + * FUNCTION: Cleans up after a file has been closed. + */ +{ + PCCB Ccb; + + DPRINT("CdfsCleanupFile(DeviceExt %x, FileObject %x)\n", + DeviceExt, + FileObject); + + + Ccb = (PCCB) (FileObject->FsContext2); + if (Ccb == NULL) + { + return STATUS_SUCCESS; + } + + /* Uninitialize the file cache. */ + CcRosReleaseFileCache (FileObject, Ccb->Fcb->RFCB.Bcb); + + return STATUS_SUCCESS; +} + +NTSTATUS STDCALL +CdfsCleanup(PDEVICE_OBJECT DeviceObject, + PIRP Irp) +{ + PDEVICE_EXTENSION DeviceExtension; + PIO_STACK_LOCATION Stack; + PFILE_OBJECT FileObject; + NTSTATUS Status; + + DPRINT("CdfsCleanup() called\n"); + + if (DeviceObject == CdfsGlobalData->DeviceObject) + { + DPRINT("Closing file system\n"); + Status = STATUS_SUCCESS; + goto ByeBye; + } + + Stack = IoGetCurrentIrpStackLocation(Irp); + FileObject = Stack->FileObject; + DeviceExtension = DeviceObject->DeviceExtension; + + ExAcquireResourceExclusiveLite(&DeviceExtension->DirResource, TRUE); + + Status = CdfsCleanupFile(DeviceExtension, FileObject); + + ExReleaseResourceLite(&DeviceExtension->DirResource); + + +ByeBye: + Irp->IoStatus.Status = Status; + Irp->IoStatus.Information = 0; + + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return(Status); +} + +/* EOF */ \ No newline at end of file diff --git a/reactos/drivers/fs/cdfs/makefile b/reactos/drivers/fs/cdfs/makefile index 410d3018192..6a9423b4cfc 100644 --- a/reactos/drivers/fs/cdfs/makefile +++ b/reactos/drivers/fs/cdfs/makefile @@ -1,4 +1,4 @@ -# $Id: makefile,v 1.3 2002/05/01 13:15:42 ekohl Exp $ +# $Id: makefile,v 1.4 2002/09/09 17:27:14 hbirr Exp $ PATH_TO_TOP = ../../.. @@ -7,7 +7,7 @@ TARGET_TYPE = driver TARGET_NAME = cdfs TARGET_OBJECTS = $(TARGET_NAME).o close.o common.o create.o dirctl.o \ - fcb.o finfo.o fsctl.o misc.o rw.o volinfo.o + fcb.o finfo.o fsctl.o misc.o rw.o volinfo.o cleanup.o include $(PATH_TO_TOP)/rules.mak