update for HEAD-2003091401
[reactos.git] / drivers / fs / cdfs / cdfs.c
1 /*
2  *  ReactOS kernel
3  *  Copyright (C) 2002 ReactOS Team
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 /* $Id$
20  *
21  * COPYRIGHT:        See COPYING in the top level directory
22  * PROJECT:          ReactOS kernel
23  * FILE:             services/fs/cdfs/cdfs.c
24  * PURPOSE:          CDROM (ISO 9660) filesystem driver
25  * PROGRAMMER:       Art Yerkes
26  * UPDATE HISTORY: 
27  */
28
29 /* INCLUDES *****************************************************************/
30
31 #include <ddk/ntddk.h>
32
33 #define NDEBUG
34 #include <debug.h>
35
36 #include "cdfs.h"
37
38
39 /* GLOBALS *****************************************************************/
40
41 PCDFS_GLOBAL_DATA CdfsGlobalData;
42
43
44 /* FUNCTIONS ****************************************************************/
45
46 NTSTATUS STDCALL
47 DriverEntry(PDRIVER_OBJECT DriverObject,
48             PUNICODE_STRING RegistryPath)
49 /*
50  * FUNCTION: Called by the system to initalize the driver
51  * ARGUMENTS:
52  *           DriverObject = object describing this driver
53  *           RegistryPath = path to our configuration entries
54  * RETURNS: Success or failure
55  */
56 {
57   PDEVICE_OBJECT DeviceObject;
58   NTSTATUS Status;
59   UNICODE_STRING DeviceName = UNICODE_STRING_INITIALIZER(L"\\Cdfs");
60
61   DPRINT("CDFS 0.0.2\n");
62
63   Status = IoCreateDevice(DriverObject,
64                           sizeof(CDFS_GLOBAL_DATA),
65                           &DeviceName,
66                           FILE_DEVICE_CD_ROM_FILE_SYSTEM,
67                           0,
68                           FALSE,
69                           &DeviceObject);
70   if (!NT_SUCCESS(Status))
71     {
72       return(Status);
73     }
74
75   /* Initialize global data */
76   CdfsGlobalData = DeviceObject->DeviceExtension;
77   RtlZeroMemory(CdfsGlobalData,
78                 sizeof(CDFS_GLOBAL_DATA));
79   CdfsGlobalData->DriverObject = DriverObject;
80   CdfsGlobalData->DeviceObject = DeviceObject;
81
82   /* Initialize driver data */
83   DeviceObject->Flags = DO_DIRECT_IO;
84   DriverObject->MajorFunction[IRP_MJ_CLOSE] = CdfsClose;
85   DriverObject->MajorFunction[IRP_MJ_CLEANUP] = CdfsCleanup;
86   DriverObject->MajorFunction[IRP_MJ_CREATE] = CdfsCreate;
87   DriverObject->MajorFunction[IRP_MJ_READ] = CdfsRead;
88   DriverObject->MajorFunction[IRP_MJ_WRITE] = CdfsWrite;
89   DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] =
90     CdfsFileSystemControl;
91   DriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] =
92     CdfsDirectoryControl;
93   DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] =
94     CdfsQueryInformation;
95   DriverObject->MajorFunction[IRP_MJ_SET_INFORMATION] = 
96     CdfsSetInformation;
97   DriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] =
98     CdfsQueryVolumeInformation;
99   DriverObject->MajorFunction[IRP_MJ_SET_VOLUME_INFORMATION] =
100     CdfsSetVolumeInformation;
101
102   DriverObject->DriverUnload = NULL;
103
104   IoRegisterFileSystem(DeviceObject);
105
106   return(STATUS_SUCCESS);
107 }
108