diff options
author | H. Peter Anvin <hpa@zytor.com> | 2007-10-30 21:46:58 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2007-11-01 15:34:58 -0700 |
commit | e63b87680dda2a538b677110489822dc1d1e77ac (patch) | |
tree | cb2657e9100137549eec36ca9b5735d8889e8b3f /mkdiskimage.in | |
parent | e6bc5d0ea8d4ff64dcdc37f400a2f7e4fa6f2f39 (diff) | |
download | syslinux-e63b87680dda2a538b677110489822dc1d1e77ac.tar.gz |
mkdiskimage: support more than 1024 cylinders
If the user wants to generate a disk image with more than 1024
cylinders, print a warning but do the right thing, including labelling
the partitions as LBA partitions.
Diffstat (limited to 'mkdiskimage.in')
-rwxr-xr-x | mkdiskimage.in | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/mkdiskimage.in b/mkdiskimage.in index e772588a..1d66dd49 100755 --- a/mkdiskimage.in +++ b/mkdiskimage.in @@ -122,8 +122,7 @@ if ( $c == 0 && $file ne '' ) { $c = $len/($h*$s); } -if ( $file eq '' || $c < 1 || $c > 1024 || - $h < 1 || $h > 256 || $s < 1 || $s > 63 ) { +if ( $file eq '' || $c < 1 || $h < 1 || $h > 256 || $s < 1 || $s > 63 ) { print STDERR "Usage: $0 [-doFMz4][-i id] file c h s (max: 1024 256 63)\n"; print STDERR " -d add DOSEMU header\n"; print STDERR " -o print filesystem offset to stdout\n"; @@ -135,6 +134,14 @@ if ( $file eq '' || $c < 1 || $c > 1024 || exit 1; } +if ($c > 1024) { + print STDERR "Warning: more than 1024 cylinders ($c).\n"; + print STDERR "Not all BIOSes will be able to boot this device.\n"; + $cc = 1024; +} else { + $cc = $c; +} + $cylsize = $h*$s*512; if ( !$is_open ) { @@ -179,9 +186,11 @@ $bhead = ($h > 1) ? 1 : 0; $bsect = 1; $bcyl = ($h > 1) ? 0 : 1; $ehead = $h-1; -$esect = $s + ((($c-1) & 0x300) >> 2); -$ecyl = ($c-1) & 0xff; -if ( $psize > 65536 ) { +$esect = $s + ((($cc-1) & 0x300) >> 2); +$ecyl = ($cc-1) & 0xff; +if ( $cc > 1024 ) { + $fstype = 0x0e; +} elsif ( $psize > 65536 ) { $fstype = 0x06; } else { $fstype = 0x04; @@ -266,9 +275,15 @@ print OUTPUT pack("V", ($offset-$header_size)>>9); # Set the partition type if ( $opt{'F'} ) { - $fstype = 0x0b; # FAT32 + if ( $cc > 1024 ) { + $fstype = 0x0c; # FAT32 LBA + } else { + $fstype = 0x0b; + } } else { - if ( $psize > 65536 ) { + if ( $cc > 1024 ) { + $fstype = 0x0e; # FAT16 LBA + } elsif ( $psize > 65536 ) { $fstype = 0x06; # FAT16 > 32MB } else { $fstype = 0x04; # FAT16 <= 32MB |