+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
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>
# 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
*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)
{