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.

165 lines
4.4 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1992, Microsoft Corporation.
  4. //
  5. // File: close.c
  6. //
  7. // Contents: This module implements the File Close and Cleanup routines for
  8. // the Dfs server.
  9. //
  10. // Functions: DfsFsdClose - FSD entry point for Close IRP
  11. // DfsFsdCleanup - FSD entry point for Cleanup IRP
  12. //
  13. //-----------------------------------------------------------------------------
  14. #include "dfsprocs.h"
  15. #include "attach.h"
  16. #include "dfswml.h"
  17. //
  18. // The local debug trace level
  19. //
  20. #define Dbg (DEBUG_TRACE_CLOSE)
  21. #ifdef ALLOC_PRAGMA
  22. #pragma alloc_text( PAGE, DfsFsdClose )
  23. #pragma alloc_text( PAGE, DfsFsdCleanup )
  24. #endif // ALLOC_PRAGMA
  25. //+-------------------------------------------------------------------
  26. //
  27. // Function: DfsFsdClose, public
  28. //
  29. // Synopsis: This routine implements the FSD part of closing down the
  30. // last reference to a file object.
  31. //
  32. // Arguments: [DeviceObject] -- Supplies the device object where the
  33. // file being closed exists
  34. // [Irp] - Supplies the Irp being processed
  35. //
  36. // Returns: NTSTATUS - The FSD status for the IRP
  37. //
  38. //--------------------------------------------------------------------
  39. NTSTATUS
  40. DfsFsdClose (
  41. IN PDEVICE_OBJECT DeviceObject,
  42. IN PIRP Irp
  43. ) {
  44. PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation( Irp );
  45. PFILE_OBJECT FileObject = IrpSp->FileObject;
  46. NTSTATUS Status;
  47. DebugTrace(+1, Dbg, "DfsFsdClose: Entered\n", 0);
  48. DFS_TRACE_HIGH(TRACE_IRP, DfsFsdClose_Entry,
  49. LOGPTR(FileObject)
  50. LOGPTR(Irp));
  51. if (DeviceObject->DeviceType == FILE_DEVICE_DFS_VOLUME) {
  52. PDFS_FCB fcb;
  53. fcb = DfsLookupFcb( IrpSp->FileObject );
  54. if (fcb != NULL) {
  55. DfsDetachFcb( IrpSp->FileObject, fcb );
  56. DfsDestroyFcb( fcb );
  57. }
  58. }
  59. if (DeviceObject->DeviceType == FILE_DEVICE_DFS_VOLUME ||
  60. DeviceObject->DeviceType == FILE_DEVICE_DISK_FILE_SYSTEM) {
  61. Status = DfsVolumePassThrough(DeviceObject, Irp);
  62. DebugTrace(-1, Dbg, "DfsFsdClose: Pass Through Exit %08lx\n", ULongToPtr( Status ));
  63. return Status;
  64. }
  65. ASSERT(DeviceObject->DeviceType == FILE_DEVICE_DFS_FILE_SYSTEM);
  66. ASSERT(IrpSp->FileObject->FsContext == UIntToPtr( DFS_OPEN_CONTEXT ));
  67. Status = STATUS_SUCCESS;
  68. DebugTrace(-1, Dbg, "DfsFsdClose: Exit -> %08lx\n", ULongToPtr( Status ));
  69. DfsCompleteRequest( Irp, Status );
  70. DFS_TRACE_HIGH(TRACE_IRP, DfsFsdClose_Exit,
  71. LOGSTATUS(Status)
  72. LOGPTR(FileObject)
  73. LOGPTR(Irp));
  74. return Status;
  75. }
  76. //+-------------------------------------------------------------------
  77. //
  78. // Function: DfsFsdCleanup, public
  79. //
  80. // Synopsis: This routine implements the FSD part of closing down the
  81. // last user handle to a file object.
  82. //
  83. // Arguments: [DeviceObject] -- Supplies the device object where the
  84. // file being closed exists
  85. // [Irp] - Supplies the Irp being processed
  86. //
  87. // Returns: NTSTATUS - The FSD status for the IRP
  88. //
  89. //--------------------------------------------------------------------
  90. NTSTATUS
  91. DfsFsdCleanup (
  92. IN PDEVICE_OBJECT DeviceObject,
  93. IN PIRP Irp
  94. ) {
  95. PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation( Irp );
  96. PFILE_OBJECT FileObject = IrpSp->FileObject;
  97. NTSTATUS Status;
  98. DebugTrace(+1, Dbg, "DfsFsdCleanup: Entered\n", 0);
  99. DFS_TRACE_HIGH(TRACE_IRP, DfsFsdCleanup_Entry,
  100. LOGPTR(FileObject)
  101. LOGPTR(Irp));
  102. if (DeviceObject->DeviceType == FILE_DEVICE_DFS_VOLUME ||
  103. DeviceObject->DeviceType == FILE_DEVICE_DISK_FILE_SYSTEM) {
  104. Status = DfsVolumePassThrough(DeviceObject, Irp);
  105. DebugTrace(-1, Dbg, "DfsFsdCleanup: Pass Through Exit %08lx\n", ULongToPtr( Status ));
  106. return Status;
  107. }
  108. ASSERT(DeviceObject->DeviceType == FILE_DEVICE_DFS_FILE_SYSTEM);
  109. ASSERT(IrpSp->FileObject->FsContext == UIntToPtr( DFS_OPEN_CONTEXT ));
  110. Status = STATUS_SUCCESS;
  111. DebugTrace(-1, Dbg, "DfsFsdCleanup: Exit -> %08lx\n", ULongToPtr( Status ));
  112. DfsCompleteRequest( Irp, Status );
  113. DFS_TRACE_HIGH(TRACE_IRP, DfsFsdCleanup_Exit,
  114. LOGSTATUS(Status)
  115. LOGPTR(FileObject)
  116. LOGPTR(Irp));
  117. return Status;
  118. }