Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

223 lines
5.2 KiB

  1. /*++
  2. Copyright (c) 1991, 1992, 1993 - 1997 Microsoft Corporation
  3. Module Name:
  4. qsfile.c
  5. Abstract:
  6. This module contains the code that is very specific to query/set file
  7. operations in the serial driver.
  8. Author:
  9. Anthony V. Ercolano 26-Sep-1991
  10. Environment:
  11. Kernel mode
  12. --*/
  13. #include "precomp.h"
  14. #ifdef ALLOC_PRAGMA
  15. #pragma alloc_text(PAGESRP0,SerialQueryInformationFile)
  16. #pragma alloc_text(PAGESRP0,SerialSetInformationFile)
  17. #endif
  18. NTSTATUS
  19. SerialQueryInformationFile(
  20. IN PDEVICE_OBJECT DeviceObject,
  21. IN PIRP Irp
  22. )
  23. /*++
  24. Routine Description:
  25. This routine is used to query the end of file information on
  26. the opened serial port. Any other file information request
  27. is retured with an invalid parameter.
  28. This routine always returns an end of file of 0.
  29. Arguments:
  30. DeviceObject - Pointer to the device object for this device
  31. Irp - Pointer to the IRP for the current request
  32. Return Value:
  33. The function value is the final status of the call
  34. --*/
  35. {
  36. //
  37. // The status that gets returned to the caller and
  38. // set in the Irp.
  39. //
  40. NTSTATUS Status;
  41. //
  42. // The current stack location. This contains all of the
  43. // information we need to process this particular request.
  44. //
  45. PIO_STACK_LOCATION IrpSp;
  46. NTSTATUS status;
  47. UNREFERENCED_PARAMETER(DeviceObject);
  48. PAGED_CODE();
  49. if ((status = SerialIRPPrologue(Irp,
  50. (PSERIAL_DEVICE_EXTENSION)DeviceObject->
  51. DeviceExtension)) != STATUS_SUCCESS) {
  52. SerialCompleteRequest((PSERIAL_DEVICE_EXTENSION)DeviceObject->
  53. DeviceExtension, Irp, IO_NO_INCREMENT);
  54. return status;
  55. }
  56. SerialDump(
  57. SERIRPPATH,
  58. ("SERIAL: Dispatch entry for: %x\n",Irp)
  59. );
  60. if (SerialCompleteIfError(
  61. DeviceObject,
  62. Irp
  63. ) != STATUS_SUCCESS) {
  64. return STATUS_CANCELLED;
  65. }
  66. IrpSp = IoGetCurrentIrpStackLocation(Irp);
  67. Irp->IoStatus.Information = 0L;
  68. Status = STATUS_SUCCESS;
  69. if (IrpSp->Parameters.QueryFile.FileInformationClass ==
  70. FileStandardInformation) {
  71. PFILE_STANDARD_INFORMATION Buf = Irp->AssociatedIrp.SystemBuffer;
  72. Buf->AllocationSize.QuadPart = 0;
  73. Buf->EndOfFile = Buf->AllocationSize;
  74. Buf->NumberOfLinks = 0;
  75. Buf->DeletePending = FALSE;
  76. Buf->Directory = FALSE;
  77. Irp->IoStatus.Information = sizeof(FILE_STANDARD_INFORMATION);
  78. } else if (IrpSp->Parameters.QueryFile.FileInformationClass ==
  79. FilePositionInformation) {
  80. ((PFILE_POSITION_INFORMATION)Irp->AssociatedIrp.SystemBuffer)->
  81. CurrentByteOffset.QuadPart = 0;
  82. Irp->IoStatus.Information = sizeof(FILE_POSITION_INFORMATION);
  83. } else {
  84. Status = STATUS_INVALID_PARAMETER;
  85. Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
  86. }
  87. SerialDump(
  88. SERIRPPATH,
  89. ("SERIAL: Complete Irp: %x\n",Irp)
  90. );
  91. SerialCompleteRequest((PSERIAL_DEVICE_EXTENSION)DeviceObject->
  92. DeviceExtension, Irp, 0);
  93. return Status;
  94. }
  95. NTSTATUS
  96. SerialSetInformationFile(
  97. IN PDEVICE_OBJECT DeviceObject,
  98. IN PIRP Irp
  99. )
  100. /*++
  101. Routine Description:
  102. This routine is used to set the end of file information on
  103. the opened parallel port. Any other file information request
  104. is retured with an invalid parameter.
  105. This routine always ignores the actual end of file since
  106. the query information code always returns an end of file of 0.
  107. Arguments:
  108. DeviceObject - Pointer to the device object for this device
  109. Irp - Pointer to the IRP for the current request
  110. Return Value:
  111. The function value is the final status of the call
  112. --*/
  113. {
  114. //
  115. // The status that gets returned to the caller and
  116. // set in the Irp.
  117. //
  118. NTSTATUS Status;
  119. UNREFERENCED_PARAMETER(DeviceObject);
  120. PAGED_CODE();
  121. if ((Status = SerialIRPPrologue(Irp,
  122. (PSERIAL_DEVICE_EXTENSION)DeviceObject->
  123. DeviceExtension)) != STATUS_SUCCESS) {
  124. SerialCompleteRequest((PSERIAL_DEVICE_EXTENSION)DeviceObject->
  125. DeviceExtension, Irp, IO_NO_INCREMENT);
  126. return Status;
  127. }
  128. SerialDump(
  129. SERIRPPATH,
  130. ("SERIAL: Dispatch entry for: %x\n",Irp)
  131. );
  132. if (SerialCompleteIfError(
  133. DeviceObject,
  134. Irp
  135. ) != STATUS_SUCCESS) {
  136. return STATUS_CANCELLED;
  137. }
  138. Irp->IoStatus.Information = 0L;
  139. if ((IoGetCurrentIrpStackLocation(Irp)->
  140. Parameters.SetFile.FileInformationClass ==
  141. FileEndOfFileInformation) ||
  142. (IoGetCurrentIrpStackLocation(Irp)->
  143. Parameters.SetFile.FileInformationClass ==
  144. FileAllocationInformation)) {
  145. Status = STATUS_SUCCESS;
  146. } else {
  147. Status = STATUS_INVALID_PARAMETER;
  148. }
  149. Irp->IoStatus.Status = Status;
  150. SerialDump(
  151. SERIRPPATH,
  152. ("SERIAL: Complete Irp: %x\n",Irp)
  153. );
  154. SerialCompleteRequest((PSERIAL_DEVICE_EXTENSION)DeviceObject->
  155. DeviceExtension, Irp, 0);
  156. return Status;
  157. }