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.

208 lines
4.0 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. FileInfo.c
  5. Abstract:
  6. This module implements the File Information routines for Raw called by
  7. the dispatch driver.
  8. Author:
  9. David Goebel [DavidGoe] 13-May-1991
  10. Revision History:
  11. --*/
  12. #include "RawProcs.h"
  13. #ifdef ALLOC_PRAGMA
  14. #pragma alloc_text(PAGE, RawQueryInformation)
  15. #pragma alloc_text(PAGE, RawSetInformation)
  16. #endif
  17. NTSTATUS
  18. RawQueryInformation (
  19. IN PVCB Vcb,
  20. IN PIRP Irp,
  21. PIO_STACK_LOCATION IrpSp
  22. )
  23. /*++
  24. Routine Description:
  25. This is the routine for querying file information, though only
  26. query current file position is supported.
  27. Arguments:
  28. Vcb - Supplies the volume being queried.
  29. Irp - Supplies the Irp being processed.
  30. IrpSp - Supplies parameters describing the query
  31. Return Value:
  32. NTSTATUS - The return status for the operation
  33. --*/
  34. {
  35. NTSTATUS Status;
  36. PULONG Length;
  37. FILE_INFORMATION_CLASS FileInformationClass;
  38. PFILE_POSITION_INFORMATION Buffer;
  39. PAGED_CODE();
  40. //
  41. // Reference our input parameters to make things easier
  42. //
  43. Length = &IrpSp->Parameters.QueryFile.Length;
  44. FileInformationClass = IrpSp->Parameters.QueryFile.FileInformationClass;
  45. Buffer = Irp->AssociatedIrp.SystemBuffer;
  46. //
  47. // The only request that is valid for raw is to query file position.
  48. //
  49. if ( FileInformationClass == FilePositionInformation ) {
  50. //
  51. // Make sure the buffer is large enough
  52. //
  53. if (*Length < sizeof(FILE_POSITION_INFORMATION)) {
  54. Irp->IoStatus.Information = 0;
  55. Status = STATUS_BUFFER_OVERFLOW;
  56. } else {
  57. //
  58. // Get the current position found in the file object.
  59. //
  60. Buffer->CurrentByteOffset = IrpSp->FileObject->CurrentByteOffset;
  61. //
  62. // Update the length, irp info, and status output variables
  63. //
  64. *Length -= sizeof( FILE_POSITION_INFORMATION );
  65. Irp->IoStatus.Information = sizeof( FILE_POSITION_INFORMATION );
  66. Status = STATUS_SUCCESS;
  67. }
  68. } else {
  69. Status = STATUS_INVALID_DEVICE_REQUEST;
  70. }
  71. RawCompleteRequest( Irp, Status );
  72. UNREFERENCED_PARAMETER( Vcb );
  73. return Status;
  74. }
  75. NTSTATUS
  76. RawSetInformation (
  77. IN PVCB Vcb,
  78. IN PIRP Irp,
  79. PIO_STACK_LOCATION IrpSp
  80. )
  81. /*++
  82. Routine Description:
  83. This is the routine for setting file information, though only
  84. setting current file position is supported.
  85. Arguments:
  86. Vcb - Supplies the volume being queried.
  87. Irp - Supplies the Irp being processed.
  88. IrpSp - Supplies parameters describing the set
  89. Return Value:
  90. NTSTATUS - The return status for the operation
  91. --*/
  92. {
  93. NTSTATUS Status;
  94. FILE_INFORMATION_CLASS FileInformationClass;
  95. PFILE_POSITION_INFORMATION Buffer;
  96. PFILE_OBJECT FileObject;
  97. PAGED_CODE();
  98. //
  99. // Reference our input parameters to make things easier
  100. //
  101. FileInformationClass = IrpSp->Parameters.SetFile.FileInformationClass;
  102. Buffer = (PFILE_POSITION_INFORMATION)Irp->AssociatedIrp.SystemBuffer;
  103. FileObject= IrpSp->FileObject;
  104. //
  105. // The only request that is valid for raw is to set file position.
  106. //
  107. if ( FileInformationClass == FilePositionInformation ) {
  108. //
  109. // Check that the new position we're supplied is aligned properly
  110. // for the device.
  111. //
  112. PDEVICE_OBJECT DeviceObject;
  113. DeviceObject = IoGetRelatedDeviceObject( IrpSp->FileObject );
  114. if ((Buffer->CurrentByteOffset.LowPart & DeviceObject->AlignmentRequirement) != 0) {
  115. Status = STATUS_INVALID_PARAMETER;
  116. } else {
  117. //
  118. // The input parameter is fine so set the current byte offset.
  119. //
  120. FileObject->CurrentByteOffset = Buffer->CurrentByteOffset;
  121. Status = STATUS_SUCCESS;
  122. }
  123. } else {
  124. Status = STATUS_INVALID_DEVICE_REQUEST;
  125. }
  126. RawCompleteRequest( Irp, Status );
  127. UNREFERENCED_PARAMETER( Vcb );
  128. return Status;
  129. }