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.

229 lines
6.1 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1992, Microsoft Corporation
  4. //
  5. // File: reset.c
  6. //
  7. // Contents: Module to reset PKT to just-inited state
  8. //
  9. // History: 12 Feb 1998 JHarper created.
  10. //
  11. //-----------------------------------------------------------------------------
  12. #include "dfsprocs.h"
  13. #include "fsctrl.h"
  14. #define Dbg DEBUG_TRACE_RESET
  15. #ifdef ALLOC_PRAGMA
  16. #pragma alloc_text( PAGE, DfsFsctrlResetPkt )
  17. #pragma alloc_text( PAGE, DfsFsctrlStopDfs )
  18. #endif // ALLOC_PRAGMA
  19. //+----------------------------------------------------------------------------
  20. //
  21. // Function: DfsFsctrlResetPkt
  22. //
  23. // Synopsis: Walks the Pkt, getting it back to 'just boot' state
  24. // Used for 'unjoin' or teardown of a Dfs/FtDfs
  25. //
  26. // Arguments: [Irp] --
  27. //
  28. // Returns: STATUS_SUCCESS
  29. //
  30. //-----------------------------------------------------------------------------
  31. NTSTATUS
  32. DfsFsctrlResetPkt(
  33. IN PIRP Irp)
  34. {
  35. PDFS_PKT Pkt;
  36. NTSTATUS status;
  37. PDFS_PKT_ENTRY curEntry;
  38. PDFS_PKT_ENTRY nextEntry;
  39. STD_FSCTRL_PROLOGUE("DfsFsctrlResetPkt", FALSE, FALSE);
  40. DebugTrace(+1, Dbg, "DfsFsctrlResetPkt()\n", 0);
  41. Pkt = _GetPkt();
  42. PktAcquireExclusive(Pkt, TRUE);
  43. curEntry = PktFirstEntry(Pkt);
  44. while (curEntry != NULL) {
  45. nextEntry = PktNextEntry(Pkt, curEntry);
  46. PktEntryDestroy(curEntry, Pkt, (BOOLEAN) TRUE);
  47. curEntry = nextEntry;
  48. }
  49. DfsFreePrefixTable(&Pkt->LocalVolTable);
  50. DfsFreePrefixTable(&Pkt->PrefixTable);
  51. DfsFreePrefixTable(&Pkt->ShortPrefixTable);
  52. DfsInitializeUnicodePrefix(&Pkt->LocalVolTable);
  53. DfsInitializeUnicodePrefix(&Pkt->PrefixTable);
  54. DfsInitializeUnicodePrefix(&Pkt->ShortPrefixTable);
  55. Pkt->DomainPktEntry = NULL;
  56. status = STATUS_SUCCESS;
  57. PktRelease(Pkt);
  58. DebugTrace(-1, Dbg, "DfsFsctrlResetPkt - returning %08lx\n", ULongToPtr( status ));
  59. DfsCompleteRequest(Irp, status);
  60. return( status );
  61. }
  62. //+----------------------------------------------------------------------------
  63. //
  64. // Function: DfsFsctrlStopDfs
  65. //
  66. // Synopsis: Sets the state of the Dfs driver so that it will stop handling
  67. // referral requests
  68. //
  69. // Arguments: [Irp] --
  70. //
  71. // Returns: [STATUS_SUCCESS] -- Successfully set the state to started.
  72. //
  73. // [STATUS_UNSUCCESSFUL] -- An error occured trying to set the
  74. // state of Dfs to stopped.
  75. //
  76. //-----------------------------------------------------------------------------
  77. NTSTATUS
  78. DfsFsctrlStopDfs(
  79. IN PIRP Irp)
  80. {
  81. NTSTATUS status;
  82. STD_FSCTRL_PROLOGUE("DfsFsctrlStopDfs", FALSE, FALSE);
  83. DebugTrace(-1, Dbg, "DfsFsctrlStopDfs()\n", 0);
  84. DfsData.OperationalState = DFS_STATE_STOPPED;
  85. DfsData.MachineState = DFS_UNKNOWN;
  86. status = STATUS_SUCCESS;
  87. DebugTrace(-1, Dbg, "DfsFsctrlStartDfs - returning %08lx\n", ULongToPtr( status ));
  88. DfsCompleteRequest(Irp, status);
  89. return( status );
  90. }
  91. //+----------------------------------------------------------------------------
  92. //
  93. // Function: DfsFsctrlMarkStalePktEntries
  94. //
  95. // Synopsis: Walks the Pkt, marking all entries stale
  96. //
  97. // Arguments: [Irp] --
  98. //
  99. // Returns: STATUS_SUCCESS
  100. //
  101. //-----------------------------------------------------------------------------
  102. NTSTATUS
  103. DfsFsctrlMarkStalePktEntries(
  104. IN PIRP Irp)
  105. {
  106. PDFS_PKT Pkt;
  107. NTSTATUS status;
  108. PDFS_PKT_ENTRY curEntry;
  109. PDFS_PKT_ENTRY nextEntry;
  110. STD_FSCTRL_PROLOGUE("DfsFsctrlMarkStalePktEntries", FALSE, FALSE);
  111. DebugTrace(+1, Dbg, "DfsFsctrlMarkStalePktEntries()\n", 0);
  112. Pkt = _GetPkt();
  113. PktAcquireExclusive(Pkt, TRUE);
  114. curEntry = PktFirstEntry(Pkt);
  115. while (curEntry != NULL) {
  116. nextEntry = PktNextEntry(Pkt, curEntry);
  117. if (curEntry->Type & PKT_ENTRY_TYPE_LOCAL_XPOINT)
  118. curEntry->Type |= PKT_ENTRY_TYPE_STALE;
  119. curEntry = nextEntry;
  120. }
  121. status = STATUS_SUCCESS;
  122. PktRelease(Pkt);
  123. DebugTrace(-1, Dbg, "DfsFsctrlMarkStalePktEntries - returning %08lx\n", ULongToPtr( status ));
  124. DfsCompleteRequest(Irp, status);
  125. return( status );
  126. }
  127. //+----------------------------------------------------------------------------
  128. //
  129. // Function: DfsFsctrlFlushStalePktEntries
  130. //
  131. // Synopsis: Walks the Pkt, removing all stale entries
  132. //
  133. // Arguments: [Irp] --
  134. //
  135. // Returns: STATUS_SUCCESS
  136. //
  137. //-----------------------------------------------------------------------------
  138. NTSTATUS
  139. DfsFsctrlFlushStalePktEntries(
  140. IN PIRP Irp)
  141. {
  142. PDFS_PKT Pkt;
  143. NTSTATUS status;
  144. PDFS_PKT_ENTRY curEntry;
  145. PDFS_PKT_ENTRY nextEntry;
  146. DFS_PKT_ENTRY_ID Id;
  147. STD_FSCTRL_PROLOGUE("DfsFsctrlFlushStalePktEntries", FALSE, FALSE);
  148. DebugTrace(+1, Dbg, "DfsFsctrlFlushStalePktEntries()\n", 0);
  149. Pkt = _GetPkt();
  150. PktAcquireExclusive(Pkt, TRUE);
  151. curEntry = PktFirstEntry(Pkt);
  152. while (curEntry != NULL) {
  153. nextEntry = PktNextEntry(Pkt, curEntry);
  154. if (curEntry->Type & PKT_ENTRY_TYPE_STALE) {
  155. Id = curEntry->Id;
  156. Id.Prefix.Buffer = ExAllocatePoolWithTag(
  157. PagedPool,
  158. Id.Prefix.MaximumLength + Id.ShortPrefix.MaximumLength,
  159. ' sfD');
  160. if (Id.Prefix.Buffer != NULL) {
  161. Id.ShortPrefix.Buffer = &Id.Prefix.Buffer[Id.Prefix.MaximumLength/sizeof(WCHAR)];
  162. RtlCopyMemory(
  163. Id.Prefix.Buffer,
  164. curEntry->Id.Prefix.Buffer,
  165. Id.Prefix.MaximumLength);
  166. RtlCopyMemory(
  167. Id.ShortPrefix.Buffer,
  168. curEntry->Id.ShortPrefix.Buffer,
  169. Id.ShortPrefix.MaximumLength);
  170. DfsInternalDeleteExitPoint(&Id, PKT_ENTRY_TYPE_CAIRO);
  171. ExFreePool(Id.Prefix.Buffer);
  172. }
  173. }
  174. curEntry = nextEntry;
  175. }
  176. status = STATUS_SUCCESS;
  177. PktRelease(Pkt);
  178. DebugTrace(-1, Dbg, "DfsFsctrlFlushStalePktEntries - returning %08lx\n", ULongToPtr( status ));
  179. DfsCompleteRequest(Irp, status);
  180. return( status );
  181. }