ab4bf93b0ee39383ebfb9066967a1265502654e0
[reactos.git] / reactos / drivers / fs / np / finfo.c
1 /* $Id$
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: services/fs/np/finfo.c
6 * PURPOSE: Named pipe filesystem
7 * PROGRAMMER: Eric Kohl <ekohl@rz-online.de>
8 */
9
10 /* INCLUDES ******************************************************************/
11
12 #include <ddk/ntddk.h>
13 #include "npfs.h"
14
15 #define NDEBUG
16 #include <debug.h>
17
18 /* FUNCTIONS *****************************************************************/
19
20 static NTSTATUS
21 NpfsQueryPipeInformation(PDEVICE_OBJECT DeviceObject,
22 PNPFS_FCB Fcb,
23 PFILE_PIPE_INFORMATION Info,
24 PULONG BufferLength)
25 {
26 PNPFS_PIPE Pipe;
27
28 DPRINT("NpfsQueryPipeInformation()\n");
29
30 Pipe = Fcb->Pipe;
31
32 RtlZeroMemory(Info,
33 sizeof(FILE_PIPE_INFORMATION));
34
35 // Info->PipeMode =
36 // Info->CompletionMode =
37
38 *BufferLength -= sizeof(FILE_PIPE_INFORMATION);
39 return(STATUS_SUCCESS);
40 }
41
42
43 static NTSTATUS
44 NpfsQueryLocalPipeInformation(PDEVICE_OBJECT DeviceObject,
45 PNPFS_FCB Fcb,
46 PFILE_PIPE_LOCAL_INFORMATION Info,
47 PULONG BufferLength)
48 {
49 PNPFS_PIPE Pipe;
50
51 DPRINT("NpfsQueryLocalPipeInformation()\n");
52
53 Pipe = Fcb->Pipe;
54
55 RtlZeroMemory(Info,
56 sizeof(FILE_PIPE_LOCAL_INFORMATION));
57
58 Info->NamedPipeType = Pipe->PipeType;
59 Info->NamedPipeConfiguration = Pipe->PipeConfiguration;
60 Info->MaximumInstances = Pipe->MaximumInstances;
61 Info->CurrentInstances = Pipe->CurrentInstances;
62 Info->InboundQuota = Pipe->InboundQuota;
63 Info->OutboundQuota = Pipe->OutboundQuota;
64 Info->NamedPipeState = Fcb->PipeState;
65 Info->NamedPipeEnd = Fcb->PipeEnd;
66
67 if (Fcb->PipeEnd == FILE_PIPE_SERVER_END)
68 {
69 Info->ReadDataAvailable = Fcb->ReadDataAvailable;
70 Info->WriteQuotaAvailable = Fcb->WriteQuotaAvailable;
71 }
72 else if (Fcb->OtherSide != NULL)
73 {
74 Info->ReadDataAvailable = Fcb->OtherSide->ReadDataAvailable;
75 Info->WriteQuotaAvailable = Fcb->OtherSide->WriteQuotaAvailable;
76 }
77
78 *BufferLength -= sizeof(FILE_PIPE_LOCAL_INFORMATION);
79 return(STATUS_SUCCESS);
80 }
81
82
83 NTSTATUS STDCALL
84 NpfsQueryInformation(PDEVICE_OBJECT DeviceObject,
85 PIRP Irp)
86 {
87 PIO_STACK_LOCATION IoStack;
88 FILE_INFORMATION_CLASS FileInformationClass;
89 PFILE_OBJECT FileObject;
90 PNPFS_DEVICE_EXTENSION DeviceExtension;
91 PNPFS_FCB Fcb;
92 PNPFS_PIPE Pipe;
93 PVOID SystemBuffer;
94 ULONG BufferLength;
95 NTSTATUS Status;
96
97 DPRINT("NpfsQueryInformation(DeviceObject %p Irp %p)\n", DeviceObject, Irp);
98
99 IoStack = IoGetCurrentIrpStackLocation (Irp);
100 FileInformationClass = IoStack->Parameters.QueryFile.FileInformationClass;
101 DeviceExtension = DeviceObject->DeviceExtension;
102 FileObject = IoStack->FileObject;
103 Fcb = (PNPFS_FCB)FileObject->FsContext;
104 Pipe = Fcb->Pipe;
105
106 SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
107 BufferLength = IoStack->Parameters.QueryFile.Length;
108
109 DPRINT("Pipe name: %wZ\n", &Pipe->PipeName);
110 DPRINT("FileInformationClass %d\n", FileInformationClass);
111 DPRINT("SystemBuffer %p\n", SystemBuffer);
112 DPRINT("BufferLength %lu\n", BufferLength);
113
114 switch (FileInformationClass)
115 {
116 case FilePipeInformation:
117 Status = NpfsQueryPipeInformation(DeviceObject,
118 Fcb,
119 SystemBuffer,
120 &BufferLength);
121 break;
122
123 case FilePipeLocalInformation:
124 Status = NpfsQueryLocalPipeInformation(DeviceObject,
125 Fcb,
126 SystemBuffer,
127 &BufferLength);
128 break;
129
130 case FilePipeRemoteInformation:
131 Status = STATUS_NOT_IMPLEMENTED;
132 break;
133
134 default:
135 Status = STATUS_NOT_SUPPORTED;
136 }
137
138 Irp->IoStatus.Status = Status;
139 if (NT_SUCCESS(Status))
140 Irp->IoStatus.Information =
141 IoStack->Parameters.QueryFile.Length - BufferLength;
142 else
143 Irp->IoStatus.Information = 0;
144 IoCompleteRequest (Irp, IO_NO_INCREMENT);
145
146 return(Status);
147 }
148
149
150 NTSTATUS STDCALL
151 NpfsSetInformation(PDEVICE_OBJECT DeviceObject,
152 PIRP Irp)
153 {
154 PIO_STACK_LOCATION IoStack;
155 FILE_INFORMATION_CLASS FileInformationClass;
156 PFILE_OBJECT FileObject;
157 PNPFS_FCB Fcb;
158 PNPFS_PIPE Pipe;
159 PVOID SystemBuffer;
160 ULONG BufferLength;
161 NTSTATUS Status;
162
163 DPRINT("NpfsSetInformation(DeviceObject %p Irp %p)\n", DeviceObject, Irp);
164
165 IoStack = IoGetCurrentIrpStackLocation (Irp);
166 FileInformationClass = IoStack->Parameters.QueryFile.FileInformationClass;
167 FileObject = IoStack->FileObject;
168 Fcb = (PNPFS_FCB)FileObject->FsContext;
169 Pipe = Fcb->Pipe;
170
171 SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
172 BufferLength = IoStack->Parameters.QueryFile.Length;
173
174 DPRINT("Pipe name: %wZ\n", &Pipe->PipeName);
175 DPRINT("FileInformationClass %d\n", FileInformationClass);
176 DPRINT("SystemBuffer %p\n", SystemBuffer);
177 DPRINT("BufferLength %lu\n", BufferLength);
178
179 switch (FileInformationClass)
180 {
181 case FilePipeInformation:
182 Status = STATUS_NOT_IMPLEMENTED;
183 break;
184 case FilePipeLocalInformation:
185 Status = STATUS_NOT_IMPLEMENTED;
186 break;
187 case FilePipeRemoteInformation:
188 Status = STATUS_NOT_IMPLEMENTED;
189 break;
190 default:
191 Status = STATUS_NOT_SUPPORTED;
192 }
193
194 Irp->IoStatus.Status = Status;
195 Irp->IoStatus.Information = 0;
196 IoCompleteRequest(Irp,
197 IO_NO_INCREMENT);
198
199 return(Status);
200 }
201
202 /* EOF */