:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[reactos.git] / drivers / fs / cdfs / cleanup.c
1 /*
2  *  ReactOS kernel
3  *  Copyright (C) 2002 ReactOS Team
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 /* $Id$
20  *
21  * COPYRIGHT:        See COPYING in the top level directory
22  * PROJECT:          ReactOS kernel
23  * FILE:             services/fs/cdfs/cleanup.c
24  * PURPOSE:          CDROM (ISO 9660) filesystem driver
25  * PROGRAMMER:       Hartmut Birr
26  * UPDATE HISTORY: 
27  */
28
29 /* INCLUDES *****************************************************************/
30
31 #include <ddk/ntddk.h>
32
33 #define NDEBUG
34 #include <debug.h>
35
36 #include "cdfs.h"
37
38
39 /* FUNCTIONS ****************************************************************/
40
41 static NTSTATUS
42 CdfsCleanupFile(PDEVICE_EXTENSION DeviceExt,
43               PFILE_OBJECT FileObject)
44 /*
45  * FUNCTION: Cleans up after a file has been closed.
46  */
47 {
48   PCCB Ccb;
49
50   DPRINT("CdfsCleanupFile(DeviceExt %x, FileObject %x)\n",
51          DeviceExt,
52          FileObject);
53
54
55   Ccb = (PCCB) (FileObject->FsContext2);
56   if (Ccb == NULL)
57     {
58       return  STATUS_SUCCESS;
59     }
60
61   /* Uninitialize the file cache. */
62   CcRosReleaseFileCache (FileObject, Ccb->Fcb->RFCB.Bcb);
63  
64   return STATUS_SUCCESS;
65 }
66
67 NTSTATUS STDCALL
68 CdfsCleanup(PDEVICE_OBJECT DeviceObject,
69           PIRP Irp)
70 {
71   PDEVICE_EXTENSION DeviceExtension;
72   PIO_STACK_LOCATION Stack;
73   PFILE_OBJECT FileObject;
74   NTSTATUS Status;
75
76   DPRINT("CdfsCleanup() called\n");
77
78   if (DeviceObject == CdfsGlobalData->DeviceObject)
79     {
80       DPRINT("Closing file system\n");
81       Status = STATUS_SUCCESS;
82       goto ByeBye;
83     }
84
85   Stack = IoGetCurrentIrpStackLocation(Irp);
86   FileObject = Stack->FileObject;
87   DeviceExtension = DeviceObject->DeviceExtension;
88
89   ExAcquireResourceExclusiveLite(&DeviceExtension->DirResource, TRUE);
90
91   Status = CdfsCleanupFile(DeviceExtension, FileObject);
92
93   ExReleaseResourceLite(&DeviceExtension->DirResource);
94
95
96 ByeBye:
97   Irp->IoStatus.Status = Status;
98   Irp->IoStatus.Information = 0;
99
100   IoCompleteRequest(Irp, IO_NO_INCREMENT);
101   return(Status);
102 }
103
104 /* EOF */