]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
libnvpair: Support prefixed nvlist symbol names as found on NetBSD
authorVladimir Serbinenko <phcoder@gmail.com>
Thu, 24 Aug 2023 22:01:25 +0000 (00:01 +0200)
committerDaniel Kiper <daniel.kiper@oracle.com>
Wed, 13 Dec 2023 12:30:33 +0000 (13:30 +0100)
NetBSD uses slightly different function names for the same functions.

Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
configure.ac
grub-core/osdep/unix/getroot.c
include/grub/util/libnvpair.h

index 8e16ce25f5db5e6705177d9641305ec7ad0d89ab..c1b98b13de38345476474760e53980c1e18ba5fa 100644 (file)
@@ -2005,8 +2005,19 @@ fi
 
 if test x"$libzfs_excuse" = x ; then
   AC_CHECK_LIB([nvpair], [nvlist_lookup_string],
-               [],
-               [libzfs_excuse="need nvpair library"])
+               [have_normal_nvpair=yes],
+               [have_normal_nvpair=no])
+  if test x"$have_normal_nvpair" = xno ; then
+    AC_CHECK_LIB([nvpair], [opensolaris_nvlist_lookup_string],
+                 [have_prefixed_nvpair=yes],
+                 [have_prefixed_nvpair=no])
+    if test x"$have_prefixed_nvpair" = xyes ; then
+      AC_DEFINE([GRUB_UTIL_NVPAIR_IS_PREFIXED], [1],
+            [Define to 1 if libnvpair symbols are prefixed with opensolaris_.])
+    else
+      libzfs_excuse="need nvpair library"
+    fi
+  fi
 fi
 
 if test x"$enable_libzfs" = xyes && test x"$libzfs_excuse" != x ; then
index 71cdf2e86b58944ccbbf9ce6447e22bbfb2a755e..ee11b02fb6ba25ebb55bf10b8c97d35a261e7bbf 100644 (file)
@@ -174,20 +174,20 @@ grub_util_find_root_devices_from_poolname (char *poolname)
   zpool = zpool_open (libzfs, poolname);
   config = zpool_get_config (zpool, NULL);
 
-  if (nvlist_lookup_nvlist (config, "vdev_tree", &vdev_tree) != 0)
+  if (NVLIST(lookup_nvlist) (config, "vdev_tree", &vdev_tree) != 0)
     error (1, errno, "nvlist_lookup_nvlist (\"vdev_tree\")");
 
-  if (nvlist_lookup_nvlist_array (vdev_tree, "children", &children, &nvlist_count) != 0)
+  if (NVLIST(lookup_nvlist_array) (vdev_tree, "children", &children, &nvlist_count) != 0)
     error (1, errno, "nvlist_lookup_nvlist_array (\"children\")");
   assert (nvlist_count > 0);
 
-  while (nvlist_lookup_nvlist_array (children[0], "children",
+  while (NVLIST(lookup_nvlist_array) (children[0], "children",
                                     &children, &nvlist_count) == 0)
     assert (nvlist_count > 0);
 
   for (i = 0; i < nvlist_count; i++)
     {
-      if (nvlist_lookup_string (children[i], "path", &device) != 0)
+      if (NVLIST(lookup_string) (children[i], "path", &device) != 0)
        error (1, errno, "nvlist_lookup_string (\"path\")");
 
       struct stat st;
index 573c7ea816a0ceb610d33a13dd11cad3a3df1e7c..a3acffb88e9c0a194c2c3c9cf925e5ddd0400581 100644 (file)
 
 typedef void nvlist_t;
 
-int nvlist_lookup_string (nvlist_t *, const char *, char **);
-int nvlist_lookup_nvlist (nvlist_t *, const char *, nvlist_t **);
-int nvlist_lookup_nvlist_array (nvlist_t *, const char *, nvlist_t ***, unsigned int *);
+#ifdef GRUB_UTIL_NVPAIR_IS_PREFIXED
+#define NVLIST(x) opensolaris_nvlist_ ## x
+#else
+#define NVLIST(x) nvlist_ ## x
+#endif
+
+int NVLIST(lookup_string) (nvlist_t *, const char *, char **);
+int NVLIST(lookup_nvlist) (nvlist_t *, const char *, nvlist_t **);
+int NVLIST(lookup_nvlist_array) (nvlist_t *, const char *, nvlist_t ***, unsigned int *);
 
 #endif /* ! HAVE_LIBNVPAIR_H */