summaryrefslogtreecommitdiff
path: root/memdisk/postprocess.pl
diff options
context:
space:
mode:
authorhpa <hpa>2001-12-10 08:20:43 +0000
committerhpa <hpa>2001-12-10 08:20:43 +0000
commitfb13c33edae163e0e29bd70780dbeca2aad071f8 (patch)
tree52138013d23e001bfc394a857308dc7d95ab3f34 /memdisk/postprocess.pl
parent886a10a343516d7680600faba3ebfa9735cd3dc3 (diff)
downloadsyslinux-fb13c33edae163e0e29bd70780dbeca2aad071f8.tar.gz
Add postprocessing to set the number of setup sectors.
Diffstat (limited to 'memdisk/postprocess.pl')
-rwxr-xr-xmemdisk/postprocess.pl41
1 files changed, 41 insertions, 0 deletions
diff --git a/memdisk/postprocess.pl b/memdisk/postprocess.pl
new file mode 100755
index 00000000..894c8b0b
--- /dev/null
+++ b/memdisk/postprocess.pl
@@ -0,0 +1,41 @@
+#!/usr/bin/perl
+## -----------------------------------------------------------------------
+##
+## Copyright 2001 H. Peter Anvin - All Rights Reserved
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, Inc., 53 Temple Place Ste 330,
+## Bostom MA 02111-1307, USA; either version 2 of the License, or
+## (at your option) any later version; incorporated herein by reference.
+##
+## -----------------------------------------------------------------------
+## $Id$
+
+#
+# Postprocess the memdisk binary.
+#
+
+($file) = @ARGV;
+
+open(FILE, "+< $file\0") or die "$0: Cannot open file: $file\n";
+
+@info = stat(FILE);
+$size = $info[7];
+
+$sectors = ($size + 511) >> 9;
+$xsize = $sectors << 9;
+
+seek(FILE, $size, SEEK_SET);
+
+if ( $size != $xsize ) {
+ # Pad to a sector boundary
+ print FILE "\0" x ($xsize-$size);
+}
+
+seek(FILE, 0x1f1, SEEK_SET); # setup_sects
+# All sectors are setup except the first
+print FILE pack("C", $sectors-1);
+
+close(FILE);
+