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.

1243 lines
25 KiB

  1. /*++
  2. Copyright (c) 1996-1997 Microsoft Corporation
  3. Module Name:
  4. clusdskp.h
  5. Abstract:
  6. Private header file for the cluster disk driver.
  7. Authors:
  8. Rod Gamache 30-Mar-1997
  9. Environment:
  10. kernel mode only
  11. Notes:
  12. Revision History:
  13. --*/
  14. #define _NTDDK_ // [HACKHACK] to make ProbeForRead work. Better to include ntddk instead of ntos //
  15. #include "ntos.h"
  16. #include "zwapi.h"
  17. #include "stdarg.h"
  18. #include "stdio.h"
  19. #include "ntddscsi.h"
  20. #include "ntdddisk.h"
  21. #include "clusdef.h"
  22. #if 1 // turn on tagging all the time
  23. #ifdef ExAllocatePool
  24. #undef ExAllocatePool
  25. #endif
  26. #define ExAllocatePool(a,b) ExAllocatePoolWithTag(a,b,'kdSC')
  27. #endif
  28. //
  29. // Global definitions
  30. //
  31. #define CLUSDISK_ROOT_DEVICE L"\\Device\\ClusDisk0"
  32. #define CLUSDISK_SIGNATURE_DISK_NAME L"DiskName"
  33. #define CLUSDISK_SIGNATURE_FIELD L"\\12345678"
  34. #define CLUSDISK_PARAMETERS_KEYNAME L"\\Parameters"
  35. #define CLUSDISK_SIGNATURE_KEYNAME L"\\Signatures"
  36. #define CLUSDISK_AVAILABLE_DISKS_KEYNAME L"\\AvailableDisks"
  37. #define CLUSDISK_SINGLE_BUS_KEYNAME L"SingleBus"
  38. #define CLUSSVC_VALUENAME_MANAGEDISKSONSYSTEMBUSES L"ManageDisksOnSystemBuses"
  39. #define ID_CLEANUP ' nlC'
  40. #define ID_CLEANUP_DEV_OBJ 'OnlC'
  41. #define ID_CLUSTER_RESET_IOCTL 'tsRI'
  42. #define ID_RESET ' tsR'
  43. #define ID_CLUSTER_ARB_RESET 'tsRA'
  44. #define ID_RESET_BUSSES 'BtsR'
  45. #define ID_GET_PARTITION 'traP'
  46. #define ID_GET_GEOMETRY 'moeG'
  47. #define UNINITIALIZED_DISK_NUMBER (ULONG)-1
  48. #define MAX_BUSSES 20 // Maximum number of shared busses
  49. #define MAX_BUFFER_SIZE 256 // Maximum buffer size
  50. #define MAX_RETRIES 2
  51. //
  52. // KeEnterCriticalRegion is required if resource
  53. // acquisition is done at a PASSIVE level in the context
  54. // of non-kernel thread.
  55. //
  56. // KeEnterCriticalRegion() == KeGetCurrentThread()->KernelApcDisable -= 1;
  57. //
  58. // guarantees that the thread in which we execute cannot get
  59. // suspeneded in APC while we own the global resource.
  60. //
  61. #define ACQUIRE_EXCLUSIVE( _lock ) \
  62. do { KeEnterCriticalRegion();ExAcquireResourceExclusiveLite(_lock, TRUE); } while(0)
  63. #define ACQUIRE_SHARED( _lock ) \
  64. do { KeEnterCriticalRegion();ExAcquireResourceSharedLite(_lock, TRUE); } while(0)
  65. #define RELEASE_EXCLUSIVE( _lock ) \
  66. do { ExReleaseResourceLite( _lock );KeLeaveCriticalRegion(); } while(0)
  67. #define RELEASE_SHARED( _lock ) \
  68. do { ExReleaseResourceLite( _lock );KeLeaveCriticalRegion(); } while(0)
  69. // #define RESERVE_TIMER 3 // [GN] moved to cluster\inc\diskarbp.h
  70. #if DBG
  71. #define ClusDiskPrint(x) ClusDiskDebugPrint x
  72. #define WCSLEN_ASSERT( _buf ) ( wcslen( _buf ) < (sizeof( _buf ) / sizeof( WCHAR )))
  73. #else
  74. #define ClusDiskPrint(x)
  75. #define WCSLEN_ASSERT( _buf )
  76. #endif // DBG
  77. //
  78. // Error log messages
  79. //
  80. #define CLUSDISK_BAD_DEVICE L"Skipping device. Possible filter driver installed!"
  81. //
  82. // Macros
  83. #define IsAlpha( c ) \
  84. ( ((c) >= 'a' && (c) <= 'z') || ((c) >='A' && (c) <= 'Z') )
  85. //
  86. // Device Extension
  87. //
  88. typedef struct _CLUS_DEVICE_EXTENSION {
  89. //
  90. // Back pointer to this extension's device object
  91. //
  92. PDEVICE_OBJECT DeviceObject;
  93. //
  94. // device object to which clusdisk's device obj is attached
  95. //
  96. PDEVICE_OBJECT TargetDeviceObject;
  97. //
  98. // back ptr to clusdisk Partition0 Device Object
  99. //
  100. PDEVICE_OBJECT PhysicalDevice;
  101. //
  102. // The SCSI_ADDRESS for this device
  103. //
  104. SCSI_ADDRESS ScsiAddress;
  105. //
  106. // Disk signature
  107. //
  108. ULONG Signature;
  109. //
  110. // Disk number for reference on verifying attach
  111. //
  112. ULONG DiskNumber;
  113. //
  114. // Disk State. This is only maintained in the physical or partition
  115. // zero extension.
  116. //
  117. ULONG DiskState;
  118. //
  119. // Reservation timer - valid on the physical (partition0) extension
  120. //
  121. ULONG ReserveTimer;
  122. //
  123. // Time last reserve started. Not protected by a lock as only one
  124. // routine ever updates this value.
  125. //
  126. LARGE_INTEGER LastReserveStart;
  127. //
  128. // Event flag for use with reservation IRP.
  129. // Use is controlled by the TimerBusy flag.
  130. //
  131. KEVENT Event;
  132. //
  133. // The bus type. E.G. Scsi, SSA, etc.
  134. //
  135. ULONG BusType;
  136. //
  137. // Last reserve failure.
  138. //
  139. NTSTATUS ReserveFailure;
  140. //
  141. // Waiting IOCTL's looking for Reserve Failure notification.
  142. //
  143. LIST_ENTRY WaitingIoctls;
  144. //
  145. // Work queue item context.
  146. //
  147. WORK_QUEUE_ITEM WorkItem;
  148. //
  149. // Reservation time IRP
  150. //
  151. BOOLEAN PerformReserves;
  152. //
  153. // Work queue item busy.
  154. //
  155. BOOLEAN TimerBusy;
  156. //
  157. // Attached state. True if this device object is supposed to be
  158. // attached. False if not sure.
  159. //
  160. BOOLEAN AttachValid;
  161. //
  162. // Device is detached.
  163. //
  164. BOOLEAN Detached;
  165. //
  166. // Flag to indicate offline/terminate is in process.
  167. //
  168. BOOLEAN OfflinePending;
  169. //
  170. // The driver object for use on repartitioning. RNGFIX -???
  171. //
  172. PDRIVER_OBJECT DriverObject;
  173. //
  174. // The partition number for the last extension created
  175. // only maintained in the physical or partition zero extension.
  176. //
  177. ULONG LastPartitionNumber;
  178. //
  179. // context value for when we deregister from disk device
  180. // notifications
  181. //
  182. PVOID DiskNotificationEntry;
  183. //
  184. // context value for when we deregister from mounted device
  185. // notifications
  186. //
  187. PVOID VolumeNotificationEntry;
  188. // [GN]
  189. // Physical Sector Size of the device
  190. // If SectorSize == 0 then
  191. // persistent writing is disabled
  192. ULONG SectorSize;
  193. //
  194. // Physical Sector which is used
  195. // for persistent reservations.
  196. ULONG ArbitrationSector;
  197. //
  198. // For tracing purposes:
  199. // Approximate time of the last write to
  200. // the disk. (Approximate, because we
  201. // update this field without holding any locks)
  202. //
  203. LARGE_INTEGER LastWriteTime;
  204. //
  205. // P0 object stores an array of handles to all volumes on
  206. // this disk to be dismounted when offline happens
  207. // First entry in this array is a number of handles in the array
  208. //
  209. PHANDLE VolumeHandles;
  210. //
  211. // Lock to prevent removal while I/O in progress.
  212. //
  213. IO_REMOVE_LOCK RemoveLock;
  214. //
  215. // Keep track of paging files, crash dump files, and hibernation files.
  216. //
  217. KEVENT PagingPathCountEvent;
  218. ULONG PagingPathCount;
  219. ULONG HibernationPathCount;
  220. ULONG DumpPathCount;
  221. //
  222. // Cache partition info when possible.
  223. //
  224. PDRIVE_LAYOUT_INFORMATION_EX DriveLayout;
  225. ULONG DriveLayoutSize;
  226. ERESOURCE DriveLayoutLock;
  227. //
  228. // Number of arbitration writes and reserves in progress.
  229. //
  230. LONG ArbWriteCount;
  231. LONG ReserveCount;
  232. //
  233. // Time when the last reserve successfully completed.
  234. // Protected by ReserveInfoLock as this value could be updated
  235. // by multiple threads.
  236. //
  237. LARGE_INTEGER LastReserveEnd;
  238. //
  239. // Lock to control access to LastReserveEnd
  240. //
  241. ERESOURCE ReserveInfoLock;
  242. } CLUS_DEVICE_EXTENSION, *PCLUS_DEVICE_EXTENSION;
  243. #define DEVICE_EXTENSION_SIZE sizeof(CLUS_DEVICE_EXTENSION)
  244. //
  245. // Device list entry
  246. //
  247. typedef struct _DEVICE_LIST_ENTRY {
  248. struct _DEVICE_LIST_ENTRY *Next;
  249. ULONG Signature;
  250. PDEVICE_OBJECT DeviceObject;
  251. BOOLEAN Attached;
  252. BOOLEAN LettersAssigned;
  253. BOOLEAN FreePool;
  254. } DEVICE_LIST_ENTRY, *PDEVICE_LIST_ENTRY;
  255. typedef struct _SCSI_BUS_ENTRY {
  256. struct _SCSI_BUS_ENTRY *Next;
  257. UCHAR Port;
  258. UCHAR Path;
  259. USHORT Reserved;
  260. } SCSI_BUS_ENTRY, *PSCSI_BUS_ENTRY;
  261. typedef enum _ClusterBusType {
  262. RootBus,
  263. ScsiBus,
  264. UnknownBus
  265. } ClusterBusType;
  266. typedef struct _WORK_CONTEXT {
  267. LIST_ENTRY ListEntry;
  268. PDEVICE_OBJECT DeviceObject;
  269. KEVENT CompletionEvent;
  270. NTSTATUS FinalStatus;
  271. PVOID Context;
  272. PIO_WORKITEM WorkItem;
  273. } WORK_CONTEXT, *PWORK_CONTEXT;
  274. //
  275. // Flags for ClusDiskpReplaceHandleArray
  276. //
  277. enum {
  278. DO_DISMOUNT = 0x00000001,
  279. RELEASE_REMOVE_LOCK = 0x00000002,
  280. CLEANUP_STORAGE = 0x00000004,
  281. SET_PART0_EVENT = 0x00000008,
  282. };
  283. typedef struct _REPLACE_CONTEXT {
  284. PCLUS_DEVICE_EXTENSION DeviceExtension;
  285. PHANDLE NewValue; // OPTIONAL
  286. PHANDLE OldValue;
  287. PKEVENT Part0Event;
  288. ULONG Flags;
  289. } REPLACE_CONTEXT, *PREPLACE_CONTEXT;
  290. typedef struct _HALTPROC_CONTEXT {
  291. PCLUS_DEVICE_EXTENSION DeviceExtension;
  292. PHANDLE FileHandle;
  293. } HALTPROC_CONTEXT, *PHALTPROC_CONTEXT;
  294. typedef struct _VOL_STATE_INFO {
  295. PIO_WORKITEM WorkItem;
  296. ULONG NewDiskState;
  297. } VOL_STATE_INFO, *PVOL_STATE_INFO;
  298. typedef struct _DEVICE_CHANGE_CONTEXT {
  299. PIO_WORKITEM WorkItem;
  300. PCLUS_DEVICE_EXTENSION DeviceExtension;
  301. UNICODE_STRING SymbolicLinkName;
  302. ULONG Signature;
  303. ULONG DeviceNumber;
  304. ULONG PartitionNumber;
  305. SCSI_ADDRESS ScsiAddress;
  306. } DEVICE_CHANGE_CONTEXT, *PDEVICE_CHANGE_CONTEXT;
  307. //
  308. // Structure for offline to preserve snapshots.
  309. //
  310. typedef struct _OFFLINE_ENTRY {
  311. ULONG DiskNumber;
  312. ULONG PartitionNumber;
  313. BOOLEAN OfflineSent;
  314. struct _OFFLINE_ENTRY * Next;
  315. } OFFLINE_ENTRY, *POFFLINE_ENTRY;
  316. //
  317. // Structure to offline disk in sync thread instead of using
  318. // worker thread (async).
  319. //
  320. typedef struct _OFFLINE_DISK_ENTRY {
  321. PCLUS_DEVICE_EXTENSION DeviceExtension;
  322. struct _OFFLINE_DISK_ENTRY * Next;
  323. } OFFLINE_DISK_ENTRY, *POFFLINE_DISK_ENTRY;
  324. //
  325. // Info for synchronous reserves and arbitration
  326. //
  327. typedef NTSTATUS ( * ArbFunction)( IN PCLUS_DEVICE_EXTENSION DeviceExtenion,
  328. IN PVOID Context );
  329. typedef enum _ArbIoType {
  330. ArbIoWrite,
  331. ArbIoReserve,
  332. ArbIoInvalid
  333. } ArbIoType;
  334. typedef struct _ARB_RESERVE_COMPLETION {
  335. LARGE_INTEGER IoStartTime;
  336. LARGE_INTEGER IoEndTime;
  337. ULONG RetriesLeft;
  338. ArbIoType Type;
  339. PVOID LockTag;
  340. PDEVICE_OBJECT DeviceObject;
  341. PCLUS_DEVICE_EXTENSION DeviceExtension;
  342. PIO_WORKITEM WorkItem;
  343. NTSTATUS FinalStatus;
  344. ArbFunction RetryRoutine; // Optional routine called if I/O fails & RetriesLeft > 0
  345. ArbFunction FailureRoutine; // Optional routine called if I/O fails & RetriesLeft == 0
  346. ArbFunction PostCompletionRoutine; // Optional routine called if I/O succeeds
  347. } ARB_RESERVE_COMPLETION, *PARB_RESERVE_COMPLETION;
  348. //
  349. // Function declarations
  350. //
  351. NTSTATUS
  352. DriverEntry(
  353. IN PDRIVER_OBJECT DriverObject,
  354. IN PUNICODE_STRING RegistryPath
  355. );
  356. VOID
  357. ClusDiskScsiInitialize(
  358. IN PDRIVER_OBJECT DriverObject,
  359. IN PVOID NextDisk,
  360. IN ULONG Count
  361. );
  362. VOID
  363. ClusDiskUnload(
  364. IN PDRIVER_OBJECT DriverObject
  365. );
  366. NTSTATUS
  367. ClusDiskCreate(
  368. IN PDEVICE_OBJECT DeviceObject,
  369. IN PIRP Irp
  370. );
  371. NTSTATUS
  372. ClusDiskClose(
  373. IN PDEVICE_OBJECT DeviceObject,
  374. IN PIRP Irp
  375. );
  376. NTSTATUS
  377. ClusDiskCleanup(
  378. IN PDEVICE_OBJECT DeviceObject,
  379. IN PIRP Irp
  380. );
  381. NTSTATUS
  382. ClusDiskRead(
  383. IN PDEVICE_OBJECT DeviceObject,
  384. IN PIRP Irp
  385. );
  386. NTSTATUS
  387. ClusDiskWrite(
  388. IN PDEVICE_OBJECT DeviceObject,
  389. IN PIRP Irp
  390. );
  391. NTSTATUS
  392. ClusDiskIoCompletion(
  393. IN PDEVICE_OBJECT DeviceObject,
  394. IN PIRP Irp,
  395. IN PVOID Context
  396. );
  397. NTSTATUS
  398. ClusDiskDeviceControl(
  399. IN PDEVICE_OBJECT DeviceObject,
  400. IN PIRP Irp
  401. );
  402. NTSTATUS
  403. ClusDiskRootDeviceControl(
  404. PDEVICE_OBJECT DeviceObject,
  405. PIRP Irp
  406. );
  407. NTSTATUS
  408. ClusDiskShutdownFlush(
  409. IN PDEVICE_OBJECT DeviceObject,
  410. IN PIRP Irp
  411. );
  412. NTSTATUS
  413. ClusDiskNewDiskCompletion(
  414. IN PDEVICE_OBJECT DeviceObject,
  415. IN PIRP Irp,
  416. IN PVOID Context
  417. );
  418. NTSTATUS
  419. ClusDiskSetLayoutCompletion(
  420. IN PDEVICE_OBJECT DeviceObject,
  421. IN PIRP Irp,
  422. IN PVOID Context
  423. );
  424. NTSTATUS
  425. ClusDiskDismountDevice(
  426. IN ULONG DiskNumber,
  427. IN BOOLEAN ForceDismount
  428. );
  429. BOOLEAN
  430. ClusDiskAttached(
  431. IN PDEVICE_OBJECT DeviceObject,
  432. IN ULONG DiskNumber
  433. );
  434. BOOLEAN
  435. ClusDiskVerifyAttach(
  436. IN PDEVICE_OBJECT DeviceObject
  437. );
  438. BOOLEAN
  439. AddAttachedDevice(
  440. IN ULONG Signature,
  441. IN PDEVICE_OBJECT DeviceObject
  442. );
  443. BOOLEAN
  444. MatchDevice(
  445. IN ULONG Signature,
  446. OUT PDEVICE_OBJECT *DeviceObject
  447. );
  448. NTSTATUS
  449. GetScsiAddress(
  450. PDEVICE_OBJECT DeviceObject,
  451. PSCSI_ADDRESS ScsiAddress
  452. );
  453. VOID
  454. ClusDiskWriteDiskInfo(
  455. IN ULONG Signature,
  456. IN ULONG DiskNumber,
  457. IN LPWSTR KeyName
  458. );
  459. PDRIVE_LAYOUT_INFORMATION_EX
  460. ClusDiskGetPartitionInfo(
  461. PCLUS_DEVICE_EXTENSION DeviceExtension
  462. );
  463. NTSTATUS
  464. ClusDiskTryAttachDevice(
  465. ULONG Signature,
  466. ULONG NextDisk,
  467. PDRIVER_OBJECT DriverObject,
  468. BOOLEAN InstallMode
  469. );
  470. NTSTATUS
  471. ClusDiskAttachDevice(
  472. ULONG Signature,
  473. ULONG NextDisk,
  474. PDRIVER_OBJECT DriverObject,
  475. BOOLEAN Reset,
  476. BOOLEAN *StopProcessing,
  477. BOOLEAN InstallMode
  478. );
  479. NTSTATUS
  480. ClusDiskDetachDevice(
  481. ULONG Signature,
  482. PDRIVER_OBJECT DriverObject
  483. );
  484. NTSTATUS
  485. DismountDevice(
  486. IN HANDLE FileHandle
  487. );
  488. NTSTATUS
  489. ClusDiskGetDiskGeometry(
  490. PDEVICE_OBJECT DeviceObject
  491. );
  492. NTSTATUS
  493. GetDiskGeometry(
  494. PDEVICE_OBJECT DeviceObject,
  495. PMEDIA_TYPE MediaType
  496. );
  497. PDRIVE_LAYOUT_INFORMATION_EX
  498. GetPartitionInfo(
  499. PDEVICE_OBJECT DeviceObject,
  500. NTSTATUS *Status
  501. );
  502. NTSTATUS
  503. ResetScsiDevice(
  504. IN HANDLE ScsiportHandle,
  505. IN PSCSI_ADDRESS ScsiAddress
  506. );
  507. NTSTATUS
  508. ReserveScsiDevice(
  509. IN PCLUS_DEVICE_EXTENSION DeviceExtension,
  510. IN PVOID Context
  511. );
  512. VOID
  513. ReleaseScsiDevice(
  514. IN PCLUS_DEVICE_EXTENSION DeviceExtension
  515. );
  516. BOOLEAN
  517. AttachedDevice(
  518. IN ULONG Signature,
  519. OUT PDEVICE_OBJECT *DeviceObject
  520. );
  521. NTSTATUS
  522. EnableHaltProcessing(
  523. IN KIRQL *Irql
  524. );
  525. NTSTATUS
  526. DisableHaltProcessing(
  527. IN KIRQL *Irql
  528. );
  529. VOID
  530. ClusDiskEventCallback(
  531. IN CLUSNET_EVENT_TYPE EventType,
  532. IN CL_NODE_ID NodeId,
  533. IN CL_NETWORK_ID NetworkId
  534. );
  535. VOID
  536. ClusDiskLogError(
  537. IN PDRIVER_OBJECT DriverObject,
  538. IN PDEVICE_OBJECT DeviceObject OPTIONAL,
  539. IN ULONG SequenceNumber,
  540. IN UCHAR MajorFunctionCode,
  541. IN UCHAR RetryCount,
  542. IN ULONG UniqueErrorValue,
  543. IN NTSTATUS FinalStatus,
  544. IN NTSTATUS SpecificIOStatus,
  545. IN ULONG LengthOfText,
  546. IN PWCHAR Text
  547. );
  548. NTSTATUS
  549. DismountPartition(
  550. IN PDEVICE_OBJECT TargetDevice,
  551. IN ULONG DiskNumber,
  552. IN ULONG PartNumber
  553. );
  554. #if DBG
  555. VOID
  556. ClusDiskDebugPrint(
  557. IN ULONG Level,
  558. IN PCHAR DebugMessage,
  559. ...
  560. );
  561. #endif
  562. VOID
  563. GetSymbolicLink(
  564. IN PWCHAR Root,
  565. IN OUT PWCHAR Path
  566. );
  567. NTSTATUS
  568. ClusDiskGetTargetDevice(
  569. IN ULONG DiskNumber,
  570. IN ULONG PartitionNumber,
  571. OUT PDEVICE_OBJECT * DeviceObject OPTIONAL,
  572. IN OUT PUNICODE_STRING UnicodeString,
  573. OUT PDRIVE_LAYOUT_INFORMATION_EX * PartitionInfo OPTIONAL,
  574. OUT PSCSI_ADDRESS ScsiAddress OPTIONAL,
  575. IN BOOLEAN Reset
  576. );
  577. //[GN]
  578. NTSTATUS
  579. ArbitrationInitialize(
  580. VOID
  581. );
  582. VOID
  583. ArbitrationDone(
  584. VOID
  585. );
  586. VOID
  587. ArbitrationTick(
  588. VOID
  589. );
  590. VOID
  591. ArbitrationWrite(
  592. IN PCLUS_DEVICE_EXTENSION DeviceExtension
  593. );
  594. NTSTATUS
  595. VerifyArbitrationArgumentsIfAny(
  596. IN PULONG InputData,
  597. IN LONG InputSize
  598. );
  599. VOID
  600. ProcessArbitrationArgumentsIfAny(
  601. IN PCLUS_DEVICE_EXTENSION DeviceExtension,
  602. IN PULONG InputData,
  603. IN LONG InputSize
  604. );
  605. NTSTATUS
  606. ProcessArbitrationEscape(
  607. IN PCLUS_DEVICE_EXTENSION DeviceExtension,
  608. IN PULONG InputData,
  609. IN LONG InputSize,
  610. IN OUT PULONG OutputSize
  611. );
  612. NTSTATUS
  613. SimpleDeviceIoControl(
  614. IN PDEVICE_OBJECT DeviceObject,
  615. IN ULONG Ioctl,
  616. IN PVOID InBuffer,
  617. IN ULONG InBufferSize,
  618. IN PVOID OutBuffer,
  619. IN ULONG OutBufferSize);
  620. NTSTATUS
  621. ClusDiskInitRegistryString(
  622. OUT PUNICODE_STRING UnicodeString,
  623. IN LPWSTR KeyName,
  624. IN ULONG KeyNameChars
  625. );
  626. NTSTATUS
  627. ClusDiskAddSignature(
  628. IN PUNICODE_STRING UnicodeString,
  629. IN ULONG Signature,
  630. IN BOOLEAN Volatile
  631. );
  632. NTSTATUS
  633. ClusDiskDeleteSignature(
  634. IN PUNICODE_STRING UnicodeString,
  635. IN ULONG Signature
  636. );
  637. ULONG
  638. ClusDiskIsSignatureDisk(
  639. IN ULONG Signature
  640. );
  641. NTSTATUS
  642. ClusDiskMarkIrpPending(
  643. PIRP Irp,
  644. PDRIVER_CANCEL CancelRoutine
  645. );
  646. VOID
  647. ClusDiskCompletePendingRequest(
  648. IN PIRP Irp,
  649. IN NTSTATUS Status,
  650. PCLUS_DEVICE_EXTENSION DeviceExtension
  651. );
  652. VOID
  653. ClusDiskIrpCancel(
  654. PDEVICE_OBJECT DeviceObject,
  655. PIRP Irp
  656. );
  657. MEDIA_TYPE
  658. GetMediaType(
  659. IN PDEVICE_OBJECT DeviceObject
  660. );
  661. NTSTATUS
  662. GetScsiPortNumber(
  663. IN ULONG DiskSignature,
  664. IN PUCHAR DiskPortNumber
  665. );
  666. NTSTATUS
  667. IsDiskClusterCapable(
  668. IN UCHAR PortNumber,
  669. OUT PBOOLEAN IsCapable
  670. );
  671. NTSTATUS
  672. GetBootTimeSystemRoot(
  673. IN OUT PWCHAR Path
  674. );
  675. NTSTATUS
  676. GetRunTimeSystemRoot(
  677. IN OUT PWCHAR Path
  678. );
  679. NTSTATUS
  680. GetSystemRootPort(
  681. VOID
  682. );
  683. VOID
  684. ResetScsiBusses(
  685. VOID
  686. );
  687. NTSTATUS
  688. GetDriveLayout(
  689. IN PDEVICE_OBJECT DeviceObject,
  690. OUT PDRIVE_LAYOUT_INFORMATION_EX *DriveLayout,
  691. BOOLEAN UpdateCachedLayout,
  692. BOOLEAN FlushStorageDrivers
  693. );
  694. NTSTATUS
  695. ClusDiskInitialize(
  696. IN PDRIVER_OBJECT DriverObject
  697. );
  698. NTSTATUS
  699. DriverEntry(
  700. IN PDRIVER_OBJECT DriverObject,
  701. IN PUNICODE_STRING RegistryPath
  702. );
  703. NTSTATUS
  704. LockVolumes(
  705. IN PCLUS_DEVICE_EXTENSION DeviceExtension
  706. );
  707. NTSTATUS
  708. ClusDiskHaltProcessingWorker(
  709. IN PVOID Context
  710. );
  711. VOID
  712. SendOfflineDirect(
  713. IN PCLUS_DEVICE_EXTENSION DeviceExtension
  714. );
  715. NTSTATUS
  716. ClusDiskRescanWorker(
  717. IN PVOID Context
  718. );
  719. VOID
  720. ClusDiskTickHandler(
  721. IN PDEVICE_OBJECT DeviceObject,
  722. IN PVOID Context
  723. );
  724. NTSTATUS
  725. RegistryQueryValue(
  726. PVOID hKey,
  727. LPWSTR pValueName,
  728. PULONG pulType,
  729. PVOID pData,
  730. PULONG pulDataSize
  731. );
  732. NTSTATUS
  733. ClusDiskCreateHandle(
  734. OUT PHANDLE pHandle,
  735. IN ULONG DiskNumber,
  736. IN ULONG PartitionNumber,
  737. IN ACCESS_MASK DesiredAccess
  738. );
  739. VOID
  740. ClusDiskCompletePendedIrps(
  741. IN PCLUS_DEVICE_EXTENSION DeviceExtension,
  742. IN PFILE_OBJECT FileObject OPTIONAL,
  743. IN ULONG Offline
  744. );
  745. NTSTATUS
  746. ClusDiskOfflineEntireDisk(
  747. IN PDEVICE_OBJECT Part0DeviceObject
  748. );
  749. NTSTATUS
  750. ClusDiskDismountVolumes(
  751. IN PDEVICE_OBJECT Part0DeviceObject,
  752. IN BOOLEAN RelRemLock
  753. );
  754. NTSTATUS
  755. ClusDiskForwardIrpSynchronous(
  756. IN PDEVICE_OBJECT DeviceObject,
  757. IN PIRP Irp
  758. );
  759. VOID
  760. ClusDiskReservationWorker(
  761. IN PCLUS_DEVICE_EXTENSION DeviceExtension
  762. );
  763. VOID
  764. ClusDiskpReplaceHandleArray(
  765. PDEVICE_OBJECT DeviceObject,
  766. PWORK_CONTEXT WorkContext
  767. );
  768. VOID
  769. ClusDiskpOpenFileHandles(
  770. PDEVICE_OBJECT Part0DeviceObject,
  771. PWORK_CONTEXT WorkContext
  772. );
  773. NTSTATUS
  774. EjectVolumes(
  775. IN PDEVICE_OBJECT DeviceObject
  776. );
  777. NTSTATUS
  778. ReclaimVolumes(
  779. IN PDEVICE_OBJECT DeviceObject
  780. );
  781. NTSTATUS
  782. ProcessDelayedWorkAsynchronous(
  783. PDEVICE_OBJECT DeviceObject,
  784. PVOID WorkerRoutine,
  785. PVOID Context
  786. );
  787. NTSTATUS
  788. ProcessDelayedWorkSynchronous(
  789. PDEVICE_OBJECT DeviceObject,
  790. PVOID WorkerRoutine,
  791. PVOID Context
  792. );
  793. VOID
  794. EnableHaltProcessingWorker(
  795. PDEVICE_OBJECT DeviceObject,
  796. PWORK_CONTEXT WorkContext
  797. );
  798. VOID
  799. DisableHaltProcessingWorker(
  800. PDEVICE_OBJECT DeviceObject,
  801. PWORK_CONTEXT WorkContext
  802. );
  803. NTSTATUS
  804. GetRegistryValue(
  805. PUNICODE_STRING KeyName,
  806. PWSTR ValueName,
  807. PULONG ReturnValue
  808. );
  809. NTSTATUS
  810. SetVolumeState(
  811. PCLUS_DEVICE_EXTENSION PhysicalDisk,
  812. ULONG NewDiskState
  813. );
  814. VOID
  815. SetVolumeStateWorker(
  816. PDEVICE_OBJECT DeviceObject,
  817. PVOID Context
  818. );
  819. NTSTATUS
  820. AttachSignatureList(
  821. PDEVICE_OBJECT DeviceObject,
  822. PULONG InBuffer,
  823. ULONG InBufferLen
  824. );
  825. NTSTATUS
  826. DetachSignatureList(
  827. PDEVICE_OBJECT DeviceObject,
  828. PULONG InBuffer,
  829. ULONG InBufferLen
  830. );
  831. NTSTATUS
  832. IsVolumeMounted(
  833. IN ULONG DiskNumber,
  834. IN ULONG PartNumber,
  835. OUT BOOLEAN *IsMounted
  836. );
  837. NTSTATUS
  838. SendFtdiskIoctlSync(
  839. PDEVICE_OBJECT TargetObject,
  840. IN ULONG DiskNumber,
  841. IN ULONG PartNumber,
  842. ULONG Ioctl
  843. );
  844. NTSTATUS
  845. ClusDiskDeviceChangeNotification(
  846. IN PDEVICE_INTERFACE_CHANGE_NOTIFICATION DeviceChangeNotification,
  847. IN PCLUS_DEVICE_EXTENSION DeviceExtension
  848. );
  849. NTSTATUS
  850. ClusDiskDeviceChangeNotificationWorker(
  851. IN PDEVICE_OBJECT DeviceObject,
  852. IN PVOID Context
  853. );
  854. NTSTATUS
  855. ClusDiskVolumeChangeNotification(
  856. IN PDEVICE_INTERFACE_CHANGE_NOTIFICATION DeviceChangeNotification,
  857. IN PCLUS_DEVICE_EXTENSION DeviceExtension
  858. );
  859. NTSTATUS
  860. ClusDiskVolumeChangeNotificationWorker(
  861. IN PDEVICE_OBJECT DeviceObject,
  862. IN PVOID Context
  863. );
  864. NTSTATUS
  865. ProcessDeviceArrival(
  866. IN PDEVICE_INTERFACE_CHANGE_NOTIFICATION DeviceChangeNotification,
  867. IN PCLUS_DEVICE_EXTENSION DeviceExtension,
  868. IN BOOLEAN VolumeArrival
  869. );
  870. NTSTATUS
  871. CleanupDeviceList(
  872. PDEVICE_OBJECT DeviceObject
  873. );
  874. VOID
  875. CleanupDeviceListWorker(
  876. PDEVICE_OBJECT DeviceObject,
  877. PVOID Context
  878. );
  879. NTSTATUS
  880. CreateVolumeObject(
  881. PCLUS_DEVICE_EXTENSION ZeroExtension,
  882. ULONG DiskNumber,
  883. ULONG PartitionNumber,
  884. PDEVICE_OBJECT TargetDev
  885. );
  886. NTSTATUS
  887. WaitForAttachCompletion(
  888. PCLUS_DEVICE_EXTENSION DeviceExtension,
  889. BOOLEAN WaitForInit,
  890. BOOLEAN CheckPhysDev
  891. );
  892. NTSTATUS
  893. GetReserveInfo(
  894. PVOID InOutBuffer,
  895. ULONG InSize,
  896. ULONG* OutSize
  897. );
  898. NTSTATUS
  899. SetDiskState(
  900. PVOID InBuffer,
  901. ULONG InBufferLength,
  902. ULONG OutBufferLength,
  903. ULONG *BytesReturned
  904. );
  905. NTSTATUS
  906. ArbReserveCompletion(
  907. IN PDEVICE_OBJECT DeviceObject,
  908. IN PIRP Irp,
  909. IN PVOID Context
  910. );
  911. RequeueArbReserveIo(
  912. IN PDEVICE_OBJECT DeviceObject,
  913. IN PVOID Context
  914. );
  915. NTSTATUS
  916. CheckReserveTiming(
  917. IN PCLUS_DEVICE_EXTENSION DeviceExtension,
  918. IN PVOID Context
  919. );
  920. NTSTATUS
  921. HandleReserveFailure(
  922. IN PCLUS_DEVICE_EXTENSION DeviceExtension,
  923. IN PVOID Context
  924. );
  925. #if DBG
  926. //
  927. // RemoveLock tracing functions.
  928. //
  929. NTSTATUS
  930. AcquireRemoveLock(
  931. IN PIO_REMOVE_LOCK RemoveLock,
  932. IN OPTIONAL PVOID Tag
  933. );
  934. VOID
  935. ReleaseRemoveLock(
  936. IN PIO_REMOVE_LOCK RemoveLock,
  937. IN PVOID Tag
  938. );
  939. VOID
  940. ReleaseRemoveLockAndWait(
  941. IN PIO_REMOVE_LOCK RemoveLock,
  942. IN PVOID Tag
  943. );
  944. //
  945. // Debug print helper routines
  946. //
  947. PCHAR
  948. PnPMinorFunctionString (
  949. UCHAR MinorFunction
  950. );
  951. PCHAR
  952. BoolToString(
  953. BOOLEAN Value
  954. );
  955. PCHAR
  956. DiskStateToString(
  957. ULONG DiskState
  958. );
  959. #else
  960. #define ReleaseRemoveLock(RemoveLock, Tag) IoReleaseRemoveLock(RemoveLock, Tag)
  961. NTSTATUS
  962. AcquireRemoveLock(
  963. IN PIO_REMOVE_LOCK RemoveLock,
  964. IN OPTIONAL PVOID Tag
  965. );
  966. VOID
  967. ReleaseRemoveLockAndWait(
  968. IN PIO_REMOVE_LOCK RemoveLock,
  969. IN PVOID Tag
  970. );
  971. #endif
  972. #define WPP_CONTROL_GUIDS \
  973. WPP_DEFINE_CONTROL_GUID(ClusdiskLH,(b25a9257,9a39,43df,9f35,b0976e28e843), \
  974. WPP_DEFINE_BIT(DEFAULT) \
  975. WPP_DEFINE_BIT(CREATE) \
  976. WPP_DEFINE_BIT(CLOSE) \
  977. WPP_DEFINE_BIT(CLEANUP) \
  978. WPP_DEFINE_BIT(UNPEND) \
  979. WPP_DEFINE_BIT(LEGACY) \
  980. ) \
  981. WPP_DEFINE_CONTROL_GUID(ClusdiskHB,(7f827e76,1a10,11d3,ba86,00c04f8eed00), \
  982. WPP_DEFINE_BIT(RESERVE) \
  983. WPP_DEFINE_BIT(READ) \
  984. WPP_DEFINE_BIT(WRITE) \
  985. WPP_DEFINE_BIT(TICK) \
  986. )