19d866de6fd04d0927c0d9f122b5281cf9aef2e1
[reactos.git] / reactos / 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 /*
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS kernel
22 * FILE: services/fs/cdfs/cleanup.c
23 * PURPOSE: CDROM (ISO 9660) filesystem driver
24 * PROGRAMMER:
25 * UPDATE HISTORY:
26 */
27
28 /* INCLUDES *****************************************************************/
29
30 #include "cdfs.h"
31
32 #define NDEBUG
33 #include <debug.h>
34
35 /* FUNCTIONS ****************************************************************/
36
37 static NTSTATUS
38 CdfsCleanupFile(PDEVICE_EXTENSION DeviceExt,
39 PFILE_OBJECT FileObject)
40 /*
41 * FUNCTION: Cleans up after a file has been closed.
42 */
43 {
44
45 DPRINT("CdfsCleanupFile(DeviceExt %p, FileObject %p)\n",
46 DeviceExt,
47 FileObject);
48
49 /* Notify about the cleanup */
50 FsRtlNotifyCleanup(DeviceExt->NotifySync,
51 &(DeviceExt->NotifyList),
52 FileObject->FsContext2);
53
54 /* Uninitialize file cache if initialized for this file object. */
55 if (FileObject->SectionObjectPointer && FileObject->SectionObjectPointer->SharedCacheMap)
56 {
57 CcUninitializeCacheMap (FileObject, NULL, NULL);
58 }
59
60 return STATUS_SUCCESS;
61 }
62
63 NTSTATUS NTAPI
64 CdfsCleanup(PDEVICE_OBJECT DeviceObject,
65 PIRP Irp)
66 {
67 PDEVICE_EXTENSION DeviceExtension;
68 PIO_STACK_LOCATION Stack;
69 PFILE_OBJECT FileObject;
70 NTSTATUS Status;
71
72 DPRINT("CdfsCleanup() called\n");
73
74 if (DeviceObject == CdfsGlobalData->DeviceObject)
75 {
76 DPRINT("Closing file system\n");
77 Status = STATUS_SUCCESS;
78 goto ByeBye;
79 }
80
81 Stack = IoGetCurrentIrpStackLocation(Irp);
82 FileObject = Stack->FileObject;
83 DeviceExtension = DeviceObject->DeviceExtension;
84
85 KeEnterCriticalRegion();
86 ExAcquireResourceExclusiveLite(&DeviceExtension->DirResource, TRUE);
87
88 Status = CdfsCleanupFile(DeviceExtension, FileObject);
89
90 ExReleaseResourceLite(&DeviceExtension->DirResource);
91 KeLeaveCriticalRegion();
92
93
94 ByeBye:
95 Irp->IoStatus.Status = Status;
96 Irp->IoStatus.Information = 0;
97
98 IoCompleteRequest(Irp, IO_NO_INCREMENT);
99 return(Status);
100 }
101
102 /* EOF */