Remove unnecessary executable bits
[reactos.git] / drivers / filesystems / cdfs_new / devctrl.c
1 /*++
2
3 Copyright (c) 1989-2000 Microsoft Corporation
4
5 Module Name:
6
7 DevCtrl.c
8
9 Abstract:
10
11 This module implements the File System Device Control routines for Cdfs
12 called by the dispatch driver.
13
14
15 --*/
16
17 #include "cdprocs.h"
18
19 //
20 // The Bug check file id for this module
21 //
22
23 #define BugCheckFileId (CDFS_BUG_CHECK_DEVCTRL)
24
25 //
26 // Local support routines
27 //
28
29 // Tell prefast this is a completion routine
30 IO_COMPLETION_ROUTINE CdDevCtrlCompletionRoutine;
31
32 NTSTATUS
33 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
34 CdDevCtrlCompletionRoutine (
35 _In_ PDEVICE_OBJECT DeviceObject,
36 _In_ PIRP Irp,
37 _In_reads_opt_(_Inexpressible_("varies")) PVOID Contxt
38 );
39
40 #ifdef ALLOC_PRAGMA
41 #pragma alloc_text(PAGE, CdCommonDevControl)
42 #endif
43
44 \f
45 NTSTATUS
46 CdCommonDevControl (
47 _Inout_ PIRP_CONTEXT IrpContext,
48 _Inout_ PIRP Irp
49 )
50
51 /*++
52
53 Routine Description:
54
55 Arguments:
56
57 Return Value:
58
59 --*/
60
61 {
62 NTSTATUS Status;
63
64 TYPE_OF_OPEN TypeOfOpen;
65 PFCB Fcb;
66 PCCB Ccb;
67
68 PIO_STACK_LOCATION IrpSp;
69 PIO_STACK_LOCATION NextIrpSp;
70
71 PAGED_CODE();
72
73 //
74 // Extract and decode the file object.
75 //
76
77 IrpSp = IoGetCurrentIrpStackLocation( Irp );
78
79 TypeOfOpen = CdDecodeFileObject( IrpContext,
80 IrpSp->FileObject,
81 &Fcb,
82 &Ccb );
83
84 //
85 // The only type of opens we accept are user volume opens.
86 //
87
88 if (TypeOfOpen != UserVolumeOpen) {
89
90 CdCompleteRequest( IrpContext, Irp, STATUS_INVALID_PARAMETER );
91 return STATUS_INVALID_PARAMETER;
92 }
93
94 if (IrpSp->Parameters.DeviceIoControl.IoControlCode == IOCTL_CDROM_READ_TOC) {
95
96 //
97 // Verify the Vcb in this case to detect if the volume has changed.
98 //
99
100 CdVerifyVcb( IrpContext, Fcb->Vcb );
101
102 //
103 // Handle the case of the disk type ourselves.
104 //
105
106 } else if (IrpSp->Parameters.DeviceIoControl.IoControlCode == IOCTL_CDROM_DISK_TYPE) {
107
108 //
109 // Verify the Vcb in this case to detect if the volume has changed.
110 //
111
112 CdVerifyVcb( IrpContext, Fcb->Vcb );
113
114 //
115 // Check the size of the output buffer.
116 //
117
118 if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof( CDROM_DISK_DATA )) {
119
120 CdCompleteRequest( IrpContext, Irp, STATUS_BUFFER_TOO_SMALL );
121 return STATUS_BUFFER_TOO_SMALL;
122 }
123
124 //
125 // Copy the data from the Vcb.
126 //
127
128 ((PCDROM_DISK_DATA) Irp->AssociatedIrp.SystemBuffer)->DiskData = Fcb->Vcb->DiskFlags;
129
130 Irp->IoStatus.Information = sizeof( CDROM_DISK_DATA );
131 CdCompleteRequest( IrpContext, Irp, STATUS_SUCCESS );
132 return STATUS_SUCCESS;
133 }
134
135 //
136 // Get the next stack location, and copy over the stack parameter
137 // information.
138 //
139
140 NextIrpSp = IoGetNextIrpStackLocation( Irp );
141
142 *NextIrpSp = *IrpSp;
143
144 //
145 // Set up the completion routine
146 //
147
148 IoSetCompletionRoutine( Irp,
149 CdDevCtrlCompletionRoutine,
150 NULL,
151 TRUE,
152 TRUE,
153 TRUE );
154
155 //
156 // Send the request.
157 //
158
159 Status = IoCallDriver( IrpContext->Vcb->TargetDeviceObject, Irp );
160
161 //
162 // Cleanup our Irp Context. The driver has completed the Irp.
163 //
164
165 CdCompleteRequest( IrpContext, NULL, STATUS_SUCCESS );
166
167 return Status;
168 }
169
170 \f
171 //
172 // Local support routine
173 //
174
175 NTSTATUS
176 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
177 CdDevCtrlCompletionRoutine (
178 _In_ PDEVICE_OBJECT DeviceObject,
179 _In_ PIRP Irp,
180 _In_reads_opt_(_Inexpressible_("varies")) PVOID Contxt
181 )
182
183 {
184 //
185 // Add the hack-o-ramma to fix formats.
186 //
187
188 if (Irp->PendingReturned) {
189
190 IoMarkIrpPending( Irp );
191 }
192
193 return STATUS_SUCCESS;
194
195 UNREFERENCED_PARAMETER( DeviceObject );
196 UNREFERENCED_PARAMETER( Contxt );
197 }
198
199