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.

255 lines
5.0 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. fsddisp.c
  5. Abstract:
  6. This module implements the FSD dispatching routines for the NT datagram
  7. browser (the Bowser).
  8. Author:
  9. Larry Osterman (larryo) 6-May-1991
  10. Revision History:
  11. 6-May-1991 larryo
  12. Created
  13. --*/
  14. #include "precomp.h"
  15. #pragma hdrstop
  16. //KSPIN_LOCK
  17. //BowserRefcountInterlock = {0};
  18. NTSTATUS
  19. BowserStopBrowser(
  20. IN PTRANSPORT Transport,
  21. IN PVOID Context
  22. );
  23. NTSTATUS
  24. BowserCancelRequestsOnTransport(
  25. IN PTRANSPORT Transport,
  26. IN PVOID Context
  27. );
  28. #ifdef ALLOC_PRAGMA
  29. #pragma alloc_text(PAGE, BowserFsdCreate)
  30. #pragma alloc_text(PAGE, BowserFsdClose)
  31. #pragma alloc_text(PAGE, BowserFsdCleanup)
  32. #pragma alloc_text(PAGE, BowserCancelRequestsOnTransport)
  33. #pragma alloc_text(PAGE, BowserStopBrowser)
  34. #pragma alloc_text(INIT, BowserInitializeFsd)
  35. #endif
  36. NTSTATUS
  37. BowserFsdCreate (
  38. IN PBOWSER_FS_DEVICE_OBJECT DeviceObject,
  39. IN PIRP Irp
  40. )
  41. /*++
  42. Routine Description:
  43. This routine processes an NtCreateFile of the NT Bowser device driver.
  44. Arguments:
  45. IN PBOWSER_FS_DEVICE_OBJECT DeviceObject - Supplies a device object for the request.
  46. IN PIRP Irp - Supplies an IRP for the create request.
  47. Return Value:
  48. NTSTATUS - Final Status of operation
  49. --*/
  50. {
  51. NTSTATUS Status = STATUS_SUCCESS;
  52. PAGED_CODE();
  53. InterlockedIncrement(&BowserNumberOfOpenFiles);
  54. BowserCompleteRequest(Irp, Status);
  55. return Status;
  56. UNREFERENCED_PARAMETER(DeviceObject);
  57. }
  58. NTSTATUS
  59. BowserFsdClose (
  60. IN PBOWSER_FS_DEVICE_OBJECT DeviceObject,
  61. IN PIRP Irp
  62. )
  63. /*++
  64. Routine Description:
  65. This routine is called when the last reference to a handle to the NT Bowser
  66. device driver is removed.
  67. Arguments:
  68. IN PBOWSER_FS_DEVICE_OBJECT DeviceObject - Supplies a device object for the request.
  69. IN PIRP Irp - Supplies an IRP for the create request.
  70. Return Value:
  71. NTSTATUS - Final Status of operation
  72. --*/
  73. {
  74. NTSTATUS Status = STATUS_SUCCESS;
  75. PAGED_CODE();
  76. BowserCompleteRequest(Irp, Status);
  77. return Status;
  78. UNREFERENCED_PARAMETER(DeviceObject);
  79. }
  80. NTSTATUS
  81. BowserFsdCleanup (
  82. IN PBOWSER_FS_DEVICE_OBJECT DeviceObject,
  83. IN PIRP Irp
  84. )
  85. /*++
  86. Routine Description:
  87. This routine is called when the last handle to the NT Bowser device
  88. driver is closed.
  89. Arguments:
  90. IN PBOWSER_FS_DEVICE_OBJECT DeviceObject - Supplies a device object for the request.
  91. IN PIRP Irp - Supplies an IRP for the create request.
  92. Return Value:
  93. NTSTATUS - Final Status of operation
  94. --*/
  95. {
  96. NTSTATUS Status = STATUS_SUCCESS;
  97. PAGED_CODE();
  98. FsRtlEnterFileSystem();
  99. BowserForEachTransport(BowserCancelRequestsOnTransport, Irp->Tail.Overlay.OriginalFileObject);
  100. if (InterlockedDecrement(&BowserNumberOfOpenFiles) == 0) {
  101. //
  102. // There are no longer any handles open to the browser.
  103. //
  104. // Make sure we aren't a browser on any of our networks now.
  105. //
  106. BowserForEachTransport(BowserStopBrowser, NULL);
  107. }
  108. FsRtlExitFileSystem();
  109. BowserCompleteRequest(Irp, Status);
  110. return Status;
  111. UNREFERENCED_PARAMETER(DeviceObject);
  112. }
  113. NTSTATUS
  114. BowserCancelRequestsOnTransport(
  115. IN PTRANSPORT Transport,
  116. IN PVOID Context
  117. )
  118. {
  119. PFILE_OBJECT FileObject = Context;
  120. PAGED_CODE();
  121. BowserCancelQueuedIoForFile(&Transport->BecomeBackupQueue, FileObject);
  122. BowserCancelQueuedIoForFile(&Transport->BecomeMasterQueue, FileObject);
  123. BowserCancelQueuedIoForFile(&Transport->FindMasterQueue, FileObject);
  124. BowserCancelQueuedIoForFile(&Transport->WaitForMasterAnnounceQueue, FileObject);
  125. BowserCancelQueuedIoForFile(&Transport->ChangeRoleQueue, FileObject);
  126. BowserCancelQueuedIoForFile(&Transport->WaitForNewMasterNameQueue, FileObject);
  127. return STATUS_SUCCESS;
  128. }
  129. NTSTATUS
  130. BowserStopBrowser(
  131. IN PTRANSPORT Transport,
  132. IN PVOID Context
  133. )
  134. {
  135. PPAGED_TRANSPORT PagedTransport = Transport->PagedTransport;
  136. PAGED_CODE();
  137. LOCK_TRANSPORT(Transport);
  138. //
  139. // Make sure that we cannot possibly participate in an election.
  140. //
  141. PagedTransport->Role = None;
  142. PagedTransport->ServiceStatus &= ~(SV_TYPE_BACKUP_BROWSER | SV_TYPE_MASTER_BROWSER | SV_TYPE_POTENTIAL_BROWSER);
  143. BowserForEachTransportName(Transport, BowserStopProcessingAnnouncements, NULL);
  144. BowserStopTimer(&Transport->ElectionTimer);
  145. BowserStopTimer(&Transport->FindMasterTimer);
  146. UNLOCK_TRANSPORT(Transport);
  147. //
  148. // Delete the names associated with being a browser.
  149. //
  150. BowserDeleteTransportNameByName(Transport,
  151. NULL,
  152. MasterBrowser);
  153. BowserDeleteTransportNameByName(Transport,
  154. NULL,
  155. DomainAnnouncement);
  156. BowserDeleteTransportNameByName(Transport,
  157. NULL,
  158. BrowserElection);
  159. return(STATUS_SUCCESS);
  160. }
  161. VOID
  162. BowserInitializeFsd(
  163. VOID
  164. )
  165. {
  166. // KeInitializeSpinLock(&BowserRefcountInterlock);
  167. }