Leaked source code of windows server 2003
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.

171 lines
4.8 KiB

  1. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Copyright (c) 1991, 1992, 1993 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. Revision History :
  13. -----------------------------------------------------------------------------*/
  14. #include "precomp.h"
  15. #ifdef ALLOC_PRAGMA
  16. #endif
  17. NTSTATUS
  18. SerialQueryInformationFile(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
  19. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  20. Routine Description:
  21. This routine is used to query the end of file information on
  22. the opened serial port. Any other file information request
  23. is retured with an invalid parameter.
  24. This routine always returns an end of file of 0.
  25. Arguments:
  26. DeviceObject - Pointer to the device object for this device
  27. Irp - Pointer to the IRP for the current request
  28. Return Value:
  29. The function value is the final status of the call
  30. -----------------------------------------------------------------------------*/
  31. {
  32. NTSTATUS Status; // The status that gets returned to the caller and set in the Irp.
  33. // The current stack location. This contains all of the
  34. // information we need to process this particular request.
  35. PIO_STACK_LOCATION IrpSp;
  36. PPORT_DEVICE_EXTENSION pPort = DeviceObject->DeviceExtension;
  37. SerialDump(SERIRPPATH,("Dispatch entry for: %x\n", Irp));
  38. SpxIRPCounter(pPort, Irp, IRP_SUBMITTED); // Increment counter for performance stats.
  39. if(SerialCompleteIfError(DeviceObject, Irp) != STATUS_SUCCESS)
  40. return STATUS_CANCELLED;
  41. IrpSp = IoGetCurrentIrpStackLocation(Irp);
  42. Irp->IoStatus.Information = 0L;
  43. Status = STATUS_SUCCESS;
  44. if(IrpSp->Parameters.QueryFile.FileInformationClass == FileStandardInformation)
  45. {
  46. PFILE_STANDARD_INFORMATION Buf = Irp->AssociatedIrp.SystemBuffer;
  47. Buf->AllocationSize.QuadPart = 0;
  48. Buf->EndOfFile = Buf->AllocationSize;
  49. Buf->NumberOfLinks = 0;
  50. Buf->DeletePending = FALSE;
  51. Buf->Directory = FALSE;
  52. Irp->IoStatus.Information = sizeof(FILE_STANDARD_INFORMATION);
  53. }
  54. else if (IrpSp->Parameters.QueryFile.FileInformationClass == FilePositionInformation)
  55. {
  56. ((PFILE_POSITION_INFORMATION)Irp->AssociatedIrp.SystemBuffer)->CurrentByteOffset.QuadPart = 0;
  57. Irp->IoStatus.Information = sizeof(FILE_POSITION_INFORMATION);
  58. }
  59. else
  60. {
  61. Status = STATUS_INVALID_PARAMETER;
  62. }
  63. Irp->IoStatus.Status = Status;
  64. SerialDump(SERIRPPATH, ("Complete Irp: %x\n", Irp));
  65. SpxIRPCounter(pPort, Irp, IRP_COMPLETED); // Increment counter for performance stats.
  66. IoCompleteRequest(Irp, 0);
  67. return Status;
  68. }
  69. NTSTATUS
  70. SerialSetInformationFile(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
  71. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  72. Routine Description:
  73. This routine is used to set the end of file information on
  74. the opened parallel port. Any other file information request
  75. is retured with an invalid parameter.
  76. This routine always ignores the actual end of file since
  77. the query information code always returns an end of file of 0.
  78. Arguments:
  79. DeviceObject - Pointer to the device object for this device
  80. Irp - Pointer to the IRP for the current request
  81. Return Value:
  82. The function value is the final status of the call
  83. -----------------------------------------------------------------------------*/
  84. {
  85. //
  86. // The status that gets returned to the caller and
  87. // set in the Irp.
  88. //
  89. NTSTATUS Status;
  90. PPORT_DEVICE_EXTENSION pPort = DeviceObject->DeviceExtension;
  91. SerialDump(SERIRPPATH, ("Dispatch entry for: %x\n", Irp));
  92. SpxIRPCounter(pPort, Irp, IRP_SUBMITTED); // Increment counter for performance stats.
  93. if(SerialCompleteIfError(DeviceObject,Irp) != STATUS_SUCCESS)
  94. return STATUS_CANCELLED;
  95. Irp->IoStatus.Information = 0L;
  96. if((IoGetCurrentIrpStackLocation(Irp)->Parameters.SetFile.FileInformationClass == FileEndOfFileInformation)
  97. || (IoGetCurrentIrpStackLocation(Irp)->Parameters.SetFile.FileInformationClass == FileAllocationInformation))
  98. {
  99. Status = STATUS_SUCCESS;
  100. }
  101. else
  102. {
  103. Status = STATUS_INVALID_PARAMETER;
  104. }
  105. Irp->IoStatus.Status = Status;
  106. SerialDump(SERIRPPATH,("Complete Irp: %x\n", Irp));
  107. SpxIRPCounter(pPort, Irp, IRP_COMPLETED); // Increment counter for performance stats.
  108. IoCompleteRequest(Irp, 0);
  109. return Status;
  110. }