- Update to r53061
[reactos.git] / drivers / serial / serial / info.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: Serial port driver
4 * FILE: drivers/dd/serial/info.c
5 * PURPOSE: Serial IRP_MJ_QUERY_INFORMATION operations
6 *
7 * PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org)
8 */
9
10 #include "serial.h"
11
12 NTSTATUS NTAPI
13 SerialQueryInformation(
14 IN PDEVICE_OBJECT DeviceObject,
15 IN PIRP Irp)
16 {
17 PSERIAL_DEVICE_EXTENSION DeviceExtension;
18 PIO_STACK_LOCATION Stack;
19 PVOID SystemBuffer;
20 ULONG BufferLength;
21 ULONG_PTR Information = 0;
22 NTSTATUS Status;
23
24 DeviceExtension = (PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
25 Stack = IoGetCurrentIrpStackLocation(Irp);
26 SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
27 BufferLength = Stack->Parameters.QueryFile.Length;
28
29 switch (Stack->Parameters.QueryFile.FileInformationClass)
30 {
31 case FileStandardInformation:
32 {
33 PFILE_STANDARD_INFORMATION StandardInfo = (PFILE_STANDARD_INFORMATION)SystemBuffer;
34
35 TRACE_(SERIAL, "IRP_MJ_QUERY_INFORMATION / FileStandardInformation\n");
36 if (BufferLength < sizeof(FILE_STANDARD_INFORMATION))
37 Status = STATUS_BUFFER_OVERFLOW;
38 else if (!StandardInfo)
39 Status = STATUS_INVALID_PARAMETER;
40 else
41 {
42 StandardInfo->AllocationSize.QuadPart = 0;
43 StandardInfo->EndOfFile.QuadPart = 0;
44 StandardInfo->Directory = FALSE;
45 StandardInfo->NumberOfLinks = 0;
46 StandardInfo->DeletePending = FALSE; /* FIXME: should be TRUE sometimes */
47 Information = sizeof(FILE_STANDARD_INFORMATION);
48 Status = STATUS_SUCCESS;
49 }
50 break;
51 }
52 case FilePositionInformation:
53 {
54 PFILE_POSITION_INFORMATION PositionInfo = (PFILE_POSITION_INFORMATION)SystemBuffer;
55
56 ASSERT(PositionInfo);
57
58 TRACE_(SERIAL, "IRP_MJ_QUERY_INFORMATION / FilePositionInformation\n");
59 if (BufferLength < sizeof(FILE_POSITION_INFORMATION))
60 Status = STATUS_BUFFER_OVERFLOW;
61 else if (!PositionInfo)
62 Status = STATUS_INVALID_PARAMETER;
63 else
64 {
65 PositionInfo->CurrentByteOffset.QuadPart = 0;
66 Information = sizeof(FILE_POSITION_INFORMATION);
67 Status = STATUS_SUCCESS;
68 }
69 break;
70 }
71 default:
72 {
73 TRACE_(SERIAL, "IRP_MJ_QUERY_INFORMATION: Unexpected file information class 0x%02x\n", Stack->Parameters.QueryFile.FileInformationClass);
74 return ForwardIrpAndForget(DeviceObject, Irp);
75 }
76 }
77
78 Irp->IoStatus.Information = Information;
79 Irp->IoStatus.Status = Status;
80 IoCompleteRequest(Irp, IO_NO_INCREMENT);
81 return Status;
82 }