1 /* $Id: iomgr.c,v 1.16 2000/10/05 19:15:50 ekohl Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/io/iomgr.c
6 * PURPOSE: Initializes the io manager
7 * PROGRAMMER: David Welch (welch@mcmail.com)
12 /* INCLUDES ****************************************************************/
15 #include <ddk/ntddk.h>
16 #include <internal/ob.h>
17 #include <internal/io.h>
20 #include <internal/debug.h>
22 /* GLOBALS *******************************************************************/
24 /* DATA ********************************************************************/
27 POBJECT_TYPE EXPORTED IoDeviceObjectType
= NULL
;
28 POBJECT_TYPE EXPORTED IoFileObjectType
= NULL
;
29 ULONG EXPORTED IoReadOperationCount
= 0; /* FIXME: unknown type */
30 ULONG EXPORTED IoReadTransferCount
= 0; /* FIXME: unknown type */
31 ULONG EXPORTED IoWriteOperationCount
= 0; /* FIXME: unknown type */
32 ULONG EXPORTED IoWriteTransferCount
= 0; /* FIXME: unknown type */
33 ULONG EXPORTED IoStatisticsLock
= 0; /* FIXME: unknown type */
35 /* FUNCTIONS ****************************************************************/
37 VOID
IopCloseFile(PVOID ObjectBody
, ULONG HandleCount
)
39 PFILE_OBJECT FileObject
= (PFILE_OBJECT
)ObjectBody
;
41 PIO_STACK_LOCATION StackPtr
;
44 DPRINT("IopCloseFile()\n");
51 ObReferenceObjectByPointer(FileObject
,
52 STANDARD_RIGHTS_REQUIRED
,
56 Irp
= IoBuildSynchronousFsdRequest(IRP_MJ_CLEANUP
,
57 FileObject
->DeviceObject
,
63 StackPtr
= IoGetNextIrpStackLocation(Irp
);
64 StackPtr
->FileObject
= FileObject
;
66 Status
= IoCallDriver(FileObject
->DeviceObject
, Irp
);
69 VOID
IopDeleteFile(PVOID ObjectBody
)
71 PFILE_OBJECT FileObject
= (PFILE_OBJECT
)ObjectBody
;
73 PIO_STACK_LOCATION StackPtr
;
76 DPRINT("IopDeleteFile()\n");
78 ObReferenceObjectByPointer(ObjectBody
,
79 STANDARD_RIGHTS_REQUIRED
,
83 Irp
= IoBuildSynchronousFsdRequest(IRP_MJ_CLOSE
,
84 FileObject
->DeviceObject
,
90 StackPtr
= IoGetNextIrpStackLocation(Irp
);
91 StackPtr
->FileObject
= FileObject
;
93 Status
= IoCallDriver(FileObject
->DeviceObject
, Irp
);
95 if (FileObject
->FileName
.Buffer
!= NULL
)
97 ExFreePool(FileObject
->FileName
.Buffer
);
98 FileObject
->FileName
.Buffer
= 0;
105 OBJECT_ATTRIBUTES attr
;
107 UNICODE_STRING UnicodeString
;
108 UNICODE_STRING DeviceName
;
111 * Register iomgr types: DeviceObjectType
113 IoDeviceObjectType
= ExAllocatePool (
118 IoDeviceObjectType
->TotalObjects
= 0;
119 IoDeviceObjectType
->TotalHandles
= 0;
120 IoDeviceObjectType
->MaxObjects
= ULONG_MAX
;
121 IoDeviceObjectType
->MaxHandles
= ULONG_MAX
;
122 IoDeviceObjectType
->PagedPoolCharge
= 0;
123 IoDeviceObjectType
->NonpagedPoolCharge
= sizeof (DEVICE_OBJECT
);
124 IoDeviceObjectType
->Dump
= NULL
;
125 IoDeviceObjectType
->Open
= NULL
;
126 IoDeviceObjectType
->Close
= NULL
;
127 IoDeviceObjectType
->Delete
= NULL
;
128 IoDeviceObjectType
->Parse
= NULL
;
129 IoDeviceObjectType
->Security
= NULL
;
130 IoDeviceObjectType
->QueryName
= NULL
;
131 IoDeviceObjectType
->OkayToClose
= NULL
;
132 IoDeviceObjectType
->Create
= IopCreateDevice
;
134 RtlInitUnicodeString (
135 & IoDeviceObjectType
->TypeName
,
140 * Register iomgr types: FileObjectType
141 * (alias DriverObjectType)
143 IoFileObjectType
= ExAllocatePool (
148 IoFileObjectType
->TotalObjects
= 0;
149 IoFileObjectType
->TotalHandles
= 0;
150 IoFileObjectType
->MaxObjects
= ULONG_MAX
;
151 IoFileObjectType
->MaxHandles
= ULONG_MAX
;
152 IoFileObjectType
->PagedPoolCharge
= 0;
153 IoFileObjectType
->NonpagedPoolCharge
= sizeof(FILE_OBJECT
);
154 IoFileObjectType
->Dump
= NULL
;
155 IoFileObjectType
->Open
= NULL
;
156 IoFileObjectType
->Close
= IopCloseFile
;
157 IoFileObjectType
->Delete
= IopDeleteFile
;
158 IoFileObjectType
->Parse
= NULL
;
159 IoFileObjectType
->Security
= NULL
;
160 IoFileObjectType
->QueryName
= NULL
;
161 IoFileObjectType
->OkayToClose
= NULL
;
162 IoFileObjectType
->Create
= IopCreateFile
;
164 RtlInitUnicodeString (
165 & IoFileObjectType
->TypeName
,
170 * Create the '\Device' directory
172 RtlInitUnicodeString (
176 InitializeObjectAttributes (
183 ZwCreateDirectoryObject (
190 * Create the '\??' directory
192 RtlInitUnicodeString (
196 InitializeObjectAttributes (
203 ZwCreateDirectoryObject (
210 * Create the '\ArcName' directory
212 RtlInitUnicodeString (
215 InitializeObjectAttributes (
222 ZwCreateDirectoryObject (
229 * Initialize remaining subsubsystem
231 IoInitCancelHandling ();
232 IoInitSymbolicLinkImplementation ();
233 IoInitFileSystemImplementation ();
234 IoInitVpbImplementation ();
235 IoInitShutdownNotification ();
238 * Create link from '\DosDevices' to '\??' directory
240 RtlInitUnicodeString (&UnicodeString
,
242 RtlInitUnicodeString (&DeviceName
,
244 IoCreateSymbolicLink (&UnicodeString
,