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.

113 lines
3.0 KiB

  1. /*++
  2. Copyright (c) 1989 - 1999 Microsoft Corporation
  3. Module Name:
  4. read.c
  5. Abstract:
  6. This module implements the mini redirector call down routines pertaining to read
  7. of file system objects.
  8. --*/
  9. #include "precomp.h"
  10. #pragma hdrstop
  11. //
  12. // The local debug trace level
  13. //
  14. #define Dbg (DEBUG_TRACE_READ)
  15. NTSTATUS
  16. NulMRxRead(
  17. IN PRX_CONTEXT RxContext
  18. )
  19. /*++
  20. Routine Description:
  21. This routine handles network read requests.
  22. Arguments:
  23. RxContext - the RDBSS context
  24. Return Value:
  25. NTSTATUS - The return status for the operation
  26. --*/
  27. {
  28. NTSTATUS Status = STATUS_SUCCESS;
  29. RxCaptureFcb;
  30. PLOWIO_CONTEXT LowIoContext = &RxContext->LowIoContext;
  31. PVOID pbUserBuffer = NULL;
  32. ULONG ByteCount = (LowIoContext->ParamsFor).ReadWrite.ByteCount;
  33. RXVBO ByteOffset = (LowIoContext->ParamsFor).ReadWrite.ByteOffset;
  34. LONGLONG FileSize = 0;
  35. NulMRxGetFcbExtension(capFcb,pFcbExtension);
  36. PMRX_NET_ROOT pNetRoot = capFcb->pNetRoot;
  37. PNULMRX_NETROOT_EXTENSION pNetRootExtension = pNetRoot->Context;
  38. BOOLEAN SynchronousIo = !BooleanFlagOn(RxContext->Flags,RX_CONTEXT_FLAG_ASYNC_OPERATION);
  39. PNULMRX_COMPLETION_CONTEXT pIoCompContext = NulMRxGetMinirdrContext(RxContext);
  40. PDEVICE_OBJECT deviceObject;
  41. RxTraceEnter("NulMRxRead");
  42. RxDbgTrace(0, Dbg, ("NetRoot is 0x%x Fcb is 0x%x\n", pNetRoot, capFcb));
  43. RxGetFileSizeWithLock((PFCB)capFcb,&FileSize);
  44. //
  45. // NB: This should be done by the wrapper ! It does this
  46. // only if READCACHEING is enabled on the FCB !!
  47. //
  48. if (!FlagOn(capFcb->FcbState,FCB_STATE_READCACHING_ENABLED)) {
  49. //
  50. // If the read starts beyond End of File, return EOF.
  51. //
  52. if (ByteOffset >= FileSize) {
  53. RxDbgTrace( 0, Dbg, ("End of File\n", 0 ));
  54. Status = STATUS_END_OF_FILE;
  55. goto Exit;
  56. }
  57. //
  58. // If the read extends beyond EOF, truncate the read
  59. //
  60. if (ByteCount > FileSize - ByteOffset) {
  61. ByteCount = (ULONG)(FileSize - ByteOffset);
  62. }
  63. }
  64. RxDbgTrace(0, Dbg, ("UserBuffer is 0x%x\n", pbUserBuffer ));
  65. RxDbgTrace(0, Dbg, ("ByteCount is %x ByteOffset is %x\n", ByteCount, ByteOffset ));
  66. //
  67. // Initialize the completion context in the RxContext
  68. //
  69. ASSERT( sizeof(*pIoCompContext) == MRX_CONTEXT_SIZE );
  70. RtlZeroMemory( pIoCompContext, sizeof(*pIoCompContext) );
  71. if( SynchronousIo ) {
  72. RxDbgTrace(0, Dbg, ("This I/O is sync\n"));
  73. pIoCompContext->IoType = IO_TYPE_SYNCHRONOUS;
  74. } else {
  75. RxDbgTrace(0, Dbg, ("This I/O is async\n"));
  76. pIoCompContext->IoType = IO_TYPE_ASYNC;
  77. }
  78. RxDbgTrace(0, Dbg, ("Status = %x Info = %x\n",RxContext->IoStatusBlock.Status,RxContext->IoStatusBlock.Information));
  79. Exit:
  80. RxTraceLeave(Status);
  81. return(Status);
  82. } // NulMRxRead