chain.c32: don't swap drives when already primary syslinux-3.70-pre17
authorH. Peter Anvin <hpa@zytor.com>
Fri, 13 Jun 2008 00:44:59 +0000 (17:44 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Fri, 13 Jun 2008 00:44:59 +0000 (17:44 -0700)
Don't install the swap stub when we are already the primary drive,
even if -swap is specified.

com32/modules/chain.c

index a162ca3..a9ebf76 100644 (file)
@@ -328,6 +328,8 @@ static void do_boot(void *boot_sector, size_t boot_size,
   struct syslinux_memmap *mmap;
   struct syslinux_movelist *mlist = NULL;
   addr_t dosmem = old_bios_fbm << 10;
+  uint8_t driveno   = regs->edx.b[0];
+  uint8_t swapdrive = driveno & 0x80;
 
   mmap = syslinux_memory_map();
 
@@ -336,10 +338,8 @@ static void do_boot(void *boot_sector, size_t boot_size,
     return;
   }
 
-  if (opt.swap) {
+  if (opt.swap && driveno != swapdrive) {
     uint8_t *p;
-    uint8_t driveno   = regs->edx.b[0];
-    uint8_t swapdrive = driveno & 0x80;
 
     regs->edx.b[0] = swapdrive;