aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhpa <hpa>2004-12-22 20:44:29 +0000
committerhpa <hpa>2004-12-22 20:44:29 +0000
commit86b393732d46b334f93efce7faa1eeebeec9f704 (patch)
treec845280ada10856906b19f262d2c2c0d1d6692a3
parent5994414ce681d9da3b7b3907e49c8ac4dd509b0f (diff)
downloadsyslinux-elf-86b393732d46b334f93efce7faa1eeebeec9f704.tar.gz
syslinux-elf-86b393732d46b334f93efce7faa1eeebeec9f704.tar.xz
syslinux-elf-86b393732d46b334f93efce7faa1eeebeec9f704.zip
Write the partition offset into the superblock as we are supposed to.syslinux-3.00-pre4
-rwxr-xr-xmkdiskimage.in15
1 files changed, 11 insertions, 4 deletions
diff --git a/mkdiskimage.in b/mkdiskimage.in
index 4a06677f..a23982c5 100755
--- a/mkdiskimage.in
+++ b/mkdiskimage.in
@@ -16,7 +16,8 @@
# Creates a blank MS-DOS formatted hard disk image
#
-eval { use bytes; };
+use bytes;
+use integer;
use Fcntl;
use Errno;
use Cwd;
@@ -132,7 +133,8 @@ $imglink = $tmpdir.'/disk.img';
die "$0: Failed to create symlink $imglink\n"
if ( !symlink(absolute_path($file), $imglink) );
-$offset = $s*512 + ($opt{'d'} ? 128 : 0);
+$header_size = ($opt{'d'} ? 128 : 0);
+$offset = $s*512 + $header_size;
open(MCONFIG, "> ${cfgfile}") or die "$0: Cannot make mtools config\n";
print MCONFIG "drive z:\n";
print MCONFIG "file=\"${imglink}\"\n";
@@ -160,6 +162,11 @@ unlink($cfgfile);
unlink($imglink);
rmdir($tmpdir);
+# MTOOLS doesn't write the bsHiddenSecs field correctly
+seek(OUTPUT, $offset + 0x1c, 0);
+print OUTPUT pack("V", ($offset-$header_size)>>9);
+
+# Set the partition type
if ( $opt{'F'} ) {
$fstype = 0x0b; # FAT32
} else {
@@ -168,7 +175,7 @@ if ( $opt{'F'} ) {
} else {
$fstype = 0x04; # FAT16 <= 32MB
}
- seek(OUTPUT, $s*512+0x36, 0);
+ seek(OUTPUT, $offset + 0x36, 0);
read(OUTPUT, $fsname, 8);
# FAT12: adjust partition type
@@ -176,7 +183,7 @@ if ( $opt{'F'} ) {
$fstype = 0x01; # FAT12
}
}
-seek(OUTPUT, 446+4, 0);
+seek(OUTPUT, 446+4 + $header_size, 0);
print OUTPUT pack("C", $fstype);
exit 0;