]> git.proxmox.com Git - grub2.git/commitdiff
2010-09-10 Robert Millan <rmh@gnu.org>
authorRobert Millan <rmh@aybabtu.com>
Fri, 10 Sep 2010 12:32:28 +0000 (14:32 +0200)
committerRobert Millan <rmh@aybabtu.com>
Fri, 10 Sep 2010 12:32:28 +0000 (14:32 +0200)
Solaris support in grub_find_zpool_from_dir().  Thanks
Seth Goldberg for referring to getextmntent() facility.

* configure.ac: Check for getextmntent(), `sys/mnttab.h' and
`sys/mkdev.h'.
* grub-core/kern/emu/misc.c [HAVE_SYS_MNTTAB_H]: Include
`<sys/mnttab.h>'.
[HAVE_SYS_MKDEV_H]: Include `<sys/mkdev.h>'.
[HAVE_GETEXTMNTENT] (grub_find_zpool_from_dir): Add getextmntent()
method for finding zpool name.

ChangeLog
configure.ac
grub-core/kern/emu/misc.c

index c5d0760a675bf357027f8e6c574b91fa7fb31173..1abd195561f6f4cb23c10108cee6158a5385b2ae 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2010-09-10  Robert Millan  <rmh@gnu.org>
+
+       Solaris support in grub_find_zpool_from_dir().  Thanks
+       Seth Goldberg for referring to getextmntent() facility.
+
+       * configure.ac: Check for getextmntent(), `sys/mnttab.h' and
+       `sys/mkdev.h'.
+       * grub-core/kern/emu/misc.c [HAVE_SYS_MNTTAB_H]: Include
+       `<sys/mnttab.h>'.
+       [HAVE_SYS_MKDEV_H]: Include `<sys/mkdev.h>'.
+       [HAVE_GETEXTMNTENT] (grub_find_zpool_from_dir): Add getextmntent()
+       method for finding zpool name.
+
 2010-09-10  Colin Watson  <cjwatson@ubuntu.com>
 
        grub-fstest needs the host and hostfs modules while other utilities
index ec1ea8d88d7bf33d22f3962110e089cfcc000a0a..d50dfe6dd71c8f2ac9132c8e9a5c1a564fa0d33c 100644 (file)
@@ -277,8 +277,8 @@ else
 fi
 
 # Check for functions and headers.
-AC_CHECK_FUNCS(posix_memalign memalign asprintf vasprintf)
-AC_CHECK_HEADERS(libzfs.h libnvpair.h sys/param.h sys/mount.h)
+AC_CHECK_FUNCS(posix_memalign memalign asprintf vasprintf getextmntent)
+AC_CHECK_HEADERS(libzfs.h libnvpair.h sys/param.h sys/mount.h sys/mnttab.h sys/mkdev.h)
 
 AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default
 #include <sys/param.h>
index db89f0eced21d8af2cfa640bfdf808ac86189a6a..c710777ea9406f6b6d85c40ca8a95400be39021d 100644 (file)
 # include <sys/mount.h>
 #endif
 
+#ifdef HAVE_SYS_MNTTAB_H
+# include <stdio.h> /* Needed by sys/mnttab.h.  */
+# include <sys/mnttab.h>
+#endif
+
+#ifdef HAVE_SYS_MKDEV_H
+# include <sys/mkdev.h> /* makedev */
+#endif
+
 int verbosity;
 
 void
@@ -299,10 +308,36 @@ grub_find_zpool_from_dir (const char *dir, char **poolname, char **poolfs)
 
     *poolname = xstrdup (mnt.f_mntfromname);
   }
-#else
-  return;
+#elif defined(HAVE_GETEXTMNTENT)
+  /* Solaris.  */
+  {
+    struct stat st;
+    struct extmnttab mnt;
+
+    if (stat (dir, &st) != 0)
+      return;
+
+    FILE *mnttab = fopen ("/etc/mnttab", "r");
+    if (! mnttab)
+      return;
+
+    while (getextmntent (mnttab, &mnt, sizeof (mnt)) == 0)
+      {
+       if (makedev (mnt.mnt_major, mnt.mnt_minor) == st.st_dev
+           && !strcmp (mnt.mnt_fstype, "zfs"))
+         {
+           *poolname = xstrdup (mnt.mnt_special);
+           break;
+         }
+      }
+
+    fclose (mnttab);
+  }
 #endif
 
+  if (! *poolname)
+    return;
+
   slash = strchr (*poolname, '/');
   if (slash)
     {