xref: /reactos/drivers/filesystems/cdfs/devctrl.c (revision 845faec4)
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         return STATUS_INVALID_DEVICE_REQUEST;
43     }
44 
45     /* Only support such operations on volume */
46     if (!(FileObject->RelatedFileObject == NULL || FileObject->RelatedFileObject->FsContext2 != NULL))
47     {
48         return STATUS_INVALID_PARAMETER;
49     }
50 
51     if (Stack->Parameters.DeviceIoControl.IoControlCode == IOCTL_CDROM_DISK_TYPE)
52     {
53         /* We should handle this one, but we don't! */
54         Status = STATUS_NOT_IMPLEMENTED;
55     }
56     else
57     {
58         /* Pass it to storage driver */
59         IoSkipCurrentIrpStackLocation(Irp);
60         Vcb = (PVCB)Stack->DeviceObject->DeviceExtension;
61 
62         /* Lower driver will complete - we don't have to */
63         IrpContext->Flags &= ~IRPCONTEXT_COMPLETE;
64 
65         Status = IoCallDriver(Vcb->StorageDevice, Irp);
66     }
67 
68     return Status;
69 }
70