[NPFS]
[reactos.git] / reactos / drivers / filesystems / npfs / npfs.h
1 #ifndef __DRIVERS_FS_NP_NPFS_H
2 #define __DRIVERS_FS_NP_NPFS_H
3
4 #include <ntifs.h>
5 #include <ndk/iotypes.h>
6
7 typedef enum _FCB_TYPE
8 {
9 FCB_DEVICE,
10 FCB_DIRECTORY,
11 FCB_PIPE
12 } FCB_TYPE;
13
14 typedef enum _CCB_TYPE
15 {
16 CCB_DEVICE,
17 CCB_DIRECTORY,
18 CCB_PIPE
19 } CCB_TYPE;
20
21 /* Volume Control Block (VCB) aka Device Extension */
22 typedef struct _NPFS_VCB
23 {
24 LIST_ENTRY PipeListHead;
25 LIST_ENTRY ThreadListHead;
26 KMUTEX PipeListLock;
27 ULONG EmptyWaiterCount;
28 ULONG MinQuota;
29 ULONG DefaultQuota;
30 ULONG MaxQuota;
31 struct _NPFS_FCB *RootFcb;
32 } NPFS_VCB, *PNPFS_VCB;
33
34 typedef struct _NPFS_FCB
35 {
36 FCB_TYPE Type;
37 PNPFS_VCB Vcb;
38 UNICODE_STRING PipeName;
39 LIST_ENTRY PipeListEntry;
40 KMUTEX CcbListLock;
41 LIST_ENTRY ServerCcbListHead;
42 LIST_ENTRY ClientCcbListHead;
43 LIST_ENTRY WaiterListHead;
44 LIST_ENTRY EmptyBufferListHead;
45 ULONG PipeType;
46 ULONG ClientReadMode;
47 ULONG ServerReadMode;
48 ULONG CompletionMode;
49 ULONG PipeConfiguration;
50 ULONG MaximumInstances;
51 ULONG CurrentInstances;
52 ULONG InboundQuota;
53 ULONG OutboundQuota;
54 LARGE_INTEGER TimeOut;
55 } NPFS_FCB, *PNPFS_FCB;
56
57 typedef struct _NPFS_CCB
58 {
59 LIST_ENTRY CcbListEntry;
60 CCB_TYPE Type;
61 PNPFS_FCB Fcb;
62
63 struct _NPFS_CCB* OtherSide;
64 struct ETHREAD *Thread;
65 KEVENT ConnectEvent;
66 KEVENT ReadEvent;
67 KEVENT WriteEvent;
68 ULONG PipeEnd;
69 ULONG PipeState;
70 ULONG ReadDataAvailable;
71 ULONG WriteQuotaAvailable;
72
73 LIST_ENTRY ReadRequestListHead;
74
75 PVOID Data;
76 PVOID ReadPtr;
77 PVOID WritePtr;
78 ULONG MaxDataLength;
79
80 FAST_MUTEX DataListLock; /* Data queue lock */
81 } NPFS_CCB, *PNPFS_CCB;
82
83 typedef struct _NPFS_CONTEXT
84 {
85 LIST_ENTRY ListEntry;
86 PKEVENT WaitEvent;
87 } NPFS_CONTEXT, *PNPFS_CONTEXT;
88
89 typedef struct _NPFS_THREAD_CONTEXT
90 {
91 ULONG Count;
92 KEVENT Event;
93 PNPFS_VCB Vcb;
94 LIST_ENTRY ListEntry;
95 PVOID WaitObjectArray[MAXIMUM_WAIT_OBJECTS];
96 KWAIT_BLOCK WaitBlockArray[MAXIMUM_WAIT_OBJECTS];
97 PIRP WaitIrpArray[MAXIMUM_WAIT_OBJECTS];
98 } NPFS_THREAD_CONTEXT, *PNPFS_THREAD_CONTEXT;
99
100 typedef struct _NPFS_WAITER_ENTRY
101 {
102 LIST_ENTRY Entry;
103 PNPFS_CCB Ccb;
104 } NPFS_WAITER_ENTRY, *PNPFS_WAITER_ENTRY;
105
106
107 extern NPAGED_LOOKASIDE_LIST NpfsPipeDataLookasideList;
108
109
110 #define KeLockMutex(x) KeWaitForSingleObject(x, \
111 UserRequest, \
112 KernelMode, \
113 FALSE, \
114 NULL);
115
116 #define KeUnlockMutex(x) KeReleaseMutex(x, FALSE);
117
118 #define PAGE_ROUND_UP(x) ( (((ULONG_PTR)x)%PAGE_SIZE) ? ((((ULONG_PTR)x)&(~(PAGE_SIZE-1)))+PAGE_SIZE) : ((ULONG_PTR)x) )
119
120 DRIVER_DISPATCH NpfsCreate;
121 NTSTATUS NTAPI NpfsCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp);
122
123 DRIVER_DISPATCH NpfsCreateNamedPipe;
124 NTSTATUS NTAPI NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject, PIRP Irp);
125
126 DRIVER_DISPATCH NpfsCleanup;
127 NTSTATUS NTAPI NpfsCleanup(PDEVICE_OBJECT DeviceObject, PIRP Irp);
128
129 DRIVER_DISPATCH NpfsClose;
130 NTSTATUS NTAPI NpfsClose(PDEVICE_OBJECT DeviceObject, PIRP Irp);
131
132 DRIVER_DISPATCH NpfsRead;
133 NTSTATUS NTAPI NpfsRead(PDEVICE_OBJECT DeviceObject, PIRP Irp);
134
135 DRIVER_DISPATCH NpfsWrite;
136 NTSTATUS NTAPI NpfsWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp);
137
138 DRIVER_DISPATCH NpfsFlushBuffers;
139 NTSTATUS NTAPI NpfsFlushBuffers(PDEVICE_OBJECT DeviceObject, PIRP Irp);
140
141 DRIVER_DISPATCH NpfsFileSystemControl;
142 NTSTATUS NTAPI NpfsFileSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp);
143
144 DRIVER_DISPATCH NpfsQueryInformation;
145 NTSTATUS NTAPI NpfsQueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp);
146
147 DRIVER_DISPATCH NpfsSetInformation;
148 NTSTATUS NTAPI NpfsSetInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp);
149
150 DRIVER_DISPATCH NpfsQueryVolumeInformation;
151 NTSTATUS NTAPI NpfsQueryVolumeInformation (PDEVICE_OBJECT DeviceObject, PIRP Irp);
152
153 NTSTATUS NTAPI
154 DriverEntry(PDRIVER_OBJECT DriverObject,
155 PUNICODE_STRING RegistryPath);
156
157 PNPFS_FCB
158 NpfsFindPipe(PNPFS_VCB Vcb,
159 PUNICODE_STRING PipeName);
160
161
162 #endif /* __DRIVERS_FS_NP_NPFS_H */