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.

155 lines
2.7 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. partsel.c
  5. Abstract:
  6. Routine to allow the user to select a partition
  7. from a list of partitions. The UI is a simple character-based
  8. deal.
  9. Author:
  10. Ted Miller (tedm) 29-May-1997
  11. Revision History:
  12. --*/
  13. #include <mytypes.h>
  14. #include <misclib.h>
  15. #include <partio.h>
  16. #include <diskio.h>
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <string.h>
  20. INT
  21. _far
  22. SelectPartition(
  23. IN UINT PartitionCount,
  24. IN CHAR *Prompt,
  25. OUT CHAR *AlternateResponse, OPTIONAL
  26. IN FPCHAR textDisk,
  27. IN FPCHAR textPaddedMbCount,
  28. IN FPCHAR textInvalidSelection
  29. )
  30. {
  31. UINT i,l;
  32. UINT DiskId;
  33. BYTE SysId;
  34. ULONG StartSector;
  35. ULONG SectorCount;
  36. BYTE Int13Unit;
  37. BYTE SectorsPerTrack;
  38. USHORT Heads;
  39. USHORT Cylinders;
  40. ULONG ExtendedSectorCount;
  41. UINT Selection;
  42. CHAR line[256];
  43. select:
  44. printf("\n\n");
  45. for(i=0; i<PartitionCount; i++) {
  46. printf("%2u) ",i+1);
  47. GetPartitionInfoById(
  48. i,
  49. 0,
  50. &DiskId,
  51. &SysId,
  52. &StartSector,
  53. &SectorCount
  54. );
  55. GetDiskInfoById(
  56. DiskId,
  57. 0,
  58. &Int13Unit,
  59. &SectorsPerTrack,
  60. &Heads,
  61. &Cylinders,
  62. &ExtendedSectorCount
  63. );
  64. printf(" ");
  65. if(Int13Unit) {
  66. printf(textDisk);
  67. printf(" ");
  68. printf("%2x",Int13Unit);
  69. } else {
  70. l = strlen(textDisk) + 3;
  71. while(l) {
  72. printf(" ");
  73. l--;
  74. }
  75. }
  76. printf(" ");
  77. switch(SysId) {
  78. case 1:
  79. printf(" FAT12 ");
  80. break;
  81. case 4:
  82. printf(" FAT16 ");
  83. break;
  84. case 6:
  85. printf("BIGFAT ");
  86. break;
  87. case 7:
  88. printf(" NTFS ");
  89. break;
  90. case 0xb:
  91. printf(" FAT32 ");
  92. break;
  93. case 0xc:
  94. printf("XFAT32 ");
  95. break;
  96. case 0xe:
  97. printf("XINT13 ");
  98. break;
  99. default:
  100. printf(" ");
  101. break;
  102. }
  103. printf(" ");
  104. printf(textPaddedMbCount,SectorCount / 2048);
  105. printf("\n");
  106. }
  107. printf("\n");
  108. printf(Prompt);
  109. printf(" ");
  110. gets(line);
  111. Selection = atoi(line);
  112. if(!Selection || (Selection > PartitionCount)) {
  113. if(AlternateResponse) {
  114. Selection = 0;
  115. strcpy(AlternateResponse,line);
  116. } else {
  117. printf("\n%s\n\n",textInvalidSelection);
  118. goto select;
  119. }
  120. }
  121. return(Selection-1);
  122. }