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.

180 lines
6.0 KiB

  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include <ftapi.h>
  4. void
  5. PrintOutDiskInfo(
  6. IN FT_LOGICAL_DISK_ID LogicalDiskId,
  7. IN WORD Indent
  8. )
  9. {
  10. BOOL b;
  11. LONGLONG volumeSize;
  12. FT_LOGICAL_DISK_TYPE diskType;
  13. FT_LOGICAL_DISK_ID members[100];
  14. WORD numMembers;
  15. PCHAR diskTypeString;
  16. WORD i;
  17. CHAR stateInfo[100];
  18. CHAR configInfo[100];
  19. PFT_MIRROR_AND_SWP_STATE_INFORMATION stripeState;
  20. PFT_PARTITION_CONFIGURATION_INFORMATION partConfig;
  21. PFT_REDISTRIBUTION_CONFIGURATION_INFORMATION redistConfig;
  22. PFT_REDISTRIBUTION_STATE_INFORMATION redistState;
  23. if (!LogicalDiskId) {
  24. for (i = 0; i < Indent; i++) {
  25. printf(" ");
  26. }
  27. printf("Disk not found.\n\n");
  28. return;
  29. }
  30. b = FtQueryLogicalDiskInformation(LogicalDiskId, &diskType, &volumeSize,
  31. 100, members, &numMembers, 100,
  32. configInfo, 100, stateInfo);
  33. if (!b) {
  34. printf("Failure retrieving disk info, %d\n", GetLastError());
  35. return;
  36. }
  37. for (i = 0; i < Indent; i++) {
  38. printf(" ");
  39. }
  40. switch (diskType) {
  41. case FtPartition:
  42. diskTypeString = "FtPartition";
  43. partConfig = (PFT_PARTITION_CONFIGURATION_INFORMATION)
  44. configInfo;
  45. printf("Disk %I64X is an %s on disk %d at offset %I64X\n",
  46. LogicalDiskId, diskTypeString, partConfig->DiskNumber,
  47. partConfig->ByteOffset);
  48. break;
  49. case FtVolumeSet:
  50. diskTypeString = "FtVolumeSet";
  51. printf("Disk %I64X is an %s composed of %d members.\n",
  52. LogicalDiskId, diskTypeString, numMembers);
  53. break;
  54. case FtStripeSet:
  55. diskTypeString = "FtStripeSet";
  56. printf("Disk %I64X is an %s composed of %d members.\n",
  57. LogicalDiskId, diskTypeString, numMembers);
  58. break;
  59. case FtMirrorSet:
  60. diskTypeString = "FtMirrorSet";
  61. stripeState = (PFT_MIRROR_AND_SWP_STATE_INFORMATION) stateInfo;
  62. printf("Disk %I64X is an %s composed of %d members.\n",
  63. LogicalDiskId, diskTypeString, numMembers);
  64. for (i = 0; i < Indent; i++) {
  65. printf(" ");
  66. }
  67. switch (stripeState->UnhealthyMemberState) {
  68. case FtMemberHealthy:
  69. printf("Mirror set is healthy.\n");
  70. break;
  71. case FtMemberRegenerating:
  72. printf("Mirror set is regenerating member %d\n",
  73. stripeState->UnhealthyMemberNumber);
  74. break;
  75. case FtMemberOrphaned:
  76. printf("Mirror set has orphaned member %d\n",
  77. stripeState->UnhealthyMemberNumber);
  78. break;
  79. }
  80. break;
  81. case FtStripeSetWithParity:
  82. diskTypeString = "FtStripeSetWithParity";
  83. stripeState = (PFT_MIRROR_AND_SWP_STATE_INFORMATION) stateInfo;
  84. printf("Disk %I64X is an %s composed of %d members.\n",
  85. LogicalDiskId, diskTypeString, numMembers);
  86. for (i = 0; i < Indent; i++) {
  87. printf(" ");
  88. }
  89. if (stripeState->IsInitializing) {
  90. printf("Stripe set with parity is initializing parity.\n");
  91. } else {
  92. switch (stripeState->UnhealthyMemberState) {
  93. case FtMemberHealthy:
  94. printf("Stripe set with parity is healthy.\n");
  95. break;
  96. case FtMemberRegenerating:
  97. printf("Stripe set with parity is regenerating member %d\n",
  98. stripeState->UnhealthyMemberNumber);
  99. break;
  100. case FtMemberOrphaned:
  101. printf("Stripe set with parity has orphaned member %d\n",
  102. stripeState->UnhealthyMemberNumber);
  103. break;
  104. }
  105. }
  106. break;
  107. case FtRedistribution:
  108. diskTypeString = "FtRedistribution";
  109. redistConfig = (PFT_REDISTRIBUTION_CONFIGURATION_INFORMATION) configInfo;
  110. redistState = (PFT_REDISTRIBUTION_STATE_INFORMATION) stateInfo;
  111. printf("Disk %I64X is an %s composed of %d members.\n",
  112. LogicalDiskId, diskTypeString, numMembers);
  113. for (i = 0; i < Indent; i++) {
  114. printf(" ");
  115. }
  116. printf("Widths = (%d, %d), Bytes redistributed = %I64d\n",
  117. redistConfig->FirstMemberWidth,
  118. redistConfig->SecondMemberWidth,
  119. redistState->BytesRedistributed);
  120. break;
  121. }
  122. for (i = 0; i < Indent; i++) {
  123. printf(" ");
  124. }
  125. printf("Disk size = %I64d\n\n", volumeSize);
  126. for (i = 0; i < numMembers; i++) {
  127. PrintOutDiskInfo(members[i], (WORD) (Indent + 4));
  128. }
  129. }
  130. void __cdecl
  131. main(
  132. int argc,
  133. char** argv
  134. )
  135. {
  136. BOOL b;
  137. FT_LOGICAL_DISK_ID diskId[100];
  138. DWORD numDisks, i;
  139. UCHAR driveLetter;
  140. WORD l;
  141. b = FtEnumerateLogicalDisks(100, diskId, &numDisks);
  142. if (!b) {
  143. printf("Could not enumerate disks %d\n", GetLastError());
  144. return;
  145. }
  146. for (i = 0; i < numDisks; i++) {
  147. b = FtQueryStickyDriveLetter(diskId[i], &driveLetter);
  148. if (b && driveLetter) {
  149. printf("%c:\n", driveLetter);
  150. }
  151. PrintOutDiskInfo(diskId[i], 0);
  152. printf("\n");
  153. }
  154. }