+typeset -Ui psz=0 # must be unsigned
+if (( g_code[0] )); then
+ # bounds check partition table values, calculate total sectors
+ if (( g_code[0] < 1 || g_code[1] < 1 || g_code[1] > 256 ||
+ g_code[2] < 1 || g_code[2] > 63 )); then
+ print -u2 Invalid geometry, values out of bounds.
+ elif [[ $(print "(${g_code[0]} * ${g_code[1]} * ${g_code[2]})" \
+ "> 4294967295" | bc) = 1 ]]; then
+ print -u2 Invalid geometry, more than 2 TiB of data.
+ else
+ # we know it's <= 2^32-1
+ (( psz = g_code[0] * g_code[1] * g_code[2] ))
+ fi
+fi
+if (( psz )); then
+ print -u2 geometry is $psz sectors \($(print \
+ "$psz * $((1 << bsh))" | bc) bytes\) in ${g_code[0]} cylinders, \
+ ${g_code[1]} heads, ${g_code[2]} sectors per track
+ if (( numsecs == 0 || (numsecs != 99 && numheads == 0) )); then
+ print -u2 warning: using these values for C/H/S boot
+ numheads=${g_code[1]}
+ numsecs=${g_code[2]}
+ fi
+ (( mbrpno )) || mbrpno=4 # default partition number