Declare fast forward from 1.47.1~rc1-1

[dgit --overwrite]
diff --git a/configure b/configure
index 866eca2..2b712e5 100755
--- a/configure
+++ b/configure
@@ -930,6 +930,7 @@
 with_libiconv_prefix
 with_libintl_prefix
 enable_largefile
+with_libarchive
 enable_fuse2fs
 enable_lto
 enable_ubsan
@@ -1646,6 +1647,7 @@
   --without-libiconv-prefix     don't search for libiconv in includedir and libdir
   --with-libintl-prefix[=DIR]  search for libintl in DIR/include and DIR/lib
   --without-libintl-prefix     don't search for libintl in includedir and libdir
+  --without-libarchive    disable use of libarchive
   --with-multiarch=ARCH   specify the multiarch triplet
   --with-udev-rules-dir[=DIR]
                           Install udev rules into DIR.
@@ -13734,7 +13736,37 @@
    MAGIC_LIB=$DLOPEN_LIB
 fi
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for archive_read_new in -larchive" >&5
+
+# Check whether --with-libarchive was given.
+if test ${with_libarchive+y}
+then :
+  withval=$with_libarchive; if test "$withval" = "no"
+then
+	try_libarchive=""
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Disabling libarchive support" >&5
+printf "%s\n" "Disabling libarchive support" >&6; }
+elif test "$withval" = "direct"
+then
+	try_libarchive="direct"
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Testing for libarchive support (forced direct link)" >&5
+printf "%s\n" "Testing for libarchive support (forced direct link)" >&6; }
+else
+	try_libarchive="yes"
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Testing for libarchive support (with dlopen)" >&5
+printf "%s\n" "Testing for libarchive support (with dlopen)" >&6; }
+fi
+
+else $as_nop
+  try_libarchive="yes"
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Try testing for libarchive support (with dlopen) by default" >&5
+printf "%s\n" "Try testing for libarchive support (with dlopen) by default" >&6; }
+
+fi
+
+ARCHIVE_LIB=
+if test -n "$try_libarchive"
+then
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for archive_read_new in -larchive" >&5
 printf %s "checking for archive_read_new in -larchive... " >&6; }
 if test ${ac_cv_lib_archive_archive_read_new+y}
 then :
@@ -13772,7 +13804,7 @@
 if test "x$ac_cv_lib_archive_archive_read_new" = xyes
 then :
   ARCHIVE_LIB=-larchive
-ac_fn_c_check_header_compile "$LINENO" "archive.h" "ac_cv_header_archive_h" "$ac_includes_default"
+    ac_fn_c_check_header_compile "$LINENO" "archive.h" "ac_cv_header_archive_h" "$ac_includes_default"
 if test "x$ac_cv_header_archive_h" = xyes
 then :
   printf "%s\n" "#define HAVE_ARCHIVE_H 1" >>confdefs.h
@@ -13781,8 +13813,17 @@
 
 fi
 
-if test "$ac_cv_func_dlopen" = yes ; then
-   ARCHIVE_LIB=$DLOPEN_LIB
+    if test "$ac_cv_func_dlopen" = yes -a "$try_libarchive" != "direct"; then
+        ARCHIVE_LIB=$DLOPEN_LIB
+
+printf "%s\n" "#define CONFIG_DLOPEN_LIBARCHIVE 1" >>confdefs.h
+
+
+    fi
+    if test "$ac_cv_header_archive_h" != "yes"
+    then
+        ARCHIVE_LIB=
+    fi
 fi
 
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lrt" >&5
diff --git a/configure.ac b/configure.ac
index cc20403..e00e8d0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1301,10 +1301,39 @@
 dnl
 dnl libarchive
 dnl
