summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2010-03-05 11:13:28 -0800
committerH. Peter Anvin <hpa@zytor.com>2010-03-05 11:13:28 -0800
commit7a82ceb63d9f67fa4018d28c698c72df7f554add (patch)
treed51573e6ea68c359fe47f2c11c1b9a2a2c5258c0
parentee43a6e64a6498f457e46f1e2844ab3506ba889d (diff)
downloadsyslinux-7a82ceb63d9f67fa4018d28c698c72df7f554add.tar.gz
chain.c32: Fix chaining to MBRs
The change to load the bootsector even when loading a bootstrap from a file broke the handing of chainloading the MBR of a disk. Fix this. Debugging-info-by: Thomas Mieslinger <thomas.mieslinger@lundl.de> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--com32/modules/chain.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/com32/modules/chain.c b/com32/modules/chain.c
index 9b6988d7..160aa703 100644
--- a/com32/modules/chain.c
+++ b/com32/modules/chain.c
@@ -690,7 +690,6 @@ static void usage(void)
int main(int argc, char *argv[])
{
char *mbr, *p;
- void *boot_sector = NULL;
struct part_entry *partinfo;
struct syslinux_rm_regs regs;
char *drivename, *partition;
@@ -850,7 +849,6 @@ int main(int argc, char *argv[])
/* Boot the MBR */
partinfo = NULL;
- boot_sector = mbr;
} else if (whichpart <= 4) {
/* Boot a primary partition */
@@ -950,10 +948,11 @@ int main(int argc, char *argv[])
ndata++;
}
- if (partinfo && (!opt.loadfile || data[0].base >= 0x7c00 + SECTOR)) {
+ if (!opt.loadfile || data[0].base >= 0x7c00 + SECTOR) {
/* Actually read the boot sector */
- /* Pick the first buffer that isn't already in use */
- if (!(data[ndata].data = read_sector(partinfo->start_lba))) {
+ if (!partinfo) {
+ data[ndata].data = mbr;
+ } else if (!(data[ndata].data = read_sector(partinfo->start_lba))) {
error("Cannot read boot sector\n");
goto bail;
}
@@ -972,7 +971,7 @@ int main(int argc, char *argv[])
* the string "cmdcons\0" to memory location 0000:7C03.
* Memory location 0000:7C00 contains the bootsector of the partition.
*/
- if (opt.cmldr) {
+ if (partinfo && opt.cmldr) {
memcpy((char *)data[ndata].data+3, cmldr_signature,
sizeof cmldr_signature);
}