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.
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * FILE: drivers/fs/cdfs/cdfs.c
24 * PURPOSE: CDROM (ISO 9660) filesystem driver
25 * PROGRAMMER: Art Yerkes
29 /* INCLUDES *****************************************************************/
36 /* GLOBALS ******************************************************************/
38 PCDFS_GLOBAL_DATA CdfsGlobalData
;
41 /* FUNCTIONS ****************************************************************/
44 DriverEntry(PDRIVER_OBJECT DriverObject
,
45 PUNICODE_STRING RegistryPath
)
47 * FUNCTION: Called by the system to initalize the driver
49 * DriverObject = object describing this driver
50 * RegistryPath = path to our configuration entries
51 * RETURNS: Success or failure
54 PDEVICE_OBJECT DeviceObject
;
56 UNICODE_STRING DeviceName
= RTL_CONSTANT_STRING(L
"\\Cdfs");
58 DPRINT("CDFS 0.0.3\n");
60 Status
= IoCreateDevice(DriverObject
,
61 sizeof(CDFS_GLOBAL_DATA
),
63 FILE_DEVICE_CD_ROM_FILE_SYSTEM
,
67 if (!NT_SUCCESS(Status
))
72 /* Initialize global data */
73 CdfsGlobalData
= DeviceObject
->DeviceExtension
;
74 RtlZeroMemory(CdfsGlobalData
,
75 sizeof(CDFS_GLOBAL_DATA
));
76 CdfsGlobalData
->DriverObject
= DriverObject
;
77 CdfsGlobalData
->DeviceObject
= DeviceObject
;
79 /* Initialize driver data */
80 DeviceObject
->Flags
= DO_DIRECT_IO
;
81 DriverObject
->MajorFunction
[IRP_MJ_CLOSE
] = CdfsClose
;
82 DriverObject
->MajorFunction
[IRP_MJ_CLEANUP
] = CdfsCleanup
;
83 DriverObject
->MajorFunction
[IRP_MJ_CREATE
] = CdfsCreate
;
84 DriverObject
->MajorFunction
[IRP_MJ_READ
] = CdfsRead
;
85 DriverObject
->MajorFunction
[IRP_MJ_WRITE
] = CdfsWrite
;
86 DriverObject
->MajorFunction
[IRP_MJ_FILE_SYSTEM_CONTROL
] =
87 CdfsFileSystemControl
;
88 DriverObject
->MajorFunction
[IRP_MJ_DIRECTORY_CONTROL
] =
90 DriverObject
->MajorFunction
[IRP_MJ_QUERY_INFORMATION
] =
92 DriverObject
->MajorFunction
[IRP_MJ_SET_INFORMATION
] =
94 DriverObject
->MajorFunction
[IRP_MJ_QUERY_VOLUME_INFORMATION
] =
95 CdfsQueryVolumeInformation
;
96 DriverObject
->MajorFunction
[IRP_MJ_SET_VOLUME_INFORMATION
] =
97 CdfsSetVolumeInformation
;
98 DriverObject
->MajorFunction
[IRP_MJ_DEVICE_CONTROL
] =
101 DriverObject
->DriverUnload
= NULL
;
104 CdfsGlobalData
->CacheMgrCallbacks
.AcquireForLazyWrite
= CdfsAcquireForLazyWrite
;
105 CdfsGlobalData
->CacheMgrCallbacks
.ReleaseFromLazyWrite
= CdfsReleaseFromLazyWrite
;
106 CdfsGlobalData
->CacheMgrCallbacks
.AcquireForReadAhead
= CdfsAcquireForLazyWrite
;
107 CdfsGlobalData
->CacheMgrCallbacks
.ReleaseFromReadAhead
= CdfsReleaseFromLazyWrite
;
109 DeviceObject
->Flags
|= DO_LOW_PRIORITY_FILESYSTEM
;
111 IoRegisterFileSystem(DeviceObject
);
112 DeviceObject
->Flags
&= ~DO_DEVICE_INITIALIZING
;
114 return(STATUS_SUCCESS
);
119 CdfsAcquireForLazyWrite(IN PVOID Context
,
122 PFCB Fcb
= (PFCB
)Context
;
124 DPRINT("CdfsAcquireForLazyWrite(): Fcb %p\n", Fcb
);
126 if (!ExAcquireResourceExclusiveLite(&(Fcb
->MainResource
), Wait
))
128 DPRINT("CdfsAcquireForLazyWrite(): ExReleaseResourceLite failed.\n");
135 CdfsReleaseFromLazyWrite(IN PVOID Context
)
137 PFCB Fcb
= (PFCB
)Context
;
139 DPRINT("CdfsReleaseFromLazyWrite(): Fcb %p\n", Fcb
);
141 ExReleaseResourceLite(&(Fcb
->MainResource
));