- Update to r53061
[reactos.git] / drivers / filesystems / 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 along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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:
26 * UPDATE HISTORY:
27 */
28
29 /* INCLUDES *****************************************************************/
30
31 #include "cdfs.h"
32
33 #define NDEBUG
34 #include <debug.h>
35
36 /* FUNCTIONS ****************************************************************/
37
38 static NTSTATUS
39 CdfsCleanupFile(PDEVICE_EXTENSION DeviceExt,
40 PFILE_OBJECT FileObject)
41 /*
42 * FUNCTION: Cleans up after a file has been closed.
43 */
44 {
45
46 DPRINT("CdfsCleanupFile(DeviceExt %x, FileObject %x)\n",
47 DeviceExt,
48 FileObject);
49
50
51 /* Uninitialize file cache if initialized for this file object. */
52 if (FileObject->SectionObjectPointer && FileObject->SectionObjectPointer->SharedCacheMap)
53 {
54 CcUninitializeCacheMap (FileObject, NULL, NULL);
55 }
56
57 return STATUS_SUCCESS;
58 }
59
60 NTSTATUS NTAPI
61 CdfsCleanup(PDEVICE_OBJECT DeviceObject,
62 PIRP Irp)
63 {
64 PDEVICE_EXTENSION DeviceExtension;
65 PIO_STACK_LOCATION Stack;
66 PFILE_OBJECT FileObject;
67 NTSTATUS Status;
68
69 DPRINT("CdfsCleanup() called\n");
70
71 if (DeviceObject == CdfsGlobalData->DeviceObject)
72 {
73 DPRINT("Closing file system\n");
74 Status = STATUS_SUCCESS;
75 goto ByeBye;
76 }
77
78 Stack = IoGetCurrentIrpStackLocation(Irp);
79 FileObject = Stack->FileObject;
80 DeviceExtension = DeviceObject->DeviceExtension;
81
82 KeEnterCriticalRegion();
83 ExAcquireResourceExclusiveLite(&DeviceExtension->DirResource, TRUE);
84
85 Status = CdfsCleanupFile(DeviceExtension, FileObject);
86
87 ExReleaseResourceLite(&DeviceExtension->DirResource);
88 KeLeaveCriticalRegion();
89
90
91 ByeBye:
92 Irp->IoStatus.Status = Status;
93 Irp->IoStatus.Information = 0;
94
95 IoCompleteRequest(Irp, IO_NO_INCREMENT);
96 return(Status);
97 }
98
99 /* EOF */
100