pull-in menuentry

This commit is contained in:
BVK Chaitanya 2010-08-04 19:23:07 +05:30
commit 8b42ba9674
6 changed files with 78 additions and 28 deletions

View file

@ -1,3 +1,28 @@
2010-08-04 Robert Millan <rmh@gnu.org>
Support OpenSolaris in ZFS device resolution.
* configure.ac: Check for getmntany().
* kern/emu/misc.c [HAVE_GETMNTANY]: Include `<sys/mnttab.h>'.
[HAVE_GETMNTANY] (grub_find_zpool_from_mount_point): Add OpenSolaris
support.
2010-08-03 Robert Millan <rmh@gnu.org>
Fix grub-emu build.
* include/grub/util/misc.h: Move `<grub/util/libzfs.h>' to ...
* include/grub/emu/misc.h: ... here.
* include/grub/util/misc.h (grub_get_libzfs_handle): Move function ...
* include/grub/emu/misc.h (grub_get_libzfs_handle): ... here.
* util/misc.c: Remove `<grub/util/libzfs.h>'.
[HAVE_LIBZFS] (libzfs_handle, fini_libzfs)
(grub_get_libzfs_handle): Move to ...
* kern/emu/misc.c [HAVE_LIBZFS] (__libzfs_handle, fini_libzfs)
(grub_get_libzfs_handle): ... here.
2010-08-03 BVK Chaitanya <bvk.groups@gmail.com>
* script/execute.c (grub_script_execute_cmdline): Check for NULL

View file

@ -247,7 +247,7 @@ else
fi
# Check for functions and headers.
AC_CHECK_FUNCS(posix_memalign memalign asprintf vasprintf getfsstat)
AC_CHECK_FUNCS(posix_memalign memalign asprintf vasprintf getfsstat getmntany)
AC_CHECK_HEADERS(libzfs.h libnvpair.h)
# For opendisk() and getrawpartition() on NetBSD.

View file

@ -21,6 +21,7 @@
#include <grub/symbol.h>
#include <grub/types.h>
#include <grub/util/libzfs.h>
#ifdef __CYGWIN__
# include <sys/fcntl.h>
@ -75,4 +76,6 @@ extern char * canonicalize_file_name (const char *path);
int grub_device_mapper_supported (void);
#endif
libzfs_handle_t *grub_get_libzfs_handle (void);
#endif /* GRUB_EMU_MISC_H */

View file

@ -29,7 +29,6 @@
#include <grub/types.h>
#include <grub/symbol.h>
#include <grub/emu/misc.h>
#include <grub/util/libzfs.h>
char *grub_util_get_path (const char *dir, const char *file);
size_t grub_util_get_fp_size (FILE *fp);
@ -61,6 +60,4 @@ char *canonicalize_file_name (const char *path);
void grub_util_init_nls (void);
libzfs_handle_t *grub_get_libzfs_handle (void);
#endif /* ! GRUB_UTIL_MISC_HEADER */

View file

@ -32,6 +32,10 @@
#include <limits.h>
#endif
#ifdef HAVE_GETMNTANY
# include <sys/mnttab.h>
#endif
#include <grub/mm.h>
#include <grub/err.h>
#include <grub/env.h>
@ -45,8 +49,11 @@
# include <libdevmapper.h>
#endif
#if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)
#ifdef HAVE_LIBZFS
# include <grub/util/libzfs.h>
#endif
#ifdef HAVE_LIBNVPAIR
# include <grub/util/libnvpair.h>
#endif
@ -246,6 +253,28 @@ get_win32_path (const char *path)
}
#endif
#ifdef HAVE_LIBZFS
static libzfs_handle_t *__libzfs_handle;
static void
fini_libzfs (void)
{
libzfs_fini (__libzfs_handle);
}
libzfs_handle_t *
grub_get_libzfs_handle (void)
{
if (! __libzfs_handle)
{
__libzfs_handle = libzfs_init ();
atexit (fini_libzfs);
}
return __libzfs_handle;
}
#endif /* HAVE_LIBZFS */
#if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)
/* Not ZFS-specific in itself, but for now it's only used by ZFS-related code. */
char *
@ -315,7 +344,7 @@ grub_find_zpool_from_mount_point (const char *mnt_point, char **poolname, char *
*poolname = *poolfs = NULL;
#ifdef HAVE_GETFSSTAT
#if defined(HAVE_GETFSSTAT) /* FreeBSD and GNU/kFreeBSD */
{
int mnt_count = getfsstat (NULL, 0, MNT_WAIT);
if (mnt_count == -1)
@ -338,6 +367,24 @@ grub_find_zpool_from_mount_point (const char *mnt_point, char **poolname, char *
free (mnt);
}
#elif defined(HAVE_GETMNTANY) /* OpenSolaris */
{
FILE *mnttab = fopen ("/etc/mnttab", "r");
struct mnttab mp;
struct mnttab mpref =
{
.mnt_special = NULL,
.mnt_mountp = mnt_point,
.mnt_fstype = "zfs",
.mnt_mntopts = NULL,
.mnt_time = NULL,
};
if (getmntany (mnttab, &mp, &mpref) == 0)
*poolname = xstrdup (mp.mnt_special);
fclose (mnttab);
}
#endif
if (! *poolname)

View file

@ -36,7 +36,6 @@
#include <grub/misc.h>
#include <grub/cache.h>
#include <grub/util/misc.h>
#include <grub/util/libzfs.h>
#include <grub/mm.h>
#include <grub/term.h>
#include <grub/time.h>
@ -295,27 +294,6 @@ grub_util_init_nls (void)
#endif /* (defined(ENABLE_NLS) && ENABLE_NLS) */
}
#ifdef HAVE_LIBZFS
static libzfs_handle_t *libzfs_handle;
static void
fini_libzfs (void)
{
libzfs_fini (libzfs_handle);
}
libzfs_handle_t *
grub_get_libzfs_handle (void)
{
if (! libzfs_handle)
{
libzfs_handle = libzfs_init ();
atexit (fini_libzfs);
}
return libzfs_handle;
}
#endif /* HAVE_LIBZFS */
#endif /* GRUB_UTIL */
int