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.

515 lines
9.5 KiB

  1. /*++
  2. Copyright (c) 1996-1998 Microsoft Corporation
  3. Module Name:
  4. disksp.h
  5. Abstract:
  6. Disks Resource DLL private definitions.
  7. Author:
  8. Rod Gamache (rodga) 29-Mar-1996
  9. Revision History:
  10. --*/
  11. #include "clusres.h"
  12. #include "ntddscsi.h"
  13. #include "ntddft.h"
  14. #include "clusdisk.h"
  15. #include "clusrtl.h"
  16. #include "disk.h"
  17. #include "clusstor.h"
  18. #define DiskpLogEvent ClusResLogEvent
  19. #define DiskpSetResourceStatus ClusResSetResourceStatus
  20. #define MAX_DISKS 100
  21. #define DISKS_PRINT printf
  22. #define FTSET_PRINT printf
  23. #define CLUSDISK_REGISTRY_AVAILABLE_DISKS \
  24. "System\\CurrentControlSet\\Services\\ClusDisk\\Parameters\\AvailableDisks"
  25. #define CLUSDISK_REGISTRY_SIGNATURES \
  26. "System\\CurrentControlSet\\Services\\ClusDisk\\Parameters\\Signatures"
  27. #define CLUSREG_VALUENAME_MANAGEDISKSONSYSTEMBUSES L"ManageDisksOnSystemBuses"
  28. #define UNINITIALIZED_UCHAR (UCHAR)-1
  29. #define MIN_USABLE_QUORUM_PARTITION_LENGTH 50 * 1000 * 1000 // 50 MB
  30. extern PLOG_EVENT_ROUTINE DiskpLogEvent;
  31. extern HANDLE DiskspClusDiskZero;
  32. //extern PSTR PartitionName;
  33. //extern PSTR DiskName;
  34. typedef struct _ARBITRATION_INFO {
  35. CLRTL_WORK_ITEM WorkItem;
  36. DWORD SectorSize;
  37. CRITICAL_SECTION DiskLock;
  38. DWORD InputData;
  39. DWORD OutputData;
  40. HANDLE ControlHandle; // Moved here from DISK_INFO //
  41. BOOL ReservationError; // Moved here from DISK_INFO //
  42. BOOL StopReserveInProgress;
  43. LONG CheckReserveInProgress;
  44. DWORD ArbitrateCount;
  45. } ARBITRATION_INFO, *PARBITRATION_INFO;
  46. typedef struct _MOUNTIE_VOLUME *PMOUNTIE_VOLUME;
  47. typedef struct _MOUNTIE_INFO {
  48. DWORD HarddiskNo;
  49. DWORD DriveLetters;
  50. DWORD NeedsUpdate;
  51. DWORD VolumeStructSize;
  52. PMOUNTIE_VOLUME Volume;
  53. DWORD UpdateThreadIsActive;
  54. } MOUNTIE_INFO, *PMOUNTIE_INFO;
  55. typedef struct _DISK_PARAMS {
  56. DWORD Signature;
  57. LPWSTR SerialNumber;
  58. LPWSTR Drive;
  59. DWORD SkipChkdsk;
  60. DWORD ConditionalMount;
  61. LPWSTR MPVolGuids; // REG_MULTI_SZ string of Volume{GUIDS}
  62. DWORD MPVolGuidsSize; // Number of bytes, not number of WCHARs!
  63. DWORD UseMountPoints;
  64. LPWSTR VolGuid;
  65. } DISK_PARAMS, *PDISK_PARAMS;
  66. //
  67. // DISK_INFO structures are common to both the physical disk resource
  68. // and the FT set resource. The underlying SCSI/filter driver interfaces
  69. // deal with DISK_INFO structures. Each one represents a physical disk.
  70. //
  71. typedef struct _DISK_INFO {
  72. LIST_ENTRY ListEntry;
  73. DISK_PARAMS Params;
  74. DWORD PhysicalDrive;
  75. HANDLE FileHandle;
  76. DWORD FailStatus;
  77. } DISK_INFO, *PDISK_INFO;
  78. typedef struct _MOUNTPOINT_INFO {
  79. DWORD MPUpdateThreadIsActive;
  80. CRITICAL_SECTION MPLock;
  81. BOOL Initialized;
  82. DWORD MPListCreateInProcess;
  83. } MOUNTPOINT_INFO, *PMOUNTPOINT_INFO;
  84. //
  85. // DISK_RESOURCE structures are used by the physical disk resource.
  86. // It encapsulates a DISK_INFO structure that represents the physical
  87. // disk. Each DISK_RESOURCE may contain multiple partitions.
  88. //
  89. typedef struct _DISK_RESOURCE {
  90. LIST_ENTRY ListEntry; // Linkage onto list of online disks
  91. DISK_INFO DiskInfo;
  92. RESOURCE_HANDLE ResourceHandle;
  93. HKEY ResourceKey;
  94. HKEY ResourceParametersKey;
  95. HKEY ClusDiskParametersKey;
  96. // HANDLE StopTimerHandle;
  97. BOOL Reserved;
  98. BOOL Valid;
  99. BOOL Inserted;
  100. BOOL Attached;
  101. CLUS_WORKER OnlineThread;
  102. CLUS_WORKER OfflineThread;
  103. PQUORUM_RESOURCE_LOST LostQuorum;
  104. PFULL_DISK_INFO DiskCpInfo; // returned from DiskGetFullDiskInfo
  105. DWORD DiskCpSize;
  106. MOUNTPOINT_INFO MPInfo;
  107. ARBITRATION_INFO ArbitrationInfo;
  108. MOUNTIE_INFO MountieInfo;
  109. } DISK_RESOURCE, *PDISK_RESOURCE;
  110. //
  111. // FTSET_RESOURCE structures are used by the FT set resource.
  112. // It encapsulates a list of DISK_INFO structures that represent
  113. // the physical members of the FT set.
  114. //
  115. typedef struct _FTSET_RESOURCE {
  116. LIST_ENTRY ListEntry; // Linkage onto list of online FT sets
  117. LIST_ENTRY MemberList;
  118. HANDLE FtSetHandle;
  119. HKEY ResourceKey;
  120. HKEY ResourceParametersKey;
  121. HKEY ClusDiskParametersKey;
  122. HANDLE StopTimerHandle;
  123. HANDLE ReservationThread;
  124. BOOL Valid;
  125. BOOL Attached;
  126. BOOL Inserted;
  127. CLUS_WORKER OnlineThread;
  128. RESOURCE_HANDLE ResourceHandle;
  129. DWORD SignatureLength;
  130. LPWSTR SignatureList;
  131. PFULL_FTSET_INFO FtSetInfo; // returned from DiskGetFullFtSetInfo
  132. DWORD FtSetSize;
  133. PQUORUM_RESOURCE_LOST LostQuorum;
  134. } FTSET_RESOURCE, *PFTSET_RESOURCE;
  135. #define FtRoot(_res_) CONTAINING_RECORD((_res_)->MemberList.Flink, \
  136. DISK_INFO, \
  137. ListEntry)
  138. typedef struct _SCSI_ADDRESS_ENTRY {
  139. SCSI_ADDRESS ScsiAddress;
  140. struct _SCSI_ADDRESS_ENTRY *Next;
  141. } SCSI_ADDRESS_ENTRY, *PSCSI_ADDRESS_ENTRY;
  142. BOOL
  143. IsVolumeDirty(
  144. IN UCHAR DriveLetter
  145. );
  146. #if 0
  147. DWORD
  148. GetSymbolicLink(
  149. IN PCHAR RootName,
  150. IN OUT PCHAR ObjectName // Assumes this points at a MAX_PATH length buffer
  151. );
  152. #endif
  153. LPSTR
  154. GetRegParameter(
  155. IN HKEY RegKey,
  156. IN LPCSTR ValueName
  157. );
  158. #if 0
  159. HANDLE
  160. OpenObject(
  161. PCHAR Directory,
  162. PCHAR Name
  163. );
  164. #endif
  165. DWORD
  166. AssignDriveLetters(
  167. HANDLE FileHandle,
  168. PDISK_INFO DiskInfo
  169. );
  170. DWORD
  171. RemoveDriveLetters(
  172. HANDLE FileHandle,
  173. PDISK_INFO DiskInfo
  174. );
  175. DWORD
  176. GoOnline(
  177. HANDLE FileHandle,
  178. RESOURCE_HANDLE ResourceHandle
  179. );
  180. DWORD
  181. FixDriveLayout(
  182. HANDLE FileHandle,
  183. RESOURCE_HANDLE ResourceHandle
  184. );
  185. DWORD
  186. GoOffline(
  187. HANDLE FileHandle,
  188. RESOURCE_HANDLE ResourceHandle
  189. );
  190. DWORD
  191. SetOfflinePending(
  192. HANDLE FileHandle,
  193. RESOURCE_HANDLE ResourceHandle
  194. );
  195. VOID
  196. DoHoldIO(
  197. VOID
  198. );
  199. VOID
  200. DoResumeIO(
  201. VOID
  202. );
  203. DWORD
  204. DoAttach(
  205. DWORD Signature,
  206. RESOURCE_HANDLE ResourceHandle
  207. );
  208. DWORD
  209. DoDetach(
  210. DWORD Signature,
  211. RESOURCE_HANDLE ResourceHandle
  212. );
  213. DWORD
  214. DoReserve(
  215. HANDLE FileHandle,
  216. RESOURCE_HANDLE ResourceHandle
  217. );
  218. DWORD
  219. DoRelease(
  220. HANDLE FileHandle,
  221. RESOURCE_HANDLE ResourceHandle
  222. );
  223. DWORD
  224. DoBreakReserve(
  225. HANDLE FileHandle,
  226. RESOURCE_HANDLE ResourceHandle
  227. );
  228. DWORD
  229. StartReserve(
  230. OUT HANDLE *FileHandle,
  231. IN DWORD Signature,
  232. IN RESOURCE_HANDLE ResourceHandle
  233. );
  234. DWORD
  235. StartReserveEx(
  236. OUT HANDLE *FileHandle,
  237. LPVOID InputData,
  238. DWORD InputDataSize,
  239. RESOURCE_HANDLE ResourceHandle
  240. );
  241. DWORD
  242. StopReserve(
  243. HANDLE FileHandle,
  244. RESOURCE_HANDLE ResourceHandle
  245. );
  246. DWORD
  247. CheckReserve(
  248. HANDLE FileHandle,
  249. RESOURCE_HANDLE ResourceHandle
  250. );
  251. DWORD
  252. DiskpSetThreadPriority(
  253. VOID
  254. );
  255. DWORD
  256. GetRegDwordValue(
  257. IN LPWSTR RegKeyName,
  258. IN LPWSTR ValueName,
  259. OUT LPDWORD ValueBuffer
  260. );
  261. //
  262. // Common registry routines.
  263. //
  264. BOOLEAN
  265. GetAssignedDriveLetter(
  266. ULONG Signature,
  267. ULONG PartitionNumber,
  268. PUCHAR DriveLetter,
  269. PUSHORT FtGroup,
  270. PBOOL AssignDriveLetter
  271. );
  272. //
  273. // Common SCSI routines.
  274. //
  275. DWORD
  276. GetScsiAddress(
  277. IN DWORD Signature,
  278. OUT LPDWORD ScsiAddress,
  279. OUT LPDWORD DiskNumber
  280. );
  281. DWORD
  282. ScsiIsAlive(
  283. IN HANDLE DiskHandle
  284. );
  285. DWORD
  286. ClusDiskGetAvailableDisks(
  287. OUT PVOID OutBuffer,
  288. IN DWORD OutBufferSize,
  289. OUT LPDWORD BytesReturned,
  290. IN BOOL FtSet
  291. );
  292. DWORD
  293. GetDiskInfo(
  294. IN DWORD Signature,
  295. OUT PVOID *OutBuffer,
  296. IN DWORD OutBufferSize,
  297. OUT LPDWORD BytesReturned,
  298. IN BOOL FtSet
  299. );
  300. VOID
  301. GetSystemBusInfo(
  302. );
  303. VOID
  304. CleanupSystemBusInfo(
  305. );
  306. BOOL
  307. IsDiskOnSystemBus(
  308. PSCSI_ADDRESS DiskAddr
  309. );
  310. BOOL
  311. IsDiskSystemDisk(
  312. PSCSI_ADDRESS DiskAddr
  313. );
  314. DWORD
  315. GetSerialNumber(
  316. IN DWORD Signature,
  317. OUT LPWSTR *SerialNumber
  318. );
  319. DWORD
  320. GetSignatureFromSerialNumber(
  321. IN LPWSTR SerialNumber,
  322. OUT LPDWORD Signature
  323. );
  324. //
  325. // Common routines for handling logical volumes
  326. //
  327. DWORD
  328. DisksDriveIsAlive(
  329. IN PDISK_RESOURCE ResourceEntry,
  330. IN BOOL Online
  331. );
  332. DWORD
  333. DisksMountDrives(
  334. IN PDISK_INFO DiskInfo,
  335. IN PDISK_RESOURCE ResourceEntry,
  336. IN DWORD Signature
  337. );
  338. DWORD
  339. DisksDismountDrive(
  340. IN PDISK_RESOURCE ResourceEntry,
  341. IN DWORD Signature
  342. );
  343. //
  344. // PnP stuff
  345. //
  346. DWORD
  347. DiskspGetQuorumPath(
  348. OUT LPWSTR* lpQuorumLogPath
  349. );
  350. DWORD
  351. DiskspSetQuorumPath(
  352. IN LPWSTR QuorumLogPath
  353. );
  354. //
  355. // [HACKHACK] Currently, there is not polically correct way
  356. // for the resource to learn whether it is a quorum resource or not
  357. //
  358. DWORD
  359. GetQuorumSignature(
  360. OUT PDWORD QuorumSignature
  361. );
  362. DWORD
  363. StartNotificationWatcherThread(
  364. VOID
  365. );
  366. VOID
  367. StopNotificationWatcher(
  368. VOID
  369. );
  370. VOID
  371. WatchDisk(
  372. IN PDISK_RESOURCE ResourceEntry
  373. );
  374. VOID
  375. StopWatchingDisk(
  376. IN PDISK_RESOURCE ResourceEntry
  377. );
  378. BOOL
  379. IsDiskInPnpVolumeList(
  380. PDISK_RESOURCE ResourceEntry,
  381. BOOL UpdateVolumeList
  382. );
  383. DWORD
  384. QueueWaitForVolumeEvent(
  385. HANDLE Event,
  386. PDISK_RESOURCE ResourceEntry
  387. );
  388. DWORD
  389. RemoveWaitForVolumeEvent(
  390. PDISK_RESOURCE ResourceEntry
  391. );
  392. //
  393. // Mount point list processing.
  394. //
  395. VOID
  396. DisksMountPointCleanup(
  397. PDISK_RESOURCE ResourceEntry
  398. );
  399. VOID
  400. DisksMountPointInitialize(
  401. PDISK_RESOURCE ResourceEntry
  402. );
  403. DWORD
  404. DisksProcessMountPointInfo(
  405. PDISK_RESOURCE ResourceEntry
  406. );
  407. DWORD
  408. DisksProcessMPControlCode(
  409. PDISK_RESOURCE ResourceEntry,
  410. DWORD ControlCode
  411. );
  412. DWORD
  413. DisksUpdateMPList(
  414. PDISK_RESOURCE ResourceEntry
  415. );
  416. DWORD
  417. PostMPInfoIntoRegistry(
  418. PDISK_RESOURCE ResourceEntry
  419. );