Print this page
fixes + mirror
*** 20,29 ****
--- 20,30 ----
#include <grub/types.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/err.h>
#include <grub/dl.h>
+ #include <grub/zfs/zfs.h>
#include <grub/device.h>
#include <grub/file.h>
#include <grub/env.h>
#include <grub/command.h>
#include <grub/search.h>
*** 42,55 ****
static struct cache_entry *cache;
void
FUNC_NAME (const char *key, const char *var, int no_floppy,
! char **hints, unsigned nhints)
{
int count = 0;
int is_cache = 0;
grub_fs_autoload_hook_t saved_autoload;
auto int iterate_device (const char *name);
int iterate_device (const char *name)
{
--- 43,57 ----
static struct cache_entry *cache;
void
FUNC_NAME (const char *key, const char *var, int no_floppy,
! char **hints, unsigned nhints, int mirror)
{
int count = 0;
int is_cache = 0;
+ grub_uint64_t txg = 0;
grub_fs_autoload_hook_t saved_autoload;
auto int iterate_device (const char *name);
int iterate_device (const char *name)
{
*** 146,163 ****
}
if (found)
{
count++;
! if (var)
grub_env_set (var, name);
! else
grub_printf (" %s", name);
}
grub_errno = GRUB_ERR_NONE;
! return (found && var);
}
auto int part_hook (grub_disk_t disk, const grub_partition_t partition);
int part_hook (grub_disk_t disk, const grub_partition_t partition)
{
--- 148,186 ----
}
if (found)
{
count++;
! if (var) {
! if (! mirror) {
grub_env_set (var, name);
! } else {
! grub_uint64_t tmp_txg = 0;
! char * nvlist = NULL;
! grub_device_t dev = grub_device_open (name);
! if (! dev) {
! grub_errno = GRUB_ERR_BAD_DEVICE;
! return 0;
! }
! grub_errno = grub_zfs_fetch_nvlist (dev, &nvlist);
! grub_device_close (dev);
! if (grub_errno)
! return 0;
! grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_POOL_TXG, &tmp_txg);
! if (tmp_txg > txg) {
! grub_env_set (var, name);
! txg = tmp_txg;
! }
! grub_free (nvlist);
! }
! } else {
grub_printf (" %s", name);
}
+ }
grub_errno = GRUB_ERR_NONE;
! return (found && var && !mirror);
}
auto int part_hook (grub_disk_t disk, const grub_partition_t partition);
int part_hook (grub_disk_t disk, const grub_partition_t partition)
{
*** 278,288 ****
{
if (argc == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
FUNC_NAME (args[0], argc == 1 ? 0 : args[1], 0, (args + 2),
! argc > 2 ? argc - 2 : 0);
return grub_errno;
}
static grub_command_t cmd;
--- 301,311 ----
{
if (argc == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
FUNC_NAME (args[0], argc == 1 ? 0 : args[1], 0, (args + 2),
! argc > 2 ? argc - 2 : 0, 0);
return grub_errno;
}
static grub_command_t cmd;