Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Oct 2025 19:46:54 GMT
From:      Bernhard Froehlich <decke@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: 1543bba0a265 - main - devel/efivar: Update to version 39 and take maintainership
Message-ID:  <202510151946.59FJksgg068676@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by decke:

URL: https://cgit.FreeBSD.org/ports/commit/?id=1543bba0a2652bcb70334c4f14bb9e298ca3d09d

commit 1543bba0a2652bcb70334c4f14bb9e298ca3d09d
Author:     Bernhard Froehlich <decke@FreeBSD.org>
AuthorDate: 2025-10-15 19:20:38 +0000
Commit:     Bernhard Froehlich <decke@FreeBSD.org>
CommitDate: 2025-10-15 19:37:06 +0000

    devel/efivar: Update to version 39 and take maintainership
    
    This is a big and important update which was initially submitted as
    part of D29332 by Norbert Kaminski <norbert.kaminski@3mdeb.com>. The
    submitted patches were for 0.24 and at the last two EuroBSDCons I've
    spend a lot of time to rework them for v39. Thanks a lot for the
    initial patches, even if there is not much of the initial work left.
    
    Differential Revision:          https://reviews.freebsd.org/D29332
---
 devel/efivar/Makefile                            |  45 ++----
 devel/efivar/distinfo                            |   6 +-
 devel/efivar/files/patch-src_compiler.h          |  13 ++
 devel/efivar/files/patch-src_creator.c           |  26 +++
 devel/efivar/files/patch-src_disk.c              |  32 ++++
 devel/efivar/files/patch-src_dp.h                |  13 ++
 devel/efivar/files/patch-src_efisecdb.c          |  38 +++++
 devel/efivar/files/patch-src_efivar.c            |  31 ++++
 devel/efivar/files/patch-src_efivarfs.c          | 162 +++++++++++++++++++
 devel/efivar/files/patch-src_gpt.c               |  59 +++++++
 devel/efivar/files/patch-src_include_defaults.mk |  26 +++
 devel/efivar/files/patch-src_include_gcc.specs   |   8 +
 devel/efivar/files/patch-src_linux.c             | 108 +++++++++++++
 devel/efivar/files/patch-src_mntent.h            | 192 +++++++++++++++++++++++
 devel/efivar/files/patch-src_test_tester.c       |  13 ++
 devel/efivar/files/patch-src_thread-test.c       |  22 +++
 devel/efivar/files/patch-src_time.c              |  20 +++
 devel/efivar/files/patch-src_util.h              |  13 ++
 devel/efivar/pkg-descr                           |   2 +-
 devel/efivar/pkg-plist                           |  41 ++++-
 20 files changed, 828 insertions(+), 42 deletions(-)

diff --git a/devel/efivar/Makefile b/devel/efivar/Makefile
index 5e30a4f9a215..f8dcfa0620f3 100644
--- a/devel/efivar/Makefile
+++ b/devel/efivar/Makefile
@@ -1,53 +1,28 @@
 PORTNAME=	efivar
-PORTVERSION=	0.15
-PORTREVISION=	9
+PORTVERSION=	39
 CATEGORIES=	devel
 
-MAINTAINER=	ports@FreeBSD.org
-COMMENT=	Tools and library to manipulate EFI variables
+MAINTAINER=	decke@FreeBSD.org
+COMMENT=	Tools and libraries to work with EFI variables
 WWW=		https://github.com/rhboot/efivar
 
 LICENSE=	LGPL21
 
 NOT_FOR_ARCHS=		powerpc powerpc64 powerpcspe
 NOT_FOR_ARCHS_REASON=	specification only supports little-endian processors
+BROKEN_FreeBSD_13=	requires at least FreeBSD 14
 
+BUILD_DEPENDS=	gsed:textproc/gsed
 LIB_DEPENDS=	libpopt.so:devel/popt
 
-CFLAGS+=	-fpermissive
+USES=		gmake pkgconfig python
 
-USES=		gmake localbase pkgconfig
 USE_GCC=	yes
 USE_GITHUB=	yes
 GH_ACCOUNT=	rhboot
 USE_LDCONFIG=	yes
+BINARY_ALIAS=	sed=${LOCALBASE}/bin/gsed
 
