summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPascal Terjan <pterjan@mandriva.com>2009-04-24 19:00:05 +0200
committerH. Peter Anvin <hpa@zytor.com>2009-05-01 11:02:05 -0700
commit9a7045801f4dcc4d54f5eeab35018b361cbd45c2 (patch)
tree5381b1ae5de297e4838b2c6164f6b6b2e4513aa9
parenta54e6fe85a89324e106e4c3d17c3f51c28e4ef4f (diff)
downloadsyslinux-9a7045801f4dcc4d54f5eeab35018b361cbd45c2.tar.gz
isohybrid: preserve MBR id in isohybrid
When running isohybrid again it's nice to preserve the MBR id There was some partial code to support setting the id using non existing to_int, but no way to use it. Signed-off-by: Pascal Terjan <pterjan@mandriva.com> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--utils/isohybrid.in14
1 files changed, 8 insertions, 6 deletions
diff --git a/utils/isohybrid.in b/utils/isohybrid.in
index e98c59f6..83f9dc02 100644
--- a/utils/isohybrid.in
+++ b/utils/isohybrid.in
@@ -100,6 +100,13 @@ if ($c > 1024) {
$cc = $c;
}
+# Preserve id when run again
+seek(FILE, 440, SEEK_SET) or die "$0: $file: $!\n";
+read(FILE, $id, 4);
+if ($id eq "\x00\x00\x00\x00") {
+ $id = pack("V", get_random());
+}
+
# Print the MBR and partition table
seek(FILE, 0, SEEK_SET) or die "$0: $file: $!\n";
@@ -117,12 +124,7 @@ if ( length($mbr) > 432 ) {
$mbr .= "\0" x (432 - length($mbr));
$mbr .= pack("VV", $de_lba*4, 0); # Offset 432: LBA of isolinux.bin
-if (defined($id)) {
- $id = to_int($id);
-} else {
- $id = get_random();
-}
-$mbr .= pack("V", $id); # Offset 440: MBR ID
+$mbr .= $id; # Offset 440: MBR ID
$mbr .= "\0\0"; # Offset 446: actual partition table
# Print partition table