From 62858144fe582fe4a908d277842cd50e00eba634 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Wed, 4 Aug 2010 00:15:29 +0200 Subject: [PATCH] 2010-08-04 Robert Millan Support OpenSolaris in ZFS device resolution. * configure.ac: Check for getmntany(). * kern/emu/misc.c [HAVE_GETMNTANY]: Include `'. [HAVE_GETMNTANY] (grub_find_zpool_from_mount_point): Add OpenSolaris support. --- ChangeLog | 9 +++++++++ configure.ac | 2 +- kern/emu/misc.c | 24 +++++++++++++++++++++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b3e7bc67f..958c55c79 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2010-08-04 Robert Millan + + Support OpenSolaris in ZFS device resolution. + + * configure.ac: Check for getmntany(). + * kern/emu/misc.c [HAVE_GETMNTANY]: Include `'. + [HAVE_GETMNTANY] (grub_find_zpool_from_mount_point): Add OpenSolaris + support. + 2010-08-03 Robert Millan Fix grub-emu build. diff --git a/configure.ac b/configure.ac index 6169a2fb5..41072eb4f 100644 --- a/configure.ac +++ b/configure.ac @@ -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. diff --git a/kern/emu/misc.c b/kern/emu/misc.c index 0838dc3c0..5a148c708 100644 --- a/kern/emu/misc.c +++ b/kern/emu/misc.c @@ -32,6 +32,10 @@ #include #endif +#ifdef HAVE_GETMNTANY +# include +#endif + #include #include #include @@ -340,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) @@ -363,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)