int partition_offset,
int nb_partitions_seen)
{
- char size[9];
+ char size[11];
char bootloader_name[9];
char *parttype;
unsigned int start, end;
int previous_size, size;
char previous_unit[3], unit[3]; // GB
- char size_iec[9]; // GiB
+ char size_iec[11]; // GiB
+ char size_dec[11]; // GB
sectors_to_size_dec(previous_unit, &previous_size, unit, &size,
d[disk_number].edd_params.sectors);
sectors_to_size(d[disk_number].edd_params.sectors, size_iec);
+ sectors_to_size_dec2(d[disk_number].edd_params.sectors, size_dec);
- snprintf(buffer, sizeof buffer, "Size : %s/%d %s (%d %s)",
- remove_spaces(size_iec), size, unit, previous_size, previous_unit);
- snprintf(statbuffer, sizeof statbuffer, "Size: %s/%d %s (%d %s)",
- remove_spaces(size_iec), size, unit, previous_size, previous_unit);
+ snprintf(buffer, sizeof buffer, "Size : %s/%s (%d %s)",
+ remove_spaces(size_iec), remove_spaces(size_dec), previous_size, previous_unit);
+ snprintf(statbuffer, sizeof statbuffer, "Size: %s/%s (%d %s)",
+ remove_spaces(size_iec), remove_spaces(size_dec), previous_size, previous_unit);
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
menu[nb_sub_disk_menu].items_count++;
- snprintf(buffer, sizeof buffer, "Host Bus / Interface : %s / %s",
+ snprintf(buffer, sizeof buffer, "Host Bus/Interface: %s / %s",
remove_spaces((char *)d[disk_number].edd_params.host_bus_type),
d[disk_number].edd_params.interface_type);
snprintf(statbuffer, sizeof statbuffer, "Host Bus / Interface: %s / %s",
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
menu[nb_sub_disk_menu].items_count++;
- snprintf(buffer, sizeof buffer, "C / H / S : %d / %d / %d",
+ snprintf(buffer, sizeof buffer, "C / H / S : %d / %d / %d",
d[disk_number].legacy_max_cylinder + 1,
d[disk_number].legacy_max_head + 1,
(int)d[disk_number].edd_params.sectors);
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
menu[nb_sub_disk_menu].items_count++;
- snprintf(buffer, sizeof buffer, "Sectors/Track : %d",
+ snprintf(buffer, sizeof buffer, "Sectors/Track : %d",
d[disk_number].legacy_sectors_per_track);
snprintf(statbuffer, sizeof statbuffer, "Sectors per Track: %d",
d[disk_number].legacy_sectors_per_track);
get_mbr_string(hardware->mbr_ids[disk_number], &mbr_name, 50);
- snprintf(buffer, sizeof buffer, "MBR : %s (0x%X)",
+ snprintf(buffer, sizeof buffer, "MBR : %s (0x%X)",
remove_spaces(mbr_name), hardware->mbr_ids[disk_number]);
snprintf(statbuffer, sizeof statbuffer, "MBR: %s (id 0x%X)",
remove_spaces(mbr_name), hardware->mbr_ids[disk_number]);
#include <stdio.h>
#include <string.h>
+/* Computing div(x,y) */
+#define sub(val) (((val%1024)*100)>>10)
+#define sub_dec(val) (((val%1000)*100)/1000)
+
void sectors_to_size(int sectors, char *buffer)
{
int b = (sectors / 2);
int tib = gib >> 10;
if (tib > 0)
- sprintf(buffer, "%3d TiB", tib);
+ sprintf(buffer, "%3d.%02d TiB", tib,sub(gib));
else if (gib > 0)
- sprintf(buffer, "%3d GiB", gib);
+ sprintf(buffer, "%3d.%02d GiB", gib,sub(mib));
else if (mib > 0)
- sprintf(buffer, "%3d MiB", mib);
+ sprintf(buffer, "%3d.%02d MiB", mib,sub(b));
else
- sprintf(buffer, "%d b", b);
+ sprintf(buffer, "%d B", b);
}
void sectors_to_size_dec(char *previous_unit, int *previous_size, char *unit,
}
}
}
+
+void sectors_to_size_dec2(int sectors, char *buffer)
+{
+ int b = (sectors / 2);
+ int mib = b / 1000;
+ int gib = mib / 1000;
+ int tib = gib / 1000;
+
+ if (tib > 0)
+ sprintf(buffer, "%3d.%02d TB", tib,sub_dec(gib));
+ else if (gib > 0)
+ sprintf(buffer, "%3d.%02d GB", gib,sub_dec(mib));
+ else if (mib > 0)
+ sprintf(buffer, "%3d.%02d MB", mib,sub_dec(b));
+ else
+ sprintf(buffer, "%d B", b);
+}