3 * Copyright (C) 2002, 2003 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/fs/cdfs/cdfs.c
23 * PURPOSE: CDROM (ISO 9660) filesystem driver
24 * PROGRAMMER: Art Yerkes
28 /* INCLUDES *****************************************************************/
35 /* GLOBALS ******************************************************************/
37 PCDFS_GLOBAL_DATA CdfsGlobalData
;
40 /* FUNCTIONS ****************************************************************/
43 DriverEntry(PDRIVER_OBJECT DriverObject
,
44 PUNICODE_STRING RegistryPath
)
46 * FUNCTION: Called by the system to initialize the driver
48 * DriverObject = object describing this driver
49 * RegistryPath = path to our configuration entries
50 * RETURNS: Success or failure
53 PDEVICE_OBJECT DeviceObject
;
55 UNICODE_STRING DeviceName
= RTL_CONSTANT_STRING(L
"\\Cdfs");
57 UNREFERENCED_PARAMETER(RegistryPath
);
59 DPRINT("CDFS 0.0.3\n");
61 Status
= IoCreateDevice(DriverObject
,
62 sizeof(CDFS_GLOBAL_DATA
),
64 FILE_DEVICE_CD_ROM_FILE_SYSTEM
,
68 if (!NT_SUCCESS(Status
))
73 /* Initialize global data */
74 CdfsGlobalData
= DeviceObject
->DeviceExtension
;
75 RtlZeroMemory(CdfsGlobalData
,
76 sizeof(CDFS_GLOBAL_DATA
));
77 CdfsGlobalData
->DriverObject
= DriverObject
;
78 CdfsGlobalData
->DeviceObject
= DeviceObject
;
80 /* Initialize driver data */
81 DeviceObject
->Flags
= DO_DIRECT_IO
;
82 DriverObject
->MajorFunction
[IRP_MJ_CLOSE
] = CdfsClose
;
83 DriverObject
->MajorFunction
[IRP_MJ_CLEANUP
] = CdfsCleanup
;
84 DriverObject
->MajorFunction
[IRP_MJ_CREATE
] = CdfsCreate
;
85 DriverObject
->MajorFunction
[IRP_MJ_READ
] = CdfsRead
;
86 DriverObject
->MajorFunction
[IRP_MJ_WRITE
] = CdfsWrite
;
87 DriverObject
->MajorFunction
[IRP_MJ_FILE_SYSTEM_CONTROL
] =
88 CdfsFileSystemControl
;
89 DriverObject
->MajorFunction
[IRP_MJ_DIRECTORY_CONTROL
] =
91 DriverObject
->MajorFunction
[IRP_MJ_QUERY_INFORMATION
] =
93 DriverObject
->MajorFunction
[IRP_MJ_SET_INFORMATION
] =
95 DriverObject
->MajorFunction
[IRP_MJ_QUERY_VOLUME_INFORMATION
] =
96 CdfsQueryVolumeInformation
;
97 DriverObject
->MajorFunction
[IRP_MJ_SET_VOLUME_INFORMATION
] =
98 CdfsSetVolumeInformation
;
99 DriverObject
->MajorFunction
[IRP_MJ_DEVICE_CONTROL
] =
102 DriverObject
->DriverUnload
= NULL
;
105 CdfsGlobalData
->CacheMgrCallbacks
.AcquireForLazyWrite
= CdfsAcquireForLazyWrite
;
106 CdfsGlobalData
->CacheMgrCallbacks
.ReleaseFromLazyWrite
= CdfsReleaseFromLazyWrite
;
107 CdfsGlobalData
->CacheMgrCallbacks
.AcquireForReadAhead
= CdfsAcquireForLazyWrite
;
108 CdfsGlobalData
->CacheMgrCallbacks
.ReleaseFromReadAhead
= CdfsReleaseFromLazyWrite
;
110 DeviceObject
->Flags
|= DO_LOW_PRIORITY_FILESYSTEM
;
112 IoRegisterFileSystem(DeviceObject
);
113 DeviceObject
->Flags
&= ~DO_DEVICE_INITIALIZING
;
115 return(STATUS_SUCCESS
);
120 CdfsAcquireForLazyWrite(IN PVOID Context
,
123 PFCB Fcb
= (PFCB
)Context
;
125 DPRINT("CdfsAcquireForLazyWrite(): Fcb %p\n", Fcb
);
127 if (!ExAcquireResourceExclusiveLite(&(Fcb
->MainResource
), Wait
))
129 DPRINT("CdfsAcquireForLazyWrite(): ExReleaseResourceLite failed.\n");
136 CdfsReleaseFromLazyWrite(IN PVOID Context
)
138 PFCB Fcb
= (PFCB
)Context
;
140 DPRINT("CdfsReleaseFromLazyWrite(): Fcb %p\n", Fcb
);
142 ExReleaseResourceLite(&(Fcb
->MainResource
));