[NPFS]
[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 PNPFS_DEVICE_EXTENSION DeviceExtension;
23 PDEVICE_OBJECT DeviceObject;
24 UNICODE_STRING DeviceName;
25 NTSTATUS Status;
26
27 DPRINT("Named Pipe FSD 0.0.2\n");
28
29 ASSERT (sizeof(NPFS_CONTEXT) <= FIELD_OFFSET(IRP, Tail.Overlay.DriverContext));
30 ASSERT (sizeof(NPFS_WAITER_ENTRY) <= FIELD_OFFSET(IRP, Tail.Overlay.DriverContext));
31
32 DriverObject->MajorFunction[IRP_MJ_CREATE] = NpfsCreate;
33 DriverObject->MajorFunction[IRP_MJ_CREATE_NAMED_PIPE] =
34 NpfsCreateNamedPipe;
35 DriverObject->MajorFunction[IRP_MJ_CLOSE] = NpfsClose;
36 DriverObject->MajorFunction[IRP_MJ_READ] = NpfsRead;
37 DriverObject->MajorFunction[IRP_MJ_WRITE] = NpfsWrite;
38 DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] =
39 NpfsQueryInformation;
40 DriverObject->MajorFunction[IRP_MJ_SET_INFORMATION] =
41 NpfsSetInformation;
42 DriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] =
43 NpfsQueryVolumeInformation;
44 DriverObject->MajorFunction[IRP_MJ_CLEANUP] = NpfsCleanup;
45 DriverObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = NpfsFlushBuffers;
46 // DriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] =
47 // NpfsDirectoryControl;
48 DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] =
49 NpfsFileSystemControl;
50 // DriverObject->MajorFunction[IRP_MJ_QUERY_SECURITY] =
51 // NpfsQuerySecurity;
52 // DriverObject->MajorFunction[IRP_MJ_SET_SECURITY] =
53 // NpfsSetSecurity;
54
55 DriverObject->DriverUnload = NULL;
56
57 RtlInitUnicodeString(&DeviceName, L"\\Device\\NamedPipe");
58 Status = IoCreateDevice(DriverObject,
59 sizeof(NPFS_DEVICE_EXTENSION),
60 &DeviceName,
61 FILE_DEVICE_NAMED_PIPE,
62 0,
63 FALSE,
64 &DeviceObject);
65 if (!NT_SUCCESS(Status))
66 {
67 DPRINT("Failed to create named pipe device! (Status %x)\n", Status);
68 return Status;
69 }
70
71 /* initialize the device object */
72 DeviceObject->Flags |= DO_DIRECT_IO;
73 DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
74
75 /* initialize the device extension */
76 DeviceExtension = DeviceObject->DeviceExtension;
77 InitializeListHead(&DeviceExtension->PipeListHead);
78 InitializeListHead(&DeviceExtension->ThreadListHead);
79 KeInitializeMutex(&DeviceExtension->PipeListLock, 0);
80 DeviceExtension->EmptyWaiterCount = 0;
81
82 /* set the size quotas */
83 DeviceExtension->MinQuota = PAGE_SIZE;
84 DeviceExtension->DefaultQuota = 8 * PAGE_SIZE;
85 DeviceExtension->MaxQuota = 64 * PAGE_SIZE;
86
87 return STATUS_SUCCESS;
88 }
89
90 /* EOF */