[CDFS_NEW] Now NtWriteFile is fixed, revert 5f25582, ie remove FastIO hack from the...
[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 NTSTATUS
30 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
31 CdDevCtrlCompletionRoutine (
32 IN PDEVICE_OBJECT DeviceObject,
33 IN PIRP Irp,
34 IN PVOID Contxt
35 );
36
37 #ifdef ALLOC_PRAGMA
38 #pragma alloc_text(PAGE, CdCommonDevControl)
39 #endif
40
41 \f
42 NTSTATUS
43 CdCommonDevControl (
44 IN PIRP_CONTEXT IrpContext,
45 IN PIRP Irp
46 )
47
48 /*++
49
50 Routine Description:
51
52 Arguments:
53
54 Return Value:
55
56 --*/
57
58 {
59 NTSTATUS Status;
60
61 TYPE_OF_OPEN TypeOfOpen;
62 PFCB Fcb;
63 PCCB Ccb;
64
65 PIO_STACK_LOCATION IrpSp;
66 PIO_STACK_LOCATION NextIrpSp;
67
68 // PVOID TargetBuffer = NULL; /* ReactOS Change: GCC unused variable */
69
70 PAGED_CODE();
71
72 //
73 // Extract and decode the file object.
74 //
75
76 IrpSp = IoGetCurrentIrpStackLocation( Irp );
77
78 TypeOfOpen = CdDecodeFileObject( IrpContext,
79 IrpSp->FileObject,
80 &Fcb,
81 &Ccb );
82
83 //
84 // The only type of opens we accept are user volume opens.
85 //
86
87 if (TypeOfOpen != UserVolumeOpen) {
88
89 CdCompleteRequest( IrpContext, Irp, STATUS_INVALID_PARAMETER );
90 return STATUS_INVALID_PARAMETER;
91 }
92
93 if (IrpSp->Parameters.DeviceIoControl.IoControlCode == IOCTL_CDROM_READ_TOC) {
94
95 //
96 // Verify the Vcb in this case to detect if the volume has changed.
97 //
98
99 CdVerifyVcb( IrpContext, Fcb->Vcb );
100
101 //
102 // Handle the case of the disk type ourselves.
103 //
104
105 } else if (IrpSp->Parameters.DeviceIoControl.IoControlCode == IOCTL_CDROM_DISK_TYPE) {
106
107 //
108 // Verify the Vcb in this case to detect if the volume has changed.
109 //
110
111 CdVerifyVcb( IrpContext, Fcb->Vcb );
112
113 //
114 // Check the size of the output buffer.
115 //
116
117 if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof( CDROM_DISK_DATA )) {
118
119 CdCompleteRequest( IrpContext, Irp, STATUS_BUFFER_TOO_SMALL );
120 return STATUS_BUFFER_TOO_SMALL;
121 }
122
123 //
124 // Copy the data from the Vcb.
125 //
126
127 ((PCDROM_DISK_DATA) Irp->AssociatedIrp.SystemBuffer)->DiskData = Fcb->Vcb->DiskFlags;
128
129 Irp->IoStatus.Information = sizeof( CDROM_DISK_DATA );
130 CdCompleteRequest( IrpContext, Irp, STATUS_SUCCESS );
131 return STATUS_SUCCESS;
132 }
133
134 //
135 // Get the next stack location, and copy over the stack parameter
136 // information.
137 //
138
139 NextIrpSp = IoGetNextIrpStackLocation( Irp );
140
141 *NextIrpSp = *IrpSp;
142
143 //
144 // Set up the completion routine
145 //
146
147 IoSetCompletionRoutine( Irp,
148 CdDevCtrlCompletionRoutine,
149 NULL,
150 TRUE,
151 TRUE,
152 TRUE );
153
154 //
155 // Send the request.
156 //
157
158 Status = IoCallDriver( IrpContext->Vcb->TargetDeviceObject, Irp );
159
160 //
161 // Cleanup our Irp Context. The driver has completed the Irp.
162 //
163
164 CdCompleteRequest( IrpContext, NULL, STATUS_SUCCESS );
165
166 return Status;
167 }
168
169 \f
170 //
171 // Local support routine
172 //
173
174 NTSTATUS
175 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
176 CdDevCtrlCompletionRoutine (
177 IN PDEVICE_OBJECT DeviceObject,
178 IN PIRP Irp,
179 IN PVOID Contxt
180 )
181
182 {
183 //
184 // Add the hack-o-ramma to fix formats.
185 //
186
187 if (Irp->PendingReturned) {
188
189 IoMarkIrpPending( Irp );
190 }
191
192 return STATUS_SUCCESS;
193
194 UNREFERENCED_PARAMETER( DeviceObject );
195 UNREFERENCED_PARAMETER( Contxt );
196 }
197
198