1c2c66affSColin Finck /*
2c2c66affSColin Finck * PROJECT: ReactOS Named Pipe FileSystem
3c2c66affSColin Finck * LICENSE: BSD - See COPYING.ARM in the top level directory
4c2c66affSColin Finck * FILE: drivers/filesystems/npfs/fileinfo.c
5c2c66affSColin Finck * PURPOSE: Pipes Information
6c2c66affSColin Finck * PROGRAMMERS: ReactOS Portable Systems Group
7c2c66affSColin Finck */
8c2c66affSColin Finck
9c2c66affSColin Finck /* INCLUDES *******************************************************************/
10c2c66affSColin Finck
11c2c66affSColin Finck #include "npfs.h"
12c2c66affSColin Finck
13c2c66affSColin Finck // File ID number for NPFS bugchecking support
14c2c66affSColin Finck #define NPFS_BUGCHECK_FILE_ID (NPFS_BUGCHECK_FILEINFO)
15c2c66affSColin Finck
16c2c66affSColin Finck /* FUNCTIONS ******************************************************************/
17c2c66affSColin Finck
18c2c66affSColin Finck NTSTATUS
19c2c66affSColin Finck NTAPI
NpSetBasicInfo(IN PNP_CCB Ccb,IN PFILE_BASIC_INFORMATION Buffer)20c2c66affSColin Finck NpSetBasicInfo(IN PNP_CCB Ccb,
21c2c66affSColin Finck IN PFILE_BASIC_INFORMATION Buffer)
22c2c66affSColin Finck {
23c2c66affSColin Finck PAGED_CODE();
24c2c66affSColin Finck return STATUS_SUCCESS;
25c2c66affSColin Finck }
26c2c66affSColin Finck
27c2c66affSColin Finck NTSTATUS
28c2c66affSColin Finck NTAPI
NpSetPipeInfo(IN PNP_FCB Fcb,IN PNP_CCB Ccb,IN PFILE_PIPE_INFORMATION Buffer,IN ULONG NamedPipeEnd,IN PLIST_ENTRY List)29c2c66affSColin Finck NpSetPipeInfo(IN PNP_FCB Fcb,
30c2c66affSColin Finck IN PNP_CCB Ccb,
31c2c66affSColin Finck IN PFILE_PIPE_INFORMATION Buffer,
32c2c66affSColin Finck IN ULONG NamedPipeEnd,
33c2c66affSColin Finck IN PLIST_ENTRY List)
34c2c66affSColin Finck {
35c2c66affSColin Finck NTSTATUS Status;
36c2c66affSColin Finck PNP_DATA_QUEUE ReadQueue, WriteQueue;
37c2c66affSColin Finck PAGED_CODE();
38c2c66affSColin Finck
39c2c66affSColin Finck if (Buffer->ReadMode == FILE_PIPE_MESSAGE_MODE && Fcb->NamedPipeType == FILE_PIPE_BYTE_STREAM_TYPE)
40c2c66affSColin Finck {
41c2c66affSColin Finck return STATUS_INVALID_PARAMETER;
42c2c66affSColin Finck }
43c2c66affSColin Finck
44c2c66affSColin Finck if (NamedPipeEnd != FILE_PIPE_CLIENT_END)
45c2c66affSColin Finck {
46c2c66affSColin Finck if (NamedPipeEnd != FILE_PIPE_SERVER_END)
47c2c66affSColin Finck {
48c2c66affSColin Finck NpBugCheck(NamedPipeEnd, 0, 0);
49c2c66affSColin Finck }
50c2c66affSColin Finck ReadQueue = &Ccb->DataQueue[FILE_PIPE_INBOUND];
51c2c66affSColin Finck WriteQueue = &Ccb->DataQueue[FILE_PIPE_OUTBOUND];
52c2c66affSColin Finck }
53c2c66affSColin Finck else
54c2c66affSColin Finck {
55c2c66affSColin Finck ReadQueue = &Ccb->DataQueue[FILE_PIPE_OUTBOUND];
56c2c66affSColin Finck WriteQueue = &Ccb->DataQueue[FILE_PIPE_INBOUND];
57c2c66affSColin Finck }
58c2c66affSColin Finck
59c2c66affSColin Finck if (Buffer->CompletionMode != FILE_PIPE_COMPLETE_OPERATION ||
60c2c66affSColin Finck Ccb->CompletionMode[NamedPipeEnd] == FILE_PIPE_COMPLETE_OPERATION ||
61c2c66affSColin Finck (ReadQueue->QueueState != ReadEntries &&
62c2c66affSColin Finck WriteQueue->QueueState != WriteEntries))
63c2c66affSColin Finck {
64c2c66affSColin Finck Ccb->ReadMode[NamedPipeEnd] = Buffer->ReadMode & 0xFF;
65c2c66affSColin Finck Ccb->CompletionMode[NamedPipeEnd] = Buffer->CompletionMode & 0xFF;
66c2c66affSColin Finck
67c2c66affSColin Finck NpCheckForNotify(Fcb->ParentDcb, FALSE, List);
68c2c66affSColin Finck Status = STATUS_SUCCESS;
69c2c66affSColin Finck }
70c2c66affSColin Finck else
71c2c66affSColin Finck {
72c2c66affSColin Finck Status = STATUS_PIPE_BUSY;
73c2c66affSColin Finck }
74c2c66affSColin Finck
75c2c66affSColin Finck return Status;
76c2c66affSColin Finck }
77c2c66affSColin Finck
78c2c66affSColin Finck NTSTATUS
79c2c66affSColin Finck NTAPI
NpCommonSetInformation(IN PDEVICE_OBJECT DeviceObject,IN PIRP Irp,IN PLIST_ENTRY List)80c2c66affSColin Finck NpCommonSetInformation(IN PDEVICE_OBJECT DeviceObject,
81c2c66affSColin Finck IN PIRP Irp,
82c2c66affSColin Finck IN PLIST_ENTRY List)
83c2c66affSColin Finck {
84c2c66affSColin Finck NODE_TYPE_CODE NodeTypeCode;
85c2c66affSColin Finck PIO_STACK_LOCATION IoStack;
86c2c66affSColin Finck ULONG InfoClass;
87c2c66affSColin Finck PVOID Buffer;
88c2c66affSColin Finck PNP_FCB Fcb;
89c2c66affSColin Finck PNP_CCB Ccb;
90c2c66affSColin Finck ULONG NamedPipeEnd;
91c2c66affSColin Finck PAGED_CODE();
92c2c66affSColin Finck
93c2c66affSColin Finck IoStack = IoGetCurrentIrpStackLocation(Irp);
94c2c66affSColin Finck
95c2c66affSColin Finck NodeTypeCode = NpDecodeFileObject(IoStack->FileObject,
96c2c66affSColin Finck (PVOID*)&Fcb,
97c2c66affSColin Finck &Ccb,
98c2c66affSColin Finck &NamedPipeEnd);
99c2c66affSColin Finck if (!NodeTypeCode) return STATUS_PIPE_DISCONNECTED;
100c2c66affSColin Finck if (NodeTypeCode != NPFS_NTC_CCB) return STATUS_INVALID_PARAMETER;
101c2c66affSColin Finck
102c2c66affSColin Finck InfoClass = IoStack->Parameters.QueryFile.FileInformationClass;
103c2c66affSColin Finck Buffer = Irp->AssociatedIrp.SystemBuffer;
104c2c66affSColin Finck
105c2c66affSColin Finck if (InfoClass == FileBasicInformation) return NpSetBasicInfo(Ccb, Buffer);
106c2c66affSColin Finck
107c2c66affSColin Finck if (InfoClass != FilePipeInformation) return STATUS_INVALID_PARAMETER;
108c2c66affSColin Finck
109c2c66affSColin Finck return NpSetPipeInfo(Fcb, Ccb, Buffer, NamedPipeEnd, List);
110c2c66affSColin Finck }
111c2c66affSColin Finck
112c2c66affSColin Finck NTSTATUS
113c2c66affSColin Finck NTAPI
NpFsdSetInformation(IN PDEVICE_OBJECT DeviceObject,IN PIRP Irp)114c2c66affSColin Finck NpFsdSetInformation(IN PDEVICE_OBJECT DeviceObject,
115c2c66affSColin Finck IN PIRP Irp)
116c2c66affSColin Finck {
117c2c66affSColin Finck NTSTATUS Status;
118c2c66affSColin Finck LIST_ENTRY DeferredList;
119c2c66affSColin Finck PAGED_CODE();
120c2c66affSColin Finck
121c2c66affSColin Finck InitializeListHead(&DeferredList);
122c2c66affSColin Finck
123c2c66affSColin Finck FsRtlEnterFileSystem();
124c2c66affSColin Finck NpAcquireExclusiveVcb();
125c2c66affSColin Finck
126c2c66affSColin Finck Status = NpCommonSetInformation(DeviceObject, Irp, &DeferredList);
127c2c66affSColin Finck
128c2c66affSColin Finck NpReleaseVcb();
129c2c66affSColin Finck NpCompleteDeferredIrps(&DeferredList);
130c2c66affSColin Finck FsRtlExitFileSystem();
131c2c66affSColin Finck
132c2c66affSColin Finck if (Status != STATUS_PENDING)
133c2c66affSColin Finck {
134c2c66affSColin Finck Irp->IoStatus.Status = Status;
135c2c66affSColin Finck IoCompleteRequest(Irp, IO_NAMED_PIPE_INCREMENT);
136c2c66affSColin Finck }
137c2c66affSColin Finck
138c2c66affSColin Finck return Status;
139c2c66affSColin Finck }
140c2c66affSColin Finck
141c2c66affSColin Finck NTSTATUS
142c2c66affSColin Finck NTAPI
NpQueryBasicInfo(IN PNP_CCB Ccb,IN PVOID Buffer,IN OUT PULONG Length)143c2c66affSColin Finck NpQueryBasicInfo(IN PNP_CCB Ccb,
144c2c66affSColin Finck IN PVOID Buffer,
145c2c66affSColin Finck IN OUT PULONG Length)
146c2c66affSColin Finck {
147c2c66affSColin Finck PFILE_BASIC_INFORMATION InfoBuffer = Buffer;
148c2c66affSColin Finck
149c2c66affSColin Finck *Length -= sizeof(*InfoBuffer);
150c2c66affSColin Finck
151c2c66affSColin Finck RtlZeroMemory(InfoBuffer, sizeof(*InfoBuffer));
152c2c66affSColin Finck InfoBuffer->FileAttributes = FILE_ATTRIBUTE_NORMAL;
153c2c66affSColin Finck
154c2c66affSColin Finck return STATUS_SUCCESS;
155c2c66affSColin Finck }
156c2c66affSColin Finck
157c2c66affSColin Finck NTSTATUS
158c2c66affSColin Finck NTAPI
NpQueryStandardInfo(IN PNP_CCB Ccb,IN PVOID Buffer,IN OUT PULONG Length,IN ULONG NamedPipeEnd)159c2c66affSColin Finck NpQueryStandardInfo(IN PNP_CCB Ccb,
160c2c66affSColin Finck IN PVOID Buffer,
161c2c66affSColin Finck IN OUT PULONG Length,
162c2c66affSColin Finck IN ULONG NamedPipeEnd)
163c2c66affSColin Finck {
164c2c66affSColin Finck PNP_DATA_QUEUE DataQueue;
165c2c66affSColin Finck PFILE_STANDARD_INFORMATION InfoBuffer = Buffer;
166c2c66affSColin Finck
167c2c66affSColin Finck *Length -= sizeof(*InfoBuffer);
168c2c66affSColin Finck
169c2c66affSColin Finck RtlZeroMemory(InfoBuffer, sizeof(*InfoBuffer));
170c2c66affSColin Finck
171c2c66affSColin Finck if (NamedPipeEnd == FILE_PIPE_SERVER_END)
172c2c66affSColin Finck {
173c2c66affSColin Finck DataQueue = &Ccb->DataQueue[FILE_PIPE_INBOUND];
174c2c66affSColin Finck }
175c2c66affSColin Finck else
176c2c66affSColin Finck {
177c2c66affSColin Finck DataQueue = &Ccb->DataQueue[FILE_PIPE_OUTBOUND];
178c2c66affSColin Finck }
179c2c66affSColin Finck
180c2c66affSColin Finck InfoBuffer->AllocationSize.LowPart = Ccb->DataQueue[FILE_PIPE_INBOUND].Quota +
181c2c66affSColin Finck Ccb->DataQueue[FILE_PIPE_OUTBOUND].Quota;
182c2c66affSColin Finck InfoBuffer->AllocationSize.HighPart = 0;
183c2c66affSColin Finck
184c2c66affSColin Finck if (DataQueue->QueueState == WriteEntries)
185c2c66affSColin Finck {
186c2c66affSColin Finck InfoBuffer->EndOfFile.HighPart = 0;
187c2c66affSColin Finck InfoBuffer->EndOfFile.LowPart = DataQueue->BytesInQueue -
188c2c66affSColin Finck DataQueue->ByteOffset;
189c2c66affSColin Finck }
190c2c66affSColin Finck
191c2c66affSColin Finck InfoBuffer->Directory = FALSE;
192c2c66affSColin Finck InfoBuffer->NumberOfLinks = 1;
193c2c66affSColin Finck InfoBuffer->DeletePending = TRUE;
194c2c66affSColin Finck
195c2c66affSColin Finck return STATUS_SUCCESS;
196c2c66affSColin Finck }
197c2c66affSColin Finck
198c2c66affSColin Finck NTSTATUS
199c2c66affSColin Finck NTAPI
NpQueryEaInfo(IN PNP_CCB Ccb,IN PVOID Buffer,IN OUT PULONG Length)200c2c66affSColin Finck NpQueryEaInfo(IN PNP_CCB Ccb,
201c2c66affSColin Finck IN PVOID Buffer,
202c2c66affSColin Finck IN OUT PULONG Length)
203c2c66affSColin Finck {
204c2c66affSColin Finck PFILE_EA_INFORMATION InfoBuffer = Buffer;
205c2c66affSColin Finck
206c2c66affSColin Finck *Length -= sizeof(*InfoBuffer);
207c2c66affSColin Finck
208c2c66affSColin Finck RtlZeroMemory(InfoBuffer, sizeof(*InfoBuffer));
209c2c66affSColin Finck
210c2c66affSColin Finck return STATUS_SUCCESS;
211c2c66affSColin Finck }
212c2c66affSColin Finck
213c2c66affSColin Finck NTSTATUS
214c2c66affSColin Finck NTAPI
NpQueryNameInfo(IN PNP_CCB Ccb,IN PVOID Buffer,IN OUT PULONG Length)215c2c66affSColin Finck NpQueryNameInfo(IN PNP_CCB Ccb,
216c2c66affSColin Finck IN PVOID Buffer,
217c2c66affSColin Finck IN OUT PULONG Length)
218c2c66affSColin Finck {
219c2c66affSColin Finck PFILE_NAME_INFORMATION InfoBuffer = Buffer;
220c2c66affSColin Finck USHORT NameLength;
221c2c66affSColin Finck NTSTATUS Status;
222c2c66affSColin Finck PWCHAR Name;
223c2c66affSColin Finck
224c2c66affSColin Finck *Length -= sizeof(*InfoBuffer);
225c2c66affSColin Finck
226c2c66affSColin Finck if (Ccb->NodeType == NPFS_NTC_ROOT_DCB_CCB)
227c2c66affSColin Finck {
228c2c66affSColin Finck NameLength = NpVcb->RootDcb->FullName.Length;
229c2c66affSColin Finck Name = NpVcb->RootDcb->FullName.Buffer;
230c2c66affSColin Finck }
231c2c66affSColin Finck else
232c2c66affSColin Finck {
233c2c66affSColin Finck NameLength = Ccb->Fcb->FullName.Length;
234c2c66affSColin Finck Name = Ccb->Fcb->FullName.Buffer;
235c2c66affSColin Finck }
236c2c66affSColin Finck
237c2c66affSColin Finck if (*Length < NameLength)
238c2c66affSColin Finck {
239c2c66affSColin Finck Status = STATUS_BUFFER_OVERFLOW;
240c2c66affSColin Finck NameLength = (USHORT)*Length;
241c2c66affSColin Finck }
242c2c66affSColin Finck else
243c2c66affSColin Finck {
244c2c66affSColin Finck Status = STATUS_SUCCESS;
245c2c66affSColin Finck }
246c2c66affSColin Finck
247c2c66affSColin Finck RtlCopyMemory(InfoBuffer->FileName, Name, NameLength);
248c2c66affSColin Finck InfoBuffer->FileNameLength = NameLength;
249c2c66affSColin Finck
250c2c66affSColin Finck *Length -= NameLength;
251c2c66affSColin Finck return Status;
252c2c66affSColin Finck }
253c2c66affSColin Finck
254c2c66affSColin Finck NTSTATUS
255c2c66affSColin Finck NTAPI
NpQueryInternalInfo(IN PNP_CCB Ccb,IN PVOID Buffer,IN OUT PULONG Length)256c2c66affSColin Finck NpQueryInternalInfo(IN PNP_CCB Ccb,
257c2c66affSColin Finck IN PVOID Buffer,
258c2c66affSColin Finck IN OUT PULONG Length)
259c2c66affSColin Finck {
260c2c66affSColin Finck PFILE_INTERNAL_INFORMATION InfoBuffer = Buffer;
261c2c66affSColin Finck
262c2c66affSColin Finck *Length -= sizeof(*InfoBuffer);
263c2c66affSColin Finck
264c2c66affSColin Finck RtlZeroMemory(InfoBuffer, sizeof(*InfoBuffer));
265c2c66affSColin Finck
266c2c66affSColin Finck return STATUS_SUCCESS;
267c2c66affSColin Finck }
268c2c66affSColin Finck
269c2c66affSColin Finck NTSTATUS
270c2c66affSColin Finck NTAPI
NpQueryPositionInfo(IN PNP_CCB Ccb,IN PVOID Buffer,IN OUT PULONG Length,IN ULONG NamedPipeEnd)271c2c66affSColin Finck NpQueryPositionInfo(IN PNP_CCB Ccb,
272c2c66affSColin Finck IN PVOID Buffer,
273c2c66affSColin Finck IN OUT PULONG Length,
274c2c66affSColin Finck IN ULONG NamedPipeEnd)
275c2c66affSColin Finck {
276c2c66affSColin Finck PNP_DATA_QUEUE DataQueue;
277c2c66affSColin Finck PFILE_POSITION_INFORMATION InfoBuffer = Buffer;
278c2c66affSColin Finck
279c2c66affSColin Finck *Length -= sizeof(*InfoBuffer);
280c2c66affSColin Finck
281c2c66affSColin Finck RtlZeroMemory(InfoBuffer, sizeof(*InfoBuffer));
282c2c66affSColin Finck
283c2c66affSColin Finck if (NamedPipeEnd == FILE_PIPE_SERVER_END)
284c2c66affSColin Finck {
285c2c66affSColin Finck DataQueue = &Ccb->DataQueue[FILE_PIPE_INBOUND];
286c2c66affSColin Finck }
287c2c66affSColin Finck else
288c2c66affSColin Finck {
289c2c66affSColin Finck DataQueue = &Ccb->DataQueue[FILE_PIPE_OUTBOUND];
290c2c66affSColin Finck }
291c2c66affSColin Finck
292c2c66affSColin Finck if (DataQueue->QueueState == WriteEntries)
293c2c66affSColin Finck {
294c2c66affSColin Finck InfoBuffer->CurrentByteOffset.QuadPart = DataQueue->BytesInQueue -
295c2c66affSColin Finck DataQueue->ByteOffset;
296c2c66affSColin Finck }
297c2c66affSColin Finck
298c2c66affSColin Finck return STATUS_SUCCESS;
299c2c66affSColin Finck }
300c2c66affSColin Finck
301c2c66affSColin Finck NTSTATUS
302c2c66affSColin Finck NTAPI
NpQueryPipeLocalInfo(IN PNP_FCB Fcb,IN PNP_CCB Ccb,IN PVOID Buffer,IN OUT PULONG Length,IN ULONG NamedPipeEnd)303c2c66affSColin Finck NpQueryPipeLocalInfo(IN PNP_FCB Fcb,
304c2c66affSColin Finck IN PNP_CCB Ccb,
305c2c66affSColin Finck IN PVOID Buffer,
306c2c66affSColin Finck IN OUT PULONG Length,
307c2c66affSColin Finck IN ULONG NamedPipeEnd)
308c2c66affSColin Finck {
309c2c66affSColin Finck PFILE_PIPE_LOCAL_INFORMATION InfoBuffer = Buffer;
310c2c66affSColin Finck PNP_DATA_QUEUE InQueue, OutQueue;
311c2c66affSColin Finck
312c2c66affSColin Finck *Length -= sizeof(*InfoBuffer);
313c2c66affSColin Finck
314c2c66affSColin Finck RtlZeroMemory(InfoBuffer, sizeof(*InfoBuffer));
315c2c66affSColin Finck
316c2c66affSColin Finck InQueue = &Ccb->DataQueue[FILE_PIPE_INBOUND];
317c2c66affSColin Finck OutQueue = &Ccb->DataQueue[FILE_PIPE_OUTBOUND];
318c2c66affSColin Finck
319c2c66affSColin Finck InfoBuffer->NamedPipeType = Fcb->NamedPipeType;
320c2c66affSColin Finck InfoBuffer->NamedPipeConfiguration = Fcb->NamedPipeConfiguration;
321c2c66affSColin Finck InfoBuffer->MaximumInstances = Fcb->MaximumInstances;
322c2c66affSColin Finck InfoBuffer->CurrentInstances = Fcb->CurrentInstances;
323c2c66affSColin Finck InfoBuffer->InboundQuota = InQueue->Quota;
324c2c66affSColin Finck InfoBuffer->OutboundQuota = OutQueue->Quota;
325c2c66affSColin Finck InfoBuffer->NamedPipeState = Ccb->NamedPipeState;
326c2c66affSColin Finck InfoBuffer->NamedPipeEnd = NamedPipeEnd;
327c2c66affSColin Finck
328c2c66affSColin Finck if (NamedPipeEnd == FILE_PIPE_SERVER_END)
329c2c66affSColin Finck {
330c2c66affSColin Finck if (InQueue->QueueState == WriteEntries)
331c2c66affSColin Finck {
332c2c66affSColin Finck InfoBuffer->ReadDataAvailable = InQueue->BytesInQueue - InQueue->ByteOffset;
333c2c66affSColin Finck }
334c2c66affSColin Finck InfoBuffer->WriteQuotaAvailable = OutQueue->Quota - OutQueue->QuotaUsed;
335c2c66affSColin Finck }
336c2c66affSColin Finck else
337c2c66affSColin Finck {
338c2c66affSColin Finck if (OutQueue->QueueState == WriteEntries)
339c2c66affSColin Finck {
340c2c66affSColin Finck InfoBuffer->ReadDataAvailable = OutQueue->BytesInQueue - OutQueue->ByteOffset;
341c2c66affSColin Finck }
342c2c66affSColin Finck InfoBuffer->WriteQuotaAvailable = OutQueue->Quota - InQueue->QuotaUsed;
343c2c66affSColin Finck }
344c2c66affSColin Finck
345c2c66affSColin Finck return STATUS_SUCCESS;
346c2c66affSColin Finck }
347c2c66affSColin Finck
348c2c66affSColin Finck NTSTATUS
349c2c66affSColin Finck NTAPI
NpQueryPipeInfo(IN PNP_FCB Fcb,IN PNP_CCB Ccb,IN PVOID Buffer,IN OUT PULONG Length,IN ULONG NamedPipeEnd)350c2c66affSColin Finck NpQueryPipeInfo(IN PNP_FCB Fcb,
351c2c66affSColin Finck IN PNP_CCB Ccb,
352c2c66affSColin Finck IN PVOID Buffer,
353c2c66affSColin Finck IN OUT PULONG Length,
354c2c66affSColin Finck IN ULONG NamedPipeEnd)
355c2c66affSColin Finck {
356c2c66affSColin Finck PFILE_PIPE_INFORMATION InfoBuffer = Buffer;
357c2c66affSColin Finck
358c2c66affSColin Finck *Length -= sizeof(*InfoBuffer);
359c2c66affSColin Finck
360c2c66affSColin Finck RtlZeroMemory(InfoBuffer, sizeof(*InfoBuffer));
361c2c66affSColin Finck
362c2c66affSColin Finck InfoBuffer->ReadMode = Ccb->ReadMode[NamedPipeEnd];
363c2c66affSColin Finck InfoBuffer->CompletionMode = Ccb->CompletionMode[NamedPipeEnd];
364c2c66affSColin Finck
365c2c66affSColin Finck return STATUS_SUCCESS;
366c2c66affSColin Finck }
367c2c66affSColin Finck
368c2c66affSColin Finck NTSTATUS
369c2c66affSColin Finck NTAPI
NpCommonQueryInformation(IN PDEVICE_OBJECT DeviceObject,IN PIRP Irp)370c2c66affSColin Finck NpCommonQueryInformation(IN PDEVICE_OBJECT DeviceObject,
371c2c66affSColin Finck IN PIRP Irp)
372c2c66affSColin Finck {
373c2c66affSColin Finck PIO_STACK_LOCATION IoStack;
374c2c66affSColin Finck NODE_TYPE_CODE NodeTypeCode;
375c2c66affSColin Finck ULONG NamedPipeEnd;
376c2c66affSColin Finck PNP_FCB Fcb;
377c2c66affSColin Finck PNP_CCB Ccb;
378c2c66affSColin Finck FILE_INFORMATION_CLASS InfoClass;
379c2c66affSColin Finck ULONG Length;
380c2c66affSColin Finck PVOID Buffer;
381c2c66affSColin Finck PFILE_ALL_INFORMATION AllInfo;
382c2c66affSColin Finck NTSTATUS Status;
383c2c66affSColin Finck PAGED_CODE();
384c2c66affSColin Finck
385c2c66affSColin Finck IoStack = IoGetCurrentIrpStackLocation(Irp);
386c2c66affSColin Finck NodeTypeCode = NpDecodeFileObject(IoStack->FileObject,
387c2c66affSColin Finck (PVOID*)&Fcb,
388c2c66affSColin Finck &Ccb,
389c2c66affSColin Finck &NamedPipeEnd);
390c2c66affSColin Finck if (!NodeTypeCode) return STATUS_PIPE_DISCONNECTED;
391c2c66affSColin Finck
392c2c66affSColin Finck Buffer = Irp->AssociatedIrp.SystemBuffer;
393c2c66affSColin Finck Length = IoStack->Parameters.QueryFile.Length;
394c2c66affSColin Finck InfoClass = IoStack->Parameters.QueryFile.FileInformationClass;
395c2c66affSColin Finck
396c2c66affSColin Finck if (NodeTypeCode != NPFS_NTC_CCB)
397c2c66affSColin Finck {
398c2c66affSColin Finck if (NodeTypeCode != NPFS_NTC_ROOT_DCB || InfoClass != FileNameInformation)
399c2c66affSColin Finck {
400c2c66affSColin Finck return STATUS_INVALID_PARAMETER;
401c2c66affSColin Finck }
402c2c66affSColin Finck }
403c2c66affSColin Finck
404c2c66affSColin Finck switch (InfoClass)
405c2c66affSColin Finck {
406c2c66affSColin Finck case FileNameInformation:
407c2c66affSColin Finck Status = NpQueryNameInfo(Ccb, Buffer, &Length);
408c2c66affSColin Finck break;
409c2c66affSColin Finck
410c2c66affSColin Finck case FilePositionInformation:
411c2c66affSColin Finck Status = NpQueryPositionInfo(Ccb, Buffer, &Length, NamedPipeEnd);
412c2c66affSColin Finck break;
413c2c66affSColin Finck
414c2c66affSColin Finck case FilePipeInformation:
415c2c66affSColin Finck Status = NpQueryPipeInfo(Fcb, Ccb, Buffer, &Length, NamedPipeEnd);
416c2c66affSColin Finck break;
417c2c66affSColin Finck
418c2c66affSColin Finck case FilePipeLocalInformation:
419c2c66affSColin Finck Status = NpQueryPipeLocalInfo(Fcb, Ccb, Buffer, &Length, NamedPipeEnd);
420c2c66affSColin Finck break;
421c2c66affSColin Finck
422c2c66affSColin Finck case FileBasicInformation:
423c2c66affSColin Finck Status = NpQueryBasicInfo(Ccb, Buffer, &Length);
424c2c66affSColin Finck break;
425c2c66affSColin Finck
426c2c66affSColin Finck case FileStandardInformation:
427c2c66affSColin Finck Status = NpQueryStandardInfo(Ccb, Buffer, &Length, NamedPipeEnd);
428c2c66affSColin Finck break;
429c2c66affSColin Finck
430c2c66affSColin Finck case FileInternalInformation:
431c2c66affSColin Finck Status = NpQueryInternalInfo(Ccb, Buffer, &Length);
432c2c66affSColin Finck break;
433c2c66affSColin Finck
434c2c66affSColin Finck case FileAllInformation:
435c2c66affSColin Finck
436*67592f97SThomas Faber Length -= sizeof(FILE_ACCESS_INFORMATION) + sizeof(FILE_MODE_INFORMATION) + sizeof(FILE_ALIGNMENT_INFORMATION);
437c2c66affSColin Finck AllInfo = (PFILE_ALL_INFORMATION)Buffer;
438c2c66affSColin Finck NpQueryBasicInfo(Ccb, &AllInfo->BasicInformation, &Length);
439c2c66affSColin Finck NpQueryStandardInfo(Ccb, &AllInfo->StandardInformation, &Length, NamedPipeEnd);
440c2c66affSColin Finck NpQueryInternalInfo(Ccb, &AllInfo->InternalInformation, &Length);
441c2c66affSColin Finck NpQueryEaInfo(Ccb, &AllInfo->EaInformation, &Length);
442c2c66affSColin Finck NpQueryPositionInfo(Ccb, &AllInfo->PositionInformation, &Length, NamedPipeEnd);
443c2c66affSColin Finck Status = NpQueryNameInfo(Ccb, &AllInfo->NameInformation, &Length);
444c2c66affSColin Finck break;
445c2c66affSColin Finck
446c2c66affSColin Finck case FileEaInformation:
447c2c66affSColin Finck Status = NpQueryEaInfo(Ccb, Buffer, &Length);
448c2c66affSColin Finck break;
449c2c66affSColin Finck
450c2c66affSColin Finck default:
451c2c66affSColin Finck Status = STATUS_INVALID_PARAMETER;
452c2c66affSColin Finck break;
453c2c66affSColin Finck }
454c2c66affSColin Finck
455*67592f97SThomas Faber Irp->IoStatus.Information = IoStack->Parameters.QueryFile.Length - Length;
456c2c66affSColin Finck return Status;
457c2c66affSColin Finck }
458c2c66affSColin Finck
459c2c66affSColin Finck NTSTATUS
460c2c66affSColin Finck NTAPI
NpFsdQueryInformation(IN PDEVICE_OBJECT DeviceObject,IN PIRP Irp)461c2c66affSColin Finck NpFsdQueryInformation(IN PDEVICE_OBJECT DeviceObject,
462c2c66affSColin Finck IN PIRP Irp)
463c2c66affSColin Finck {
464c2c66affSColin Finck NTSTATUS Status;
465c2c66affSColin Finck PAGED_CODE();
466c2c66affSColin Finck
467c2c66affSColin Finck FsRtlEnterFileSystem();
468c2c66affSColin Finck NpAcquireSharedVcb();
469c2c66affSColin Finck
470c2c66affSColin Finck Status = NpCommonQueryInformation(DeviceObject, Irp);
471c2c66affSColin Finck
472c2c66affSColin Finck NpReleaseVcb();
473c2c66affSColin Finck FsRtlExitFileSystem();
474c2c66affSColin Finck
475c2c66affSColin Finck if (Status != STATUS_PENDING)
476c2c66affSColin Finck {
477c2c66affSColin Finck Irp->IoStatus.Status = Status;
478c2c66affSColin Finck IoCompleteRequest(Irp, IO_NAMED_PIPE_INCREMENT);
479c2c66affSColin Finck }
480c2c66affSColin Finck
481c2c66affSColin Finck return Status;
482c2c66affSColin Finck }
483c2c66affSColin Finck
484c2c66affSColin Finck /* EOF */
485