Don't overflow when calculating the size in MB of a partition.
No more 241MB 4+ gig partitions for me!
This commit is contained in:
parent
2895de58f2
commit
637fe2f7f3
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=26389
@ -429,17 +429,26 @@ static struct dos_partition mtpart = { 0 };
|
|||||||
static void
|
static void
|
||||||
print_part(int i)
|
print_part(int i)
|
||||||
{
|
{
|
||||||
struct dos_partition *partp = ((struct dos_partition *) &mboot.parts) + i;
|
struct dos_partition *partp;
|
||||||
|
u_int64_t part_mb;
|
||||||
|
|
||||||
|
partp = ((struct dos_partition *) &mboot.parts) + i;
|
||||||
|
|
||||||
if (!bcmp(partp, &mtpart, sizeof (struct dos_partition))) {
|
if (!bcmp(partp, &mtpart, sizeof (struct dos_partition))) {
|
||||||
printf("<UNUSED>\n");
|
printf("<UNUSED>\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* Be careful not to overflow.
|
||||||
|
*/
|
||||||
|
part_mb = partp->dp_size;
|
||||||
|
part_mb *= secsize;
|
||||||
|
part_mb /= (1024 * 1024);
|
||||||
printf("sysid %d,(%s)\n", partp->dp_typ, get_type(partp->dp_typ));
|
printf("sysid %d,(%s)\n", partp->dp_typ, get_type(partp->dp_typ));
|
||||||
printf(" start %ld, size %ld (%ld Meg), flag %x\n",
|
printf(" start %ld, size %ld (%qd Meg), flag %x\n",
|
||||||
partp->dp_start,
|
partp->dp_start,
|
||||||
partp->dp_size, partp->dp_size * secsize / (1024 * 1024),
|
partp->dp_size,
|
||||||
|
part_mb,
|
||||||
partp->dp_flag);
|
partp->dp_flag);
|
||||||
printf("\tbeg: cyl %d/ sector %d/ head %d;\n\tend: cyl %d/ sector %d/ head %d\n"
|
printf("\tbeg: cyl %d/ sector %d/ head %d;\n\tend: cyl %d/ sector %d/ head %d\n"
|
||||||
,DPCYL(partp->dp_scyl, partp->dp_ssect)
|
,DPCYL(partp->dp_scyl, partp->dp_ssect)
|
||||||
|
@ -429,17 +429,26 @@ static struct dos_partition mtpart = { 0 };
|
|||||||
static void
|
static void
|
||||||
print_part(int i)
|
print_part(int i)
|
||||||
{
|
{
|
||||||
struct dos_partition *partp = ((struct dos_partition *) &mboot.parts) + i;
|
struct dos_partition *partp;
|
||||||
|
u_int64_t part_mb;
|
||||||
|
|
||||||
|
partp = ((struct dos_partition *) &mboot.parts) + i;
|
||||||
|
|
||||||
if (!bcmp(partp, &mtpart, sizeof (struct dos_partition))) {
|
if (!bcmp(partp, &mtpart, sizeof (struct dos_partition))) {
|
||||||
printf("<UNUSED>\n");
|
printf("<UNUSED>\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* Be careful not to overflow.
|
||||||
|
*/
|
||||||
|
part_mb = partp->dp_size;
|
||||||
|
part_mb *= secsize;
|
||||||
|
part_mb /= (1024 * 1024);
|
||||||
printf("sysid %d,(%s)\n", partp->dp_typ, get_type(partp->dp_typ));
|
printf("sysid %d,(%s)\n", partp->dp_typ, get_type(partp->dp_typ));
|
||||||
printf(" start %ld, size %ld (%ld Meg), flag %x\n",
|
printf(" start %ld, size %ld (%qd Meg), flag %x\n",
|
||||||
partp->dp_start,
|
partp->dp_start,
|
||||||
partp->dp_size, partp->dp_size * secsize / (1024 * 1024),
|
partp->dp_size,
|
||||||
|
part_mb,
|
||||||
partp->dp_flag);
|
partp->dp_flag);
|
||||||
printf("\tbeg: cyl %d/ sector %d/ head %d;\n\tend: cyl %d/ sector %d/ head %d\n"
|
printf("\tbeg: cyl %d/ sector %d/ head %d;\n\tend: cyl %d/ sector %d/ head %d\n"
|
||||||
,DPCYL(partp->dp_scyl, partp->dp_ssect)
|
,DPCYL(partp->dp_scyl, partp->dp_ssect)
|
||||||
|
Loading…
Reference in New Issue
Block a user