-AC_CHECK_LIB(archive, archive_read_new, [ARCHIVE_LIB=-larchive
-AC_CHECK_HEADERS([archive.h])])
-if test "$ac_cv_func_dlopen" = yes ; then
-   ARCHIVE_LIB=$DLOPEN_LIB
+AC_ARG_WITH([libarchive],
+AS_HELP_STRING([--without-libarchive],[disable use of libarchive]),
+[if test "$withval" = "no"
+then
+	try_libarchive=""
+	AC_MSG_RESULT([Disabling libarchive support])
+elif test "$withval" = "direct"
+then
+	try_libarchive="direct"
+	AC_MSG_RESULT([Testing for libarchive support (forced direct link)])
+else
+	try_libarchive="yes"
+	AC_MSG_RESULT([Testing for libarchive support (with dlopen)])
+fi]
+,
+try_libarchive="yes"
+AC_MSG_RESULT([Try testing for libarchive support (with dlopen) by default])
+)
+ARCHIVE_LIB=
+if test -n "$try_libarchive"
+then
+    AC_CHECK_LIB(archive, archive_read_new, [ARCHIVE_LIB=-larchive
+    AC_CHECK_HEADERS([archive.h])])
+    if test "$ac_cv_func_dlopen" = yes -a "$try_libarchive" != "direct"; then
+        ARCHIVE_LIB=$DLOPEN_LIB
+	AC_DEFINE(CONFIG_DLOPEN_LIBARCHIVE, 1,
+		[Define to 1 if using dlopen to access libarchive])
+
+    fi
+    if test "$ac_cv_header_archive_h" != "yes"
+    then
+        ARCHIVE_LIB=
+    fi
 fi
 AC_SUBST(ARCHIVE_LIB)
 dnl
diff --git a/debian/changelog b/debian/changelog
index 18743b6..702b1a3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,16 @@
+e2fsprogs (1.47.1~rc1-3) unstable; urgency=medium
+
+  * Remove duplicated work in release notes
+  * Fix resize2fs's calculation of free clusters in the last block group
+    for file systems larger than 4TB
+  * Fix FTBFS on Hurd caused by trying to install e2scrub's systemd unit
+    files which aren't built since e2scrub isn't supported on Hurd
+  * Don't build mke2fs with libarchive support on mips64el since a bug in
+    libarchive only on that architecture causes a FTBFS due to the
+    regression test suite failing.  (See Debian Bug 1070042 for more details)
+
+ -- Theodore Y. Ts'o <tytso@mit.edu>  Mon, 29 Apr 2024 21:57:42 -0400
+
 e2fsprogs (1.47.1~rc1-1) unstable; urgency=medium
 
   * Re-enable metadata_csum_seed and orphan_file by default now that
@@ -37,7 +50,7 @@
   * Fix a potential e2fsck divide by zero crash caused by a maliciously
     fuzzed file system.
   * Fix dumpe2fs to report free block ranges correctly for bigalloc file
-    file systems.
+    systems.
   * Fix resize2fs where resizing a bigalloc file system can result in the
     free cluster count in the last block group and the total free clusters
     count to be incorrect.
