2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: drivers/filesystems/npfs/finfo.c
5 * PURPOSE: Named pipe filesystem
6 * PROGRAMMER: Eric Kohl
9 /* INCLUDES ******************************************************************/
16 /* FUNCTIONS *****************************************************************/
20 NpfsSetPipeInformation(PDEVICE_OBJECT DeviceObject
,
22 PFILE_PIPE_INFORMATION Info
,
26 PFILE_PIPE_INFORMATION Request
;
28 UNREFERENCED_PARAMETER(DeviceObject
);
30 DPRINT("NpfsSetPipeInformation()\n");
32 if (*BufferLength
< sizeof(FILE_PIPE_INFORMATION
))
34 /* Buffer too small */
35 return STATUS_INFO_LENGTH_MISMATCH
;
39 /* Get the Pipe and data */
41 Request
= (PFILE_PIPE_INFORMATION
)Info
;
43 if ((Fcb
->PipeType
== FILE_PIPE_BYTE_STREAM_TYPE
) && (Request
->ReadMode
== FILE_PIPE_MESSAGE_MODE
))
45 DPRINT("Cannot change readmode to message type on a byte type pipe!\n");
46 return STATUS_ACCESS_DENIED
;
50 if (Ccb
->PipeEnd
== FILE_PIPE_CLIENT_END
)
52 Fcb
->ClientReadMode
= Request
->ReadMode
;
56 Fcb
->ServerReadMode
= Request
->ReadMode
;
59 Fcb
->CompletionMode
= Request
->CompletionMode
;
62 return STATUS_SUCCESS
;
67 NpfsSetPipeRemoteInformation(PDEVICE_OBJECT DeviceObject
,
69 PFILE_PIPE_INFORMATION Info
,
73 PFILE_PIPE_REMOTE_INFORMATION Request
;
75 UNREFERENCED_PARAMETER(DeviceObject
);
77 DPRINT("NpfsSetPipeRemoteInformation()\n");
79 if (*BufferLength
< sizeof(FILE_PIPE_REMOTE_INFORMATION
))
81 /* Buffer too small */
82 return STATUS_INFO_LENGTH_MISMATCH
;
85 /* Get the Pipe and data */
87 Request
= (PFILE_PIPE_REMOTE_INFORMATION
)Info
;
89 /* Set the Settings */
90 Fcb
->TimeOut
= Request
->CollectDataTime
;
91 Fcb
->InboundQuota
= Request
->MaximumCollectionCount
;
94 return STATUS_SUCCESS
;
99 NpfsQueryPipeInformation(PDEVICE_OBJECT DeviceObject
,
101 PFILE_PIPE_INFORMATION Info
,
105 ULONG ConnectionSideReadMode
;
107 UNREFERENCED_PARAMETER(DeviceObject
);
109 DPRINT("NpfsQueryPipeInformation()\n");
111 if (*BufferLength
< sizeof(FILE_PIPE_INFORMATION
))
113 /* Buffer too small */
114 *BufferLength
= sizeof(FILE_PIPE_INFORMATION
);
115 return STATUS_BUFFER_OVERFLOW
;
122 RtlZeroMemory(Info
, sizeof(FILE_PIPE_INFORMATION
));
124 if (Ccb
->PipeEnd
== FILE_PIPE_CLIENT_END
) ConnectionSideReadMode
=Ccb
->Fcb
->ClientReadMode
;
125 else ConnectionSideReadMode
= Ccb
->Fcb
->ServerReadMode
;
128 Info
->CompletionMode
= Fcb
->CompletionMode
;
129 Info
->ReadMode
= ConnectionSideReadMode
;
132 *BufferLength
= sizeof(FILE_PIPE_INFORMATION
);
133 return STATUS_SUCCESS
;
138 NpfsQueryPipeRemoteInformation(PDEVICE_OBJECT DeviceObject
,
140 PFILE_PIPE_REMOTE_INFORMATION Info
,
145 UNREFERENCED_PARAMETER(DeviceObject
);
147 DPRINT("NpfsQueryPipeRemoteInformation()\n");
149 if (*BufferLength
< sizeof(FILE_PIPE_REMOTE_INFORMATION
))
151 /* Buffer too small */
152 *BufferLength
= sizeof(FILE_PIPE_REMOTE_INFORMATION
);
153 return STATUS_BUFFER_OVERFLOW
;
160 RtlZeroMemory(Info
, sizeof(FILE_PIPE_REMOTE_INFORMATION
));
163 Info
->MaximumCollectionCount
= Fcb
->InboundQuota
;
164 Info
->CollectDataTime
= Fcb
->TimeOut
;
167 *BufferLength
= sizeof(FILE_PIPE_REMOTE_INFORMATION
);
168 return STATUS_SUCCESS
;
173 NpfsQueryLocalPipeInformation(PDEVICE_OBJECT DeviceObject
,
175 PFILE_PIPE_LOCAL_INFORMATION Info
,
180 UNREFERENCED_PARAMETER(DeviceObject
);
182 DPRINT("NpfsQueryLocalPipeInformation()\n");
184 if (*BufferLength
< sizeof(FILE_PIPE_REMOTE_INFORMATION
))
186 /* Buffer too small */
187 *BufferLength
= sizeof(FILE_PIPE_REMOTE_INFORMATION
);
188 return STATUS_BUFFER_OVERFLOW
;
196 sizeof(FILE_PIPE_LOCAL_INFORMATION
));
199 Info
->NamedPipeType
= Fcb
->PipeType
;
200 Info
->NamedPipeConfiguration
= Fcb
->PipeConfiguration
;
201 Info
->MaximumInstances
= Fcb
->MaximumInstances
;
202 Info
->CurrentInstances
= Fcb
->CurrentInstances
;
203 Info
->InboundQuota
= Fcb
->InboundQuota
;
204 Info
->OutboundQuota
= Fcb
->OutboundQuota
;
205 Info
->NamedPipeState
= Ccb
->PipeState
;
206 Info
->NamedPipeEnd
= Ccb
->PipeEnd
;
208 if (Ccb
->PipeEnd
== FILE_PIPE_SERVER_END
)
210 Info
->ReadDataAvailable
= Ccb
->ReadDataAvailable
;
211 Info
->WriteQuotaAvailable
= Ccb
->WriteQuotaAvailable
;
213 else if (Ccb
->OtherSide
!= NULL
)
215 Info
->ReadDataAvailable
= Ccb
->OtherSide
->ReadDataAvailable
;
216 Info
->WriteQuotaAvailable
= Ccb
->OtherSide
->WriteQuotaAvailable
;
219 *BufferLength
= sizeof(FILE_PIPE_LOCAL_INFORMATION
);
220 return STATUS_SUCCESS
;
225 NpfsQueryInformation(PDEVICE_OBJECT DeviceObject
,
228 PIO_STACK_LOCATION IoStack
;
229 FILE_INFORMATION_CLASS FileInformationClass
;
230 PFILE_OBJECT FileObject
;
238 DPRINT("NpfsQueryInformation(DeviceObject %p Irp %p)\n", DeviceObject
, Irp
);
240 IoStack
= IoGetCurrentIrpStackLocation (Irp
);
241 FileInformationClass
= IoStack
->Parameters
.QueryFile
.FileInformationClass
;
242 //Vcb = (PNPFS_VCB)DeviceObject->DeviceExtension;
243 FileObject
= IoStack
->FileObject
;
244 Ccb
= (PNPFS_CCB
)FileObject
->FsContext2
;
247 SystemBuffer
= Irp
->AssociatedIrp
.SystemBuffer
;
248 BufferLength
= IoStack
->Parameters
.QueryFile
.Length
;
250 DPRINT("Pipe name: %wZ\n", &Fcb
->PipeName
);
251 DPRINT("FileInformationClass %d\n", FileInformationClass
);
252 DPRINT("SystemBuffer %p\n", SystemBuffer
);
253 DPRINT("BufferLength %lu\n", BufferLength
);
255 switch (FileInformationClass
)
257 case FilePipeInformation
:
258 Status
= NpfsQueryPipeInformation(DeviceObject
,
264 case FilePipeLocalInformation
:
265 Status
= NpfsQueryLocalPipeInformation(DeviceObject
,
271 case FilePipeRemoteInformation
:
272 Status
= NpfsQueryPipeRemoteInformation(DeviceObject
,
279 Status
= STATUS_NOT_SUPPORTED
;
283 Irp
->IoStatus
.Status
= Status
;
284 Irp
->IoStatus
.Information
= BufferLength
;
286 IoCompleteRequest (Irp
, IO_NO_INCREMENT
);
293 NpfsSetInformation(PDEVICE_OBJECT DeviceObject
,
296 PIO_STACK_LOCATION IoStack
;
297 FILE_INFORMATION_CLASS FileInformationClass
;
298 PFILE_OBJECT FileObject
;
305 DPRINT("NpfsSetInformation(DeviceObject %p Irp %p)\n", DeviceObject
, Irp
);
307 IoStack
= IoGetCurrentIrpStackLocation (Irp
);
308 FileInformationClass
= IoStack
->Parameters
.QueryFile
.FileInformationClass
;
309 FileObject
= IoStack
->FileObject
;
310 Ccb
= (PNPFS_CCB
)FileObject
->FsContext2
;
313 SystemBuffer
= Irp
->AssociatedIrp
.SystemBuffer
;
314 BufferLength
= IoStack
->Parameters
.QueryFile
.Length
;
316 DPRINT("Pipe name: %wZ\n", &Fcb
->PipeName
);
317 DPRINT("FileInformationClass %d\n", FileInformationClass
);
318 DPRINT("SystemBuffer %p\n", SystemBuffer
);
319 DPRINT("BufferLength %lu\n", BufferLength
);
321 switch (FileInformationClass
)
323 case FilePipeInformation
:
324 /* Call the handler */
325 Status
= NpfsSetPipeInformation(DeviceObject
,
331 case FilePipeLocalInformation
:
332 Status
= STATUS_NOT_IMPLEMENTED
;
335 case FilePipeRemoteInformation
:
336 /* Call the handler */
337 Status
= NpfsSetPipeRemoteInformation(DeviceObject
,
343 Status
= STATUS_NOT_SUPPORTED
;
346 Irp
->IoStatus
.Status
= Status
;
347 Irp
->IoStatus
.Information
= 0;
348 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);