f2db3c302b604f24e40c38e11123089a5918bfc0
[reactos.git] / reactos / drivers / filesystems / cdfs / devctrl.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: drivers/filesystems/cdfs/devctrl.c
5 * PURPOSE: CDROM (ISO 9660) filesystem driver
6 * PROGRAMMER: Pierre Schweitzer
7 *
8 */
9
10 /* INCLUDES *****************************************************************/
11
12 #include "cdfs.h"
13
14 #define NDEBUG
15 #include <debug.h>
16
17 /* FUNCTIONS ****************************************************************/
18
19 NTSTATUS NTAPI
20 CdfsDeviceControl(
21 PCDFS_IRP_CONTEXT IrpContext)
22 {
23 PIRP Irp;
24 NTSTATUS Status;
25 PVCB Vcb = NULL;
26 PFILE_OBJECT FileObject;
27 PIO_STACK_LOCATION Stack;
28
29 DPRINT("CdfsDeviceControl()\n");
30
31 ASSERT(IrpContext);
32
33 Irp = IrpContext->Irp;
34 Stack = IrpContext->Stack;
35 FileObject = Stack->FileObject;
36 Irp->IoStatus.Information = 0;
37
38 /* FIXME: HACK, it means that CD has changed */
39 if (!FileObject)
40 {
41 DPRINT1("FIXME: CdfsDeviceControl called without FileObject!\n");
42 Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
43 return STATUS_INVALID_DEVICE_REQUEST;
44 }
45
46 /* Only support such operations on volume */
47 if (!(FileObject->RelatedFileObject == NULL || FileObject->RelatedFileObject->FsContext2 != NULL))
48 {
49 Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
50 return STATUS_INVALID_PARAMETER;
51 }
52
53 if (Stack->Parameters.DeviceIoControl.IoControlCode == IOCTL_CDROM_DISK_TYPE)
54 {
55 /* We should handle this one, but we don't! */
56 Status = STATUS_NOT_IMPLEMENTED;
57 Irp->IoStatus.Status = Status;
58 }
59 else
60 {
61 /* Pass it to storage driver */
62 IoSkipCurrentIrpStackLocation(Irp);
63 Vcb = (PVCB)Stack->DeviceObject->DeviceExtension;
64
65 /* Lower driver will complete - we don't have to */
66 IrpContext->Flags &= ~IRPCONTEXT_COMPLETE;
67
68 Status = IoCallDriver(Vcb->StorageDevice, Irp);
69 }
70
71 return Status;
72 }