Skip to content

Commit

Permalink
DISK: Fix VHD to Ensure that the CHS capacity exceeds the disk length
Browse files Browse the repository at this point in the history
If the total sectors exceeds 127Gb this is not possible, but normal
simh disks are smaller and the largest user settable size via RAUSER
is just under 1Tb.  The excessive size case (>127Gb) will have a CHS
of 0xFFFF10FF.

simh never cares about the CHS Disk Geometry value in the VHD footer
data structure, but other applications which do care about the CHS
value using the previously incorrect value as the capacity of the disk
even though the Current Size indicated in the footer may have been
larger.
  • Loading branch information
rdebath authored and markpizz committed Sep 4, 2023
1 parent 348f5f2 commit d4f85d0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sim_disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -5758,7 +5758,7 @@ if (1) { /* CHS Calculation */
cylinderTimesHeads = totalSectors / sectorsPerTrack;
}
}
cylinders = cylinderTimesHeads / heads;
cylinders = (totalSectors + sectorsPerTrack * heads - 1) / (sectorsPerTrack * heads);
Footer.DiskGeometry = NtoHl ((cylinders<<16)|(heads<<8)|sectorsPerTrack);
}
Footer.Checksum = NtoHl (CalculateVhdFooterChecksum(&Footer, sizeof(Footer)));
Expand Down

0 comments on commit d4f85d0

Please sign in to comment.