2010-08-01 Robert Millan <rmh@gnu.org>
Make it even harder to use uninitialized `libzfs_handle' (and make the interface a bit simpler). * include/grub/util/misc.h (grub_util_init_libzfs) (libzfs_handle): Remove. (grub_get_libzfs_handle): New prototype. * util/misc.c [HAVE_LIBZFS] (libzfs_handle): Add `static' attribute. (grub_util_init_libzfs): Remove. (grub_get_libzfs_handle): New function. * kern/emu/getroot.c (find_root_device_from_libzfs): Use grub_get_libzfs_handle() to obtain a libzfs handle instead of accessing `libzfs_handle' directly.
This commit is contained in:
parent
c882acc031
commit
f7abdefbdd
4 changed files with 27 additions and 12 deletions
18
ChangeLog
18
ChangeLog
|
@ -1,3 +1,21 @@
|
|||
2010-08-01 Robert Millan <rmh@gnu.org>
|
||||
|
||||
Make it even harder to use uninitialized `libzfs_handle' (and
|
||||
make the interface a bit simpler).
|
||||
|
||||
* include/grub/util/misc.h (grub_util_init_libzfs)
|
||||
(libzfs_handle): Remove.
|
||||
(grub_get_libzfs_handle): New prototype.
|
||||
|
||||
* util/misc.c [HAVE_LIBZFS] (libzfs_handle): Add `static'
|
||||
attribute.
|
||||
(grub_util_init_libzfs): Remove.
|
||||
(grub_get_libzfs_handle): New function.
|
||||
|
||||
* kern/emu/getroot.c (find_root_device_from_libzfs): Use
|
||||
grub_get_libzfs_handle() to obtain a libzfs handle instead of
|
||||
accessing `libzfs_handle' directly.
|
||||
|
||||
2010-08-01 Robert Millan <rmh@gnu.org>
|
||||
|
||||
* include/grub/emu/misc.h (grub_find_mount_point_from_dir)
|
||||
|
|
|
@ -61,7 +61,6 @@ char *canonicalize_file_name (const char *path);
|
|||
|
||||
void grub_util_init_nls (void);
|
||||
|
||||
void grub_util_init_libzfs (void);
|
||||
extern libzfs_handle_t *libzfs_handle;
|
||||
libzfs_handle_t *grub_get_libzfs_handle (void);
|
||||
|
||||
#endif /* ! GRUB_UTIL_MISC_HEADER */
|
||||
|
|
|
@ -197,9 +197,7 @@ find_root_device_from_libzfs (const char *dir)
|
|||
nvlist_t **nvlist_array;
|
||||
unsigned int nvlist_count;
|
||||
|
||||
grub_util_init_libzfs ();
|
||||
|
||||
zpool = zpool_open (libzfs_handle, poolname);
|
||||
zpool = zpool_open (grub_get_libzfs_handle (), poolname);
|
||||
nvlist = zpool_get_config (zpool, NULL);
|
||||
|
||||
if (nvlist_lookup_nvlist (nvlist, "vdev_tree", &nvlist) != 0)
|
||||
|
|
14
util/misc.c
14
util/misc.c
|
@ -296,27 +296,27 @@ grub_util_init_nls (void)
|
|||
}
|
||||
|
||||
#ifdef HAVE_LIBZFS
|
||||
libzfs_handle_t *libzfs_handle;
|
||||
static libzfs_handle_t *libzfs_handle;
|
||||
|
||||
static void
|
||||
fini_libzfs (void)
|
||||
{
|
||||
libzfs_fini (libzfs_handle);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
grub_util_init_libzfs (void)
|
||||
libzfs_handle_t *
|
||||
grub_get_libzfs_handle (void)
|
||||
{
|
||||
#ifdef HAVE_LIBZFS
|
||||
if (! libzfs_handle)
|
||||
{
|
||||
libzfs_handle = libzfs_init ();
|
||||
atexit (fini_libzfs);
|
||||
}
|
||||
#endif
|
||||
|
||||
return libzfs_handle;
|
||||
}
|
||||
#endif
|
||||
#endif /* HAVE_LIBZFS */
|
||||
#endif /* GRUB_UTIL */
|
||||
|
||||
int
|
||||
grub_dl_ref (grub_dl_t mod)
|
||||
|
|
Loading…
Reference in a new issue