[syslinux] [PATCH] mboot: set boot device

Sebastian Herbszt herbszt at gmx.de
Sat Jul 10 13:00:01 PDT 2010


H. Peter Anvin wrote:
> On 07/10/2010 03:29 AM, Sebastian Herbszt wrote:
>> Miller, Shao wrote:
>>> Speaking of mbinfo.boot_device (some time ago, but it's relationship
>>> with "legacy GRUB"'s stage2's install_partition structure):
>>>
>>> I see Sebastian's patch wasn't merged. H. Peter had a concern over
>>> precision.
>>>
>>> If some of chain.c32 gets librarized (such as the start in my
>>> com32lib_disk branch), we could potentially do the right thing for this
>>> assignment in mboot.c32, as Gert H. and Paul B. gave consideration to in
>>> chain.c32.
>>
>> I think some testing is needed on how grub behaves depending on the boot
>> medium.  Especially booting from cdrom and network are interesting. My patch
>> assumed if it's not a network boot the drive number without partition should be good
>> enough. Neither floppies nor cds support partitions AFAIK.
>>
> 
> In practice they don't, that's right, but the hard disk case is 
> important, of course.
> 
> -hpa

I did some testing and the following code mimics grub's behaviour. Comments?

Sebastian

diff --git a/com32/mboot/mboot.c b/com32/mboot/mboot.c
index 35450e0..70e0a55 100644
--- a/com32/mboot/mboot.c
+++ b/com32/mboot/mboot.c
@@ -234,6 +234,22 @@ int main(int argc, char *argv[])
     mboot_apm();
     mboot_syslinux_info();

+    /* Set boot device info */
+    const union syslinux_derivative_info *sdi;
+    sdi = syslinux_derivative_info();
+    if (sdi->c.filesystem == SYSLINUX_FS_PXELINUX) {
+        mbinfo.boot_device = (0x20 << 24) | 0xffffff; /* NETWORK_DRIVE */
+        mbinfo.flags |= MB_INFO_BOOTDEV;
+    } else if (sdi->c.filesystem == SYSLINUX_FS_ISOLINUX) {
+        mbinfo.boot_device = (sdi->disk.drive_number << 24) | 0xffffff;
+        mbinfo.flags |= MB_INFO_BOOTDEV;
+    } else if (sdi->c.filesystem == SYSLINUX_FS_SYSLINUX) {
+        if (sdi->disk.drive_number < 0x80) { /* floppy */
+            mbinfo.boot_device = (sdi->disk.drive_number << 24) | 0xffffff;
+            mbinfo.flags |= MB_INFO_BOOTDEV;
+        }
+    }
+
     if (opt.solaris)
        mboot_solaris_dhcp_hack();





More information about the Syslinux mailing list