3 Copyright (c) 1989-2000 Microsoft Corporation
11 This module implements the File System Device Control routines for Cdfs
12 called by the dispatch driver.
20 // The Bug check file id for this module
23 #define BugCheckFileId (CDFS_BUG_CHECK_DEVCTRL)
26 // Local support routines
30 CdDevCtrlCompletionRoutine (
31 IN PDEVICE_OBJECT DeviceObject
,
37 #pragma alloc_text(PAGE, CdCommonDevControl)
43 IN PIRP_CONTEXT IrpContext
,
60 TYPE_OF_OPEN TypeOfOpen
;
64 PIO_STACK_LOCATION IrpSp
;
65 PIO_STACK_LOCATION NextIrpSp
;
67 // PVOID TargetBuffer = NULL; /* ReactOS Change: GCC unused variable */
72 // Extract and decode the file object.
75 IrpSp
= IoGetCurrentIrpStackLocation( Irp
);
77 TypeOfOpen
= CdDecodeFileObject( IrpContext
,
83 // The only type of opens we accept are user volume opens.
86 if (TypeOfOpen
!= UserVolumeOpen
) {
88 CdCompleteRequest( IrpContext
, Irp
, STATUS_INVALID_PARAMETER
);
89 return STATUS_INVALID_PARAMETER
;
92 if (IrpSp
->Parameters
.DeviceIoControl
.IoControlCode
== IOCTL_CDROM_READ_TOC
) {
95 // Verify the Vcb in this case to detect if the volume has changed.
98 CdVerifyVcb( IrpContext
, Fcb
->Vcb
);
101 // Handle the case of the disk type ourselves.
104 } else if (IrpSp
->Parameters
.DeviceIoControl
.IoControlCode
== IOCTL_CDROM_DISK_TYPE
) {
107 // Verify the Vcb in this case to detect if the volume has changed.
110 CdVerifyVcb( IrpContext
, Fcb
->Vcb
);
113 // Check the size of the output buffer.
116 if (IrpSp
->Parameters
.DeviceIoControl
.OutputBufferLength
< sizeof( CDROM_DISK_DATA
)) {
118 CdCompleteRequest( IrpContext
, Irp
, STATUS_BUFFER_TOO_SMALL
);
119 return STATUS_BUFFER_TOO_SMALL
;
123 // Copy the data from the Vcb.
126 ((PCDROM_DISK_DATA
) Irp
->AssociatedIrp
.SystemBuffer
)->DiskData
= Fcb
->Vcb
->DiskFlags
;
128 Irp
->IoStatus
.Information
= sizeof( CDROM_DISK_DATA
);
129 CdCompleteRequest( IrpContext
, Irp
, STATUS_SUCCESS
);
130 return STATUS_SUCCESS
;
134 // Get the next stack location, and copy over the stack parameter
138 NextIrpSp
= IoGetNextIrpStackLocation( Irp
);
143 // Set up the completion routine
146 IoSetCompletionRoutine( Irp
,
147 CdDevCtrlCompletionRoutine
,
157 Status
= IoCallDriver( IrpContext
->Vcb
->TargetDeviceObject
, Irp
);
160 // Cleanup our Irp Context. The driver has completed the Irp.
163 CdCompleteRequest( IrpContext
, NULL
, STATUS_SUCCESS
);
170 // Local support routine
174 CdDevCtrlCompletionRoutine (
175 IN PDEVICE_OBJECT DeviceObject
,
182 // Add the hack-o-ramma to fix formats.
185 if (Irp
->PendingReturned
) {
187 IoMarkIrpPending( Irp
);
190 return STATUS_SUCCESS
;
192 UNREFERENCED_PARAMETER( DeviceObject
);
193 UNREFERENCED_PARAMETER( Contxt
);