diff --git a/debian/patches/0001-Remove-duplicated-word-in-release-notes b/debian/patches/0001-Remove-duplicated-word-in-release-notes
new file mode 100644
index 0000000..dc2b25a
--- /dev/null
+++ b/debian/patches/0001-Remove-duplicated-word-in-release-notes
@@ -0,0 +1,27 @@
+From 0b44576eaf51eb12141dd6079db5af1743cd06bc Mon Sep 17 00:00:00 2001
+From: Theodore Ts'o <tytso@mit.edu>
+Date: Sun, 28 Apr 2024 12:34:42 -0400
+Subject: [PATCH 1/6] Remove duplicated word in release notes
+
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+---
+ debian/changelog         | 2 +-
+ doc/RelNotes/v1.47.1.txt | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/doc/RelNotes/v1.47.1.txt b/doc/RelNotes/v1.47.1.txt
+index 53eeee9e6..82998f984 100644
+--- a/doc/RelNotes/v1.47.1.txt
++++ b/doc/RelNotes/v1.47.1.txt
+@@ -87,7 +87,7 @@ Fix a potential e2fsck divide by zero crash caused by a maliciously
+ fuzzed file system.
+ 
+ Fix dumpe2fs to report free block ranges correctly for bigalloc file
+-file systems.
++systems.
+ 
+ Fix resize2fs where resizing a bigalloc file system can result in the
+ free cluster count in the last block group and the total free clusters
+-- 
+2.43.0
+
diff --git a/debian/patches/0002-resize2fs-fix-last-bg-s-free-clusters-calculation b/debian/patches/0002-resize2fs-fix-last-bg-s-free-clusters-calculation
new file mode 100644
index 0000000..434ccc8
--- /dev/null
+++ b/debian/patches/0002-resize2fs-fix-last-bg-s-free-clusters-calculation
@@ -0,0 +1,30 @@
+From 1da249a125cb2ae138a6dd1d262754e2b4d45175 Mon Sep 17 00:00:00 2001
+From: Theodore Ts'o <tytso@mit.edu>
+Date: Sun, 28 Apr 2024 23:26:19 -0400
+Subject: [PATCH 2/6] resize2fs: fix last bg's free clusters calculation on
+ 64-bit file systems
+
+Fixes-Coverity-bug: 1596645
+Fixes: d43fb24ca0db ("resize2fs: fix r_bigalloc_big_expand test failure")
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+---
+ resize/resize2fs.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/resize/resize2fs.c b/resize/resize2fs.c
+index 4daa068b8..f4a409805 100644
+--- a/resize/resize2fs.c
++++ b/resize/resize2fs.c
+@@ -2870,7 +2870,8 @@ static errcode_t resize2fs_calculate_summary_stats(ext2_filsys fs)
+ 		if ((group == fs->group_desc_count - 1) && (max & 7)) {
+ 			n = 0;
+ 			for (b = (fs->super->s_first_data_block +
+-				  (fs->super->s_blocks_per_group * group));
++				  ((blk64_t) fs->super->s_blocks_per_group *
++				   group));
+ 			     b < ext2fs_blocks_count(fs->super);
+ 			     b += EXT2FS_CLUSTER_RATIO(fs)) {
+ 				if (ext2fs_test_block_bitmap2(fs->block_map, b))
+-- 
+2.43.0
+
diff --git a/debian/patches/0003-configure-add-without-libarchive-option b/debian/patches/0003-configure-add-without-libarchive-option
new file mode 100644
index 0000000..413977a
--- /dev/null
+++ b/debian/patches/0003-configure-add-without-libarchive-option
@@ -0,0 +1,202 @@
+From 7272a9724468622129978507c70efc68769aaf9f Mon Sep 17 00:00:00 2001
+From: Theodore Ts'o <tytso@mit.edu>
+Date: Mon, 29 Apr 2024 01:23:29 -0400
+Subject: [PATCH 3/6] configure: add --without-libarchive option
+
+Teach configure the --without-libarchive option, which forcibly
+disables use of the libarchive library.
+
+The option --with-libarchive=direct will disable the use of dlopen,
+and will link mke2fs with -larchive directly.  This doesn't work when
+building mke2f.static, since -larchive has a large number of
+depedencies, and even "pkgconf --libs --static libarchive" doesn't
+provide all of the appropriate library dependencies.  :-(
+
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+---
+ configure                      | 49 +++++++++++++++++++++++++++++++---
+ configure.ac                   | 37 ++++++++++++++++++++++---
+ lib/config.h.in                |  3 +++
+ misc/Makefile.in               |  2 +-
+ misc/create_inode_libarchive.c |  2 +-
+ 5 files changed, 83 insertions(+), 10 deletions(-)
+
+diff --git a/configure b/configure
+index 866eca252..2b712e5d3 100755
+--- a/configure
++++ b/configure
+@@ -930,6 +930,7 @@ enable_rpath
+ with_libiconv_prefix
+ with_libintl_prefix
+ enable_largefile
++with_libarchive
+ enable_fuse2fs
+ enable_lto
+ enable_ubsan
+@@ -1646,6 +1647,7 @@ Optional Packages:
+   --without-libiconv-prefix     don't search for libiconv in includedir and libdir
+   --with-libintl-prefix[=DIR]  search for libintl in DIR/include and DIR/lib
+   --without-libintl-prefix     don't search for libintl in includedir and libdir
++  --without-libarchive    disable use of libarchive
+   --with-multiarch=ARCH   specify the multiarch triplet
+   --with-udev-rules-dir[=DIR]
+                           Install udev rules into DIR.
+@@ -13734,7 +13736,37 @@ if test "$ac_cv_func_dlopen" = yes ; then
+    MAGIC_LIB=$DLOPEN_LIB
+ fi
+ 
+-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for archive_read_new in -larchive" >&5
++
++# Check whether --with-libarchive was given.
++if test ${with_libarchive+y}
++then :
++  withval=$with_libarchive; if test "$withval" = "no"
++then
++	try_libarchive=""
++	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Disabling libarchive support" >&5
++printf "%s\n" "Disabling libarchive support" >&6; }
++elif test "$withval" = "direct"
++then
++	try_libarchive="direct"
++	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Testing for libarchive support (forced direct link)" >&5
++printf "%s\n" "Testing for libarchive support (forced direct link)" >&6; }
++else
++	try_libarchive="yes"
++	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Testing for libarchive support (with dlopen)" >&5
++printf "%s\n" "Testing for libarchive support (with dlopen)" >&6; }
++fi
++
++else $as_nop
++  try_libarchive="yes"
++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Try testing for libarchive support (with dlopen) by default" >&5
++printf "%s\n" "Try testing for libarchive support (with dlopen) by default" >&6; }
++
++fi
++
++ARCHIVE_LIB=
++if test -n "$try_libarchive"
++then
++    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for archive_read_new in -larchive" >&5
+ printf %s "checking for archive_read_new in -larchive... " >&6; }
+ if test ${ac_cv_lib_archive_archive_read_new+y}
+ then :
+@@ -13772,7 +13804,7 @@ printf "%s\n" "$ac_cv_lib_archive_archive_read_new" >&6; }
+ if test "x$ac_cv_lib_archive_archive_read_new" = xyes
+ then :
+   ARCHIVE_LIB=-larchive
+-ac_fn_c_check_header_compile "$LINENO" "archive.h" "ac_cv_header_archive_h" "$ac_includes_default"
++    ac_fn_c_check_header_compile "$LINENO" "archive.h" "ac_cv_header_archive_h" "$ac_includes_default"
+ if test "x$ac_cv_header_archive_h" = xyes
+ then :
+   printf "%s\n" "#define HAVE_ARCHIVE_H 1" >>confdefs.h
+@@ -13781,8 +13813,17 @@ fi
+ 
+ fi
+ 
+-if test "$ac_cv_func_dlopen" = yes ; then
+-   ARCHIVE_LIB=$DLOPEN_LIB
++    if test "$ac_cv_func_dlopen" = yes -a "$try_libarchive" != "direct"; then
++        ARCHIVE_LIB=$DLOPEN_LIB
++
++printf "%s\n" "#define CONFIG_DLOPEN_LIBARCHIVE 1" >>confdefs.h
++
++
++    fi
++    if test "$ac_cv_header_archive_h" != "yes"
++    then
++        ARCHIVE_LIB=
++    fi
+ fi
+ 
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lrt" >&5
+diff --git a/configure.ac b/configure.ac
+index cc204031d..e00e8d0e0 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1301,10 +1301,39 @@ AC_SUBST(MAGIC_LIB)
+ dnl
+ dnl libarchive
+ dnl
+-AC_CHECK_LIB(archive, archive_read_new, [ARCHIVE_LIB=-larchive
+-AC_CHECK_HEADERS([archive.h])])
+-if test "$ac_cv_func_dlopen" = yes ; then
+-   ARCHIVE_LIB=$DLOPEN_LIB
++AC_ARG_WITH([libarchive],
++AS_HELP_STRING([--without-libarchive],[disable use of libarchive]),
++[if test "$withval" = "no"
++then
++	try_libarchive=""
++	AC_MSG_RESULT([Disabling libarchive support])
++elif test "$withval" = "direct"
++then
++	try_libarchive="direct"
++	AC_MSG_RESULT([Testing for libarchive support (forced direct link)])
++else
++	try_libarchive="yes"
++	AC_MSG_RESULT([Testing for libarchive support (with dlopen)])
++fi]
++,
++try_libarchive="yes"
++AC_MSG_RESULT([Try testing for libarchive support (with dlopen) by default])
++)
++ARCHIVE_LIB=
++if test -n "$try_libarchive"
++then
++    AC_CHECK_LIB(archive, archive_read_new, [ARCHIVE_LIB=-larchive
++    AC_CHECK_HEADERS([archive.h])])
++    if test "$ac_cv_func_dlopen" = yes -a "$try_libarchive" != "direct"; then
++        ARCHIVE_LIB=$DLOPEN_LIB
++	AC_DEFINE(CONFIG_DLOPEN_LIBARCHIVE, 1,
++		[Define to 1 if using dlopen to access libarchive])
++
++    fi
++    if test "$ac_cv_header_archive_h" != "yes"
++    then
++        ARCHIVE_LIB=
++    fi
+ fi
+ AC_SUBST(ARCHIVE_LIB)
+ dnl
+diff --git a/lib/config.h.in b/lib/config.h.in
+index 9a4058ec5..04cec72b8 100644
+--- a/lib/config.h.in
++++ b/lib/config.h.in
+@@ -12,6 +12,9 @@
+ /* Define to 1 for features for use by ext4 developers */
+ #undef CONFIG_DEVELOPER_FEATURES
+ 
++/* Define to 1 if using dlopen to access libarchive */
++#undef CONFIG_DLOPEN_LIBARCHIVE
++
+ /* Define to 1 if debugging ext3/4 journal code */
+ #undef CONFIG_JBD_DEBUG
+ 
+diff --git a/misc/Makefile.in b/misc/Makefile.in
+index 814e7064d..37c269991 100644
+--- a/misc/Makefile.in
++++ b/misc/Makefile.in
+@@ -290,7 +290,7 @@ mke2fs.static: $(MKE2FS_OBJS) $(STATIC_DEPLIBS) $(STATIC_LIBE2P) $(DEPSTATIC_LIB
+ 	$(Q) $(CC) $(LDFLAGS_STATIC) -o mke2fs.static $(MKE2FS_OBJS) \
+ 		$(STATIC_LIBS) $(STATIC_LIBE2P) \
+ 		$(STATIC_LIBBLKID) $(STATIC_LIBUUID) $(LIBINTL) $(SYSLIBS) \
+-		$(LIBMAGIC)
++		$(LIBMAGIC) $(LIBARCHIVE)
+ 
+ mke2fs.profiled: $(MKE2FS_OBJS) $(PROFILED_DEPLIBS) \
+ 	$(PROFILED_LIBE2P) $(PROFILED_DEPLIBBLKID) $(PROFILED_DEPLIBUUID)
+diff --git a/misc/create_inode_libarchive.c b/misc/create_inode_libarchive.c
+index 6ca0f9f2c..ebd62d449 100644
+--- a/misc/create_inode_libarchive.c
++++ b/misc/create_inode_libarchive.c
+@@ -51,7 +51,7 @@ static int (*dl_archive_read_open_filename)(struct archive *,
+ static int (*dl_archive_read_support_filter_all)(struct archive *);
+ static int (*dl_archive_read_support_format_all)(struct archive *);
+ 
+-#ifdef HAVE_DLOPEN
++#ifdef CONFIG_DLOPEN_LIBARCHIVE
+ #include <dlfcn.h>
+ 
+ static void *libarchive_handle;
+-- 
+2.43.0
+
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..d03f585
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1,3 @@
+0001-Remove-duplicated-word-in-release-notes
+0002-resize2fs-fix-last-bg-s-free-clusters-calculation
+0003-configure-add-without-libarchive-option
diff --git a/debian/rules b/debian/rules
index b95e0fa..d449eca 100755
--- a/debian/rules
+++ b/debian/rules
@@ -23,6 +23,11 @@
 SKIP_FUSE2FS=yes
 endif
 
+ifneq (,$(filter-out parallel=1,$(filter parallel=%,$(DEB_BUILD_OPTIONS))))
+    NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
+    JOBS = -j$(NUMJOBS)
+endif
+
 COMERR_VERSION ?= $(shell grep ELF_VERSION lib/et/Makefile.in | cut '-d ' -f3)
 SS_VERSION ?= $(shell grep ELF_VERSION lib/ss/Makefile.in | cut '-d ' -f3)
 
@@ -61,6 +66,11 @@
 COMMON_CONF_FLAGS += --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE)
 endif
 
+# work around Debian Bug #1070042
+ifeq ($(DEB_HOST_ARCH),mips64el)
+COMMON_CONF_FLAGS += --without-libarchive
+endif
+
 %:
 	dh $@ -B${stdbuilddir}
 
@@ -72,7 +82,7 @@
 		../../configure ${COMMON_CONF_FLAGS}
 
 override_dh_auto_build:
-	$(MAKE) -C ${stdbuilddir} V=1 all
+	$(MAKE) -C ${stdbuilddir} V=1 $(JOBS) all
 ifeq (,$(filter pkg.e2fsprogs.no-static,$(DEB_BUILD_PROFILES)))
 	$(MAKE) -C ${stdbuilddir}/e2fsck V=1 e2fsck.static
 endif
@@ -153,9 +163,10 @@
 	dh_installinfo -pcomerr-dev ${stdbuilddir}/lib/et/com_err.info
 	dh_installinfo -plibext2fs-dev ${stdbuilddir}/doc/libext2fs.info
 
+ifneq ($(DEB_HOST_ARCH_OS), hurd)
 override_dh_installsystemd:
 	dh_installsystemd -p e2fsprogs --no-restart-after-upgrade --no-stop-on-upgrade e2scrub_all.timer e2scrub_reap.service
-	dh_installsystemd --name=service1
+endif
 
 override_dh_makeshlibs:
 	for i in $(SYMBOL_LIBS); \
@@ -188,7 +199,7 @@
 
 override_dh_auto_test:
 ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
-	PRINT_FAILED=yes $(MAKE) -C ${stdbuilddir} V=1 check
+	PRINT_FAILED=yes $(MAKE) -C ${stdbuilddir} V=1 $(JOBS) check
 endif
 
 test_printenv:
diff --git a/doc/RelNotes/v1.47.1.txt b/doc/RelNotes/v1.47.1.txt
index 53eeee9..82998f9 100644
--- a/doc/RelNotes/v1.47.1.txt
+++ b/doc/RelNotes/v1.47.1.txt
@@ -87,7 +87,7 @@
 fuzzed file system.
 
 Fix dumpe2fs to report free block ranges correctly for bigalloc file
-file systems.
+systems.
 
 Fix resize2fs where resizing a bigalloc file system can result in the
 free cluster count in the last block group and the total free clusters
diff --git a/lib/config.h.in b/lib/config.h.in
index 9a4058e..04cec72 100644
--- a/lib/config.h.in
+++ b/lib/config.h.in
@@ -12,6 +12,9 @@
 /* Define to 1 for features for use by ext4 developers */
 #undef CONFIG_DEVELOPER_FEATURES
 
+/* Define to 1 if using dlopen to access libarchive */
+#undef CONFIG_DLOPEN_LIBARCHIVE
+
 /* Define to 1 if debugging ext3/4 journal code */
 #undef CONFIG_JBD_DEBUG
 
diff --git a/misc/Makefile.in b/misc/Makefile.in
index 814e706..37c2699 100644
--- a/misc/Makefile.in
+++ b/misc/Makefile.in
@@ -290,7 +290,7 @@
 	$(Q) $(CC) $(LDFLAGS_STATIC) -o mke2fs.static $(MKE2FS_OBJS) \
 		$(STATIC_LIBS) $(STATIC_LIBE2P) \
 		$(STATIC_LIBBLKID) $(STATIC_LIBUUID) $(LIBINTL) $(SYSLIBS) \
-		$(LIBMAGIC)
+		$(LIBMAGIC) $(LIBARCHIVE)
 
 mke2fs.profiled: $(MKE2FS_OBJS) $(PROFILED_DEPLIBS) \
 	$(PROFILED_LIBE2P) $(PROFILED_DEPLIBBLKID) $(PROFILED_DEPLIBUUID)
diff --git a/misc/create_inode_libarchive.c b/misc/create_inode_libarchive.c
index 6ca0f9f..ebd62d4 100644
--- a/misc/create_inode_libarchive.c
+++ b/misc/create_inode_libarchive.c
@@ -51,7 +51,7 @@
 static int (*dl_archive_read_support_filter_all)(struct archive *);
 static int (*dl_archive_read_support_format_all)(struct archive *);
 
-#ifdef HAVE_DLOPEN
+#ifdef CONFIG_DLOPEN_LIBARCHIVE
 #include <dlfcn.h>
 
 static void *libarchive_handle;
diff --git a/resize/resize2fs.c b/resize/resize2fs.c
index 4daa068..f4a4098 100644
--- a/resize/resize2fs.c
+++ b/resize/resize2fs.c
@@ -2870,7 +2870,8 @@
 		if ((group == fs->group_desc_count - 1) && (max & 7)) {
 			n = 0;
 			for (b = (fs->super->s_first_data_block +
-				  (fs->super->s_blocks_per_group * group));
+				  ((blk64_t) fs->super->s_blocks_per_group *
+				   group));
 			     b < ext2fs_blocks_count(fs->super);
 			     b += EXT2FS_CLUSTER_RATIO(fs)) {
 				if (ext2fs_test_block_bitmap2(fs->block_map, b))