aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-05-21 13:34:12 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-05-21 13:35:22 -0700
commitd4d9f190900d31b5e9428401a0175012957d7cb7 (patch)
tree3b1bfe13f7b711905591ee1e92fde70ee3ab437d /utils
parent652070309f5d283efacaa8c5102368da20a92c4a (diff)
downloadsyslinux-d4d9f190900d31b5e9428401a0175012957d7cb7.tar.gz
syslinux-d4d9f190900d31b5e9428401a0175012957d7cb7.tar.xz
syslinux-d4d9f190900d31b5e9428401a0175012957d7cb7.zip
isohybrid: allow selecting the _c and _f versions of the prefix
Allow selecting the _f or _c versions of the prefix in addition to the default one. This is specified with the -forcehd0 or -ctrlhd0 options. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'utils')
-rw-r--r--utils/Makefile7
-rw-r--r--utils/bin2hex.pl1
-rw-r--r--utils/isohybrid.in51
-rw-r--r--utils/mkdiskimage.in22
4 files changed, 58 insertions, 23 deletions
diff --git a/utils/Makefile b/utils/Makefile
index 179d5da6..7670bef6 100644
--- a/utils/Makefile
+++ b/utils/Makefile
@@ -23,6 +23,8 @@ LDFLAGS = -O2 -s
TARGETS = mkdiskimage isohybrid gethostip
ASIS = keytab-lilo lss16toppm md5pass ppmtolss16 sha1pass syslinux2ansi
+ISOHDPFX = ../mbr/isohdpfx.bin ../mbr/isohdpfx_f.bin ../mbr/isohdpfx_c.bin
+
all: $(TARGETS)
%.o: %.c
@@ -32,8 +34,9 @@ mkdiskimage: mkdiskimage.in ../mbr/mbr.bin bin2hex.pl
$(PERL) bin2hex.pl < ../mbr/mbr.bin | cat mkdiskimage.in - > $@
chmod a+x $@
-isohybrid: isohybrid.in ../mbr/isohdpfx.bin bin2hex.pl
- $(PERL) bin2hex.pl < ../mbr/isohdpfx.bin | cat isohybrid.in - > $@
+isohybrid: isohybrid.in $(ISOHDPFX) bin2hex.pl
+ cp -f isohybrid.in $@
+ for f in $(ISOHDPFX) ; do $(PERL) bin2hex.pl < $$f >> $@ ; done
chmod a+x $@
gethostip: gethostip.o
diff --git a/utils/bin2hex.pl b/utils/bin2hex.pl
index 3c86ec27..0cb486e7 100644
--- a/utils/bin2hex.pl
+++ b/utils/bin2hex.pl
@@ -41,4 +41,5 @@ while ( read(STDIN,$ch,1) ) {
}
}
print "\n" if ( $len );
+print "*\n";
exit 0;
diff --git a/utils/isohybrid.in b/utils/isohybrid.in
index 61ff795d..2bbaada4 100644
--- a/utils/isohybrid.in
+++ b/utils/isohybrid.in
@@ -2,6 +2,7 @@
## -----------------------------------------------------------------------
##
## Copyright 2002-2008 H. Peter Anvin - All Rights Reserved
+## Copyright 2009 Intel Corporation; author: H. Peter Anvin
##
## 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
@@ -41,17 +42,27 @@ use Fcntl;
'offset' => [0, 64],
'type' => [0, 255],
'id' => [0, 0xffffffff],
+ 'hd0' => [0, 2],
+);
+
+# Boolean options just set other options
+%bool_opt = (
+ 'nohd0' => ['hd0', 0],
+ 'forcehd0' => ['hd0', 1],
+ 'ctrlhd0' => ['hd0', 2],
);
sub usage() {
- print STDERR "Usage: $0 [options] filename\n",
+ print STDERR "Usage: $0 [options] filename.iso\n",
"Options:\n",
- " -h Number of default geometry heads\n",
- " -s Number of default geometry sectors\n",
- " -entry Specify partition entry number (1-4)\n",
- " -offset Specify partition offset (default 0)\n",
- " -type Specify partition type (default 0x17)\n",
- " -id Specify MBR ID (default random)\n";
+ " -h Number of default geometry heads\n",
+ " -s Number of default geometry sectors\n",
+ " -entry Specify partition entry number (1-4)\n",
+ " -offset Specify partition offset (default 0)\n",
+ " -type Specify partition type (default 0x17)\n",
+ " -id Specify MBR ID (default random)\n",
+ " -forcehd0 Always assume we are loaded as disk ID 0\n",
+ " -ctrlhd0 Assume disk ID 0 if the Ctrl key is pressed\n",
exit 1;
}
@@ -77,10 +88,26 @@ sub get_random() {
return ($$+time()) & 0xffffffff;
}
+sub get_hex_data() {
+ my $mbr = '';
+ my $line, $byte;
+ while ( $line = <DATA> ) {
+ chomp $line;
+ last if ($line eq '*');
+ foreach $byte ( split(/\s+/, $line) ) {
+ $mbr .= chr(hex($byte));
+ }
+ }
+ return $mbr;
+}
+
while ($ARGV[0] =~ /^\-(.*)$/) {
$o = $1;
shift @ARGV;
- if (exists($opt{$o})) {
+ if (defined($bool_opt{$o})) {
+ ($o, $v) = @{$bool_opt{$o}};
+ $opt{$o} = $v;
+ } elsif (exists($opt{$o})) {
$opt{$o} = doh(shift @ARGV);
if (defined($valid_range{$o})) {
($l, $h) = @{$valid_range{$o}};
@@ -175,12 +202,8 @@ if (defined($opt{'id'})) {
# Print the MBR and partition table
seek(FILE, 0, SEEK_SET) or die "$0: $file: $!\n";
-$mbr = '';
-while ( $line = <DATA> ) {
- chomp $line;
- foreach $byte ( split(/\s+/, $line) ) {
- $mbr .= chr(hex($byte));
- }
+for ($i = 0; $i <= $opt{'hd0'}; $i++) {
+ $mbr = get_hex_data();
}
if ( length($mbr) > 432 ) {
die "$0: Bad MBR code\n";
diff --git a/utils/mkdiskimage.in b/utils/mkdiskimage.in
index 1ce8b64f..9231fa21 100644
--- a/utils/mkdiskimage.in
+++ b/utils/mkdiskimage.in
@@ -2,6 +2,7 @@
## -----------------------------------------------------------------------
##
## Copyright 2002-2008 H. Peter Anvin - All Rights Reserved
+## Copyright 2009 Intel Corporation; author: H. Peter Anvin
##
## 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
@@ -55,6 +56,19 @@ sub get_random() {
return ($$+time()) & 0xffffffff;
}
+sub get_hex_data() {
+ my $mbr = '';
+ my $line, $byte;
+ while ( $line = <DATA> ) {
+ chomp $line;
+ last if ($line eq '*');
+ foreach $byte ( split(/\s+/, $line) ) {
+ $mbr .= chr(hex($byte));
+ }
+ }
+ return $mbr;
+}
+
$is_linux = is_linux();
if ( $is_linux ) {
# IOCTL numbers
@@ -157,13 +171,7 @@ if ( $opt{'d'} ) {
}
# Print the MBR and partition table
-$mbr = '';
-while ( $line = <DATA> ) {
- chomp $line;
- foreach $byte ( split(/\s+/, $line) ) {
- $mbr .= chr(hex($byte));
- }
-}
+$mbr = get_hex_data();
if ( length($mbr) > 440 ) {
die "$0: Bad MBR code\n";
}