ReactOS 0.4.16-dev-91-g764881a
fileinfo.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Named Pipe FileSystem
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: drivers/filesystems/npfs/fileinfo.c
5 * PURPOSE: Pipes Information
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9/* INCLUDES *******************************************************************/
10
11#include "npfs.h"
12
13// File ID number for NPFS bugchecking support
14#define NPFS_BUGCHECK_FILE_ID (NPFS_BUGCHECK_FILEINFO)
15
16/* FUNCTIONS ******************************************************************/
17
22{
23 PAGED_CODE();
24 return STATUS_SUCCESS;
25}
26
32 IN ULONG NamedPipeEnd,
34{
36 PNP_DATA_QUEUE ReadQueue, WriteQueue;
37 PAGED_CODE();
38
39 if (Buffer->ReadMode == FILE_PIPE_MESSAGE_MODE && Fcb->NamedPipeType == FILE_PIPE_BYTE_STREAM_TYPE)
40 {
42 }
43
44 if (NamedPipeEnd != FILE_PIPE_CLIENT_END)
45 {
46 if (NamedPipeEnd != FILE_PIPE_SERVER_END)
47 {
48 NpBugCheck(NamedPipeEnd, 0, 0);
49 }
50 ReadQueue = &Ccb->DataQueue[FILE_PIPE_INBOUND];
51 WriteQueue = &Ccb->DataQueue[FILE_PIPE_OUTBOUND];
52 }
53 else
54 {
55 ReadQueue = &Ccb->DataQueue[FILE_PIPE_OUTBOUND];
56 WriteQueue = &Ccb->DataQueue[FILE_PIPE_INBOUND];
57 }
58
59 if (Buffer->CompletionMode != FILE_PIPE_COMPLETE_OPERATION ||
60 Ccb->CompletionMode[NamedPipeEnd] == FILE_PIPE_COMPLETE_OPERATION ||
61 (ReadQueue->QueueState != ReadEntries &&
62 WriteQueue->QueueState != WriteEntries))
63 {
64 Ccb->ReadMode[NamedPipeEnd] = Buffer->ReadMode & 0xFF;
65 Ccb->CompletionMode[NamedPipeEnd] = Buffer->CompletionMode & 0xFF;
66
69 }
70 else
71 {
73 }
74
75 return Status;
76}
77
81 IN PIRP Irp,
83{
84 NODE_TYPE_CODE NodeTypeCode;
85 PIO_STACK_LOCATION IoStack;
86 ULONG InfoClass;
90 ULONG NamedPipeEnd;
91 PAGED_CODE();
92
94
95 NodeTypeCode = NpDecodeFileObject(IoStack->FileObject,
96 (PVOID*)&Fcb,
97 &Ccb,
98 &NamedPipeEnd);
99 if (!NodeTypeCode) return STATUS_PIPE_DISCONNECTED;
100 if (NodeTypeCode != NPFS_NTC_CCB) return STATUS_INVALID_PARAMETER;
101
102 InfoClass = IoStack->Parameters.QueryFile.FileInformationClass;
103 Buffer = Irp->AssociatedIrp.SystemBuffer;
104
105 if (InfoClass == FileBasicInformation) return NpSetBasicInfo(Ccb, Buffer);
106
107 if (InfoClass != FilePipeInformation) return STATUS_INVALID_PARAMETER;
108
109 return NpSetPipeInfo(Fcb, Ccb, Buffer, NamedPipeEnd, List);
110}
111
113NTAPI
115 IN PIRP Irp)
116{
118 LIST_ENTRY DeferredList;
119 PAGED_CODE();
120
121 InitializeListHead(&DeferredList);
122
125
127
128 NpReleaseVcb();
129 NpCompleteDeferredIrps(&DeferredList);
131
132 if (Status != STATUS_PENDING)
133 {
134 Irp->IoStatus.Status = Status;
136 }
137
138 return Status;
139}
140
142NTAPI
146{
147 PFILE_BASIC_INFORMATION InfoBuffer = Buffer;
148
149 *Length -= sizeof(*InfoBuffer);
150
151 RtlZeroMemory(InfoBuffer, sizeof(*InfoBuffer));
153
154 return STATUS_SUCCESS;
155}
156
158NTAPI
162 IN ULONG NamedPipeEnd)
163{
164 PNP_DATA_QUEUE DataQueue;
166
167 *Length -= sizeof(*InfoBuffer);
168
169 RtlZeroMemory(InfoBuffer, sizeof(*InfoBuffer));
170
171 if (NamedPipeEnd == FILE_PIPE_SERVER_END)
172 {
173 DataQueue = &Ccb->DataQueue[FILE_PIPE_INBOUND];
174 }
175 else
176 {
177 DataQueue = &Ccb->DataQueue[FILE_PIPE_OUTBOUND];
178 }
179
180 InfoBuffer->AllocationSize.LowPart = Ccb->DataQueue[FILE_PIPE_INBOUND].Quota +
181 Ccb->DataQueue[FILE_PIPE_OUTBOUND].Quota;
182 InfoBuffer->AllocationSize.HighPart = 0;
183
184 if (DataQueue->QueueState == WriteEntries)
185 {
186 InfoBuffer->EndOfFile.HighPart = 0;
187 InfoBuffer->EndOfFile.LowPart = DataQueue->BytesInQueue -
188 DataQueue->ByteOffset;
189 }
190
191 InfoBuffer->Directory = FALSE;
192 InfoBuffer->NumberOfLinks = 1;
193 InfoBuffer->DeletePending = TRUE;
194
195 return STATUS_SUCCESS;
196}
197
199NTAPI
203{
204 PFILE_EA_INFORMATION InfoBuffer = Buffer;
205
206 *Length -= sizeof(*InfoBuffer);
207
208 RtlZeroMemory(InfoBuffer, sizeof(*InfoBuffer));
209
210 return STATUS_SUCCESS;
211}
212
214NTAPI
218{
219 PFILE_NAME_INFORMATION InfoBuffer = Buffer;
220 USHORT NameLength;
222 PWCHAR Name;
223
224 *Length -= sizeof(*InfoBuffer);
225
226 if (Ccb->NodeType == NPFS_NTC_ROOT_DCB_CCB)
227 {
228 NameLength = NpVcb->RootDcb->FullName.Length;
229 Name = NpVcb->RootDcb->FullName.Buffer;
230 }
231 else
232 {
233 NameLength = Ccb->Fcb->FullName.Length;
234 Name = Ccb->Fcb->FullName.Buffer;
235 }
236
237 if (*Length < NameLength)
238 {
240 NameLength = (USHORT)*Length;
241 }
242 else
243 {
245 }
246
247 RtlCopyMemory(InfoBuffer->FileName, Name, NameLength);
248 InfoBuffer->FileNameLength = NameLength;
249
250 *Length -= NameLength;
251 return Status;
252}
253
255NTAPI
259{
261
262 *Length -= sizeof(*InfoBuffer);
263
264 RtlZeroMemory(InfoBuffer, sizeof(*InfoBuffer));
265
266 return STATUS_SUCCESS;
267}
268
270NTAPI
274 IN ULONG NamedPipeEnd)
275{
276 PNP_DATA_QUEUE DataQueue;
278
279 *Length -= sizeof(*InfoBuffer);
280
281 RtlZeroMemory(InfoBuffer, sizeof(*InfoBuffer));
282
283 if (NamedPipeEnd == FILE_PIPE_SERVER_END)
284 {
285 DataQueue = &Ccb->DataQueue[FILE_PIPE_INBOUND];
286 }
287 else
288 {
289 DataQueue = &Ccb->DataQueue[FILE_PIPE_OUTBOUND];
290 }
291
292 if (DataQueue->QueueState == WriteEntries)
293 {
294 InfoBuffer->CurrentByteOffset.QuadPart = DataQueue->BytesInQueue -
295 DataQueue->ByteOffset;
296 }
297
298 return STATUS_SUCCESS;
299}
300
302NTAPI
304 IN PNP_CCB Ccb,
307 IN ULONG NamedPipeEnd)
308{
310 PNP_DATA_QUEUE InQueue, OutQueue;
311
312 *Length -= sizeof(*InfoBuffer);
313
314 RtlZeroMemory(InfoBuffer, sizeof(*InfoBuffer));
315
316 InQueue = &Ccb->DataQueue[FILE_PIPE_INBOUND];
317 OutQueue = &Ccb->DataQueue[FILE_PIPE_OUTBOUND];
318
319 InfoBuffer->NamedPipeType = Fcb->NamedPipeType;
320 InfoBuffer->NamedPipeConfiguration = Fcb->NamedPipeConfiguration;
321 InfoBuffer->MaximumInstances = Fcb->MaximumInstances;
322 InfoBuffer->CurrentInstances = Fcb->CurrentInstances;
323 InfoBuffer->InboundQuota = InQueue->Quota;
324 InfoBuffer->OutboundQuota = OutQueue->Quota;
325 InfoBuffer->NamedPipeState = Ccb->NamedPipeState;
326 InfoBuffer->NamedPipeEnd = NamedPipeEnd;
327
328 if (NamedPipeEnd == FILE_PIPE_SERVER_END)
329 {
330 if (InQueue->QueueState == WriteEntries)
331 {
332 InfoBuffer->ReadDataAvailable = InQueue->BytesInQueue - InQueue->ByteOffset;
333 }
334 InfoBuffer->WriteQuotaAvailable = OutQueue->Quota - OutQueue->QuotaUsed;
335 }
336 else
337 {
338 if (OutQueue->QueueState == WriteEntries)
339 {
340 InfoBuffer->ReadDataAvailable = OutQueue->BytesInQueue - OutQueue->ByteOffset;
341 }
342 InfoBuffer->WriteQuotaAvailable = OutQueue->Quota - InQueue->QuotaUsed;
343 }
344
345 return STATUS_SUCCESS;
346}
347
349NTAPI
351 IN PNP_CCB Ccb,
354 IN ULONG NamedPipeEnd)
355{
356 PFILE_PIPE_INFORMATION InfoBuffer = Buffer;
357
358 *Length -= sizeof(*InfoBuffer);
359
360 RtlZeroMemory(InfoBuffer, sizeof(*InfoBuffer));
361
362 InfoBuffer->ReadMode = Ccb->ReadMode[NamedPipeEnd];
363 InfoBuffer->CompletionMode = Ccb->CompletionMode[NamedPipeEnd];
364
365 return STATUS_SUCCESS;
366}
367
369NTAPI
371 IN PIRP Irp)
372{
373 PIO_STACK_LOCATION IoStack;
374 NODE_TYPE_CODE NodeTypeCode;
375 ULONG NamedPipeEnd;
376 PNP_FCB Fcb;
377 PNP_CCB Ccb;
378 FILE_INFORMATION_CLASS InfoClass;
381 PFILE_ALL_INFORMATION AllInfo;
383 PAGED_CODE();
384
386 NodeTypeCode = NpDecodeFileObject(IoStack->FileObject,
387 (PVOID*)&Fcb,
388 &Ccb,
389 &NamedPipeEnd);
390 if (!NodeTypeCode) return STATUS_PIPE_DISCONNECTED;
391
392 Buffer = Irp->AssociatedIrp.SystemBuffer;
393 Length = IoStack->Parameters.QueryFile.Length;
394 InfoClass = IoStack->Parameters.QueryFile.FileInformationClass;
395
396 if (NodeTypeCode != NPFS_NTC_CCB)
397 {
398 if (NodeTypeCode != NPFS_NTC_ROOT_DCB || InfoClass != FileNameInformation)
399 {
401 }
402 }
403
404 switch (InfoClass)
405 {
408 break;
409
411 Status = NpQueryPositionInfo(Ccb, Buffer, &Length, NamedPipeEnd);
412 break;
413
415 Status = NpQueryPipeInfo(Fcb, Ccb, Buffer, &Length, NamedPipeEnd);
416 break;
417
419 Status = NpQueryPipeLocalInfo(Fcb, Ccb, Buffer, &Length, NamedPipeEnd);
420 break;
421
424 break;
425
427 Status = NpQueryStandardInfo(Ccb, Buffer, &Length, NamedPipeEnd);
428 break;
429
432 break;
433
435
437 AllInfo = (PFILE_ALL_INFORMATION)Buffer;
439 NpQueryStandardInfo(Ccb, &AllInfo->StandardInformation, &Length, NamedPipeEnd);
442 NpQueryPositionInfo(Ccb, &AllInfo->PositionInformation, &Length, NamedPipeEnd);
444 break;
445
448 break;
449
450 default:
452 break;
453 }
454
455 Irp->IoStatus.Information = IoStack->Parameters.QueryFile.Length - Length;
456 return Status;
457}
458
460NTAPI
462 IN PIRP Irp)
463{
465 PAGED_CODE();
466
469
471
472 NpReleaseVcb();
474
475 if (Status != STATUS_PENDING)
476 {
477 Irp->IoStatus.Status = Status;
479 }
480
481 return Status;
482}
483
484/* EOF */
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define PAGED_CODE()
struct NameRec_ * Name
Definition: cdprocs.h:460
LONG NTSTATUS
Definition: precomp.h:26
_In_ PFCB Fcb
Definition: cdprocs.h:159
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:592
Definition: bufpool.h:45
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
USHORT NODE_TYPE_CODE
Definition: nodetype.h:22
VOID NTAPI NpCheckForNotify(IN PNP_DCB Dcb, IN BOOLEAN SecondList, IN PLIST_ENTRY List)
Definition: create.c:20
NTSTATUS NTAPI NpSetPipeInfo(IN PNP_FCB Fcb, IN PNP_CCB Ccb, IN PFILE_PIPE_INFORMATION Buffer, IN ULONG NamedPipeEnd, IN PLIST_ENTRY List)
Definition: fileinfo.c:29
NTSTATUS NTAPI NpQueryEaInfo(IN PNP_CCB Ccb, IN PVOID Buffer, IN OUT PULONG Length)
Definition: fileinfo.c:200
NTSTATUS NTAPI NpQueryPipeLocalInfo(IN PNP_FCB Fcb, IN PNP_CCB Ccb, IN PVOID Buffer, IN OUT PULONG Length, IN ULONG NamedPipeEnd)
Definition: fileinfo.c:303
NTSTATUS NTAPI NpQueryPipeInfo(IN PNP_FCB Fcb, IN PNP_CCB Ccb, IN PVOID Buffer, IN OUT PULONG Length, IN ULONG NamedPipeEnd)
Definition: fileinfo.c:350
NTSTATUS NTAPI NpCommonSetInformation(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PLIST_ENTRY List)
Definition: fileinfo.c:80
NTSTATUS NTAPI NpQueryBasicInfo(IN PNP_CCB Ccb, IN PVOID Buffer, IN OUT PULONG Length)
Definition: fileinfo.c:143
NTSTATUS NTAPI NpQueryInternalInfo(IN PNP_CCB Ccb, IN PVOID Buffer, IN OUT PULONG Length)
Definition: fileinfo.c:256
NTSTATUS NTAPI NpFsdQueryInformation(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fileinfo.c:461
NTSTATUS NTAPI NpQueryPositionInfo(IN PNP_CCB Ccb, IN PVOID Buffer, IN OUT PULONG Length, IN ULONG NamedPipeEnd)
Definition: fileinfo.c:271
NTSTATUS NTAPI NpCommonQueryInformation(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fileinfo.c:370
NTSTATUS NTAPI NpSetBasicInfo(IN PNP_CCB Ccb, IN PFILE_BASIC_INFORMATION Buffer)
Definition: fileinfo.c:20
NTSTATUS NTAPI NpQueryNameInfo(IN PNP_CCB Ccb, IN PVOID Buffer, IN OUT PULONG Length)
Definition: fileinfo.c:215
NTSTATUS NTAPI NpFsdSetInformation(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fileinfo.c:114
NTSTATUS NTAPI NpQueryStandardInfo(IN PNP_CCB Ccb, IN PVOID Buffer, IN OUT PULONG Length, IN ULONG NamedPipeEnd)
Definition: fileinfo.c:159
FORCEINLINE VOID NpAcquireExclusiveVcb(VOID)
Definition: npfs.h:336
FORCEINLINE VOID NpReleaseVcb(VOID)
Definition: npfs.h:344
#define NPFS_NTC_ROOT_DCB_CCB
Definition: npfs.h:117
#define NPFS_NTC_ROOT_DCB
Definition: npfs.h:113
PNP_VCB NpVcb
Definition: strucsup.c:19
FORCEINLINE VOID NpAcquireSharedVcb(VOID)
Definition: npfs.h:328
@ ReadEntries
Definition: npfs.h:123
@ WriteEntries
Definition: npfs.h:124
#define NpBugCheck(p1, p2, p3)
Definition: npfs.h:106
FORCEINLINE VOID NpCompleteDeferredIrps(IN PLIST_ENTRY DeferredList)
Definition: npfs.h:356
#define NPFS_NTC_CCB
Definition: npfs.h:115
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
NODE_TYPE_CODE NTAPI NpDecodeFileObject(IN PFILE_OBJECT FileObject, OUT PVOID *PrimaryContext OPTIONAL, OUT PNP_CCB *Ccb, OUT PULONG NamedPipeEnd OPTIONAL)
Definition: fileobsup.c:20
@ FilePositionInformation
Definition: from_kernel.h:75
@ FilePipeLocalInformation
Definition: from_kernel.h:85
@ FileAllInformation
Definition: from_kernel.h:79
@ FileInternalInformation
Definition: from_kernel.h:67
@ FileEaInformation
Definition: from_kernel.h:68
@ FilePipeInformation
Definition: from_kernel.h:84
@ FileNameInformation
Definition: from_kernel.h:70
@ FileBasicInformation
Definition: from_kernel.h:65
enum _FILE_INFORMATION_CLASS FILE_INFORMATION_CLASS
Definition: directory.c:44
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
Status
Definition: gdiplustypes.h:25
struct _FILE_ALL_INFORMATION * PFILE_ALL_INFORMATION
#define FILE_PIPE_OUTBOUND
Definition: iotypes.h:82
#define FILE_PIPE_INBOUND
Definition: iotypes.h:81
#define FILE_PIPE_BYTE_STREAM_TYPE
Definition: iotypes.h:75
#define FILE_PIPE_CLIENT_END
Definition: iotypes.h:84
#define FILE_PIPE_COMPLETE_OPERATION
Definition: iotypes.h:80
#define FILE_PIPE_SERVER_END
Definition: iotypes.h:85
#define FILE_PIPE_MESSAGE_MODE
Definition: iotypes.h:78
struct _FILE_ALIGNMENT_INFORMATION FILE_ALIGNMENT_INFORMATION
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define IoCompleteRequest
Definition: irp.c:1240
#define STATUS_PIPE_DISCONNECTED
Definition: ntstatus.h:412
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_PIPE_BUSY
Definition: ntstatus.h:410
unsigned short USHORT
Definition: pedump.c:61
struct _FILE_ACCESS_INFORMATION FILE_ACCESS_INFORMATION
#define FileStandardInformation
Definition: propsheet.cpp:61
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
struct _FCB * ParentDcb
Definition: fatstruc.h:836
struct _FCB::@729::@732 Fcb
FILE_STANDARD_INFORMATION StandardInformation
Definition: winternl.h:797
FILE_EA_INFORMATION EaInformation
Definition: winternl.h:799
FILE_INTERNAL_INFORMATION InternalInformation
Definition: winternl.h:798
FILE_NAME_INFORMATION NameInformation
Definition: winternl.h:804
FILE_POSITION_INFORMATION PositionInformation
Definition: winternl.h:801
FILE_BASIC_INFORMATION BasicInformation
Definition: winternl.h:796
LARGE_INTEGER CurrentByteOffset
Definition: nt_native.h:955
LARGE_INTEGER AllocationSize
Definition: propsheet.cpp:54
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
struct _IO_STACK_LOCATION::@3974::@3983 QueryFile
union _IO_STACK_LOCATION::@1575 Parameters
Definition: typedefs.h:120
Definition: npfs.h:259
ULONG Quota
Definition: npfs.h:144
ULONG QueueState
Definition: npfs.h:139
ULONG QuotaUsed
Definition: npfs.h:142
ULONG BytesInQueue
Definition: npfs.h:140
ULONG ByteOffset
Definition: npfs.h:143
Definition: npfs.h:229
PNP_DCB RootDcb
Definition: npfs.h:281
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IN
Definition: typedefs.h:39
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONGLONG QuadPart
Definition: typedefs.h:114
ULONG LowPart
Definition: typedefs.h:106
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
#define IO_NAMED_PIPE_INCREMENT
Definition: iotypes.h:604