#define arraysize(a) (sizeof(a) / sizeof((a)[0]))
#define arraylimit(a) ((a) + arraysize(a))
-#define SORNOT(n) ((n) == 1 ? "" : "s")
+#define SORNOT(n) ((n) == 1 ? " " : "s")
int probing = 0, autopartmode = 0;
if(table[i].sysind == NO_PART)
break;
+
+ /* Free space before this partition? */
if(table[i].lowsec > free_sec) {
/* Free region before this partition. */
regions[nr_regions].free_sec_start = free_sec;
}
}
+ /* Sanity check. */
if(autopartmode && si > 1) {
if(table[i].lowsec < table[sort_order[si-1]].lowsec ||
table[i].lowsec < table[sort_order[si-1]].lowsec + table[sort_order[si-1]].size) {
}
}
+ /* Remember used region. */
memcpy(®ions[nr_regions].used_part, &table[i], sizeof(table[i]));
free_sec = table[i].lowsec+table[i].size;
+ regions[nr_regions].is_used_part = 1;
nr_partitions++;
-
nr_regions++;
used_regions++;
}
unit = 'G';
}
}
- sprintf(str, "%d %cB%s", kb, unit,
+ sprintf(str, "%4d %cB%s", kb, unit,
toosmall ? " - too small for MINIX3" : "");
return str;
}
void
-printregions(region_t *theregions, int indent, int p_nr_partitions, int p_free_regions, int p_nr_regions)
+printregions(region_t *theregions, int indent, int p_nr_partitions, int p_free_regions, int p_nr_regions, int numbers)
{
int r, nofree = 0;
region_t *reg;
name = typ2txt(reg->used_part.sysind);
if(!name || strlen(name) < 2)
name = "unknown system";
- printf("%*s\033[31m%2d. in use by %s", indent, "", r, name);
+ printf("%*s\033[31m", indent, "");
+ if(numbers) printf("%2d. ", r);
+ printf("In use by %-10s ", name);
units = reg->used_part.size / 2;
printf("\033[0m (%s)\n", prettysizeprint(units));
} else if(!nofree) {
- printf("%*s\033[36m%2d. free space", indent, "", r);
+ printf("%*s\033[36m", indent, "");
+ if(numbers) printf("%2d. ", r);
+ printf("Free space ");
units = ((reg->free_sec_last - reg->free_sec_start+1))/2;
printf("\033[0m (%s)\n", prettysizeprint(units));
}
do {
printf("\nI've found the following region%s on this disk (%s).\n\n",
SORNOT(nr_regions), prettysizeprint(table[0].size/2));
- printregions(regions, 0, nr_partitions, free_regions, nr_regions);
+ printregions(regions, 0, nr_partitions, free_regions, nr_regions, 1);
if(nofree) {
printf("\nOnly the expert mode can free a slot to use the free space.\n");
printf("\nProbing done; %d drive%s found.\n", drives, SORNOT(drives));
- printf("\nI've found the following drive%s on your system.\n\n", SORNOT(drives));
+ printf("\nI've found the following drive%s on your system.\n", SORNOT(drives));
for(i = 0; i < drives; i++) {
if(drives > 1)
printf(", %d unallocated one%s ",
devices[i].free_regions, SORNOT(devices[i].free_regions));
}
- printf(" (%s)\n\n", prettysizeprint(devices[i].sectors/2));
- printf("regions :%d %d %d\n",
- i, devices[i].nr_partitions, devices[i].free_regions);
+ printf(" (%s)\n", prettysizeprint(devices[i].sectors/2));
printregions(devices[i].regions, 8,
devices[i].nr_partitions,
devices[i].free_regions,
- devices[i].nr_regions);
+ devices[i].nr_regions, 0);
}
if(drives > 1) {
argv++;
}
- for (i= 1; i < argc; i++) newdevice(argv[i], 0, 0);
+ for (i= 0; i < argc; i++) newdevice(argv[i], 0, 0);
if (firstdev == nil) {
getdevices(autopart);