3 * Copyright (C) 2002 ReactOS Team
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.
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.
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.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS kernel
22 * FILE: drivers/filesystems/cdfs/cleanup.c
23 * PURPOSE: CDROM (ISO 9660) filesystem driver
28 /* INCLUDES *****************************************************************/
35 /* FUNCTIONS ****************************************************************/
38 CdfsCleanupFile(PCDFS_IRP_CONTEXT IrpContext
,
39 PFILE_OBJECT FileObject
)
41 * FUNCTION: Cleans up after a file has been closed.
44 PDEVICE_EXTENSION DeviceExt
;
47 DPRINT("CdfsCleanupFile(IrpContext %p, FileObject %p)\n",
51 DeviceExt
= IrpContext
->DeviceObject
->DeviceExtension
;
52 Fcb
= FileObject
->FsContext
;
55 return STATUS_SUCCESS
;
58 DeviceExt
->OpenHandleCount
--;
60 /* Notify about the cleanup */
61 FsRtlNotifyCleanup(DeviceExt
->NotifySync
,
62 &(DeviceExt
->NotifyList
),
63 FileObject
->FsContext2
);
65 if (!CdfsFCBIsDirectory(Fcb
) &&
66 FsRtlAreThereCurrentFileLocks(&Fcb
->FileLock
))
68 FsRtlFastUnlockAll(&Fcb
->FileLock
,
70 IoGetRequestorProcess(IrpContext
->Irp
),
74 /* Uninitialize file cache if initialized for this file object. */
75 if (FileObject
->SectionObjectPointer
&& FileObject
->SectionObjectPointer
->SharedCacheMap
)
77 CcUninitializeCacheMap (FileObject
, NULL
, NULL
);
80 /* Inform cleanup is complete */
81 FileObject
->Flags
|= FO_CLEANUP_COMPLETE
;
83 return STATUS_SUCCESS
;
88 PCDFS_IRP_CONTEXT IrpContext
)
91 PDEVICE_OBJECT DeviceObject
;
92 PDEVICE_EXTENSION DeviceExtension
;
93 PIO_STACK_LOCATION Stack
;
94 PFILE_OBJECT FileObject
;
97 DPRINT("CdfsCleanup() called\n");
101 Irp
= IrpContext
->Irp
;
102 DeviceObject
= IrpContext
->DeviceObject
;
103 Stack
= IrpContext
->Stack
;
105 if (DeviceObject
== CdfsGlobalData
->CdFsDeviceObject
|| DeviceObject
== CdfsGlobalData
->HddFsDeviceObject
)
107 DPRINT("Closing file system\n");
108 Status
= STATUS_SUCCESS
;
112 FileObject
= Stack
->FileObject
;
113 DeviceExtension
= DeviceObject
->DeviceExtension
;
115 KeEnterCriticalRegion();
116 ExAcquireResourceExclusiveLite(&DeviceExtension
->DirResource
, TRUE
);
118 Status
= CdfsCleanupFile(IrpContext
, FileObject
);
120 ExReleaseResourceLite(&DeviceExtension
->DirResource
);
121 KeLeaveCriticalRegion();
124 Irp
->IoStatus
.Information
= 0;