e2040b7e438eb94b11a4bd11fa9bfd15c253771e
[reactos.git] / reactos / drivers / fs / np / mount.c
1 /* $Id: mount.c,v 1.2 1999/12/04 20:58:42 ea Exp $
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: services/fs/np/mount.c
6 * PURPOSE: Named pipe filesystem
7 * PROGRAMMER: David Welch <welch@cwcom.net>
8 */
9
10 /* INCLUDES ******************************************************************/
11
12 #include <ddk/ntddk.h>
13
14 //#define NDEBUG
15 #include <internal/debug.h>
16
17 #include "npfs.h"
18
19 /* GLOBALS *******************************************************************/
20
21 static PDRIVER_OBJECT DriverObject;
22
23 /* FUNCTIONS *****************************************************************/
24
25 NTSTATUS NpfsMount(PDEVICE_OBJECT DeviceToMount)
26 {
27 NTSTATUS Status;
28 PDEVICE_OBJECT DeviceObject;
29 PNPFS_DEVICE_EXTENSION DeviceExt;
30
31 Status = IoCreateDevice(DriverObject,
32 sizeof(NPFS_DEVICE_EXTENSION),
33 NULL,
34 FILE_DEVICE_FILE_SYSTEM,
35 0,
36 FALSE,
37 &DeviceObject);
38 if (!NT_SUCCESS(Status))
39 {
40 return(Status);
41 }
42
43 DeviceObject->Flags = DeviceObject->Flags | DO_DIRECT_IO;
44 DeviceExt = (PNPFS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
45
46 DeviceExt->StorageDevice = IoAttachDeviceToDeviceStack(DeviceObject,
47 DeviceToMount);
48
49 return(STATUS_SUCCESS);
50 }
51
52 NTSTATUS NpfsFileSystemControl(PDEVICE_OBJECT DeviceObject,
53 PIRP Irp)
54 {
55 PIO_STACK_LOCATION IoStack = IoGetCurrentIrpStackLocation(Irp);
56 PVPB Vpb = IoStack->Parameters.Mount.Vpb;
57 PDEVICE_OBJECT DeviceToMount = IoStack->Parameters.Mount.DeviceObject;
58 NTSTATUS Status;
59
60 Status = NpfsMount(DeviceToMount);
61
62 Irp->IoStatus.Status = Status;
63 Irp->IoStatus.Information = 0;
64
65 IoCompleteRequest(Irp, IO_NO_INCREMENT);
66
67 return(Status);
68
69 }
70
71 NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject,
72 PUNICODE_STRING RegistryPath)
73 {
74 PDEVICE_OBJECT DeviceObject;
75 NTSTATUS Status;
76 UNICODE_STRING DeviceName;
77
78 DbgPrint("Named Pipe Filesystem\n");
79
80 DriverObject = _DriverObject;
81
82 RtlInitUnicodeString(&DeviceName, L"\\Device\\Npfs");
83 Status = IoCreateDevice(DriverObject,
84 0,
85 &DeviceName,
86 FILE_DEVICE_FILE_SYSTEM,
87 0,
88 FALSE,
89 &DeviceObject);
90 if (!NT_SUCCESS(Status))
91 {
92 return(Status);
93 }
94
95 DeviceObject->Flags = 0;
96 DeviceObject->MajorFunction[IRP_MJ_CLOSE] = NpfsClose;
97 DeviceObject->MajorFunction[IRP_MJ_CREATE] = NpfsCreate;
98 DeviceObject->MajorFunction[IRP_MJ_READ] = NpfsRead;
99 DeviceObject->MajorFunction[IRP_MJ_WRITE] = NpfsWrite;
100 DeviceObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] =
101 NpfsFileSystemControl;
102 DeviceObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] =
103 NpfsDirectoryControl;
104 DeviceObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] =
105 NpfsQueryInformation;
106 DeviceObject->MajorFunction[IRP_MJ_SET_INFORMATION] =
107 NpfsSetInformation;
108 DeviceObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = NpfsFlushBuffers;
109 DeviceObject->MajorFunction[IRP_MJ_SHUTDOWN] = NpfsShutdown;
110 DeviceObject->MajorFunction[IRP_MJ_CLEANUP] = NpfsCleanup;
111 DeviceObject->MajorFunction[IRP_MJ_QUERY_SECURITY] =
112 NpfsQuerySecurity;
113 DeviceObject->MajorFunction[IRP_MJ_SET_SECURITY] =
114 NpfsSetSecurity;
115 DeviceObject->MajorFunction[IRP_MJ_QUERY_QUOTA] =
116 NpfsQueryQuota;
117 DeviceObject->MajorFunction[IRP_MJ_SET_QUOTA] =
118 NpfsSetQuota;
119
120 DriverObject->DriverUnload = NULL;
121
122 IoRegisterFileSystem(DeviceObject);
123
124 return(STATUS_SUCCESS);
125 }
126
127
128 /* EOF */