]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2010-08-04 Robert Millan <rmh@gnu.org>
authorRobert Millan <rmh@aybabtu.com>
Tue, 3 Aug 2010 22:15:29 +0000 (00:15 +0200)
committerRobert Millan <rmh@aybabtu.com>
Tue, 3 Aug 2010 22:15:29 +0000 (00:15 +0200)
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.

ChangeLog
configure.ac
kern/emu/misc.c

index b3e7bc67f0129fae009cea9088dec643dc58b2e3..958c55c798e3ec34b9ac83f520bc20fdabf01b6f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+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.
index 6169a2fb51dd8df4eb299370d6c8d91c8ff5b634..41072eb4f334b7415950f80e0efd9ee9c61e79c9 100644 (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.
index 0838dc3c09643d6acb9bb6b7c362553ab8ba349f..5a148c708bb8c468c95c6635fa971de9bb7737d0 100644 (file)
 #include <limits.h>
 #endif
 
+#ifdef HAVE_GETMNTANY
+# include <sys/mnttab.h>
+#endif
+
 #include <grub/mm.h>
 #include <grub/err.h>
 #include <grub/env.h>
@@ -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)