[PATCH 14/14] mm: Use %x and a case for displaying sizeof.
There is some variance in how compiler treat sizeof especially on 32-bit platforms where it can be naturally either int or long. Explicit cast solves the issue Signed-off-by: Vladimir Serbinenko From 3e738cb99eb15f2cfa9d5c7dc887d2869143a69e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 25 Aug 2023 13:37:43 +0200 Subject: [PATCH 14/14] mm: Use %x and a case for displaying sizeof. There is some variance in how compiler treat sizeof especially on 32-bit platforms where it can be naturally either int or long. Explicit cast solves the issue Signed-off-by: Vladimir Serbinenko --- grub-core/kern/mm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c index 792ab0a83..2ba0c184e 100644 --- a/grub-core/kern/mm.c +++ b/grub-core/kern/mm.c @@ -238,8 +238,8 @@ grub_mm_init_region (void *addr, grub_size_t size) * ||-q->post_size-|size-| */ grub_dprintf ("regions", "Can we extend into region below?" -" %p + %" PRIxGRUB_SIZE " + %" PRIxGRUB_SIZE " + %" PRIxGRUB_SIZE " ?=? %p\n", -(grub_uint8_t *) q, sizeof(*q), q->size, q->post_size, (grub_uint8_t *) addr); +" %p + %x + %" PRIxGRUB_SIZE " + %" PRIxGRUB_SIZE " ?=? %p\n", +(grub_uint8_t *) q, (int) sizeof(*q), q->size, q->post_size, (grub_uint8_t *) addr); if ((grub_uint8_t *) q + sizeof (*q) + q->size + q->post_size == (grub_uint8_t *) addr) { -- 2.39.2 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH 13/14] configure: Add RPATH for freetype on NetBSD
Without this build-time mkfont fails dynamic linking. This is not ideal but improves the situation until a better solution is available Signed-off-by: Vladimir Serbinenko From 77daaa1d869c713f674917a90295046a4e3ae8b3 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 25 Aug 2023 01:54:09 +0200 Subject: [PATCH 13/14] configure: Add RPATH for freetype on NetBSD Without this build-time mkfont fails dynamic linking. This is not ideal but improves the situation until a better solution is available Signed-off-by: Vladimir Serbinenko --- configure.ac | 8 1 file changed, 8 insertions(+) diff --git a/configure.ac b/configure.ac index a35dbdcf2..c1b98b13d 100644 --- a/configure.ac +++ b/configure.ac @@ -1716,6 +1716,9 @@ if test x"$grub_mkfont_excuse" = x ; then CPPFLAGS="$SAVED_CPPFLAGS" LIBS="$SAVED_LIBS" ], [grub_mkfont_excuse=["need freetype2 library"]]) + if test x"$grub_mkfont_excuse" = x && test x"$host_kernel" = xnetbsd ; then + FREETYPE_LIBS="$FREETYPE_LIBS -Wl,-R,/usr/pkg/lib" ; + fi fi if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then @@ -1770,6 +1773,11 @@ if test x"$grub_build_mkfont_excuse" = x ; then LIBS="$SAVED_LIBS" CPPFLAGS="$SAVED_CPPFLAGS_2" ], [grub_build_mkfont_excuse=["need freetype2 library"]]) + if test x"$grub_build_mkfont_excuse" = x ; then +case x"$build_os" in + xnetbsd*) BUILD_FREETYPE_LIBS="$BUILD_FREETYPE_LIBS -Wl,-R,/usr/pkg/lib" ;; +esac + fi PKG_CONFIG="$SAVED_PKG_CONFIG" fi -- 2.39.2 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH 12/14] Support prefixed nvlist symbol names as found on NetBSD
NetBSD uses slightly different function names for the same functions. Signed-off-by: Vladimir Serbinenko From ec4433f62273c16db2b25a19a60492a838aa5178 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 25 Aug 2023 00:01:25 +0200 Subject: [PATCH 12/14] Support prefixed nvlist symbol names as found on NetBSD NetBSD uses slightly different function names for the same functions. Signed-off-by: Vladimir Serbinenko --- 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 1fffe996d..a35dbdcf2 100644 --- a/configure.ac +++ b/configure.ac @@ -1997,8 +1997,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", _tree) != 0) + if (NVLIST(lookup_nvlist) (config, "vdev_tree", _tree) != 0) error (1, errno, "nvlist_lookup_nvlist (\"vdev_tree\")"); - if (nvlist_lookup_nvlist_array (vdev_tree, "children", , _count) != 0) + if (NVLIST(lookup_nvlist_array) (vdev_tree, "children", , _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", , _count) == 0) assert (nvlist_count > 0); for (i = 0; i < nvlist_count; i++) { - if (nvlist_lookup_string (children[i], "path", ) != 0) + if (NVLIST(lookup_string) (children[i], "path", ) != 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.39.2 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH 11/14] configure: Add *BSD font paths
*BSD puts fonts in other places. Add them to the list Signed-off-by: Vladimir Serbinenko From 49c7688352fd815eab6e9fcf214f9e05d9833279 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 25 Aug 2023 00:00:52 +0200 Subject: [PATCH 11/14] configure: Add *BSD font paths *BSD puts fonts in other places. Add them to the list Signed-off-by: Vladimir Serbinenko --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 5e6e7d377..1fffe996d 100644 --- a/configure.ac +++ b/configure.ac @@ -1817,7 +1817,7 @@ if test "x$with_dejavufont" = x; then # search in well-known directories if test x"$starfield_excuse" = x; then for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do - for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu /usr/share/fonts/truetype; do + for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu /usr/share/fonts/truetype /usr/pkg/share/fonts/X11/TTF /usr/local/share/fonts/dejavu /usr/X11R6/lib/X11/fonts/TTF; do if test -f "$dir/DejaVuSans.$ext"; then DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext" break 2 @@ -1846,7 +1846,7 @@ AC_ARG_WITH([unifont], if test "x$with_unifont" = x; then # search in well-known directories for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do -for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/unifont /usr/share/fonts/uni /usr/share/fonts/truetype/unifont /usr/share/fonts/misc; do +for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/unifont /usr/share/fonts/uni /usr/share/fonts/truetype/unifont /usr/share/fonts/misc /usr/pkg/share/fonts/X11/misc /usr/local/share/fonts/gnu-unifont /usr/local/share/fonts/unifont; do if test -f "$dir/unifont.$ext"; then md5="$(md5sum "$dir/unifont.$ext"|awk '{ print $1; }')" # PCF and BDF from version 6.3 isn't hanled properly by libfreetype. -- 2.39.2 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH 10/14] autogen: Accept python3.10 as a python alternative
NetBSD doesn't provide python or python3 Signed-off-by: Vladimir Serbinenko -- Regards Vladimir 'phcoder' Serbinenko From a07508b0d0de0ff976378c4765f0b613ee4667b1 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 24 Aug 2023 23:25:48 +0200 Subject: [PATCH 10/14] autogen: Accept python3.10 as a python alternative NetBSD doesn't provide python or python3 Signed-off-by: Vladimir Serbinenko --- autogen.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autogen.sh b/autogen.sh index 5a5c356fd..195daa541 100755 --- a/autogen.sh +++ b/autogen.sh @@ -9,7 +9,7 @@ fi # Detect python if [ -z "$PYTHON" ]; then - for i in python3 python; do + for i in python3 python3.10 python; do if command -v "$i" > /dev/null 2>&1; then PYTHON="$i" echo "Using $PYTHON..." -- 2.39.2 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH 09/14] Rename HAVE_LIBZFS to USE_LIBZFS
HAVE_LIBZFS is defined by libzfs test and hence conflicts with manual definition On NetBSD it ends up detecting zfs but not detecting nvpair and creates confusion Split them Signed-off-by: Vladimir Serbinenko From 5291725d6f64b590ee90d51d11877cc52d52e733 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 24 Aug 2023 23:24:30 +0200 Subject: [PATCH 09/14] Rename HAVE_LIBZFS to USE_LIBZFS HAVE_LIBZFS is defined by libzfs test and hence conflicts with manual definition On NetBSD it ends up detecting zfs but not detecting nvpair and creates confusion Split them Signed-off-by: Vladimir Serbinenko --- configure.ac | 6 ++ grub-core/osdep/unix/getroot.c | 4 ++-- util/getroot.c | 6 +++--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index c19779c14..5e6e7d377 100644 --- a/configure.ac +++ b/configure.ac @@ -2008,11 +2008,9 @@ fi if test x"$libzfs_excuse" = x ; then # We need both libzfs and libnvpair for a successful build. LIBZFS="-lzfs" - AC_DEFINE([HAVE_LIBZFS], [1], -[Define to 1 if you have the ZFS library.]) LIBNVPAIR="-lnvpair" - AC_DEFINE([HAVE_LIBNVPAIR], [1], -[Define to 1 if you have the NVPAIR library.]) + AC_DEFINE([USE_LIBZFS], [1], +[Define to 1 if ZFS library should be used.]) fi AC_SUBST([LIBZFS]) diff --git a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getroot.c index cde821eb9..71cdf2e86 100644 --- a/grub-core/osdep/unix/getroot.c +++ b/grub-core/osdep/unix/getroot.c @@ -53,7 +53,7 @@ #include -#if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR) +#ifdef USE_LIBZFS # include # include #endif @@ -158,7 +158,7 @@ grub_util_find_root_devices_from_poolname (char *poolname) size_t ndevices = 0; size_t devices_allocated = 0; -#if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR) +#ifdef USE_LIBZFS zpool_handle_t *zpool; libzfs_handle_t *libzfs; nvlist_t *config, *vdev_tree; diff --git a/util/getroot.c b/util/getroot.c index 086581998..75a7d5f21 100644 --- a/util/getroot.c +++ b/util/getroot.c @@ -47,7 +47,7 @@ #include -#if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR) +#ifdef USE_LIBZFS # include # include #endif @@ -456,7 +456,7 @@ grub_util_biosdisk_is_present (const char *os_dev) return ret; } -#ifdef HAVE_LIBZFS +#ifdef USE_LIBZFS static libzfs_handle_t *__libzfs_handle; static void @@ -478,5 +478,5 @@ grub_get_libzfs_handle (void) return __libzfs_handle; } -#endif /* HAVE_LIBZFS */ +#endif /* USE_LIBZFS */ -- 2.39.2 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH 08/14] gnulib: Tolerate always_inline attribute being ignored.
It's not critical, Werror on it is inappropriate. We don't want to modify gnulib too much. This warning is pretty much irrelevant. Signed-off-by: Vladimir Serbinenko From 8aca438ea92fa0cae827c026678fbc55b5613d80 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 24 Aug 2023 22:45:53 +0200 Subject: [PATCH 08/14] gnulib: Tolerate always_inline attribute being ignored. It's not critical, Werror on it is inappropriate. We don't want to modify gnulib too much. This warning is pretty much irrelevant. Signed-off-by: Vladimir Serbinenko --- conf/Makefile.common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/Makefile.common b/conf/Makefile.common index f8faa92e9..b8f216f6c 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -75,7 +75,7 @@ grubconfdir = $(sysconfdir)/grub.d platformdir = $(pkglibdir)/$(target_cpu)-$(platform) starfielddir = $(pkgdatadir)/themes/starfield -CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion +CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion -Wno-error=attributes CPPFLAGS_GNULIB = -I$(top_builddir)/grub-core/lib/gnulib -I$(top_srcdir)/grub-core/lib/gnulib CFLAGS_POSIX = -fno-builtin -- 2.39.2 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH 07/14] Don't use %m formatter
It's not available on NetBSD outside of syslog. Using strerror is more reliable as we retrieve errno immediately rather than down the stack Signed-off-by: Vladimir Serbinenko -- Regards Vladimir 'phcoder' Serbinenko From c8990bda2de54cf87de65835436ba0b2182b0e5c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 24 Aug 2023 22:32:45 +0200 Subject: [PATCH 07/14] Don't use %m formatter It's not available on NetBSD outside of syslog. Using strerror is more reliable as we retrieve errno immediately rather than down the stack Signed-off-by: Vladimir Serbinenko --- util/editenv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/editenv.c b/util/editenv.c index c532b046f..9cafd838d 100644 --- a/util/editenv.c +++ b/util/editenv.c @@ -91,7 +91,7 @@ grub_util_create_envblk_file (const char *name) else if (retsize < 0) { free (linkbuf); - grub_util_error (_("cannot rename the file %s to %s: %m"), namenew, name); + grub_util_error (_("cannot rename the file %s to %s: %s"), namenew, name, strerror(errno)); } else if (retsize == size) { @@ -128,7 +128,7 @@ grub_util_create_envblk_file (const char *name) free (rename_target); if (rc < 0) -grub_util_error (_("cannot rename the file %s to %s: %m"), namenew, name); +grub_util_error (_("cannot rename the file %s to %s: %s"), namenew, name, strerror(errno)); #endif free (namenew); -- 2.39.2 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH 06/14] bsd/hostdisk: Fix NetBSD compilation
Wrong function and variable name cause a stupid compilation error on NetBSD and OpenBSD. Only NetBSD and OpenBSD use this file. No other platform is affected Signed-off-by: Vladimir Serbinenko From abfb6d28342de26ce3e750f3a5a477221efcdc62 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 24 Aug 2023 21:48:20 +0200 Subject: [PATCH 06/14] bsd/hostdisk: Fix NetBSD compilation Wrong function and variable name cause a stupid compilation error on NetBSD and OpenBSD. Only NetBSD and OpenBSD use this file. No other platform is affected Signed-off-by: Vladimir Serbinenko --- grub-core/osdep/bsd/hostdisk.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/grub-core/osdep/bsd/hostdisk.c b/grub-core/osdep/bsd/hostdisk.c index 891109462..1a7ea97b4 100644 --- a/grub-core/osdep/bsd/hostdisk.c +++ b/grub-core/osdep/bsd/hostdisk.c @@ -56,6 +56,10 @@ # endif #if defined(__NetBSD__) +# ifndef RAW_FLOPPY_MAJOR +# define RAW_FLOPPY_MAJOR 9 +# endif /* ! RAW_FLOPPY_MAJOR */ + /* Adjust device driver parameters. This function should be called just after successfully opening the device. For now, it simply prevents the floppy driver from retrying operations on failure, as otherwise the @@ -92,7 +96,7 @@ grub_util_fd_open (const char *os_dev, int flags) ret = open (os_dev, flags, S_IROTH | S_IRGRP | S_IRUSR | S_IWUSR); if (ret >= 0) -configure_device_driver (fd); +configure_device_driver (ret); return ret; } @@ -105,7 +109,7 @@ grub_util_get_fd_size_os (grub_util_fd_t fd, const char *name, unsigned *log_sec unsigned sector_size, log_sector_size; #if defined(__NetBSD__) - grub_hostdisk_configure_device_driver (fd); + configure_device_driver (fd); #endif if (ioctl (fd, DIOCGDINFO, ) == -1) -- 2.39.2 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH 05/14] bootstrap: Don't check gettext version
NetBSD gettext is older than the check but we don't actually need 0.18.3, older works fine. This is needed to make bootstrap work on NetBSD Signed-off-by: Vladimir Serbinenko From 42fd822c4606ccd13c8b4ac58b3b07dbee55d7da Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 24 Aug 2023 21:47:50 +0200 Subject: [PATCH 05/14] bootstrap: Don't check gettext version NetBSD gettext is older than the check but we don't actually need 0.18.3, older works fine. This is needed to make bootstrap work on NetBSD Signed-off-by: Vladimir Serbinenko --- bootstrap.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap.conf b/bootstrap.conf index 64ea9bcb5..7a7813d28 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -68,7 +68,7 @@ SKIP_PO=t buildreq="\ autoconf 2.64 automake 1.14 -gettext0.18.3 +gettext- git1.5.5 patch - tar- -- 2.39.2 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH 04/14] Fix compilation of generic/blocklist
After recent change in blocklist types we have a type mismatch. Fixing it requires a wrapper or large changes. I feel like wrapper makes more sense Without this patch we end up with a compilation problem and without wrapping callback data is not passed properly anymore Signed-off-by: Vladimir Serbinenko --- grub-core/osdep/generic/blocklist.c | 27 +-- 1 file changed, 25 insertions(+), 2 deletions(-) From e8ed2571c4215ac8cbc56b8524d6d363485c8c1f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 24 Aug 2023 09:33:47 +0200 Subject: [PATCH 04/14] Fix compilation of generic/blocklist After recent change in blocklist types we have a type mismatch. Fixing it requires a wrapper or large changes. I feel like wrapper makes more sense Without this patch we end up with a compilation problem and without wrapping callback data is not passed properly anymore Signed-off-by: Vladimir Serbinenko --- grub-core/osdep/generic/blocklist.c | 27 +-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/grub-core/osdep/generic/blocklist.c b/grub-core/osdep/generic/blocklist.c index 2d9040302..97e416866 100644 --- a/grub-core/osdep/generic/blocklist.c +++ b/grub-core/osdep/generic/blocklist.c @@ -30,6 +30,25 @@ #define MAX_TRIES 5 +struct wrapper_hook_data +{ + void (*callback) (grub_disk_addr_t sector, + unsigned offset, + unsigned length, + void *data); + void *callback_data; +}; + +static grub_err_t +callback_wrapper (grub_disk_addr_t sector, + unsigned offset, unsigned length, + char *buf, void *data) +{ + struct wrapper_hook_data *wrap = data; + wrap->callback(sector, offset, length, wrap->callback_data); + return GRUB_ERR_NONE; +} + void grub_install_get_blocklist (grub_device_t root_dev, const char *core_path, const char *core_img, @@ -43,6 +62,10 @@ grub_install_get_blocklist (grub_device_t root_dev, int i; char *tmp_img; char *core_path_dev; + struct wrapper_hook_data wrap_hook_data = { +.callback = callback, +.callback_data = hook_data + }; core_path_dev = grub_make_system_path_relative_to_its_root (core_path); @@ -120,8 +143,8 @@ grub_install_get_blocklist (grub_device_t root_dev, if (! file) grub_util_error ("%s", grub_errmsg); - file->read_hook = callback; - file->read_hook_data = hook_data; + file->read_hook = callback_wrapper; + file->read_hook_data = _hook_data; if (grub_file_read (file, tmp_img, core_size) != (grub_ssize_t) core_size) grub_util_error ("%s", _("failed to read the sectors of the core image")); -- 2.39.2 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH 03/14] diskfilter: Remove unused variable
Variable e is set but never used. We can just remove it now. Signed-off-by: Vladimir Serbinenko From 2c24c247d81de30aa28e671da1ac6a7587c2f54e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 24 Aug 2023 02:32:55 +0200 Subject: [PATCH 03/14] diskfilter: Remove unused variable Variable e is set but never used. We can just remove it now. Signed-off-by: Vladimir Serbinenko --- grub-core/disk/diskfilter.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c index 61a311efd..21e239511 100644 --- a/grub-core/disk/diskfilter.c +++ b/grub-core/disk/diskfilter.c @@ -720,7 +720,7 @@ read_segment (struct grub_diskfilter_segment *seg, grub_disk_addr_t sector, case GRUB_DISKFILTER_RAID6: { grub_disk_addr_t read_sector; - grub_uint64_t b, p, n, disknr, e; + grub_uint64_t b, p, n, disknr; /* n = 1 for level 4 and 5, 2 for level 6. */ n = seg->type / 3; @@ -770,7 +770,6 @@ read_segment (struct grub_diskfilter_segment *seg, grub_disk_addr_t sector, if (read_size > size) read_size = size; - e = 0; /* Reset read error. */ if (grub_errno == GRUB_ERR_READ_ERROR || grub_errno == GRUB_ERR_UNKNOWN_DEVICE) @@ -784,7 +783,6 @@ read_segment (struct grub_diskfilter_segment *seg, grub_disk_addr_t sector, if ((err) && (err != GRUB_ERR_READ_ERROR && err != GRUB_ERR_UNKNOWN_DEVICE)) return err; - e++; if (err) { -- 2.39.2 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH 02/14] Tolerate unused-but-set in generated lexer/bison files
We don't really control the small aspects of generated files and NetBSD version has an unused variable that is then detected by gcc as warning that is then promoted to error. Signed-off-by: Vladimir Serbinenko From 2c05ed1ac720f99f94387dbb40558e7f3551e9ae Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 24 Aug 2023 02:32:26 +0200 Subject: [PATCH 02/14] Tolerate unused-but-set in generated lexer/bison files We don't really control the small aspects of generated files and NetBSD version has an unused variable that is then detected by gcc as warning that is then promoted to error. Signed-off-by: Vladimir Serbinenko --- Makefile.util.def | 2 +- grub-core/Makefile.core.def | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.util.def b/Makefile.util.def index 6fe08efd8..9432365a9 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -55,7 +55,7 @@ library = { library = { name = libgrubmods.a; - cflags = '-fno-builtin -Wno-undef'; + cflags = '-fno-builtin -Wno-undef -Wno-unused-but-set-variable'; cppflags = '-I$(srcdir)/grub-core/lib/minilzo -I$(srcdir)/grub-core/lib/xzembed -I$(srcdir)/grub-core/lib/zstd -DMINILZO_HAVE_CONFIG_H'; common_nodist = grub_script.tab.c; diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index d2cf29584..1571421d7 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1993,7 +1993,7 @@ module = { extra_dist = script/yylex.l; extra_dist = script/parser.y; - cflags = '$(CFLAGS_POSIX) -Wno-redundant-decls'; + cflags = '$(CFLAGS_POSIX) -Wno-redundant-decls -Wno-unused-but-set-variable'; cppflags = '$(CPPFLAGS_POSIX)'; }; -- 2.39.2 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH 01/14] loader/bsd: Fix loading after unaligned module
Current code implicitly assumes that aligning chunk_size + *kern_end is the same as aligning on curload which is not the case because chunk_size starts at zero even if *kern_end is unaligned and ALIGN_PAGE moved curload to an aligned position but not *kern_end + chunk_size This fixes booting of FreeBSD with zfs module. Signed-off-by: Vladimir Serbinenko From 6363af27854bcfc7740ef3bdee5707111d5d19a9 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 10 Jul 2023 17:17:35 +0200 Subject: [PATCH 01/14] loader/bsd: Fix loading after unaligned module Current code implicitly assumes that aligning chunk_size + *kern_end is the same as aligning on curload which is not the case because chunk_size starts at zero even if *kern_end is unaligned and ALIGN_PAGE moved curload to an aligned position but not *kern_end + chunk_size This fixes booting of FreeBSD with zfs module. Signed-off-by: Vladimir Serbinenko --- grub-core/loader/i386/bsdXX.c | 20 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/grub-core/loader/i386/bsdXX.c b/grub-core/loader/i386/bsdXX.c index 09d909f1b..d3de8a29b 100644 --- a/grub-core/loader/i386/bsdXX.c +++ b/grub-core/loader/i386/bsdXX.c @@ -88,10 +88,9 @@ SUFFIX (grub_freebsd_load_elfmodule_obj) (struct grub_relocator *relocator, Elf_Shnum shnum; grub_addr_t curload, module; grub_err_t err; - grub_size_t chunk_size = 0; void *chunk_src; - curload = module = ALIGN_PAGE (*kern_end); + module = ALIGN_PAGE (*kern_end); err = read_headers (file, argv[0], , ); if (err != GRUB_ERR_NONE) @@ -101,6 +100,8 @@ SUFFIX (grub_freebsd_load_elfmodule_obj) (struct grub_relocator *relocator, if (err != GRUB_ERR_NONE) goto out; + curload = module; + for (s = shdr; s < (Elf_Shdr *) ((grub_uint8_t *) shdr + shnum * e.e_shentsize); s = (Elf_Shdr *) ((grub_uint8_t *) s + e.e_shentsize)) { @@ -108,21 +109,24 @@ SUFFIX (grub_freebsd_load_elfmodule_obj) (struct grub_relocator *relocator, continue; if (s->sh_addralign) - chunk_size = ALIGN_UP (chunk_size + *kern_end, s->sh_addralign) - - *kern_end; + curload = ALIGN_UP (curload, s->sh_addralign); - chunk_size += s->sh_size; + curload += s->sh_size; } + *kern_end = ALIGN_PAGE (curload); + { grub_relocator_chunk_t ch; err = grub_relocator_alloc_chunk_addr (relocator, , - module, chunk_size); + module, curload - module); if (err != GRUB_ERR_NONE) goto out; chunk_src = get_virtual_current_address (ch); } + curload = module; + for (s = shdr; s < (Elf_Shdr *) ((grub_uint8_t *) shdr + shnum * e.e_shentsize); s = (Elf_Shdr *) ((grub_uint8_t *) s + e.e_shentsize)) { @@ -141,13 +145,13 @@ SUFFIX (grub_freebsd_load_elfmodule_obj) (struct grub_relocator *relocator, { default: case SHT_PROGBITS: - err = load (file, argv[0], (grub_uint8_t *) chunk_src + curload - *kern_end, + err = load (file, argv[0], (grub_uint8_t *) chunk_src + curload - module, s->sh_offset, s->sh_size); if (err != GRUB_ERR_NONE) goto out; break; case SHT_NOBITS: - grub_memset ((grub_uint8_t *) chunk_src + curload - *kern_end, 0, + grub_memset ((grub_uint8_t *) chunk_src + curload - module, 0, s->sh_size); break; } -- 2.39.2 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH 00/14] Fix compilation on *BSD platforms
This patch series fixes compilation problems and one boot bug for different BSD platforms. Mostly they are safe and touch files which are not used by Linux ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel