summaryrefslogtreecommitdiff
path: root/filesystems/e2fsprogs-core
diff options
context:
space:
mode:
authorRobert Clausecker <fuz@FreeBSD.org>2024-09-27 12:48:46 +0200
committerRobert Clausecker <fuz@FreeBSD.org>2024-11-06 16:17:35 +0100
commit6e2da9672f79f44048d597f0f61e4646cdeade9d (patch)
treec92e4b3158e3419e8cec38e00227d08dcdaab3e9 /filesystems/e2fsprogs-core
parentmath/sdpa: speed up build (diff)
filesystems: add new category for file systems and related utilities
The filesystems category houses file systems and file system utilities. It is added mainly to turn the sysutils/fusefs-* pseudo-category into a proper one, but is also useful for the sundry of other file systems related ports found in the tree. Ports that seem like they belong there are moved to the new category. Two ports, sysutils/fusefs-funionfs and sysutils/fusefs-fusepak are not moved as they currently don't fetch and don't have TIMESTAMP set in their distinfo, but that is required to be able to push a rename of the port by the pre-receive hook. Approved by: portmgr (rene) Reviewed by: mat Pull Request: https://github.com/freebsd/freebsd-ports/pull/302 PR: 281988
Diffstat (limited to 'filesystems/e2fsprogs-core')
-rw-r--r--filesystems/e2fsprogs-core/Makefile331
-rw-r--r--filesystems/e2fsprogs-core/distinfo3
-rw-r--r--filesystems/e2fsprogs-core/files/extrapatch-e2fsck_sigcatcher.c19
-rw-r--r--filesystems/e2fsprogs-core/files/extrapatch-no-sbrk34
-rw-r--r--filesystems/e2fsprogs-core/files/fix-ss_err.h.sed3
-rw-r--r--filesystems/e2fsprogs-core/files/fsck_ext2fs.895
-rw-r--r--filesystems/e2fsprogs-core/files/fsck_ext2fs.c145
-rw-r--r--filesystems/e2fsprogs-core/files/patch-e2fsck__unix.c78
-rw-r--r--filesystems/e2fsprogs-core/files/patch-lib__uuid__gen_uuid.c57
-rw-r--r--filesystems/e2fsprogs-core/files/patch-lib_blkid_devname.c110
-rw-r--r--filesystems/e2fsprogs-core/files/patch-lib_et_com__err.311
-rw-r--r--filesystems/e2fsprogs-core/files/patch-lib_support_plausible.c11
-rw-r--r--filesystems/e2fsprogs-core/files/patch-lib_support_sort__r.h13
-rw-r--r--filesystems/e2fsprogs-core/files/patch-misc__Makefile.in81
-rw-r--r--filesystems/e2fsprogs-core/files/patch-misc_blkid.8.in17
-rw-r--r--filesystems/e2fsprogs-core/files/patch-misc_e2fuzz.c13
-rw-r--r--filesystems/e2fsprogs-core/files/patch-tests_Makefile.in11
-rw-r--r--filesystems/e2fsprogs-core/files/patch-tests_f__detect__junk_script11
-rw-r--r--filesystems/e2fsprogs-core/files/patch-tests_m__offset_script11
-rw-r--r--filesystems/e2fsprogs-core/files/patch-tests_t__mmp__fail_script19
-rw-r--r--filesystems/e2fsprogs-core/files/unwanted8
-rw-r--r--filesystems/e2fsprogs-core/pkg-descr1
-rw-r--r--filesystems/e2fsprogs-core/pkg-install76
-rw-r--r--filesystems/e2fsprogs-core/pkg-message8
-rw-r--r--filesystems/e2fsprogs-core/pkg-plist127
25 files changed, 1293 insertions, 0 deletions
diff --git a/filesystems/e2fsprogs-core/Makefile b/filesystems/e2fsprogs-core/Makefile
new file mode 100644
index 000000000000..03e90db801f3
--- /dev/null
+++ b/filesystems/e2fsprogs-core/Makefile
@@ -0,0 +1,331 @@
+PORTNAME= e2fsprogs
+PORTVERSION= 1.47.1
+PORTREVISION?= 0 # NOTE: when bumping PORTREVISION, also bump ../e2fsprogs/Makefile!
+CATEGORIES?= filesystems sysutils
+MASTER_SITES= KERNEL_ORG/linux/kernel/people/tytso/${PORTNAME}/v${PORTVERSION}
+
+MAINTAINER?= mandree@FreeBSD.org
+COMMENT?= Utilities & library to manipulate ext2/3/4 filesystems
+WWW= https://e2fsprogs.sourceforge.net/
+
+LICENSE?= GPLv2+
+.if !defined(_no_license_file)
+LICENSE_FILE?= ${WRKSRC}/NOTICE
+.endif
+LICENSE_DISTFILES_GPLv2+ = ${DISTNAME}${EXTRACT_SUFX}
+
+USES= cpe gmake makeinfo pkgconfig tar:xz
+CPE_VENDOR= e2fsprogs_project
+USE_CSTD= gnu99
+# this seems a bit redundant to the --rpath below, but
+# the latter should be more robust in case someone needs
+# to deal with the file systems from a system not yet fully booted.
+.if !defined(PKGNAMESUFFIX)
+USE_LDCONFIG= ${PREFIX}/lib/e2fsprogs
+.endif
+GNU_CONFIGURE= yes
+GNU_CONFIGURE_MANPREFIX= ${PREFIX}/share
+
+# while we use the system blkid, we need to --enable-libblkid
+# so that the tools get built:
+CONFIGURE_ARGS?=--disable-fsck \
+ --disable-e2initrd-helper \
+ --disable-libuuid \
+ --disable-uuidd \
+ --enable-libblkid \
+ --enable-elf-shlibs \
+ --libdir='${PREFIX}/lib/e2fsprogs/' \
+ --includedir='${PREFIX}/include/e2fsprogs/' \
+ --with-root-prefix='${PREFIX}' \
+ LDFLAGS='${LDFLAGS} -L${LOCALBASE}/lib -Wl,--rpath -Wl,${LOCALBASE}/lib/e2fsprogs'
+CONFIGURE_ENV?= LIBS='-Wl,--as-needed ${LIBS} -lexecinfo -lelf'
+CPPFLAGS+= ${_FUSEFS_CFLAGS} -I${WRKSRC}/lib -I${LOCALBASE}/include
+CFLAGS+= -Wno-unused-command-line-argument # -D_FILE_OFFSET_BITS=64 # the latter for fuse-libs
+MAKE_ARGS+= pkgconfigdir='${PREFIX}/libdata/pkgconfig'
+MAKE_ENV+= CHECK_CMD=@true
+
+PORTSCOUT= ignore:1 # cannot handle the version in the directory
+
+.if !defined(MASTERDIR)
+CPPFLAGS+= -D__GNUC_PREREQ\(a,b\)=1
+
+INSTALL_TARGET= install install-libs
+
+OPTIONS_DEFINE= DOCS NLS FUSEFS PARALLELTESTS SLOWTESTS BASHTESTS LIBUNWIND
+OPTIONS_EXCLUDE+= EXAMPLES
+OPTIONS_SUB= yes
+
+OPTIONS_SINGLE= SELFTEST
+OPTIONS_SINGLE_SELFTEST= NOTESTS SMALLTESTS ALLTESTS
+OPTIONS_DEFAULT= SMALLTESTS
+FUSEFS_DESC= Build user-land ext2/3/4 FUSE module (slow!)
+SELFTEST_DESC= Choose which set of self-tests to run
+NOTESTS_DESC= Do not run any self-tests (Tier-1, DISCOURAGED)
+SMALLTESTS_DESC=Run tests that need <500 MB disk space (DEFAULT)
+ALLTESTS_DESC= Run most self-tests (needs more RAM/disk space)
+PARALLELTESTS_DESC= Parallelize self-tests (needs more disk space)
+SLOWTESTS_DESC= Enable slow tests that are skipped by default
+BASHTESTS_DESC= Enable tests that require the GNU bash shell
+LIBUNWIND_DESC= Backtrace with libunwind (do set WITH_DEBUG_PORTS+=${PKGORIGIN}!)
+
+FUSEFS_CONFIGURE_ENABLE= fuse2fs
+FUSEFS_USES= fuse:3
+# we can't use FUSEFS_CFLAGS, see below for workaround
+FUSEFS_LIBS= -Wl,--as-needed -lfuse3 -lpthread
+FUSEFS_LDFLAGS= -L${LOCALBASE}/lib
+
+NLS_USES= gettext iconv:build
+
+BASHTESTS_BUILD_DEPENDS= ${BASH_CMD}:shells/bash
+BASH_CMD= ${LOCALBASE}/bin/bash
+
+LIB_DEPENDS+= libblkid.so:filesystems/e2fsprogs-libblkid
+LIB_DEPENDS+= libuuid.so:misc/e2fsprogs-libuuid
+
+LIBUNWIND_LIB_DEPENDS= libunwind.so:devel/libunwind
+LIBUNWIND_LIBS+= -L${LOCALBASE}/lib -lunwind
+LIBUNWIND_LDFLAGS+= -rdynamic
+LIBUNWIND_EXTRA_PATCHES=${FILESDIR}/extrapatch-e2fsck_sigcatcher.c
+
+PORTDOCS= NOTICE README RELEASE-NOTES SUBMITTING-PATCHES
+.endif
+
+# even under DEVELOPER, no REINPLACE_CMD warnings desired
+# it simply makes no sense to warn about dozens of files
+# for systematic edits that run over files that don't need the edits.
+# a "warn if nothing was edited by one command" would be acceptable,
+# but until we have that in the framework, just
+# avoid Tools/scripts/sed_checked altogether:
+REINPLACE_CMD= ${SED} ${REINPLACE_ARGS}
+
+PKGDEINSTALL= ${PKGINSTALL}
+
+MAKE_ARGS+= V=1
+
+.include <bsd.port.options.mk>
+
+.if ${MASTERDIR} == ${.CURDIR}
+PKGNAMESUFFIX= -core
+.endif
+
+.if !empty(PORT_OPTIONS:MFUSEFS)
+# this dance is required becuse the -I must go before the default -I${LOCALBASE}/include, so we can't use FUSEFS_CFLAGS
+_FUSEFS_CFLAGS= -I${LOCALBASE}/include/fuse3
+.else
+_FUSEFS_CFLAGS=
+.endif
+
+. if ! empty(ARCH:Mpowerpc*)
+# Fix powerpc64/powerpc SIGSEGV,
+# see https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=231570 (ppc64)
+# see https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=242798 (ppc32 - untested)
+USES+= compiler:c11
+. endif
+
+.if empty(PORT_OPTIONS:MNOTESTS) && ${MASTERDIR} == ${.CURDIR}
+USES+= perl5
+USE_PERL5= build
+.endif
+
+.include <bsd.port.pre.mk>
+
+.if ${PORT_OPTIONS:MNLS}
+. if empty(ICONV_LIB)
+libintl= ${LOCALBASE}/lib/libintl.a
+. else
+libintl= ${LOCALBASE}/lib/libintl.a ${LOCALBASE}/lib/libiconv.a
+. endif
+.else
+CONFIGURE_ARGS+=--disable-nls
+libintl=
+.endif
+
+.if ${MASTERDIR} == ${.CURDIR} && (${ARCH} == "aarch64" || ${ARCH} == "riscv64")
+EXTRA_PATCHES+= ${FILESDIR}/extrapatch-no-sbrk
+.endif
+
+post-patch::
+.if !empty(DISTFILES)
+ @${REINPLACE_CMD} -e 's/<malloc\.h>/<stdlib.h>/' ${WRKSRC}/*/*.c
+ @${REINPLACE_CMD} -e 's,/etc/blkid.tab,${ETCDIR}/blkid.tab,' ${WRKSRC}/misc/blkid* ${WRKSRC}/lib/blkid/blkidP.h
+ @${REINPLACE_CMD} -E -e 's/__GNUC_PREREQ\>/__GNUC_PREREQ__/' ${WRKSRC}/*/*/*.[ch] ${WRKSRC}/*/*.c
+. if empty(PORT_OPTIONS:MALLTESTS)
+. for i in \
+ d_fallocate_blkmap \
+ f_baddir \
+ f_bbfile \
+ f_convert_bmap \
+ f_detect_junk \
+ f_inode_ea_collision \
+ f_lpffile \
+ f_no_cache_corrupt_inode \
+ f_opt_extent \
+ j_corrupt_descr_csum \
+ m_bigjournal \
+ m_hugefile_slack \
+ m_offset \
+ m_raid_opt \
+ r_32to64bit \
+ r_32to64bit_expand_full \
+ r_32to64bit_meta \
+ r_32to64bit_move_itable \
+ r_64to32bit \
+ r_64to32bit_meta \
+ r_expand_full \
+ r_min_itable \
+ t_change_uuid_mounted \
+ t_dangerous \
+ t_disable_changed_csum_seed_mounted \
+ t_disable_mcsum \
+ t_disable_mcsum_noinitbg \
+ t_disable_mcsum_yesinitbg \
+ t_enable_mcsum \
+ t_enable_mcsum_initbg \
+ t_iexpand_full \
+ t_iexpand_mcsum \
+ t_uninit_bg_rm \
+ u_dryrun \
+ u_mke2fs_opt_offset
+ @${MV} ${WRKSRC}/tests/${i} ${WRKSRC}/tests/disabled_test-${i}
+. endfor
+. endif
+. if ${PORT_OPTIONS:MBASHTESTS}
+ ${REINPLACE_CMD} -e 's}^SHELL *=.*}SHELL = ${_CHECK_SHELL}}' ${WRKSRC}/MCONFIG.in
+. else
+. for i in f_large_dir
+ @${MV} ${WRKSRC}/tests/${i} ${WRKSRC}/tests/disabled_test-${i}
+. endfor
+. endif
+.endif
+
+##############################################################
+# Master port stuff that is not to be seen by the slave ports.
+##############################################################
+.if ${MASTERDIR} == ${.CURDIR}
+# NOTE: The previous .if block goes all the way to the end of the file.
+
+.if !empty(PORT_OPTIONS:MNOTESTS) && (${OPSYS} == FreeBSD) && (${OSVERSION} >= 1500000 || (${ARCH} != amd64))
+BROKEN= it was not tested on your system by the maintainer; you must run self-tests
+.endif
+
+pre-build:
+# fix up Makefile ordering for parallel builds
+ cd ${WRKSRC}/lib/et && ${DO_MAKE_BUILD} compile_et
+ cd ${WRKSRC}/lib/ss && _ET_DIR_OVERRIDE=../et ../et/compile_et ss_err.et \
+ && ${REINPLACE_CMD} -f ${FILESDIR}/fix-ss_err.h.sed ss_err.h
+ cd ${WRKSRC}/lib/support && ${DO_MAKE_BUILD} prof_err.h
+
+.if ${PORT_OPTIONS:MPARALLELTESTS}
+_CHECK_JOBS=${_MAKE_JOBS}
+.else
+_CHECK_JOBS=
+.endif
+
+_checkaddargs=
+.if ${PORT_OPTIONS:MBASHTESTS}
+_CHECK_SHELL=${LOCALBASE}/bin/bash
+_checkaddargs+=--eval SHELL:=${BASH_CMD}
+.else
+_CHECK_SHELL=${SH}
+.endif
+
+.if !defined(TMPDIR)
+_checkaddargs+=TMPDIR=${WRKDIR}/tmp
+.endif
+
+.if ${PORT_OPTIONS:MSLOWTESTS}
+_check_target=SKIP_SLOW_TESTS= check
+_check_timeout=7200
+.else
+_check_target=check
+_check_timeout=180
+.endif
+
+.if ${PORT_OPTIONS:MLIBUNWIND}
+_staticlibs+=${LOCALBASE}/lib/libunwind.a /usr/lib/liblzma.a /usr/lib/libmd.a
+.endif
+
+post-build:
+# Relink e2fsck statically - We need to make sure that tools for the root file
+# system are statically linked against anything that is outside the root fs,
+# else we're in trouble if e2fsck is needed for boot:
+# (we don't use e2fsck.static, since we can link libc.so dynamically)
+# NOTE: we need to link libgcc statically, it might be under /usr/local!
+# => do not add a -Bdynamic - but instead list the dynamic libraries
+# before the -Bstatic
+ cd ${WRKSRC}/e2fsck && ${RM} -f e2fsck \
+ && ${MAKE_CMD} e2fsck V=1 \
+ LIBS="-static-libgcc -lc -Bstatic ../lib/libsupport.a ../lib/libext2fs.a ../lib/libcom_err.a \
+ ${_staticlibs} /usr/lib/libexecinfo.a /usr/lib/libelf.a \
+ ${LOCALBASE}/lib/libblkid.a ${LOCALBASE}/lib/libuuid.a ${libintl} ../lib/libe2p.a " \
+ && ${STRIP_CMD} e2fsck
+# Regression check: avoid a port (not upstream!) regression from 1.40.5,
+# check that e2fsck isn't dynalinked against anything but libc.so:
+ @${ECHO_CMD} -n "===> checking that e2fsck depends on no shared objects outside /lib: "
+ @a="$$(ldd ${WRKSRC}/e2fsck/e2fsck 2>/dev/null \
+ | ${GREP} -v 'not a dynamic executable' \
+ | ${GREP} '=>' \
+ | ${AWK} '{print $$3;}' \
+ | ${EGREP} -v '^/lib/lib.*\.so\.' || :)"; \
+ if test "x$$a" = "x" ; then echo 'PASS' ; else \
+ echo 'FAIL' ; echo '===> e2fsck depends on:' ; echo "$$a" ; exit 1 ; fi
+# Update translation binary files
+.if ${PORT_OPTIONS:MNLS}
+ cd ${WRKSRC}/po && ${MAKE_CMD} update-gmo
+.endif
+# Build fsck(8) wrapper
+ ${CC} ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} -s ${LIBS} \
+ -o ${WRKSRC}/fsck_ext2fs ${FILESDIR}/fsck_ext2fs.c
+# While the ${MAKE} check can take a minute on an end user's system, the
+# correctness of tools such as e2fsck is critical to the health of the
+# file systems. The upstream is not using any *BSD as his development
+# system, and therefore let's exercise due diligence in running the self-
+# test on each and every system and not just package building hosts.
+# There have been subtle failures induced by Linux-isms in the past.
+# -- Matthias Andree, package maintainer, 2007-09-18
+.if empty(PORT_OPTIONS:MNOTESTS)
+ @${ECHO_CMD} '===> Running e2fsprogs self-test suite'
+# do not add -j options unconditionally to ${MAKE_CMD} below, this might break
+# due to excessive disk space use.
+ cd ${WRKSRC}/tests && \
+ ulimit -t ${_check_timeout} && \
+ ${MKDIR} ${WRKDIR}/tmp && \
+ ${SETENV} e2fsprogs_inhibit_SIGINFO=1 BLKID_FILE=${WRKDIR}/tmp/blkid.tab SHELL=${_CHECK_SHELL} \
+ ${MAKE_CMD} ${_check_target} ${_CHECK_JOBS} ${_checkaddargs} \
+ || { head -n30000 ${WRKSRC}/tests/*.failed 2>/dev/null ; exit 1 ; }
+.else
+ @${ECHO_CMD} '===> SKIPPING e2fsprogs self-test suite (DISCOURAGED!)'
+.endif
+
+post-install:
+ ${INSTALL_PROGRAM} ${WRKSRC}/fsck_ext2fs ${STAGEDIR}${PREFIX}/sbin/
+ ${LN} -fs e2fsck ${STAGEDIR}${PREFIX}/sbin/fsck.ext2
+ ${LN} -fs e2fsck ${STAGEDIR}${PREFIX}/sbin/fsck.ext3
+ ${LN} -fs e2fsck ${STAGEDIR}${PREFIX}/sbin/fsck.ext4
+ # now the remainder of the usual post-install jobs:
+ ${INSTALL_MAN} ${FILESDIR}/fsck_ext2fs.8 ${STAGEDIR}${PREFIX}/share/man/man8/
+.if ${PORT_OPTIONS:MDOCS}
+ ${MKDIR} ${STAGEDIR}${DOCSDIR}
+.for i in ${PORTDOCS}
+ ${INSTALL_DATA} ${WRKSRC}/${i} ${STAGEDIR}${DOCSDIR}
+.endfor
+.endif
+ # remove or relocate files installed by other ports already, or shadowing system files:
+ cd ${STAGEDIR}${PREFIX} && \
+ ${XARGS} <${FILESDIR}/unwanted ${RM} && \
+ ${RMDIR} include/e2fsprogs/blkid
+ ${MV} ${STAGEDIR}${PREFIX}/bin/compile_et ${STAGEDIR}${PREFIX}/bin/e2fsprogs-compile_et
+ ${MV} ${STAGEDIR}${PREFIX}/share/man/man1/compile_et.1 ${STAGEDIR}${PREFIX}/share/man/man1/e2fsprogs-compile_et.1
+ ${MKDIR} ${STAGEDIR}${DATADIR}/et/
+ ${MV} ${STAGEDIR}${PREFIX}/share/et/* ${STAGEDIR}${DATADIR}/et/
+ ${REINPLACE_CMD} -e 's}^DIR=.*$$}DIR=${DATADIR}/et}' -i '' ${STAGEDIR}${PREFIX}/bin/e2fsprogs-compile_et
+ ${RMDIR} ${STAGEDIR}${PREFIX}/share/et
+ ${MV} -f ${STAGEDIR}${PREFIX}/share/man/man3/com_err.3 \
+ ${STAGEDIR}${PREFIX}/share/man/man3/e2fsprogs-com_err.3
+ ${RM} ${STAGEDIR}${PREFIX}/share/man/man3/libblkid.3
+
+#
+# the next line closes .if ${MASTERDIR} == ${.CURDIR}
+.endif
+
+.include <bsd.port.post.mk>
diff --git a/filesystems/e2fsprogs-core/distinfo b/filesystems/e2fsprogs-core/distinfo
new file mode 100644
index 000000000000..fba31cb081b8
--- /dev/null
+++ b/filesystems/e2fsprogs-core/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1717066777
+SHA256 (e2fsprogs-1.47.1.tar.xz) = 5a33dc047fd47284bca4bb10c13cfe7896377ae3d01cb81a05d406025d99e0d1
+SIZE (e2fsprogs-1.47.1.tar.xz) = 7271444
diff --git a/filesystems/e2fsprogs-core/files/extrapatch-e2fsck_sigcatcher.c b/filesystems/e2fsprogs-core/files/extrapatch-e2fsck_sigcatcher.c
new file mode 100644
index 000000000000..10288de1dc58
--- /dev/null
+++ b/filesystems/e2fsprogs-core/files/extrapatch-e2fsck_sigcatcher.c
@@ -0,0 +1,19 @@
+--- e2fsck/sigcatcher.c.orig 2020-01-06 23:10:17 UTC
++++ e2fsck/sigcatcher.c
+@@ -17,6 +17,7 @@
+ #ifdef HAVE_EXECINFO_H
+ #include <execinfo.h>
+ #endif
++#include <libunwind.h>
+
+ #include "e2fsck.h"
+
+@@ -376,7 +377,7 @@ static void die_signal_handler(int signum, siginfo_t *
+ void *stack_syms[32];
+ int frames;
+
+- frames = backtrace(stack_syms, 32);
++ frames = unw_backtrace(stack_syms, 32);
+ backtrace_symbols_fd(stack_syms, frames, 2);
+ }
+ #endif
diff --git a/filesystems/e2fsprogs-core/files/extrapatch-no-sbrk b/filesystems/e2fsprogs-core/files/extrapatch-no-sbrk
new file mode 100644
index 000000000000..6aa12d2b05a5
--- /dev/null
+++ b/filesystems/e2fsprogs-core/files/extrapatch-no-sbrk
@@ -0,0 +1,34 @@
+diff -up ./e2fsck/e2fsck.h.orig ./e2fsck/e2fsck.h
+--- ./e2fsck/e2fsck.h.orig 2018-05-16 01:42:44.000000000 +0200
++++ ./e2fsck/e2fsck.h 2018-07-07 12:50:43.420944000 +0200
+@@ -134,7 +134,7 @@ struct dx_dirblock_info {
+ #define DX_FLAG_FIRST 4
+ #define DX_FLAG_LAST 8
+
+-#define RESOURCE_TRACK
++#undef RESOURCE_TRACK
+
+ #ifdef RESOURCE_TRACK
+ /*
+diff -up ./resize/resource_track.c.orig ./resize/resource_track.c
+--- ./resize/resource_track.c.orig 2018-05-16 01:42:44.000000000 +0200
++++ ./resize/resource_track.c 2018-07-07 14:24:54.728576000 +0200
+@@ -27,7 +27,6 @@ void init_resource_track(struct resource
+ io_stats io_start = 0;
+
+ track->desc = desc;
+- track->brk_start = sbrk(0);
+ gettimeofday(&track->time_start, 0);
+ #ifdef HAVE_GETRUSAGE
+ #ifdef sun
+@@ -84,9 +83,7 @@ void print_resource_track(ext2_resize_t
+ kbytes(malloc_info.arena), kbytes(malloc_info.hblkhd),
+ kbytes(malloc_info.uordblks), kbytes(malloc_info.fordblks));
+ #else
+- printf("Memory used: %lu, ",
+- (unsigned long) (((char *) sbrk(0)) -
+- ((char *) track->brk_start)));
++ printf("Memory used: unknown, ");
+ #endif
+ #ifdef HAVE_GETRUSAGE
+ getrusage(RUSAGE_SELF, &r);
diff --git a/filesystems/e2fsprogs-core/files/fix-ss_err.h.sed b/filesystems/e2fsprogs-core/files/fix-ss_err.h.sed
new file mode 100644
index 000000000000..1b72045c519b
--- /dev/null
+++ b/filesystems/e2fsprogs-core/files/fix-ss_err.h.sed
@@ -0,0 +1,3 @@
+/#define __ss_err_h__/a\
+#include <stdio.h>
+#include <com_err.h>
diff --git a/filesystems/e2fsprogs-core/files/fsck_ext2fs.8 b/filesystems/e2fsprogs-core/files/fsck_ext2fs.8
new file mode 100644
index 000000000000..3ab4c664f740
--- /dev/null
+++ b/filesystems/e2fsprogs-core/files/fsck_ext2fs.8
@@ -0,0 +1,95 @@
+.TH fsck_ext2fs 8 2006-07-02 "Matthias Andree" "FreeBSD Ports"
+.\"
+.\" fsck_ext2fs.8 - manual page for fsck_ext2fs wrapper
+.\"
+.\" (C) Copyright 2006 by Matthias Andree <matthias.andree@gmx.de>
+.\"
+.\" License: This file may be redistributed in accordance with the terms
+.\" of the GNU General Public License v2.
+.\"
+.\" Upstream $Id: fsck_ext2fs.8,v 1.3 2006/07/02 11:45:21 emma Exp $
+.\"
+.SH NAME
+.B fsck_ext2fs
+\- compatibility wrapper for e2fsck
+.SH SYNOPSIS
+.P
+.B fsck_ext2fs
+[\fB\-Fpfnyv\fR] [\fB\-b\fR \fIblock\fR]
+.SH DESCRIPTION
+.P
+\fBfsck_ext2fs\fR maps the traditional FreeBSD \fBfsck_ffs\fR options to
+options with the same functionality for \fBe2fsck,\fR runs \fBe2fsck\fR
+and then maps its exit status to values that FreeBSD understands.
+\fBe2fsck\fR is a utility to check and repair ext2 and ext3 file
+systems.
+
+.SH OPTIONS
+.IP \fB\-F\fR
+(check foreground mode required) Immediately exits with status 1 to tell
+\fBfsck\fR that ext2fs cannot be checked in the background. \fBfsck\fR
+usually runs \fBfsck_*\fR programs twice, first with \fB\-F\fR to find
+out if they can do background checking, then either immediately without
+\fB\-F\fR for foreground checking or deferred in the background with
+\fB\-B\fR.
+.IP \fB\-p\fR
+(preen mode) This option suppresses adding the \fB\-f\fR option (unless
+\fB\-f\fR is also given) and adds the \fB\-p\fR option to the
+\fBe2fsck\fR command line. This causes \fBe2fsck\fR to automatically fix
+any filesystem problems that can safely be fixed without operator
+intervention. Without this option given, \fBe2fsck\fR will be run with
+the \fB\-f\fR option to force a check, since interactive scan and repair
+mode is the default on FreeBSD, but not on Linux where \fBe2fsck\fR
+comes from.
+.IP \fB\-f\fR
+(force check) This option forces the check of a clean file system while
+preening and is passed to \fBe2fsck\fR verbatim.
+.IP \fB\-n\fR
+("no" mode) This option causes the file system to be opened in read-only
+mode and assume "no" as answer to all questions. This is the only way to
+safely run \fBfsck\fR on a mounted ext2 or ext3 file system. This option
+is passed to \fBe2fsck\fR verbatim.
+.IP \fB\-y\fR
+("yes" mode) This option is passed verbatim to \fBe2fsck\fR and causes
+it to assume "yes" as answer to all questions. This allows the
+non-interactive use of e2fsck but is rather aggressive. Use with care.
+.IP \fB\-v\fR
+(verbose output) This option is passed verbatim to \fBe2fsck\fR and
+causes it to verbosely report its progress.
+.IP "\fB\-b\fR \fIblock\fR"
+(use alternate super block) This option is passed verbatim to
+\fBe2fsck\fR and selects an alternate super block, for use when the
+primary super block has been damaged. Please see the \fBe2fsck\fR(8)
+manual page for details.
+
+.SH EXIT STATUS
+If errors remain after \fBe2fsck\fR, an invalid option or too many
+options have been specified, \fBe2fsck\fR was killed with a signal or
+the \fIfork\fB system call failed, \fBfsck_ext2fs\fR exits with status
+EXIT_FAILURE (usually 1). If \fBe2fsck\fR cannot be started, exits with
+status 127. If the file system is clean after \fBe2fsck\fR operation,
+exits with status EXIT_SUCCESS (0).
+
+.SH NOTES
+.P
+This utility is merely meant as an adaptor so that \fBe2fsck\fR can be
+run during the boot process, it does not support all options that
+\fBe2fsck\fR offers. If you need one of its advanced options, please run
+\fBe2fsck\fR directly.
+
+.SH FILES
+.TP
+.I /sbin/e2fsck
+is the location of the \fBe2fsck\fR program to run.
+
+.SH AUTHOR
+.P
+Matthias Andree <matthias.andree@gmx.de> wrote the program and this
+manual page.
+.SH CONFORMING TO
+The FreeBSD 6.1 command line interface for \fBfsck_ufs\fR(8).
+.SH SEE ALSO
+.BR fsck (8),
+.BR e2fsck (8)
+and
+.BR fsck_ufs (8).
diff --git a/filesystems/e2fsprogs-core/files/fsck_ext2fs.c b/filesystems/e2fsprogs-core/files/fsck_ext2fs.c
new file mode 100644
index 000000000000..9634c414242e
--- /dev/null
+++ b/filesystems/e2fsprogs-core/files/fsck_ext2fs.c
@@ -0,0 +1,145 @@
+/*
+ * fsck_ext2fs - wrapper for e2fsck on FreeBSD
+ * Copyright (C) 2004,2006 Matthias Andree <matthias.andree@gmx.de>
+ * redistributable in accordance with the
+ * GNU General Public License v2
+ *
+ * Upstream: $Id: fsck_ext2fs.c,v 1.6 2006/07/02 11:37:49 emma Exp $
+ *
+ * format: gindent -kr
+ */
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <errno.h>
+
+__attribute__ ((noreturn))
+static int die(const char *tag)
+{
+ perror(tag);
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char **argv)
+{
+ int ch, i = 1, force = 0, status, verbose = 0, t;
+ long block = 0;
+ enum { normal, preen, yes, no } mode = normal;
+ char *cmd[256];
+ pid_t pid;
+
+ cmd[0] = "/sbin/e2fsck";
+ while ((ch = getopt(argc, argv, "BFpfnyb:v")) != -1) {
+ switch (ch) {
+ case 'p':
+ mode = preen;
+ break;
+ case 'f':
+ force = 1;
+ break;
+ case 'n':
+ mode = no;
+ break;
+ case 'y':
+ mode = yes;
+ break;
+ case 'b':
+ block = atol(optarg);
+ break;
+ case 'v':
+ verbose++;
+ break;
+ case 'F':
+ /* e2fsck does not support background checking,
+ * hence exit with nonzero status to force
+ * the foreground check. */
+ exit(1);
+ case 'B':
+ default:
+ fprintf(stderr, "%s: unknown option -%c\n",
+ argv[0], optopt);
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ if (force)
+ cmd[i++] = "-f";
+
+ switch (mode) {
+ case normal:
+ /* FreeBSD needs -f to force a check only in context
+ * with -p -- so map normal to force to match
+ * expectations */
+ if (!force)
+ cmd[i++] = "-f";
+ break;
+ case yes:
+ cmd[i++] = "-y";
+ break;
+ case no:
+ cmd[i++] = "-n";
+ break;
+ case preen:
+ cmd[i++] = "-p";
+ break;
+ }
+
+ if (block) {
+ static char b[30];
+
+ sprintf(b, "-b %ld", block);
+ cmd[i++] = b;
+ }
+
+ /* silently limit verbose to 15 so we don't overflow the cmd array */
+ if (verbose > 15)
+ verbose = 15;
+
+ for (t = verbose; t > 1; t--)
+ cmd[i++] = "-v";
+
+ while (optind < argc) {
+ cmd[i++] = argv[optind++];
+ /* sanity check so we don't overflow the cmd buffer */
+ if (i+1 == sizeof(cmd)/sizeof(cmd[0])) {
+ errno = E2BIG;
+ die(argv[0]);
+ }
+ }
+
+ cmd[i++] = 0;
+
+ if (verbose) {
+ for (i=0; cmd[i]; i++)
+ fputs(cmd[i], stderr),
+ fputc(' ', stderr);
+ fputc('\n', stderr);
+ }
+
+ pid = fork();
+ switch (pid) {
+ case -1:
+ /* error */
+ die("fork");
+ break;
+ case 0:
+ /* child */
+ (void) execv(cmd[0], cmd);
+ perror("execve");
+ _exit(127);
+ default:
+ /* parent */
+ if (pid != waitpid(pid, &status, 0))
+ die("waitpid");
+ if (WIFSIGNALED(status)
+ || (WIFEXITED(status) && WEXITSTATUS(status) >= 4))
+ exit(EXIT_FAILURE);
+ }
+ exit(EXIT_SUCCESS);
+}
diff --git a/filesystems/e2fsprogs-core/files/patch-e2fsck__unix.c b/filesystems/e2fsprogs-core/files/patch-e2fsck__unix.c
new file mode 100644
index 000000000000..fe98d8988b57
--- /dev/null
+++ b/filesystems/e2fsprogs-core/files/patch-e2fsck__unix.c
@@ -0,0 +1,78 @@
+// SIGINFO is a Berkeley extension, so we need to
+// remove the #define _XOPEN_SOURCE 600
+// It would hide all non-POSIX declarations, including SIGINFO.
+
+--- e2fsck/unix.c.orig 2024-05-21 02:52:47 UTC
++++ e2fsck/unix.c
+@@ -9,8 +9,6 @@
+ * %End-Header%
+ */
+
+-#define _XOPEN_SOURCE 600 /* for inclusion of sa_handler in Solaris */
+-
+ #include "config.h"
+ #include <stdio.h>
+ #ifdef HAVE_STDLIB_H
+@@ -37,7 +35,7 @@ extern int optind;
+ #include <sys/ioctl.h>
+ #endif
+ #ifdef HAVE_MALLOC_H
+-#include <malloc.h>
++#include <stdlib.h>
+ #endif
+ #ifdef HAVE_SYS_TYPES_H
+ #include <sys/types.h>
+@@ -608,6 +606,24 @@ static int e2fsck_update_progress(e2fsck_t ctx, int pa
+ return 0;
+ }
+
++static int e2fsck_progress_once(e2fsck_t ctx, int pass, unsigned long cur, unsigned long max)
++{
++ char buf[80];
++ float percent;
++
++ if (pass == 0)
++ return 0;
++
++ percent = calc_percent(&e2fsck_tbl, pass, cur, max);
++ e2fsck_simple_progress(ctx, ctx->device_name,
++ percent, 0);
++
++ printf("\n");
++ ctx->progress = 0;
++ return 0;
++}
++
++
+ #define PATH_SET "PATH=/sbin"
+
+ /*
+@@ -641,6 +657,17 @@ static void signal_progress_on(int sig EXT2FS_ATTR((un
+ ctx->progress = e2fsck_update_progress;
+ }
+
++static void signal_progress_now(int sig EXT2FS_ATTR((unused)))
++{
++ e2fsck_t ctx = e2fsck_global_ctx;
++
++ if (!ctx)
++ return;
++
++ ctx->progress = e2fsck_progress_once;
++ ctx->progress_fd = 0;
++}
++
+ static void signal_progress_off(int sig EXT2FS_ATTR((unused)))
+ {
+ e2fsck_t ctx = e2fsck_global_ctx;
+@@ -1127,6 +1154,10 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t
+ sigaction(SIGUSR1, &sa, 0);
+ sa.sa_handler = signal_progress_off;
+ sigaction(SIGUSR2, &sa, 0);
++ sa.sa_handler = signal_progress_now;
++ if (!getenv("e2fsprogs_inhibit_SIGINFO")) {
++ sigaction(SIGINFO, &sa, 0);
++ }
+ #endif
+
+ /* Update our PATH to include /sbin if we need to run badblocks */
diff --git a/filesystems/e2fsprogs-core/files/patch-lib__uuid__gen_uuid.c b/filesystems/e2fsprogs-core/files/patch-lib__uuid__gen_uuid.c
new file mode 100644
index 000000000000..13e7b8c2f6b5
--- /dev/null
+++ b/filesystems/e2fsprogs-core/files/patch-lib__uuid__gen_uuid.c
@@ -0,0 +1,57 @@
+--- lib/uuid/gen_uuid.c.orig 2024-05-21 02:52:47 UTC
++++ lib/uuid/gen_uuid.c
+@@ -92,6 +92,7 @@
+ #ifdef HAVE_SYS_RESOURCE_H
+ #include <sys/resource.h>
+ #endif
++#include <ifaddrs.h>
+
+ #include "uuidP.h"
+ #include "uuidd.h"
+@@ -288,6 +289,28 @@ static int get_node_id(unsigned char *node_id)
+ }
+ }
+ close(sd);
++#else
++ struct ifaddrs *ifaddrsp, *ifaddrp;
++ unsigned char *a;
++
++ if (getifaddrs(&ifaddrsp) < 0)
++ return -1;
++ for (ifaddrp = ifaddrsp; ifaddrp != NULL; ifaddrp = ifaddrp->ifa_next)
++ {
++ if (ifaddrp->ifa_addr == NULL)
++ continue;
++ if (ifaddrp->ifa_addr->sa_family != AF_LINK)
++ continue;
++ a = LLADDR((struct sockaddr_dl *)ifaddrp->ifa_addr);
++ if (!a[0] && !a[1] && !a[2] && !a[3] && !a[4] && !a[5])
++ continue;
++ if (node_id) {
++ memcpy(node_id, a, 6);
++ freeifaddrs(ifaddrsp);
++ return 1;
++ }
++ }
++ freeifaddrs(ifaddrsp);
+ #endif
+ return 0;
+ }
+@@ -472,7 +495,7 @@ static void close_all_fds(void)
+ }
+ #endif /* defined(USE_UUIDD) && defined(HAVE_SYS_UN_H) */
+
+-#if __GNUC_PREREQ (4, 6)
++#if __GNUC_PREREQ__ (4, 6)
+ #pragma GCC diagnostic push
+ #if !defined(USE_UUIDD) || !defined(HAVE_SYS_UN_H)
+ #pragma GCC diagnostic ignored "-Wunused-parameter"
+@@ -560,7 +583,7 @@ fail:
+ #endif
+ return -1;
+ }
+-#if __GNUC_PREREQ (4, 6)
++#if __GNUC_PREREQ__ (4, 6)
+ #pragma GCC diagnostic pop
+ #endif
+
diff --git a/filesystems/e2fsprogs-core/files/patch-lib_blkid_devname.c b/filesystems/e2fsprogs-core/files/patch-lib_blkid_devname.c
new file mode 100644
index 000000000000..9a59112ed239
--- /dev/null
+++ b/filesystems/e2fsprogs-core/files/patch-lib_blkid_devname.c
@@ -0,0 +1,110 @@
+--- lib/blkid/devname.c.orig 2020-03-21 04:24:04 UTC
++++ lib/blkid/devname.c
+@@ -40,6 +40,9 @@
+ #include <sys/sysmacros.h>
+ #endif
+ #include <time.h>
++#ifdef __FreeBSD__
++#include <sys/sysctl.h>
++#endif
+
+ #include "blkidP.h"
+
+@@ -397,11 +400,15 @@ evms_probe_all(blkid_cache cache, int only_if_new)
+ static int probe_all(blkid_cache cache, int only_if_new)
+ {
+ FILE *proc;
++#ifndef __FreeBSD__
+ char line[1024];
++ int ma, mi;
++#else
++ char *line;
++#endif /* __FreeBSD__ */
+ char ptname0[129], ptname1[129], *ptname = 0;
+ char *ptnames[2];
+ dev_t devs[2];
+- int ma, mi;
+ unsigned long long sz;
+ int lens[2] = { 0, 0 };
+ int which = 0, last = 0;
+@@ -423,20 +430,68 @@ static int probe_all(blkid_cache cache, int only_if_ne
+ lvm_probe_all(cache, only_if_new);
+ #endif
+
++#ifndef __FreeBSD__
+ proc = fopen(PROC_PARTITIONS, "r");
+ if (!proc)
+ return -BLKID_ERR_PROC;
+
+ while (fgets(line, sizeof(line), proc)) {
++#else
++ size_t len, bufsiz = 4096;
++ char *buf = NULL;
++
++ for(;;) {
++ buf = realloc(buf, bufsiz);
++ if (!buf) return -BLKID_ERR_MEM;
++ len = bufsiz - 1;
++ if (sysctlbyname("kern.geom.conftxt", buf, &len, NULL, 0)) {
++ if (ENOMEM != errno) {
++ free(buf);
++ return -BLKID_ERR_IO;
++ }
++ bufsiz <<= 1;
++ } else {
++ if (len < bufsiz) buf[len] = '\0';
++ else buf[bufsiz - 1] = '\0';
++ break;
++ }
++ }
++ char *str = buf;
++ while ((line = strsep(&str, "\n"))) {
++#endif /* __FreeBSD__ */
+ last = which;
+ which ^= 1;
+ ptname = ptnames[which];
+
++#ifndef __FreeBSD__
+ if (sscanf(line, " %d %d %llu %128[^\n ]",
+ &ma, &mi, &sz, ptname) != 4)
+ continue;
+ devs[which] = makedev(ma, mi);
++#else
++ char type[6];
++ int dummy;
+
++ if (sscanf(line, "%*d %5s %128[^ ] %lld %d",
++ type, ptname, &sz, &dummy) != 4)
++ continue;
++ sz /= 1024;
++
++ if (strcmp("PART", type) && strcmp("DISK", type))
++ continue;
++ {
++ struct stat st;
++ char dn[128];
++ if (snprintf(dn, sizeof dn, "/dev/%s", ptname) >= sizeof dn)
++ continue;
++
++ if (stat(dn, &st))
++ continue;
++
++ devs[which] = st.st_rdev;
++ }
++#endif /* __FreeBSD__ */
++
+ DBG(DEBUG_DEVNAME, printf("read partition name %s\n", ptname));
+
+ /* Skip whole disk devs unless they have no partitions.
+@@ -507,7 +562,11 @@ static int probe_all(blkid_cache cache, int only_if_ne
+ if (lens[which])
+ probe_one(cache, ptname, devs[which], 0, only_if_new);
+
++#ifndef __FreeBSD__
+ fclose(proc);
++#else
++ free(buf);
++#endif /* __FreeBSD__ */
+ blkid_flush_cache(cache);
+ return 0;
+ }
diff --git a/filesystems/e2fsprogs-core/files/patch-lib_et_com__err.3 b/filesystems/e2fsprogs-core/files/patch-lib_et_com__err.3
new file mode 100644
index 000000000000..bc3b522f46ea
--- /dev/null
+++ b/filesystems/e2fsprogs-core/files/patch-lib_et_com__err.3
@@ -0,0 +1,11 @@
+--- lib/et/com_err.3.orig 2021-08-19 02:53:01 UTC
++++ lib/et/com_err.3
+@@ -18,6 +18,8 @@ proc = reset_com_err_hook ();
+ void initialize_XXXX_error_table ();
+ .fi
+ .SH DESCRIPTION
++This is the manual page for com_err as bundled with the e2fsprogs package.
++.P
+ .I Com_err
+ displays an error message on the standard error stream
+ .I stderr
diff --git a/filesystems/e2fsprogs-core/files/patch-lib_support_plausible.c b/filesystems/e2fsprogs-core/files/patch-lib_support_plausible.c
new file mode 100644
index 000000000000..3d23b30e9c8f
--- /dev/null
+++ b/filesystems/e2fsprogs-core/files/patch-lib_support_plausible.c
@@ -0,0 +1,11 @@
+--- lib/support/plausible.c.orig 2020-01-06 23:10:17 UTC
++++ lib/support/plausible.c
+@@ -62,7 +62,7 @@ static void *magic_handle;
+ static int magic_library_available(void)
+ {
+ if (!magic_handle) {
+- magic_handle = dlopen("libmagic.so.1", RTLD_NOW);
++ magic_handle = dlopen("libmagic.so", RTLD_NOW);
+ if (!magic_handle)
+ return 0;
+
diff --git a/filesystems/e2fsprogs-core/files/patch-lib_support_sort__r.h b/filesystems/e2fsprogs-core/files/patch-lib_support_sort__r.h
new file mode 100644
index 000000000000..c01a084feb6b
--- /dev/null
+++ b/filesystems/e2fsprogs-core/files/patch-lib_support_sort__r.h
@@ -0,0 +1,13 @@
+--- lib/support/sort_r.h.orig 2024-05-21 02:52:47 UTC
++++ lib/support/sort_r.h
+@@ -238,10 +238,6 @@ static _SORT_R_INLINE void sort_r_simple(void *base, s
+
+ #if defined _SORT_R_BSD
+
+- /* Ensure qsort_r is defined */
+- extern void qsort_r(void *base, size_t nel, size_t width, void *thunk,
+- int (*compar)(void *_thunk,
+- const void *_a, const void *_b));
+
+ #endif
+
diff --git a/filesystems/e2fsprogs-core/files/patch-misc__Makefile.in b/filesystems/e2fsprogs-core/files/patch-misc__Makefile.in
new file mode 100644
index 000000000000..ec0ff218a622
--- /dev/null
+++ b/filesystems/e2fsprogs-core/files/patch-misc__Makefile.in
@@ -0,0 +1,81 @@
+--- misc/Makefile.in.orig 2021-01-29 22:02:31 UTC
++++ misc/Makefile.in
+@@ -38,17 +38,17 @@ MKDIR_P = @MKDIR_P@
+
+ SPROGS= mke2fs badblocks tune2fs dumpe2fs $(BLKID_PROG) logsave \
+ $(E2IMAGE_PROG) @FSCK_PROG@ e2undo
+-USPROGS= mklost+found filefrag e2freefrag $(UUIDD_PROG) \
++USPROGS= mklost+found e2freefrag $(UUIDD_PROG) \
+ $(E4DEFRAG_PROG) $(E4CRYPT_PROG)
+ SMANPAGES= tune2fs.8 mklost+found.8 mke2fs.8 dumpe2fs.8 badblocks.8 \
+ e2label.8 $(FINDFS_MAN) $(BLKID_MAN) $(E2IMAGE_MAN) \
+- logsave.8 filefrag.8 e2freefrag.8 e2undo.8 \
+- $(UUIDD_MAN) $(E4DEFRAG_MAN) $(E4CRYPT_MAN) @FSCK_MAN@ \
++ logsave.8 e2freefrag.8 e2undo.8 \
++ $(E4DEFRAG_MAN) $(E4CRYPT_MAN) @FSCK_MAN@ \
+ e2mmpstatus.8
+ FMANPAGES= mke2fs.conf.5 ext4.5
+
+-UPROGS= chattr lsattr $(FUSE_PROG) @UUID_CMT@ uuidgen
+-UMANPAGES= chattr.1 lsattr.1 @UUID_CMT@ uuidgen.1
++UPROGS= chattr lsattr $(FUSE_PROG)
++UMANPAGES= chattr.1 lsattr.1
+ UMANPAGES+= @FUSE_CMT@ fuse2fs.1
+
+ LPROGS= @E2INITRD_PROG@
+@@ -154,14 +154,14 @@ profiled:
+
+ mke2fs.conf: $(srcdir)/mke2fs.conf.in
+ if test -f $(srcdir)/mke2fs.conf.custom.in ; then \
+- cp $(srcdir)/mke2fs.conf.custom.in mke2fs.conf; \
++ cp $(srcdir)/mke2fs.conf.custom.in mke2fs.conf.dist; \
+ else \
+- cp $(srcdir)/mke2fs.conf.in mke2fs.conf; \
++ cp $(srcdir)/mke2fs.conf.in mke2fs.conf.dist; \
+ fi
+
+ default_profile.c: mke2fs.conf $(srcdir)/profile-to-c.awk
+ $(E) " PROFILE_TO_C mke2fs.conf"
+- $(Q) $(AWK) -f $(srcdir)/profile-to-c.awk < mke2fs.conf \
++ $(Q) $(AWK) -f $(srcdir)/profile-to-c.awk < mke2fs.conf.dist \
+ > default_profile.c
+ findsuper: findsuper.o
+ $(E) " LD $@"
+@@ -612,34 +612,9 @@ install: all $(SMANPAGES) $(UMANPAGES) installdirs
+ (cd $(DESTDIR)$(man5dir); \
+ $(LN) $(LINK_INSTALL_FLAGS) ext4.5 $$i.5); \
+ done
+- $(Q) if test -f $(DESTDIR)$(root_sysconfdir)/mke2fs.conf; then \
+- if cmp -s $(DESTDIR)$(root_sysconfdir)/mke2fs.conf \
+- mke2fs.conf; then \
+- true; \
+- else \
+- if grep -q ext4dev $(DESTDIR)$(root_sysconfdir)/mke2fs.conf ; then \
+- $(ES) " INSTALL_DATA $(root_sysconfdir)/mke2fs.conf.e2fsprogs-new"; \
+- $(INSTALL_DATA) mke2fs.conf \
+- $(DESTDIR)$(root_sysconfdir)/mke2fs.conf.e2fsprogs-new; \
+- echo "Warning: installing mke2fs.conf in $(DESTDIR)$(root_sysconfdir)/mke2fs.conf.e2fsprogs-new"; \
+- echo "Check to see if you need to update your $(root_sysconfdir)/mke2fs.conf"; \
+- else \
+- $(ES) " INSTALL_DATA $(root_sysconfdir)/mke2fs.conf"; \
+- mv $(DESTDIR)$(root_sysconfdir)/mke2fs.conf \
+- $(DESTDIR)$(root_sysconfdir)/mke2fs.conf.e2fsprogs-old; \
+- $(INSTALL_DATA) mke2fs.conf \
+- $(DESTDIR)$(root_sysconfdir)/mke2fs.conf; \
+- echo "Your mke2fs.conf is too old. Backing up old version in"; \
+- echo "$(DESTDIR)$(root_sysconfdir)/mke2fs.conf.e2fsprogs-old. Please check to see"; \
+- echo "if you have any local customizations that you wish to preserve."; \
+- fi; \
+- echo " "; \
+- fi; \
+- else \
+- $(ES) " INSTALL_DATA $(root_sysconfdir)/mke2fs.conf"; \
+- $(INSTALL_DATA) mke2fs.conf \
+- $(DESTDIR)$(root_sysconfdir)/mke2fs.conf; \
+- fi
++ $(Q) $(ES) " INSTALL_DATA $(root_sysconfdir)/mke2fs.conf"; \
++ $(INSTALL_DATA) mke2fs.conf.dist \
++ $(DESTDIR)$(root_sysconfdir)/mke2fs.conf.dist
+
+ install-strip: install
+ $(Q) for i in $(SPROGS); do \
diff --git a/filesystems/e2fsprogs-core/files/patch-misc_blkid.8.in b/filesystems/e2fsprogs-core/files/patch-misc_blkid.8.in
new file mode 100644
index 000000000000..c6532a4a1a2e
--- /dev/null
+++ b/filesystems/e2fsprogs-core/files/patch-misc_blkid.8.in
@@ -0,0 +1,17 @@
+--- misc/blkid.8.in.orig 2020-03-21 04:24:04 UTC
++++ misc/blkid.8.in
+@@ -144,10 +144,10 @@ option.
+ Display tokens from only the specified device. It is possible to
+ give multiple
+ .I device
+-options on the command line. If none is given, all devices which
+-appear in
+-.I /proc/partitions
+-are shown, if they are recognized.
++options on the command line. If none is given, all DISK and PART devices which
++appear in the
++.I kern.geom.conftxt
++sysctl variable are shown, if they are recognized.
+ .SH "RETURN CODE"
+ If the specified token was found, or if any tags were shown from (specified)
+ devices, 0 is returned. If the specified token was not found, or no
diff --git a/filesystems/e2fsprogs-core/files/patch-misc_e2fuzz.c b/filesystems/e2fsprogs-core/files/patch-misc_e2fuzz.c
new file mode 100644
index 000000000000..a9f56490e5b6
--- /dev/null
+++ b/filesystems/e2fsprogs-core/files/patch-misc_e2fuzz.c
@@ -0,0 +1,13 @@
+--- misc/e2fuzz.c.orig 2020-03-23 08:29:36 UTC
++++ misc/e2fuzz.c
+@@ -278,8 +278,8 @@ static int process_fs(const char *fsname)
+ c |= 0x80;
+ if (verbose)
+ printf("Corrupting byte %lld in block %lld to 0x%x\n",
+- off % fs->blocksize,
+- off / fs->blocksize, c);
++ (long long)off % fs->blocksize,
++ (long long)off / fs->blocksize, c);
+ if (dryrun)
+ continue;
+ #ifdef HAVE_PWRITE64
diff --git a/filesystems/e2fsprogs-core/files/patch-tests_Makefile.in b/filesystems/e2fsprogs-core/files/patch-tests_Makefile.in
new file mode 100644
index 000000000000..a5f9b50df891
--- /dev/null
+++ b/filesystems/e2fsprogs-core/files/patch-tests_Makefile.in
@@ -0,0 +1,11 @@
+--- tests/Makefile.in.orig 2021-01-29 05:51:02 UTC
++++ tests/Makefile.in
+@@ -17,7 +17,7 @@ all:: @DO_TEST_SUITE@ test_one test_script
+ test_one: $(srcdir)/test_one.in Makefile mke2fs.conf test_data.tmp
+ @echo "Creating test_one script..."
+ @[ -f test_one ] && chmod u+w test_one || true
+- @echo "#!/bin/sh" > test_one
++ @echo "#!${SHELL}" > test_one
+ @echo "HTREE=y" >> test_one
+ @echo "QUOTA=y" >> test_one
+ @echo "SRCDIR=@srcdir@" >> test_one
diff --git a/filesystems/e2fsprogs-core/files/patch-tests_f__detect__junk_script b/filesystems/e2fsprogs-core/files/patch-tests_f__detect__junk_script
new file mode 100644
index 000000000000..45b544cf691d
--- /dev/null
+++ b/filesystems/e2fsprogs-core/files/patch-tests_f__detect__junk_script
@@ -0,0 +1,11 @@
+--- tests/f_detect_junk/script.orig 2023-02-07 03:31:53 UTC
++++ tests/f_detect_junk/script
+@@ -9,7 +9,7 @@ FSCK_OPT=-fn
+ IMAGE=$test_dir/image.bz2
+
+ bzip2 -d < $IMAGE > $TMPFILE
+-$DD if=/dev/zero of=$TMPFILE conv=notrunc oflag=append bs=1024k count=16 > /dev/null 2>&1
++$DD if=/dev/zero of=$TMPFILE conv=notrunc bs=1024k count=16 2>/dev/null >>$TMPFILE
+
+ # Run fsck to fix things?
+ if [ -x $DEBUGFS_EXE ]; then
diff --git a/filesystems/e2fsprogs-core/files/patch-tests_m__offset_script b/filesystems/e2fsprogs-core/files/patch-tests_m__offset_script
new file mode 100644
index 000000000000..9cc4232eec3a
--- /dev/null
+++ b/filesystems/e2fsprogs-core/files/patch-tests_m__offset_script
@@ -0,0 +1,11 @@
+--- tests/m_offset/script.orig 2023-02-02 15:57:32 UTC
++++ tests/m_offset/script
+@@ -13,7 +13,7 @@ $MKE2FS -F -b 1024 -E offset=524288 "$TMPFILE" 1024 >>
+ # compute crc of the first and last 512 1k blocks
+ crc_first2=`$DD if="$TMPFILE" bs=1k count=512 2>/dev/null | $CRCSUM`
+ crc_last2=`$DD if="$TMPFILE" bs=1k count=512 skip=1536 2>/dev/null | $CRCSUM`
+-crc_exp=`yes a | $DD bs=1k count=512 2>/dev/null | $CRCSUM`
++crc_exp=`yes a | $DD bs=1k count=512 iflag=fullblock 2>/dev/null | $CRCSUM`
+ # a warning should be only emitted by the first mke2fs call
+ warning=`grep -c "offset specified without an explicit file system size." \
+ "$OUT"`
diff --git a/filesystems/e2fsprogs-core/files/patch-tests_t__mmp__fail_script b/filesystems/e2fsprogs-core/files/patch-tests_t__mmp__fail_script
new file mode 100644
index 000000000000..77fd70e4ccf2
--- /dev/null
+++ b/filesystems/e2fsprogs-core/files/patch-tests_t__mmp__fail_script
@@ -0,0 +1,19 @@
+--- tests/t_mmp_fail/script.orig 2023-02-07 03:31:53 UTC
++++ tests/t_mmp_fail/script
+@@ -10,14 +10,14 @@ fi
+
+ $TUNE2FS -O project $TMPFILE >> $test_name.log 2>&1
+ status=$?
+-if [ "$status" == 0 ] ; then
++if [ "$status" = 0 ] ; then
+ echo "'tune2fs -O project' succeeded on small inode" > $test_name.failed
+ echo "$test_name: $test_description: failed"
+ return 1
+ fi
+ $TUNE2FS -o bad_option $TMPFILE >> $test_name.log 2>&1
+ status=$?
+-if [ "$status" == 0 ] ; then
++if [ "$status" = 0 ] ; then
+ echo "'tune2fs -o bad_option' succeeded" > $test_name.failed
+ echo "$test_name: $test_description: failed"
+ return 1
diff --git a/filesystems/e2fsprogs-core/files/unwanted b/filesystems/e2fsprogs-core/files/unwanted
new file mode 100644
index 000000000000..693deb364915
--- /dev/null
+++ b/filesystems/e2fsprogs-core/files/unwanted
@@ -0,0 +1,8 @@
+include/e2fsprogs/blkid/blkid.h
+include/e2fsprogs/blkid/blkid_types.h
+lib/e2fsprogs/libblkid.a
+lib/e2fsprogs/libblkid.so
+lib/e2fsprogs/libblkid.so.1
+lib/e2fsprogs/libblkid.so.1.0
+libdata/pkgconfig/blkid.pc
+man/man3/libblkid.3
diff --git a/filesystems/e2fsprogs-core/pkg-descr b/filesystems/e2fsprogs-core/pkg-descr
new file mode 100644
index 000000000000..d03ad983f1fb
--- /dev/null
+++ b/filesystems/e2fsprogs-core/pkg-descr
@@ -0,0 +1 @@
+Set of utilities and library to manipulate an ext2, ext3 or ext4 filesystem.
diff --git a/filesystems/e2fsprogs-core/pkg-install b/filesystems/e2fsprogs-core/pkg-install
new file mode 100644
index 000000000000..114087fa032a
--- /dev/null
+++ b/filesystems/e2fsprogs-core/pkg-install
@@ -0,0 +1,76 @@
+#!/bin/sh
+set -eu
+
+PKGNAME="$1"
+MODE="$2" # PRE-INSTALL, POST-INSTALL, DEINSTALL, POST-DEINSTALL
+
+case "$MODE" in
+POST-INSTALL)
+ #
+ # install configuration file and update config files from
+ # old "ext4dev" to current "ext4" name.
+ #
+ if test -s ${PKG_PREFIX}/etc/mke2fs.conf; then
+ if cmp -s ${PKG_PREFIX}/etc/mke2fs.conf.dist \
+ ${PKG_PREFIX}/etc/mke2fs.conf; then
+ true
+ else
+ rc=0
+ grep -q ext4dev ${PKG_PREFIX}/etc/mke2fs.conf || rc=$?
+ # !!! the echo messages below deliberately contain spacing errors
+ # so that the file names can be double-clicked in a typical console
+ # window for copying and pasting without keen targeting with the mouse.
+ case $rc in
+ 1) # ext4dev not found (old name)
+ cp -f -p ${PKG_PREFIX}/etc/mke2fs.conf.dist \
+ ${PKG_PREFIX}/etc/mke2fs.conf.e2fsprogs-new
+ echo "==========================================================================="
+ echo "Warning: installing mke2fs.conf in ${PKG_PREFIX}/etc/mke2fs.conf.e2fsprogs-new"
+ echo "Check to see if you need to update your ${PKG_PREFIX}/etc/mke2fs.conf ."
+ echo "==========================================================================="
+ ;;
+ 0) # ext4dev found (old name)
+ mv ${PKG_PREFIX}/etc/mke2fs.conf \
+ ${PKG_PREFIX}/etc/mke2fs.conf.e2fsprogs-old
+ cp -f -p ${PKG_PREFIX}/etc/mke2fs.conf.dist \
+ ${PKG_PREFIX}/etc/mke2fs.conf
+ echo "==========================================================================="
+ echo "Your mke2fs.conf is too old. Backing up old version in"
+ echo "${PKG_PREFIX}/etc/mke2fs.conf.e2fsprogs-old . Please check to see"
+ echo "if you have any local customizations that you wish to preserve."
+ echo "==========================================================================="
+ ;;
+ *) # grep failed
+ exit $rc
+ ;;
+ esac
+ fi
+ else
+ # missing -> install
+ cp -p ${PKG_PREFIX}/etc/mke2fs.conf.dist \
+ ${PKG_PREFIX}/etc/mke2fs.conf
+ fi
+
+ ;;
+DEINSTALL)
+ # !!! the echo messages below deliberately contain spacing errors
+ # so that the file names can be double-clicked in a typical console
+ # window for copying and pasting without keen targeting with the mouse.
+ if cmp -s ${PKG_PREFIX}/etc/mke2fs.conf \
+ ${PKG_PREFIX}/etc/mke2fs.conf.dist
+ then
+ rm -f ${PKG_PREFIX}/etc/mke2fs.conf
+ elif [ "_${PKG_UPGRADE-upgrade}" = _upgrade ] ; then
+ echo "If and only if you are deleting e2fsprogs forever,"
+ echo "remember to delete ${PKG_PREFIX}/etc/mke2fs.conf ."
+ fi
+ # e2fsck.conf is no longer part of the distribution, but still supported,
+ # => no pkg-list @sample line possible
+ # and no reference e2fsck.conf.sample or e2fsck.conf.dist is available
+ if test -f ${PKG_PREFIX}/etc/e2fsck.conf -a "_${PKG_UPGRADE-upgrade}" = _upgrade
+ then
+ echo "If and only if you are deleting e2fsprogs forever,"
+ echo "remember to delete ${PKG_PREFIX}/etc/e2fsck.conf ."
+ fi
+ ;;
+esac
diff --git a/filesystems/e2fsprogs-core/pkg-message b/filesystems/e2fsprogs-core/pkg-message
new file mode 100644
index 000000000000..68a7a422b142
--- /dev/null
+++ b/filesystems/e2fsprogs-core/pkg-message
@@ -0,0 +1,8 @@
+[
+{ message: <<EOM
+Note: this is a modified version of the e2fsprogs package, not the official
+package. Report all building and run-time trouble that originates in the
+package to the port maintainer, mandree@FreeBSD.org.
+EOM
+}
+]
diff --git a/filesystems/e2fsprogs-core/pkg-plist b/filesystems/e2fsprogs-core/pkg-plist
new file mode 100644
index 000000000000..369ce002d590
--- /dev/null
+++ b/filesystems/e2fsprogs-core/pkg-plist
@@ -0,0 +1,127 @@
+bin/chattr
+bin/e2fsprogs-compile_et
+%%FUSEFS%%bin/fuse2fs
+bin/lsattr
+bin/mk_cmds
+etc/mke2fs.conf.dist
+include/e2fsprogs/com_err.h
+include/e2fsprogs/e2p/e2p.h
+include/e2fsprogs/et/com_err.h
+include/e2fsprogs/ext2fs/bitops.h
+include/e2fsprogs/ext2fs/ext2_err.h
+include/e2fsprogs/ext2fs/ext2_ext_attr.h
+include/e2fsprogs/ext2fs/ext2_fs.h
+include/e2fsprogs/ext2fs/ext2_io.h
+include/e2fsprogs/ext2fs/ext2_types.h
+include/e2fsprogs/ext2fs/ext2fs.h
+include/e2fsprogs/ext2fs/ext3_extents.h
+include/e2fsprogs/ext2fs/hashmap.h
+include/e2fsprogs/ext2fs/qcow2.h
+include/e2fsprogs/ext2fs/tdb.h
+include/e2fsprogs/ss/ss.h
+include/e2fsprogs/ss/ss_err.h
+lib/e2fsprogs/libcom_err.a
+lib/e2fsprogs/libcom_err.so
+lib/e2fsprogs/libcom_err.so.2
+lib/e2fsprogs/libcom_err.so.2.1
+lib/e2fsprogs/libe2p.a
+lib/e2fsprogs/libe2p.so
+lib/e2fsprogs/libe2p.so.2
+lib/e2fsprogs/libe2p.so.2.3
+lib/e2fsprogs/libext2fs.a
+lib/e2fsprogs/libext2fs.so
+lib/e2fsprogs/libext2fs.so.2
+lib/e2fsprogs/libext2fs.so.2.4
+lib/e2fsprogs/libss.so.2.0
+lib/e2fsprogs/libss.so
+lib/e2fsprogs/libss.a
+lib/e2fsprogs/libss.so.2
+libdata/pkgconfig/com_err.pc
+libdata/pkgconfig/e2p.pc
+libdata/pkgconfig/ext2fs.pc
+libdata/pkgconfig/ss.pc
+share/man/man1/chattr.1.gz
+share/man/man1/e2fsprogs-compile_et.1.gz
+%%FUSEFS%%share/man/man1/fuse2fs.1.gz
+share/man/man1/lsattr.1.gz
+share/man/man1/mk_cmds.1.gz
+share/man/man3/e2fsprogs-com_err.3.gz
+share/man/man5/e2fsck.conf.5.gz
+share/man/man5/mke2fs.conf.5.gz
+share/man/man5/ext2.5.gz
+share/man/man5/ext3.5.gz
+share/man/man5/ext4.5.gz
+share/man/man8/badblocks.8.gz
+share/man/man8/debugfs.8.gz
+share/man/man8/dumpe2fs.8.gz
+share/man/man8/e2fsck.8.gz
+share/man/man8/e2image.8.gz
+share/man/man8/e2label.8.gz
+share/man/man8/e2mmpstatus.8.gz
+share/man/man8/e2undo.8.gz
+share/man/man8/mke2fs.8.gz
+share/man/man8/mklost+found.8.gz
+share/man/man8/resize2fs.8.gz
+share/man/man8/tune2fs.8.gz
+share/man/man8/fsck.ext2.8.gz
+share/man/man8/fsck.ext3.8.gz
+share/man/man8/fsck.ext4.8.gz
+share/man/man8/mkfs.ext2.8.gz
+share/man/man8/mkfs.ext3.8.gz
+share/man/man8/mkfs.ext4.8.gz
+share/man/man8/findfs.8.gz
+share/man/man8/blkid.8.gz
+share/man/man8/logsave.8.gz
+share/man/man8/fsck_ext2fs.8.gz
+share/man/man8/e2freefrag.8.gz
+sbin/badblocks
+sbin/blkid
+sbin/debugfs
+sbin/dumpe2fs
+sbin/e2freefrag
+sbin/e2fsck
+sbin/e2image
+sbin/e2label
+sbin/e2mmpstatus
+sbin/e2undo
+sbin/findfs
+sbin/fsck.ext2
+sbin/fsck.ext3
+sbin/fsck.ext4
+sbin/fsck_ext2fs
+sbin/logsave
+sbin/mke2fs
+sbin/mkfs.ext2
+sbin/mkfs.ext3
+sbin/mkfs.ext4
+sbin/mklost+found
+sbin/resize2fs
+sbin/tune2fs
+%%DATADIR%%/et/et_c.awk
+%%DATADIR%%/et/et_h.awk
+%%PORTDOCS%%share/info/libext2fs.info.gz
+%%NLS%%share/locale/ca/LC_MESSAGES/e2fsprogs.mo
+%%NLS%%share/locale/cs/LC_MESSAGES/e2fsprogs.mo
+%%NLS%%share/locale/da/LC_MESSAGES/e2fsprogs.mo
+%%NLS%%share/locale/de/LC_MESSAGES/e2fsprogs.mo
+%%NLS%%share/locale/eo/LC_MESSAGES/e2fsprogs.mo
+%%NLS%%share/locale/es/LC_MESSAGES/e2fsprogs.mo
+%%NLS%%share/locale/fi/LC_MESSAGES/e2fsprogs.mo
+%%NLS%%share/locale/fr/LC_MESSAGES/e2fsprogs.mo
+%%NLS%%share/locale/fur/LC_MESSAGES/e2fsprogs.mo
+%%NLS%%share/locale/hu/LC_MESSAGES/e2fsprogs.mo
+%%NLS%%share/locale/id/LC_MESSAGES/e2fsprogs.mo
+%%NLS%%share/locale/it/LC_MESSAGES/e2fsprogs.mo
+%%NLS%%share/locale/ms/LC_MESSAGES/e2fsprogs.mo
+%%NLS%%share/locale/nl/LC_MESSAGES/e2fsprogs.mo
+%%NLS%%share/locale/pl/LC_MESSAGES/e2fsprogs.mo
+%%NLS%%share/locale/pt/LC_MESSAGES/e2fsprogs.mo
+%%NLS%%share/locale/ro/LC_MESSAGES/e2fsprogs.mo
+%%NLS%%share/locale/sr/LC_MESSAGES/e2fsprogs.mo
+%%NLS%%share/locale/sv/LC_MESSAGES/e2fsprogs.mo
+%%NLS%%share/locale/tr/LC_MESSAGES/e2fsprogs.mo
+%%NLS%%share/locale/uk/LC_MESSAGES/e2fsprogs.mo
+%%NLS%%share/locale/vi/LC_MESSAGES/e2fsprogs.mo
+%%NLS%%share/locale/zh_CN/LC_MESSAGES/e2fsprogs.mo
+share/ss/ct_c.awk
+share/ss/ct_c.sed