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.

93 lines
2.8 KiB

  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include <ftapi.h>
  4. void __cdecl
  5. main(
  6. int argc,
  7. char** argv
  8. )
  9. {
  10. FT_LOGICAL_DISK_ID diskId[2], newDiskId;
  11. ULONG weight1, weight2;
  12. FT_REDISTRIBUTION_CONFIGURATION_INFORMATION configInfo;
  13. BOOL b;
  14. LONGLONG volsize1, volsize2, newSize, rowSize, numRows, tmp;
  15. INT d;
  16. CHAR c;
  17. if (argc != 5) {
  18. printf("usage: %s <diskId1> <diskId2> <width1> <width2>\n", argv[0]);
  19. return;
  20. }
  21. sscanf(argv[1], "%I64X", &diskId[0]);
  22. sscanf(argv[2], "%I64X", &diskId[1]);
  23. sscanf(argv[3], "%d", &weight1);
  24. sscanf(argv[4], "%d", &weight2);
  25. if (weight1 >= 0x10000 || weight2 >= 0x10000) {
  26. printf("Weight too large.\n");
  27. return;
  28. }
  29. printf("Redistributing data on disk %I64X with disk %I64X\n",
  30. diskId[0], diskId[1]);
  31. printf("Weightings are %d for first disk and %d for second disk.\n",
  32. weight1, weight2);
  33. configInfo.StripeSize = 0x10000;
  34. configInfo.FirstMemberWidth = (USHORT) weight1;
  35. configInfo.SecondMemberWidth = (USHORT) weight2;
  36. b = FtQueryLogicalDiskInformation(diskId[0], NULL, &volsize1,
  37. 0, NULL, NULL, 0, NULL, 0, NULL);
  38. if (!b) {
  39. printf("Invalid disk id.\n");
  40. return;
  41. }
  42. b = FtQueryLogicalDiskInformation(diskId[1], NULL, &volsize2,
  43. 0, NULL, NULL, 0, NULL, 0, NULL);
  44. if (!b) {
  45. printf("Invalid disk id.\n");
  46. return;
  47. }
  48. printf("Total disk size before redistribution = %I64d\n", volsize1);
  49. rowSize = configInfo.StripeSize*(configInfo.FirstMemberWidth +
  50. configInfo.SecondMemberWidth);
  51. numRows = volsize1/(configInfo.StripeSize*configInfo.FirstMemberWidth);
  52. tmp = volsize2/(configInfo.StripeSize*configInfo.SecondMemberWidth);
  53. if (tmp < numRows) {
  54. numRows = tmp;
  55. }
  56. newSize = numRows*rowSize;
  57. printf("Total disk size after redistribution = %I64d\n", newSize);
  58. printf("Disk space wasted by redistribution = %I64d\n",
  59. volsize1 + volsize2 - newSize);
  60. if (newSize < volsize1) {
  61. printf("New size less than existing size.\n");
  62. return;
  63. }
  64. printf("\nPress <CTRL-C> to cancel operation...");
  65. c = getchar();
  66. printf("\nCreating redistribution...\n");
  67. b = FtCreateLogicalDisk(FtRedistribution, 2, diskId,
  68. sizeof(configInfo), &configInfo, &newDiskId);
  69. if (b) {
  70. printf("Redistribution %I64X created.\n", newDiskId);
  71. } else {
  72. printf("Redistribution create failed with %d\n", GetLastError());
  73. }
  74. }