74fe99baeb6784091919ceebd0f1f2fda92b1479
[reactos.git] / reactos / drivers / filesystems / npfs / npfs.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: drivers/fs/np/mount.c
5 * PURPOSE: Named pipe filesystem
6 * PROGRAMMER: David Welch <welch@cwcom.net>
7 */
8
9 /* INCLUDES ******************************************************************/
10
11 #include "npfs.h"
12
13 #define NDEBUG
14 #include <debug.h>
15
16 /* FUNCTIONS *****************************************************************/
17
18 NTSTATUS NTAPI
19 DriverEntry(PDRIVER_OBJECT DriverObject,
20 PUNICODE_STRING RegistryPath)
21 {
22 PDEVICE_OBJECT DeviceObject;
23 UNICODE_STRING DeviceName;
24 PNPFS_VCB Vcb;
25 PNPFS_FCB Fcb;
26 NTSTATUS Status;
27
28 DPRINT("Named Pipe FSD 0.0.2\n");
29
30 ASSERT (sizeof(NPFS_CONTEXT) <= FIELD_OFFSET(IRP, Tail.Overlay.DriverContext));
31 ASSERT (sizeof(NPFS_WAITER_ENTRY) <= FIELD_OFFSET(IRP, Tail.Overlay.DriverContext));
32
33 DriverObject->MajorFunction[IRP_MJ_CREATE] = NpfsCreate;
34 DriverObject->MajorFunction[IRP_MJ_CREATE_NAMED_PIPE] =
35 NpfsCreateNamedPipe;
36 DriverObject->MajorFunction[IRP_MJ_CLOSE] = NpfsClose;
37 DriverObject->MajorFunction[IRP_MJ_READ] = NpfsRead;
38 DriverObject->MajorFunction[IRP_MJ_WRITE] = NpfsWrite;
39 DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] =
40 NpfsQueryInformation;
41 DriverObject->MajorFunction[IRP_MJ_SET_INFORMATION] =
42 NpfsSetInformation;
43 DriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] =
44 NpfsQueryVolumeInformation;
45 DriverObject->MajorFunction[IRP_MJ_CLEANUP] = NpfsCleanup;
46 DriverObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = NpfsFlushBuffers;
47 // DriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] =
48 // NpfsDirectoryControl;
49 DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] =
50 NpfsFileSystemControl;
51 // DriverObject->MajorFunction[IRP_MJ_QUERY_SECURITY] =
52 // NpfsQuerySecurity;
53 // DriverObject->MajorFunction[IRP_MJ_SET_SECURITY] =
54 // NpfsSetSecurity;
55
56 DriverObject->DriverUnload = NULL;
57
58 RtlInitUnicodeString(&DeviceName, L"\\Device\\NamedPipe");
59 Status = IoCreateDevice(DriverObject,
60 sizeof(NPFS_VCB),
61 &DeviceName,
62 FILE_DEVICE_NAMED_PIPE,
63 0,
64 FALSE,
65 &DeviceObject);
66 if (!NT_SUCCESS(Status))
67 {
68 DPRINT("Failed to create named pipe device! (Status %x)\n", Status);
69 return Status;
70 }
71
72 /* Initialize the device object */
73 DeviceObject->Flags |= DO_DIRECT_IO;
74 DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
75
76 /* Initialize the Volume Control Block (VCB) */
77 Vcb = (PNPFS_VCB)DeviceObject->DeviceExtension;
78 InitializeListHead(&Vcb->PipeListHead);
79 InitializeListHead(&Vcb->ThreadListHead);
80 KeInitializeMutex(&Vcb->PipeListLock, 0);
81 Vcb->EmptyWaiterCount = 0;
82
83 /* set the size quotas */
84 Vcb->MinQuota = PAGE_SIZE;
85 Vcb->DefaultQuota = 8 * PAGE_SIZE;
86 Vcb->MaxQuota = 64 * PAGE_SIZE;
87
88 /* Create the device FCB */
89 Fcb = ExAllocatePool(NonPagedPool, sizeof(NPFS_FCB));
90 Fcb->Type = FCB_DEVICE;
91 Fcb->Vcb = Vcb;
92 Vcb->DeviceFcb = Fcb;
93
94 /* Create the root directory FCB */
95 Fcb = ExAllocatePool(NonPagedPool, sizeof(NPFS_FCB));
96 Fcb->Type = FCB_DIRECTORY;
97 Fcb->Vcb = Vcb;
98 Vcb->RootFcb = Fcb;
99
100 return STATUS_SUCCESS;
101 }
102
103 /* EOF */