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.

186 lines
5.7 KiB

  1. /*--------------------------------------------------------------------------
  2. *
  3. * Copyright (C) Cyclades Corporation, 1997-2001.
  4. * All rights reserved.
  5. *
  6. * Cyclades-Z Port Driver
  7. *
  8. * This file: cyzqset.c
  9. *
  10. * Description: This module contains the code related to query/set
  11. * file operations in the Cyclades-Z Port driver.
  12. *
  13. * Notes: This code supports Windows 2000 and Windows XP,
  14. * x86 and IA64 processors.
  15. *
  16. * Complies with Cyclades SW Coding Standard rev 1.3.
  17. *
  18. *--------------------------------------------------------------------------
  19. */
  20. /*-------------------------------------------------------------------------
  21. *
  22. * Change History
  23. *
  24. *--------------------------------------------------------------------------
  25. *
  26. *
  27. *--------------------------------------------------------------------------
  28. */
  29. #include "precomp.h"
  30. #ifdef ALLOC_PRAGMA
  31. #pragma alloc_text(PAGESRP0,CyzQueryInformationFile)
  32. #pragma alloc_text(PAGESRP0,CyzSetInformationFile)
  33. #endif
  34. NTSTATUS
  35. CyzQueryInformationFile(
  36. IN PDEVICE_OBJECT DeviceObject,
  37. IN PIRP Irp
  38. )
  39. /*--------------------------------------------------------------------------
  40. CyzQueryInformationFile()
  41. Routine Description: This routine is used to query the end of file
  42. information on the opened serial port. Any other file information
  43. request is retured with an invalid parameter.
  44. This routine always returns an end of file of 0.
  45. Arguments:
  46. DeviceObject - Pointer to the device object for this device
  47. Irp - Pointer to the IRP for the current request
  48. Return Value: The function value is the final status of the call
  49. --------------------------------------------------------------------------*/
  50. {
  51. NTSTATUS Status;
  52. PIO_STACK_LOCATION IrpSp; // current stack location
  53. NTSTATUS status;
  54. UNREFERENCED_PARAMETER(DeviceObject);
  55. PAGED_CODE();
  56. if ((status = CyzIRPPrologue(Irp,
  57. (PCYZ_DEVICE_EXTENSION)DeviceObject->
  58. DeviceExtension)) != STATUS_SUCCESS) {
  59. if (status != STATUS_PENDING) {
  60. CyzCompleteRequest((PCYZ_DEVICE_EXTENSION)DeviceObject->
  61. DeviceExtension, Irp, IO_NO_INCREMENT);
  62. }
  63. return status;
  64. }
  65. CyzDbgPrintEx(CYZIRPPATH, "Dispatch entry for: %x\n", Irp);
  66. if (CyzCompleteIfError(DeviceObject, Irp) != STATUS_SUCCESS) {
  67. return STATUS_CANCELLED;
  68. }
  69. IrpSp = IoGetCurrentIrpStackLocation(Irp);
  70. Irp->IoStatus.Information = 0L;
  71. Status = STATUS_SUCCESS;
  72. if (IrpSp->Parameters.QueryFile.FileInformationClass ==
  73. FileStandardInformation) {
  74. PFILE_STANDARD_INFORMATION Buf = Irp->AssociatedIrp.SystemBuffer;
  75. Buf->AllocationSize.QuadPart = 0;
  76. Buf->EndOfFile = Buf->AllocationSize;
  77. Buf->NumberOfLinks = 0;
  78. Buf->DeletePending = FALSE;
  79. Buf->Directory = FALSE;
  80. Irp->IoStatus.Information = sizeof(FILE_STANDARD_INFORMATION);
  81. } else if (IrpSp->Parameters.QueryFile.FileInformationClass ==
  82. FilePositionInformation) {
  83. ((PFILE_POSITION_INFORMATION)Irp->AssociatedIrp.SystemBuffer)->
  84. CurrentByteOffset.QuadPart = 0;
  85. Irp->IoStatus.Information = sizeof(FILE_POSITION_INFORMATION);
  86. } else {
  87. Status = STATUS_INVALID_PARAMETER;
  88. Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
  89. }
  90. CyzCompleteRequest((PCYZ_DEVICE_EXTENSION)DeviceObject->
  91. DeviceExtension, Irp, 0);
  92. return Status;
  93. }
  94. NTSTATUS
  95. CyzSetInformationFile(
  96. IN PDEVICE_OBJECT DeviceObject,
  97. IN PIRP Irp
  98. )
  99. /*--------------------------------------------------------------------------
  100. CyzSetInformationFile()
  101. Routine Description: This routine is used to set the end of file
  102. information on the opened serial port. Any other file information
  103. request is retured with an invalid parameter.
  104. This routine always ignores the actual end of file since
  105. the query information code always returns an end of file of 0.
  106. Arguments:
  107. DeviceObject - Pointer to the device object for this device
  108. Irp - Pointer to the IRP for the current request
  109. Return Value: The function value is the final status of the call
  110. --------------------------------------------------------------------------*/
  111. {
  112. NTSTATUS Status;
  113. UNREFERENCED_PARAMETER(DeviceObject);
  114. PAGED_CODE();
  115. if ((Status = CyzIRPPrologue(Irp,
  116. (PCYZ_DEVICE_EXTENSION)DeviceObject->
  117. DeviceExtension)) != STATUS_SUCCESS) {
  118. if(Status != STATUS_PENDING) {
  119. CyzCompleteRequest((PCYZ_DEVICE_EXTENSION)DeviceObject->
  120. DeviceExtension, Irp, IO_NO_INCREMENT);
  121. }
  122. return Status;
  123. }
  124. CyzDbgPrintEx(CYZIRPPATH, "Dispatch entry for: %x\n", Irp);
  125. if (CyzCompleteIfError(DeviceObject, Irp) != STATUS_SUCCESS) {
  126. return STATUS_CANCELLED;
  127. }
  128. Irp->IoStatus.Information = 0L;
  129. if ((IoGetCurrentIrpStackLocation(Irp)->
  130. Parameters.SetFile.FileInformationClass ==
  131. FileEndOfFileInformation) ||
  132. (IoGetCurrentIrpStackLocation(Irp)->
  133. Parameters.SetFile.FileInformationClass ==
  134. FileAllocationInformation)) {
  135. Status = STATUS_SUCCESS;
  136. } else {
  137. Status = STATUS_INVALID_PARAMETER;
  138. }
  139. Irp->IoStatus.Status = Status;
  140. CyzCompleteRequest((PCYZ_DEVICE_EXTENSION)DeviceObject->
  141. DeviceExtension, Irp, 0);
  142. return Status;
  143. }
  144.