-.include <bsd.port.pre.mk>
-
-post-patch:
-	@${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|g' ${WRKSRC}/src/efivar.pc.in
-
-do-install:
-	${INSTALL_PROGRAM} ${WRKSRC}/src/efivar ${STAGEDIR}${PREFIX}/bin
-	${INSTALL_LIB} ${WRKSRC}/src/libefivar.so ${STAGEDIR}${PREFIX}/lib
-	${INSTALL_LIB} ${WRKSRC}/src/libefivar.so.0 ${STAGEDIR}${PREFIX}/lib
-	${INSTALL_DATA} ${WRKSRC}/src/efivar.h ${STAGEDIR}${PREFIX}/include
-	${INSTALL_DATA} ${WRKSRC}/src/efivar-guids.h ${STAGEDIR}${PREFIX}/include
-	${INSTALL_DATA} ${WRKSRC}/src/efivar.pc ${STAGEDIR}${PREFIX}/libdata/pkgconfig
-	${INSTALL_MAN} ${WRKSRC}/docs/efivar.1 ${STAGEDIR}${PREFIX}/share/man/man1
-	${INSTALL_MAN} ${WRKSRC}/docs/efi_append_variable.3 ${STAGEDIR}${PREFIX}/share/man/man3
-	${INSTALL_MAN} ${WRKSRC}/docs/efi_del_variable.3 ${STAGEDIR}${PREFIX}/share/man/man3
-	${INSTALL_MAN} ${WRKSRC}/docs/efi_get_next_variable_name.3 ${STAGEDIR}${PREFIX}/share/man/man3
-	${INSTALL_MAN} ${WRKSRC}/docs/efi_get_variable.3 ${STAGEDIR}${PREFIX}/share/man/man3
-	${INSTALL_MAN} ${WRKSRC}/docs/efi_get_variable_attributes.3 ${STAGEDIR}${PREFIX}/share/man/man3
-	${INSTALL_MAN} ${WRKSRC}/docs/efi_get_variable_size.3 ${STAGEDIR}${PREFIX}/share/man/man3
-	${INSTALL_MAN} ${WRKSRC}/docs/efi_guid_to_name.3 ${STAGEDIR}${PREFIX}/share/man/man3
-	${INSTALL_MAN} ${WRKSRC}/docs/efi_guid_to_str.3 ${STAGEDIR}${PREFIX}/share/man/man3
-	${INSTALL_MAN} ${WRKSRC}/docs/efi_guid_to_symbol.3 ${STAGEDIR}${PREFIX}/share/man/man3
-	${INSTALL_MAN} ${WRKSRC}/docs/efi_name_to_guid.3 ${STAGEDIR}${PREFIX}/share/man/man3
-	${INSTALL_MAN} ${WRKSRC}/docs/efi_set_variable.3 ${STAGEDIR}${PREFIX}/share/man/man3
-	${INSTALL_MAN} ${WRKSRC}/docs/efi_str_to_guid.3 ${STAGEDIR}${PREFIX}/share/man/man3
-	${INSTALL_MAN} ${WRKSRC}/docs/efi_symbol_to_guid.3 ${STAGEDIR}${PREFIX}/share/man/man3
-	${INSTALL_MAN} ${WRKSRC}/docs/efi_variables_supported.3 ${STAGEDIR}${PREFIX}/share/man/man3
-
-.include <bsd.port.post.mk>
+MAKE_ARGS+=	CC="${CC}" LIBDIR="${PREFIX}/lib"
+
+.include <bsd.port.mk>
diff --git a/devel/efivar/distinfo b/devel/efivar/distinfo
index 4d6a04753aca..77a79246775d 100644
--- a/devel/efivar/distinfo
+++ b/devel/efivar/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1544125008
-SHA256 (rhboot-efivar-0.15_GH0.tar.gz) = 8e5a45ebbd116a96a43176e96b211c73f3ec8452da3bd0ce75a5716f86d4343f
-SIZE (rhboot-efivar-0.15_GH0.tar.gz) = 30064
+TIMESTAMP = 1730568659
+SHA256 (rhboot-efivar-39_GH0.tar.gz) = c9edd15f2eeeea63232f3e669a48e992c7be9aff57ee22672ac31f5eca1609a6
+SIZE (rhboot-efivar-39_GH0.tar.gz) = 463349
diff --git a/devel/efivar/files/patch-src_compiler.h b/devel/efivar/files/patch-src_compiler.h
new file mode 100644
index 000000000000..ad398379bffa
--- /dev/null
+++ b/devel/efivar/files/patch-src_compiler.h
@@ -0,0 +1,13 @@
+--- src/compiler.h.orig	2024-01-31 20:08:46 UTC
++++ src/compiler.h
+@@ -74,7 +74,9 @@
+ 
+ #define __ALIGN_MASK(x, mask)   (((x) + (mask)) & ~(mask))
+ #define __ALIGN(x, a)           __ALIGN_MASK(x, (typeof(x))(a) - 1)
+-#define ALIGN(x, a)             __ALIGN((x), (a))
++#if !defined(ALIGN)
++# define ALIGN(x, a)             __ALIGN((x), (a))
++#endif
+ #define ALIGN_DOWN(x, a)        __ALIGN((x) - ((a) - 1), (a))
+ 
+ #define ALIGNMENT_PADDING(value, align) ((align - (value % align)) % align)
diff --git a/devel/efivar/files/patch-src_creator.c b/devel/efivar/files/patch-src_creator.c
new file mode 100644
index 000000000000..21c7feb2106f
--- /dev/null
+++ b/devel/efivar/files/patch-src_creator.c
@@ -0,0 +1,26 @@
+--- src/creator.c.orig	2024-01-31 20:08:46 UTC
++++ src/creator.c
+@@ -9,16 +9,22 @@
+ #include <fcntl.h>
+ #include <inttypes.h>
+ #include <limits.h>
++#if defined(__linux__)
+ #include <mntent.h>
++#endif
++#include <sys/types.h>
+ #include <netinet/in.h>
+ #include <netinet/ip.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+-#include <sys/types.h>
+ #include <sys/stat.h>
+ #include <sys/socket.h>
+ 
+ #include "efiboot.h"
++
++#if defined(__FreeBSD__)
++#  include "mntent.h"
++#endif
+ 
+ static int NONNULL(1, 2, 3)
+ find_file(const char * const filepath, char **devicep, char **relpathp)
diff --git a/devel/efivar/files/patch-src_disk.c b/devel/efivar/files/patch-src_disk.c
new file mode 100644
index 000000000000..796a0904ed29
--- /dev/null
+++ b/devel/efivar/files/patch-src_disk.c
@@ -0,0 +1,32 @@
+--- src/disk.c.orig	2024-01-31 20:08:46 UTC
++++ src/disk.c
+@@ -14,6 +14,10 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#ifdef __FreeBSD__
++#  include <sys/disk.h>
++#  undef LIST_HEAD
++#endif
+ #include <sys/ioctl.h>
+ #include <sys/mount.h>
+ #include <sys/stat.h>
+@@ -158,8 +162,18 @@ msdos_disk_get_partition_info (int fd, int write_signa
+ 	} else if (num == 0) {
+ 		/* Whole disk */
+ 		*start = 0;
++#if defined(__linux__)
+ 		ioctl(fd, BLKGETSIZE, &disk_size);
+ 		*size = disk_size;
++#elif defined(__FreeBSD__)
++		long sector_size=0;
++		ioctl(fd, DIOCGMEDIASIZE, &disk_size);
++		ioctl(fd, DIOCGSECTORSIZE, &sector_size);
++		*size = disk_size / sector_size;
++#else
++		efi_error("could not get disk size (not implemented on your OS)");
++		return -1;
++#endif
+ 	} else if (num >= 1 && num <= 4) {
+ 		/* Primary partition */
+ 		*start = mbr->partition[num-1].starting_lba;
diff --git a/devel/efivar/files/patch-src_dp.h b/devel/efivar/files/patch-src_dp.h
new file mode 100644
index 000000000000..27a3cc282b2b
--- /dev/null
+++ b/devel/efivar/files/patch-src_dp.h
@@ -0,0 +1,13 @@
+--- src/dp.h.orig	2024-01-31 20:08:46 UTC
++++ src/dp.h
+@@ -6,7 +6,9 @@
+ #ifndef _EFIVAR_INTERNAL_DP_H
+ #define _EFIVAR_INTERNAL_DP_H
+ 
+-#include <alloca.h>
++#if defined(__linux__)
++#  include <alloca.h>
++#endif
+ #include <stdarg.h>
+ #include <stdio.h>
+ #include <stdlib.h>
diff --git a/devel/efivar/files/patch-src_efisecdb.c b/devel/efivar/files/patch-src_efisecdb.c
new file mode 100644
index 000000000000..dd61da8d2eb3
--- /dev/null
+++ b/devel/efivar/files/patch-src_efisecdb.c
@@ -0,0 +1,38 @@
+--- src/efisecdb.c.orig	2024-01-31 20:08:46 UTC
++++ src/efisecdb.c
+@@ -93,7 +93,7 @@ secdb_warnx(const char * const fmt, ...)
+ 	int errnum = errno;
+ 
+ 	fflush(stdout);
+-	fprintf(stderr, "%s: ", program_invocation_short_name);
++	fprintf(stderr, "%s: ", getprogname());
+ 	va_start(ap, fmt);
+ 	vfprintf(stderr, fmt, ap);
+ 	va_end(ap);
+@@ -109,7 +109,7 @@ secdb_err(int status, const char * const fmt, ...)
+ 	int errnum = errno;
+ 
+ 	fflush(stdout);
+-	fprintf(stderr, "%s: ", program_invocation_short_name);
++	fprintf(stderr, "%s: ", getprogname());
+ 	va_start(ap, fmt);
+ 	vfprintf(stderr, fmt, ap);
+ 	va_end(ap);
+@@ -126,7 +126,7 @@ secdb_errx(int status, const char * const fmt, ...)
+ 	int errnum = errno;
+ 
+ 	fflush(stdout);
+-	fprintf(stderr, "%s: ", program_invocation_short_name);
++	fprintf(stderr, "%s: ", getprogname());
+ 	va_start(ap, fmt);
+ 	errno = errnum;
+ 	vfprintf(stderr, fmt, ap);
+@@ -149,7 +149,7 @@ usage(int status)
+ 		"  -t, --type=<hash-type>    hash type to add (\"help\" lists options)\n"
+ 		"  -c, --certificate=<file>  certificate file to add\n"
+ 		"  -L, --list-guids          list well known guids\n",
+-		program_invocation_short_name);
++		getprogname());
+ 	exit(status);
+ }
+ 
diff --git a/devel/efivar/files/patch-src_efivar.c b/devel/efivar/files/patch-src_efivar.c
new file mode 100644
index 000000000000..5a419a603b42
--- /dev/null
+++ b/devel/efivar/files/patch-src_efivar.c
@@ -0,0 +1,31 @@
+--- src/efivar.c.orig	2024-01-31 20:08:46 UTC
++++ src/efivar.c
+@@ -20,6 +20,10 @@
+ #include <string.h>
+ #include <limits.h>
+ 
++#if defined(__FreeBSD__)
++#  undef LIST_HEAD
++#endif
++
+ extern char *optarg;
+ extern int optind, opterr, optopt;
+ 
+@@ -408,7 +412,7 @@ prepare_data(const char *filename, uint8_t **data, siz
+ 		goto err;
+ 
+ 	buflen = statbuf.st_size;
+-	buf = mmap(NULL, buflen, PROT_READ, MAP_PRIVATE|MAP_POPULATE, fd, 0);
++	buf = mmap(NULL, buflen, PROT_READ, MAP_PRIVATE, fd, 0);
+ 	if (buf == MAP_FAILED)
+ 		goto err;
+ 
+@@ -447,7 +451,7 @@ usage(int ret)
+ 		"Help options:\n"
+ 		"  -?, --help                        Show this help message\n"
+ 		"      --usage                       Display brief usage message\n",
+-		program_invocation_short_name);
++		getprogname());
+ 	exit(ret);
+ }
+ 
diff --git a/devel/efivar/files/patch-src_efivarfs.c b/devel/efivar/files/patch-src_efivarfs.c
new file mode 100644
index 000000000000..1ca8a549aba8
--- /dev/null
+++ b/devel/efivar/files/patch-src_efivarfs.c
@@ -0,0 +1,162 @@
+--- src/efivarfs.c.orig	2024-01-31 20:08:46 UTC
++++ src/efivarfs.c
+@@ -9,20 +9,32 @@
+ #include <err.h>
+ #include <errno.h>
+ #include <fcntl.h>
+-#include <linux/magic.h>
++#if defined(__linux__)
++#  include <linux/magic.h>
++#endif
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <sys/mman.h>
+ #include <sys/types.h>
++#include <sys/param.h>
++#include <sys/mount.h>
+ #include <sys/stat.h>
+ #include <sys/uio.h>
+-#include <sys/vfs.h>
++#if defined(__linux__)
++#  include <sys/vfs.h>
++#endif
+ #include <unistd.h>
+ 
++#if defined(__FreeBSD__)
++#  undef LIST_HEAD
++#endif
++
+ #include "efivar.h"
+ 
+-#include <linux/fs.h>
++#if defined(__linux__)
++#  include <linux/fs.h>
++#endif
+ 
+ #ifndef EFIVARFS_MAGIC
+ #  define EFIVARFS_MAGIC 0xde5e81e4
+@@ -102,6 +114,7 @@ efivarfs_set_fd_immutable(int fd, int immutable)
+ static int
+ efivarfs_set_fd_immutable(int fd, int immutable)
+ {
++#if defined(__linux__)
+ 	unsigned int flags;
+ 	int rc = 0;
+ 
+@@ -124,11 +137,42 @@ efivarfs_set_fd_immutable(int fd, int immutable)
+ 	}
+ 
+ 	return rc;
++#elif defined(__FreeBSD__)
++	struct stat sb;
++	int rc = 0;
++	unsigned long flags;
++
++	if (fstat(fd, &sb) == -1) {
++		if (errno == EBADF)
++			rc = 0;
++		else
++			efi_error("fstat(%d) failed", fd);
++		return rc;
++	}
++
++	flags = sb.st_flags;
++
++	if ((immutable && !(flags & UF_IMMUTABLE)) ||
++	    (!immutable && (flags & UF_IMMUTABLE))) {
++		if (immutable)
++			flags |= UF_IMMUTABLE;
++		else
++			flags &= ~UF_IMMUTABLE;
++
++		if (chflagsat(fd, "", flags, AT_EMPTY_PATH) == -1) {
++			efi_error("chflagsat(%d) failed\n", fd);
++			rc = -1;
++		}
++	}
++
++	return rc;
++#endif
+ }
+ 
+ static int
+ efivarfs_make_fd_mutable(int fd, unsigned long *orig_attrs)
+ {
++#if defined(__linux__)
+ 	unsigned long mutable_attrs = 0;
+ 
+ 	*orig_attrs = 0;
+@@ -145,6 +189,26 @@ efivarfs_make_fd_mutable(int fd, unsigned long *orig_a
+ 		return -1;
+ 
+ 	return 0;
++#elif defined(__FreeBSD__)
++	struct stat sb;
++
++	*orig_attrs = 0;
++
++	if (fstat(fd, &sb) == -1)
++		return -1;
++
++	*orig_attrs = sb.st_flags;
++
++	// if the file is not immutable, nothing to do
++	if ((sb.st_flags & UF_IMMUTABLE) == 0)
++		return 0;
++
++	// remove user immutable flag
++	if (chflagsat(fd, "", sb.st_flags & ~UF_IMMUTABLE, AT_EMPTY_PATH) == -1)
++		return -1;
++
++	return 0;
++#endif
+ }
+ 
+ static int
+@@ -375,10 +439,17 @@ efivarfs_set_variable(efi_guid_t guid, const char *nam
+ 			goto err;
+ 		}
+ 
++#if defined(__linux__)
+ 		/* if the file is indeed immutable, clear and remember it */
+ 		if (efivarfs_make_fd_mutable(rfd, &orig_attrs) == 0 &&
+ 		    (orig_attrs & FS_IMMUTABLE_FL))
+ 			restore_immutable_fd = rfd;
++#elif defined(__FreeBSD__)
++		/* if the file is indeed immutable, clear and remember it */
++		if (efivarfs_make_fd_mutable(rfd, &orig_attrs) == 0 &&
++		    (orig_attrs & UF_IMMUTABLE))
++			restore_immutable_fd = rfd;
++#endif
+ 	}
+ 
+ 	/*
+@@ -414,9 +485,15 @@ efivarfs_set_variable(efi_guid_t guid, const char *nam
+ 	 * immediately, and the write() below would fail otherwise.
+ 	 */
+ 	if (rfd == -1) {
++#if defined(__linux__)
+ 		if (efivarfs_make_fd_mutable(wfd, &orig_attrs) == 0 &&
+ 		    (orig_attrs & FS_IMMUTABLE_FL))
+ 			restore_immutable_fd = wfd;
++#elif defined(__FreeBSD__)
++		if (efivarfs_make_fd_mutable(wfd, &orig_attrs) == 0 &&
++		    (orig_attrs & UF_IMMUTABLE))
++			restore_immutable_fd = wfd;
++#endif
+ 	} else {
+ 		/* make sure rfd and wfd refer to the same file */
+ 		struct stat wfd_stat;
+@@ -452,7 +529,11 @@ err:
+ 	if (ret == -1 && rfd == -1 && wfd != -1 && unlink(path) == -1)
+ 		efi_error("failed to unlink %s", path);
+ 
++#if defined(__linux__)
+ 	ioctl(restore_immutable_fd, FS_IOC_SETFLAGS, &orig_attrs);
++#elif defined(__FreeBSD__)
++	chflagsat(restore_immutable_fd, "", orig_attrs, AT_EMPTY_PATH);
++#endif
+ 
+ 	if (wfd >= 0)
+ 		close(wfd);
diff --git a/devel/efivar/files/patch-src_gpt.c b/devel/efivar/files/patch-src_gpt.c
new file mode 100644
index 000000000000..87d6d523d72a
--- /dev/null
+++ b/devel/efivar/files/patch-src_gpt.c
@@ -0,0 +1,59 @@
+--- src/gpt.c.orig	2024-01-31 20:08:46 UTC
++++ src/gpt.c
+@@ -16,6 +16,11 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#if defined(__FreeBSD__)
++#  include <sys/disk.h>
++#  undef LIST_HEAD
++#endif
++#include <sys/ioctl.h>
+ #include <sys/mount.h>
+ #include <sys/param.h>
+ #include <sys/stat.h>
+@@ -60,6 +65,7 @@ is_pmbr_valid(legacy_mbr *mbr)
+ 	return (magic && found);
+ }
+ 
++#if defined(__linux__)
+ /**
+  * kernel_has_blkgetsize64()
+  *
+@@ -92,6 +98,7 @@ kernel_has_blkgetsize64(void)
+ 		return 0;
+ 	return 1;
+ }
++#endif
+ 
+ /************************************************************
+  * _get_num_sectors
+@@ -114,6 +121,8 @@ _get_num_sectors(int filedes)
+ 	unsigned long sectors=0;
+ 	uint64_t bytes=0;
+ 	int rc;
++
++#if defined(__linux__)
+ 	if (kernel_has_blkgetsize64()) {
+ 		rc = ioctl(filedes, BLKGETSIZE64, &bytes);
+ 		if (!rc)
+@@ -125,6 +134,19 @@ _get_num_sectors(int filedes)
+ 		return 0;
+ 
+ 	return sectors;
++#elif defined(__FreeBSD__)
++	rc = ioctl(filedes, DIOCGMEDIASIZE, &bytes);
++	if (rc == -1)
++		return 0;
++
++	rc = ioctl(filedes, DIOCGSECTORSIZE, &sectors);
++	if (rc == -1)
++		return 0;
++
++	return bytes / sectors;
++#else
++	return 0;
++#endif
+ }
+ 
+ /************************************************************
diff --git a/devel/efivar/files/patch-src_include_defaults.mk b/devel/efivar/files/patch-src_include_defaults.mk
new file mode 100644
index 000000000000..9c56eb219471
--- /dev/null
+++ b/devel/efivar/files/patch-src_include_defaults.mk
@@ -0,0 +1,26 @@
+--- src/include/defaults.mk.orig	2024-01-31 20:08:46 UTC
++++ src/include/defaults.mk
+@@ -43,7 +43,6 @@ override CFLAGS = $(_CFLAGS) \
+ override CFLAGS = $(_CFLAGS) \
+ 		  -std=gnu11 \
+ 		  -funsigned-char \
+-		  -fvisibility=hidden \
+ 		  $(call family,CFLAGS) \
+ 		  $(call pkg-config-cflags)
+ LDFLAGS_CLANG ?= -rtlib=compiler-rt
+@@ -53,7 +52,6 @@ override LDFLAGS = $(CFLAGS) -L. $(_LDFLAGS) $(_CCLDFL
+ override _LDFLAGS := $(LDFLAGS)
+ override LDFLAGS = $(CFLAGS) -L. $(_LDFLAGS) $(_CCLDFLAGS) \
+ 		   -Wl,--build-id \
+-		   -Wl,--no-allow-shlib-undefined \
+ 		   -Wl,--no-undefined-version \
+ 		   -Wl,-z,now \
+ 		   -Wl,-z,muldefs \
+@@ -99,7 +97,6 @@ override HOST_LDFLAGS = $(HOST_CFLAGS) -L. \
+ override HOST_LDFLAGS = $(HOST_CFLAGS) -L. \
+ 			$(_HOST_LDFLAGS) $(_HOST_CCLDFLAGS) \
+ 			-Wl,--build-id \
+-			-Wl,--no-allow-shlib-undefined \
+ 			-Wl,-z,now \
+ 			-Wl,-z,muldefs \
+ 			$(call family,HOST_LDFLAGS) \
diff --git a/devel/efivar/files/patch-src_include_gcc.specs b/devel/efivar/files/patch-src_include_gcc.specs
new file mode 100644
index 000000000000..388f3d9e22cd
--- /dev/null
+++ b/devel/efivar/files/patch-src_include_gcc.specs
@@ -0,0 +1,8 @@
+--- src/include/gcc.specs.orig	2024-01-31 20:08:46 UTC
++++ src/include/gcc.specs
+@@ -5,4 +5,4 @@ + %{!shared:%{!static:%{!r:-pie}}} %{static:-Wl,-no-fa
+ + %{!shared:%{!static:%{!r:-pie}}} %{static:-Wl,-no-fatal-warnings -Wl,-static -static -Wl,-z,relro,-z,now} -grecord-gcc-switches
+ 
+ *link:
+-+ %{!static:--fatal-warnings} --no-undefined-version --no-allow-shlib-undefined -z now --build-id %{!static:%{!shared:-pie}} %{shared:-z relro} %{static:%<pie}
+++ %{!static:--fatal-warnings} --no-undefined-version -z now --build-id %{!static:%{!shared:-pie}} %{shared:-z relro} %{static:%<pie}
diff --git a/devel/efivar/files/patch-src_linux.c b/devel/efivar/files/patch-src_linux.c
new file mode 100644
index 000000000000..1948fba2d92b
--- /dev/null
+++ b/devel/efivar/files/patch-src_linux.c
@@ -0,0 +1,108 @@
+--- src/linux.c.orig	2024-01-31 20:08:46 UTC
++++ src/linux.c
+@@ -12,17 +12,30 @@
+ #include <fcntl.h>
+ #include <inttypes.h>
+ #include <limits.h>
+-#include <linux/ethtool.h>
+-#include <linux/version.h>
+-#include <linux/sockios.h>
++#if defined(__linux__)
++#  include <linux/ethtool.h>
++#  include <linux/version.h>
++#  include <linux/sockios.h>
++#elif defined(__FreeBSD__)
++#  include <net/if.h>
++#  include <net/if_dl.h>
++#endif
+ #include <net/if.h>
+-#include <scsi/scsi.h>
++#if defined(__linux__)
++#  include <scsi/scsi.h>
++#endif
+ #include <stdbool.h>
+ #include <stdio.h>
++#if defined(__FreeBSD__)
++#  include <sys/disk.h>
++#  undef LIST_HEAD
++#endif
+ #include <sys/ioctl.h>
+ #include <sys/mount.h>
+ #include <sys/socket.h>
+-#include <sys/sysmacros.h>
++#if defined(__linux__)
++#  include <sys/sysmacros.h>
++#endif
+ #include <sys/types.h>
+ #include <sys/param.h>
+ #include <sys/stat.h>
+@@ -630,6 +643,7 @@ make_blockdev_path(uint8_t *buf, ssize_t size, struct 
+ 	return off;
+ }
+ 
++#if defined(__linux__)
+ ssize_t HIDDEN
+ make_mac_path(uint8_t *buf, ssize_t size, const char * const ifname)
+ {
+@@ -693,7 +707,48 @@ err:
+ 	        close(fd);
+ 	return ret;
+ }
++#elif defined(__FreeBSD__)
++ssize_t HIDDEN
++make_mac_path(uint8_t *buf, ssize_t size, const char * const ifname)
++{
++	int fd;
++	struct ifreq ifr;
++	struct sockaddr_dl *sdl;
++	ssize_t ret = -1;
+ 
++	if (!buf || !ifname)
++		return -1;
++
++	fd = socket(AF_INET, SOCK_DGRAM, 0);
++	if (fd < 0)
++		return -1;
++
++	memset(&ifr, 0, sizeof(ifr));
++	strncpy(ifr.ifr_name, ifname, IFNAMSIZ-1);
++	ifr.ifr_name[IFNAMSIZ-1] = '\0';
++
++	if (ioctl(fd, SIOCGIFADDR, &ifr) < 0) {
++		close(fd);
++		return -1;
++	}
++
++	// For MAC, use AF_LINK (sockaddr_dl)
++	if (ioctl(fd, SIOCGIFCONF, &ifr) < 0) {
++		close(fd);
++		return -1;
++	}
++
++	sdl = (struct sockaddr_dl *)&ifr.ifr_addr;
++	if (sdl->sdl_alen > 0 && sdl->sdl_alen <= size) {
++		memcpy(buf, LLADDR(sdl), sdl->sdl_alen);
++		ret = sdl->sdl_alen;
++	}
++
++	close(fd);
++	return ret;
++}
++#endif
++
+ /************************************************************
+  * get_sector_size
+  * Requires:
+@@ -707,7 +762,12 @@ get_sector_size(int filedes)
+ {
+ 	int rc, sector_size = 512;
+ 
++	(void)filedes;
++#if defined(__linux__)
+ 	rc = ioctl(filedes, BLKSSZGET, &sector_size);
++#elif defined(__FreeBSD__)
++	rc = ioctl(filedes, DIOCGSECTORSIZE, &sector_size);
++#endif
+ 	if (rc)
+ 	        sector_size = 512;
+ 	return sector_size;
diff --git a/devel/efivar/files/patch-src_mntent.h b/devel/efivar/files/patch-src_mntent.h
new file mode 100644
index 000000000000..f4cf03ef4d55
--- /dev/null
+++ b/devel/efivar/files/patch-src_mntent.h
@@ -0,0 +1,192 @@
+--- src/mntent.h.orig	2025-10-12 11:00:40 UTC
++++ src/mntent.h
+@@ -0,0 +1,189 @@
++/*
++ *  mntent
++ *  mntent.h - compatibility header for FreeBSD
++ *
++ *  Copyright (c) 2001 David Rufino <daverufino@btinternet.com>
++ *  All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ *    notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ *    notice, this list of conditions and the following disclaimer in the
++ *    documentation and/or other materials provided with the distribution.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ */
++
++#ifndef VIFM__UTILS__MNTENT_H__
++#define VIFM__UTILS__MNTENT_H__
++
++#include <stddef.h>
++#include <stdio.h>
++
++#define MOUNTED "dummy"
++
++#define MNTTYPE_NFS "nfs"
++
++struct mntent
++{
++	char *mnt_fsname;
++	char *mnt_dir;
++	char *mnt_type;
++	char *mnt_opts;
++	int mnt_freq;
++	int mnt_passno;
++};
++
++#define setmntent(x,y) ((FILE *)0x1)
++struct mntent * getmntent(FILE *fp);
++char * hasmntopt(const struct mntent *mnt, const char option[]);
++#define endmntent(x) ((int)1)
++
++#endif /* VIFM__UTILS__MNTENT_H__ */
++
++#include <sys/param.h>
++#include <sys/ucred.h>
++#include <sys/mount.h>
++
++#include <stdlib.h>
++#include <string.h>
++
++#ifdef __NetBSD__
++#define statfs statvfs
++#define f_flags f_flag
++#endif
++
++static struct mntent * statfs_to_mntent(struct statfs *mntbuf);
++static char * flags2opts(int flags);
++static char * catopt(char s0[], const char s1[]);
++
++char *
++hasmntopt(const struct mntent *mnt, const char option[])
++{
++	char *opt, *optbuf;
++
++	optbuf = strdup(mnt->mnt_opts);
++	for(opt = optbuf; (opt = strtok(opt, " ")) != NULL; opt = NULL)
++	{
++		if(!strcasecmp(opt, option))
++		{
++			opt = opt - optbuf + mnt->mnt_opts;
++			free(optbuf);
++			return (opt);
++		}
++	}
++	free(optbuf);
++	return NULL;
++}
++
++struct mntent *
++getmntent(FILE *fp)
++{
++	static int pos = -1;
++	static int mntsize = -1;
++
++	static struct statfs *mntbuf;
++
++	(void)fp;
++
++	if(pos == -1 || mntsize == -1)
++	{
++		mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
++	}
++
++	pos++;
++	if(pos == mntsize)
++	{
++		pos = mntsize = -1;
++		return NULL;
++	}
++
++	return statfs_to_mntent(&mntbuf[pos]);
++}
++
++static struct mntent *
++statfs_to_mntent(struct statfs *mntbuf)
++{
++	static struct mntent _mntent;
++	static char opts_buf[40], *tmp;
++
++	_mntent.mnt_fsname = mntbuf->f_mntfromname;
++	_mntent.mnt_dir = mntbuf->f_mntonname;
++	_mntent.mnt_type = mntbuf->f_fstypename;
++	tmp = flags2opts (mntbuf->f_flags);
++	if(tmp != NULL)
++	{
++		opts_buf[sizeof(opts_buf) - 1] = '\0';
++		strncpy(opts_buf, tmp, sizeof(opts_buf) - 1);
++		free(tmp);
++	}
++	else
++	{
++		*opts_buf = '\0';
++	}
++	_mntent.mnt_opts = opts_buf;
++	_mntent.mnt_freq = _mntent.mnt_passno = 0;
++	return &_mntent;
++}
++
++static char *
++flags2opts(int flags)
++{
++	char *res = catopt(NULL, (flags & MNT_RDONLY) ? "ro" : "rw");
++	if(flags & MNT_SYNCHRONOUS) res = catopt(res, "sync");
++	if(flags & MNT_NOEXEC)      res = catopt(res, "noexec");
++	if(flags & MNT_NOSUID)      res = catopt(res, "nosuid");
++#ifndef __OpenBSD__
++	if(flags & MNT_UNION)       res = catopt(res, "union");
++#endif
++	if(flags & MNT_ASYNC)       res = catopt(res, "async");
++	if(flags & MNT_NOATIME)     res = catopt(res, "noatime");
++#if !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(__NetBSD__)
++	if(flags & MNT_NOCLUSTERR)  res = catopt(res, "noclusterr");
++	if(flags & MNT_NOCLUSTERW)  res = catopt(res, "noclusterw");
++	if(flags & MNT_NOSYMFOLLOW) res = catopt(res, "nosymfollow");
++	if(flags & MNT_SUIDDIR)     res = catopt(res, "suiddir");
++#endif
++
++	return res;
++}
++
++static char *
++catopt(char s0[], const char s1[])
++{
++	char *cp;
++
++	if(s1 == NULL || *s1 == '\0')
++	{
++		return s0;
++	}
++	if(s0 && *s0)
++	{
++		const size_t i = strlen(s0) + strlen(s1) + 1 + 1;
++		if((cp = malloc(i)) == NULL)
++		{
++			return NULL;
++		}
++		(void)snprintf(cp, i, "%s %s", s0, s1);
++	}
++	else
++	{
++		cp = strdup(s1);
++	}
++
++	free(s0);
++	return cp;
++}
diff --git a/devel/efivar/files/patch-src_test_tester.c b/devel/efivar/files/patch-src_test_tester.c
new file mode 100644
index 000000000000..d93bb2d6456c
--- /dev/null
+++ b/devel/efivar/files/patch-src_test_tester.c
@@ -0,0 +1,13 @@
+--- src/test/tester.c.orig	2024-01-31 20:08:46 UTC
++++ src/test/tester.c
+@@ -5,7 +5,9 @@
+  * Copyright 2012-2018 Peter M. Jones <pjones@redhat.com>
+  */
+ 
+-#include <alloca.h>
++#if defined(__linux__)
++#  include <alloca.h>
++#endif
+ #include <errno.h>
+ #include <fcntl.h>
+ #include <stdarg.h>
diff --git a/devel/efivar/files/patch-src_thread-test.c b/devel/efivar/files/patch-src_thread-test.c
new file mode 100644
index 000000000000..b46bf0bb4ead
--- /dev/null
+++ b/devel/efivar/files/patch-src_thread-test.c
@@ -0,0 +1,22 @@
+--- src/thread-test.c.orig	2024-01-31 20:08:46 UTC
++++ src/thread-test.c
+@@ -6,7 +6,9 @@
+ 
+ #include "fix_coverity.h"
+ 
+-#include <alloca.h>
++#if defined(__linux__)
++#  include <alloca.h>
++#endif
+ #include <efivar.h>
+ #include <err.h>
+ #include <errno.h>
+@@ -125,7 +127,7 @@ usage(int ret)
+ 		"Help options:\n"
+ 		"  -?, --help                        Show this help message\n"
+ 		"      --usage                       Display brief usage message\n",
+-		program_invocation_short_name);
++		getprogname());
+ 	exit(ret);
+ }
+ 
diff --git a/devel/efivar/files/patch-src_time.c b/devel/efivar/files/patch-src_time.c
new file mode 100644
index 000000000000..4a7edf743ef4
--- /dev/null
+++ b/devel/efivar/files/patch-src_time.c
@@ -0,0 +1,20 @@
+--- src/time.c.orig	2024-01-31 20:08:46 UTC
++++ src/time.c
+@@ -52,7 +52,17 @@ tm_to_efi_time(const struct tm * const s, efi_time_t *
+ 
+ 	if (tzadj) {
+ 		tzset();
++
++#if defined(__FreeBSD__)
++		time_t t = time(NULL);
++		struct tm lt = {0};
++
++		localtime_r(&t, &lt);
++
++		d->timezone = lt.tm_gmtoff / 60;
++#else
+ 		d->timezone = timezone / 60;
++#endif
+ 	}
+ 
+ 	return 0;
diff --git a/devel/efivar/files/patch-src_util.h b/devel/efivar/files/patch-src_util.h
new file mode 100644
index 000000000000..7c47def1ebf9
--- /dev/null
+++ b/devel/efivar/files/patch-src_util.h
@@ -0,0 +1,13 @@
+--- src/util.h.orig	2024-01-31 20:08:46 UTC
++++ src/util.h
+@@ -8,7 +8,9 @@
+ #ifndef EFIVAR_UTIL_H
+ #define EFIVAR_UTIL_H 1
+ 
*** 78 LINES SKIPPED ***


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202510151946.59FJksgg068676>