This patch adds OpenSolaris support as well, but unfortunately I can't
test it.  I will commit if someone (Seth?) can confirm it works.
=== modified file 'configure.ac'
--- configure.ac	2010-07-30 19:43:12 +0000
+++ configure.ac	2010-07-30 20:20:43 +0000
@@ -247,7 +247,7 @@ else
 fi
 
 # Check for functions.
-AC_CHECK_FUNCS(posix_memalign memalign asprintf vasprintf getfsstat)
+AC_CHECK_FUNCS(posix_memalign memalign asprintf vasprintf getfsstat getmntany)
 
 # For opendisk() and getrawpartition() on NetBSD.
 # Used in util/deviceiter.c and in util/hostdisk.c.

=== modified file 'kern/emu/getroot.c'
--- kern/emu/getroot.c	2010-07-30 19:43:12 +0000
+++ kern/emu/getroot.c	2010-07-30 20:24:05 +0000
@@ -52,6 +52,10 @@
 # include <sys/mount.h>
 #endif
 
+#ifdef HAVE_GETMNTANY
+# include <sys/mnttab.h>
+#endif
+
 #include <grub/mm.h>
 #include <grub/misc.h>
 #include <grub/emu/misc.h>
@@ -247,7 +251,7 @@ find_root_device_from_libzfs (const char
 
   mnt_point = find_mount_point_from_dir (dir);
 
-#ifdef HAVE_GETFSSTAT
+#if defined(HAVE_GETFSSTAT)
   {
     int mnt_count = getfsstat (NULL, 0, MNT_WAIT);
     if (mnt_count == -1)
@@ -270,6 +274,24 @@ find_root_device_from_libzfs (const char
 
     free (mnt);
   }
+#elif defined(HAVE_GETMNTANY)
+  {
+    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)

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to