diff -r 59814c4fed40 -r 21692a51cebb loader/i386/bsd.c --- a/loader/i386/bsd.c Thu Feb 18 13:44:25 2010 -0800 +++ b/loader/i386/bsd.c Sun Feb 21 16:34:39 2010 -0800 @@ -54,6 +54,7 @@ static grub_dl_t my_mod; static grub_addr_t entry, entry_hi, kern_start, kern_end; static grub_uint32_t bootflags; +static grub_uint64_t zpool_guid = 0; static char *mod_buf; static grub_uint32_t mod_buf_len, mod_buf_max, kern_end_mdofs; static int is_elf_kernel, is_64bit; @@ -559,7 +560,7 @@ } else grub_unix_real_boot (entry, bootflags | FREEBSD_RB_BOOTINFO, bootdev, - 0, 0, 0, &bi, bi.tags, kern_end); + zpool_guid ? 4 : 0, zpool_guid, &bi, bi.tags, kern_end); /* Not reached. */ return GRUB_ERR_NONE; @@ -742,6 +743,7 @@ grub_free (netbsd_root); netbsd_root = NULL; + zpool_guid = 0; return GRUB_ERR_NONE; } @@ -954,6 +956,30 @@ return result; } +static void +grub_fetch_zpool_guid(void) +{ + grub_device_t dev; + grub_fs_t fs; + char *uuid = NULL; + + dev = grub_device_open (NULL); + if (! dev) + return; + + fs = grub_fs_probe (dev); + if (! fs) + return; + + if (grub_strcmp(fs->name, "zfs") != 0 || + ! fs->uuid || fs->uuid (dev, &uuid) || !uuid) + return; + + zpool_guid = grub_strtoull(uuid, NULL, 16); + + grub_free (uuid); +} + static grub_err_t grub_cmd_freebsd (grub_extcmd_t cmd, int argc, char *argv[]) { @@ -1012,6 +1038,7 @@ return err; } grub_loader_set (grub_freebsd_boot, grub_bsd_unload, 1); + grub_fetch_zpool_guid(); } return grub_errno;