grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: "Vladimir 'phcoder' Serbinenko" <phcoder@gmail.com>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: [PATCH 11/13] Support prefixed nvlist symbol names as found on NetBSD
Date: Sun, 8 Oct 2023 16:02:35 +0200	[thread overview]
Message-ID: <CAEaD8JOcx5Q4WGRFkw5e5Zw==ATWFe6q5JHbCtmK1NVmsS4coA@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #1.2: Type: text/html, Size: 23 bytes --]

[-- Attachment #2: 0011-Support-prefixed-nvlist-symbol-names-as-found-on-Net.patch --]
[-- Type: text/x-diff, Size: 3515 bytes --]

From 186cb47e71ae9d14699c54f93b61ce5d749e8fa8 Mon Sep 17 00:00:00 2001
From: Vladimir Serbinenko <phcoder@gmail.com>
Date: Fri, 25 Aug 2023 00:01:25 +0200
Subject: [PATCH 11/13] Support prefixed nvlist symbol names as found on NetBSD

---
 configure.ac                   | 15 +++++++++++++--
 grub-core/osdep/unix/getroot.c |  8 ++++----
 include/grub/util/libnvpair.h  | 12 +++++++++---
 3 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/configure.ac b/configure.ac
index 2902f9533..9fa0931b3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1983,8 +1983,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
diff --git a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getroot.c
index 71cdf2e86..ee11b02fb 100644
--- a/grub-core/osdep/unix/getroot.c
+++ b/grub-core/osdep/unix/getroot.c
@@ -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;
diff --git a/include/grub/util/libnvpair.h b/include/grub/util/libnvpair.h
index 573c7ea81..a3acffb88 100644
--- a/include/grub/util/libnvpair.h
+++ b/include/grub/util/libnvpair.h
@@ -29,9 +29,15 @@
 
 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 */
 
-- 
2.42.0


[-- Attachment #3: Type: text/plain, Size: 141 bytes --]

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

                 reply	other threads:[~2023-10-08 14:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEaD8JOcx5Q4WGRFkw5e5Zw==ATWFe6q5JHbCtmK1NVmsS4coA@mail.gmail.com' \
    --to=phcoder@gmail.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).