2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: drivers/fs/np/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
;
27 DPRINT("NpfsSetPipeInformation()\n");
29 if (*BufferLength
< sizeof(FILE_PIPE_INFORMATION
))
31 /* Buffer too small */
32 return STATUS_INFO_LENGTH_MISMATCH
;
36 /* Get the Pipe and data */
38 Request
= (PFILE_PIPE_INFORMATION
)Info
;
40 if ((Fcb
->PipeType
== FILE_PIPE_BYTE_STREAM_TYPE
) && (Request
->ReadMode
== FILE_PIPE_MESSAGE_MODE
))
42 DPRINT("Cannot change readmode to message type on a byte type pipe!\n");
43 return STATUS_ACCESS_DENIED
;
47 if (Ccb
->PipeEnd
== FILE_PIPE_CLIENT_END
)
49 Fcb
->ClientReadMode
= Request
->ReadMode
;
53 Fcb
->ServerReadMode
= Request
->ReadMode
;
56 Fcb
->CompletionMode
= Request
->CompletionMode
;
59 return STATUS_SUCCESS
;
64 NpfsSetPipeRemoteInformation(PDEVICE_OBJECT DeviceObject
,
66 PFILE_PIPE_INFORMATION Info
,
70 PFILE_PIPE_REMOTE_INFORMATION Request
;
71 DPRINT("NpfsSetPipeRemoteInformation()\n");
73 if (*BufferLength
< sizeof(FILE_PIPE_REMOTE_INFORMATION
))
75 /* Buffer too small */
76 return STATUS_INFO_LENGTH_MISMATCH
;
79 /* Get the Pipe and data */
81 Request
= (PFILE_PIPE_REMOTE_INFORMATION
)Info
;
83 /* Set the Settings */
84 Fcb
->TimeOut
= Request
->CollectDataTime
;
85 Fcb
->InboundQuota
= Request
->MaximumCollectionCount
;
88 return STATUS_SUCCESS
;
93 NpfsQueryPipeInformation(PDEVICE_OBJECT DeviceObject
,
95 PFILE_PIPE_INFORMATION Info
,
99 ULONG ConnectionSideReadMode
;
100 DPRINT("NpfsQueryPipeInformation()\n");
102 if (*BufferLength
< sizeof(FILE_PIPE_INFORMATION
))
104 /* Buffer too small */
105 *BufferLength
= sizeof(FILE_PIPE_INFORMATION
);
106 return STATUS_BUFFER_OVERFLOW
;
113 RtlZeroMemory(Info
, sizeof(FILE_PIPE_INFORMATION
));
115 if (Ccb
->PipeEnd
== FILE_PIPE_CLIENT_END
) ConnectionSideReadMode
=Ccb
->Fcb
->ClientReadMode
;
116 else ConnectionSideReadMode
= Ccb
->Fcb
->ServerReadMode
;
119 Info
->CompletionMode
= Fcb
->CompletionMode
;
120 Info
->ReadMode
= ConnectionSideReadMode
;
123 *BufferLength
= sizeof(FILE_PIPE_INFORMATION
);
124 return STATUS_SUCCESS
;
129 NpfsQueryPipeRemoteInformation(PDEVICE_OBJECT DeviceObject
,
131 PFILE_PIPE_REMOTE_INFORMATION Info
,
135 DPRINT("NpfsQueryPipeRemoteInformation()\n");
137 if (*BufferLength
< sizeof(FILE_PIPE_REMOTE_INFORMATION
))
139 /* Buffer too small */
140 *BufferLength
= sizeof(FILE_PIPE_REMOTE_INFORMATION
);
141 return STATUS_BUFFER_OVERFLOW
;
148 RtlZeroMemory(Info
, sizeof(FILE_PIPE_REMOTE_INFORMATION
));
151 Info
->MaximumCollectionCount
= Fcb
->InboundQuota
;
152 Info
->CollectDataTime
= Fcb
->TimeOut
;
155 *BufferLength
= sizeof(FILE_PIPE_REMOTE_INFORMATION
);
156 return STATUS_SUCCESS
;
161 NpfsQueryLocalPipeInformation(PDEVICE_OBJECT DeviceObject
,
163 PFILE_PIPE_LOCAL_INFORMATION Info
,
168 DPRINT("NpfsQueryLocalPipeInformation()\n");
170 if (*BufferLength
< sizeof(FILE_PIPE_REMOTE_INFORMATION
))
172 /* Buffer too small */
173 *BufferLength
= sizeof(FILE_PIPE_REMOTE_INFORMATION
);
174 return STATUS_BUFFER_OVERFLOW
;
182 sizeof(FILE_PIPE_LOCAL_INFORMATION
));
185 Info
->NamedPipeType
= Fcb
->PipeType
;
186 Info
->NamedPipeConfiguration
= Fcb
->PipeConfiguration
;
187 Info
->MaximumInstances
= Fcb
->MaximumInstances
;
188 Info
->CurrentInstances
= Fcb
->CurrentInstances
;
189 Info
->InboundQuota
= Fcb
->InboundQuota
;
190 Info
->OutboundQuota
= Fcb
->OutboundQuota
;
191 Info
->NamedPipeState
= Ccb
->PipeState
;
192 Info
->NamedPipeEnd
= Ccb
->PipeEnd
;
194 if (Ccb
->PipeEnd
== FILE_PIPE_SERVER_END
)
196 Info
->ReadDataAvailable
= Ccb
->ReadDataAvailable
;
197 Info
->WriteQuotaAvailable
= Ccb
->WriteQuotaAvailable
;
199 else if (Ccb
->OtherSide
!= NULL
)
201 Info
->ReadDataAvailable
= Ccb
->OtherSide
->ReadDataAvailable
;
202 Info
->WriteQuotaAvailable
= Ccb
->OtherSide
->WriteQuotaAvailable
;
205 *BufferLength
= sizeof(FILE_PIPE_LOCAL_INFORMATION
);
206 return STATUS_SUCCESS
;
211 NpfsQueryInformation(PDEVICE_OBJECT DeviceObject
,
214 PIO_STACK_LOCATION IoStack
;
215 FILE_INFORMATION_CLASS FileInformationClass
;
216 PFILE_OBJECT FileObject
;
217 PNPFS_DEVICE_EXTENSION DeviceExtension
;
224 DPRINT("NpfsQueryInformation(DeviceObject %p Irp %p)\n", DeviceObject
, Irp
);
226 IoStack
= IoGetCurrentIrpStackLocation (Irp
);
227 FileInformationClass
= IoStack
->Parameters
.QueryFile
.FileInformationClass
;
228 DeviceExtension
= DeviceObject
->DeviceExtension
;
229 FileObject
= IoStack
->FileObject
;
230 Ccb
= (PNPFS_CCB
)FileObject
->FsContext2
;
233 SystemBuffer
= Irp
->AssociatedIrp
.SystemBuffer
;
234 BufferLength
= IoStack
->Parameters
.QueryFile
.Length
;
236 DPRINT("Pipe name: %wZ\n", &Fcb
->PipeName
);
237 DPRINT("FileInformationClass %d\n", FileInformationClass
);
238 DPRINT("SystemBuffer %p\n", SystemBuffer
);
239 DPRINT("BufferLength %lu\n", BufferLength
);
241 switch (FileInformationClass
)
243 case FilePipeInformation
:
244 Status
= NpfsQueryPipeInformation(DeviceObject
,
250 case FilePipeLocalInformation
:
251 Status
= NpfsQueryLocalPipeInformation(DeviceObject
,
257 case FilePipeRemoteInformation
:
258 Status
= NpfsQueryPipeRemoteInformation(DeviceObject
,
265 Status
= STATUS_NOT_SUPPORTED
;
269 Irp
->IoStatus
.Status
= Status
;
270 Irp
->IoStatus
.Information
= BufferLength
;
272 IoCompleteRequest (Irp
, IO_NO_INCREMENT
);
279 NpfsSetInformation(PDEVICE_OBJECT DeviceObject
,
282 PIO_STACK_LOCATION IoStack
;
283 FILE_INFORMATION_CLASS FileInformationClass
;
284 PFILE_OBJECT FileObject
;
291 DPRINT("NpfsSetInformation(DeviceObject %p Irp %p)\n", DeviceObject
, Irp
);
293 IoStack
= IoGetCurrentIrpStackLocation (Irp
);
294 FileInformationClass
= IoStack
->Parameters
.QueryFile
.FileInformationClass
;
295 FileObject
= IoStack
->FileObject
;
296 Ccb
= (PNPFS_CCB
)FileObject
->FsContext2
;
299 SystemBuffer
= Irp
->AssociatedIrp
.SystemBuffer
;
300 BufferLength
= IoStack
->Parameters
.QueryFile
.Length
;
302 DPRINT("Pipe name: %wZ\n", &Fcb
->PipeName
);
303 DPRINT("FileInformationClass %d\n", FileInformationClass
);
304 DPRINT("SystemBuffer %p\n", SystemBuffer
);
305 DPRINT("BufferLength %lu\n", BufferLength
);
307 switch (FileInformationClass
)
309 case FilePipeInformation
:
310 /* Call the handler */
311 Status
= NpfsSetPipeInformation(DeviceObject
,
317 case FilePipeLocalInformation
:
318 Status
= STATUS_NOT_IMPLEMENTED
;
321 case FilePipeRemoteInformation
:
322 /* Call the handler */
323 Status
= NpfsSetPipeRemoteInformation(DeviceObject
,
329 Status
= STATUS_NOT_SUPPORTED
;
332 Irp
->IoStatus
.Status
= Status
;
333 Irp
->IoStatus
.Information
= 0;
334 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);