fix(vhd-lib): fix geometry computation for more than 2^28 sectors (#3451)

Fixes https://gitlab.com/vates/xoa-support/issues/942
It was a bug in the disk geometry computation.
This commit is contained in:
Nicolas Raynaud
2018-09-25 05:51:17 -07:00
committed by Julien Fontanet
parent b22514646e
commit ac2ab21826
2 changed files with 4 additions and 4 deletions

View File

@@ -1,13 +1,10 @@
import { SECTOR_SIZE } from './_constants'
export default function computeGeometryForSize (size) {
const totalSectors = Math.ceil(size / 512)
const totalSectors = Math.min(Math.ceil(size / 512), 65535 * 16 * 255)
let sectorsPerTrackCylinder
let heads
let cylinderTimesHeads
if (totalSectors > 65535 * 16 * 255) {
throw Error('disk is too big')
}
// straight copypasta from the file spec appendix on CHS Calculation
if (totalSectors >= 65535 * 16 * 63) {
sectorsPerTrackCylinder = 255