2023-01-21 20:37:50

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 00/38] e2fsprogs: misc fixes, and add a GitHub Actions file

The last patch of this series adds a workflow file for GitHub Actions
that builds and tests e2fsprogs on Ubuntu, macOS, and Windows. It's
enforced that the build does not produce warnings with -Wall.

(For now, the Windows build is much more basic than the others; only
mke2fs is built, and the unit tests are not run.)

The workflow will run on pushes to any fork of e2fsprogs that has GitHub
Actions enabled. I'm hoping that Ted will enable it for the "official"
fork at https://github.com/tytso/e2fsprogs, but anyone can use it in
their own fork too. The results for this patch series are at
https://github.com/ebiggers/e2fsprogs/actions/runs/3976382057

As a prerequisite to actually getting everything to pass, patches 1-37
of this series fix a large number of miscellaneous issues, mainly
pertaining to warnings with -Wall or to the Windows build.

Some patches in this series I've already sent out individually. This
series supersedes all my previous patches.

Eric Biggers (38):
configure.ac: only use Windows I/O manager on native Windows
configure.ac: disable tdb by default on Windows
configure.ac: automatically add include/mingw/ headers
configure: regenerate
config/install-sh: update to latest version
lib, misc: eliminate dependency on Winsock
lib/blkid: remove 32-bit x86 byteswap assembly
lib/blkid: fix unaligned access to hfs_mdb
lib/blkid: fix -Wunused-variable warning in blkid_get_dev_size()
lib/blkid: suppress -Wunused-result warning in blkid_flush_cache()
lib/blkid: suppress -Wstringop-truncation warning in blkid_strndup()
lib/e2p: fix a -Wunused-variable warning in getflags()
lib/{e2p,ss}: remove manual declarations of errno
lib/et: fix "unused variable" warnings when !HAVE_FCNTL
lib/ext2fs: remove 32-bit x86 bitops assembly
lib/ext2fs: consistently use #ifdefs in ext2fs_print_bmap_statistics()
lib/ext2fs: remove unused variable in ext2fs_xattrs_read_inode()
lib/ext2fs: fix a printf format specifier in file_test()
lib/ext2fs: fix two compiler warnings in windows_io.c
lib/ext2fs: fix a -Wpointer-sign warning in ext2fs_mmp_start()
lib/{ext2fs,support}: fix 32-bit Windows build
lib/ss: fix 'make install' by creating man1dir
lib/support: remove unused label in get_devname()
lib/support: clean up definition of flags_array
lib/uuid: remove conflicting Windows implementation of gettimeofday()
e2fsck: use real functions for kernel slab functions
misc/create_inode: fix -Wunused-variable warnings in __populate_fs()
misc/create_inode: simplify logic in scandir()
misc/e4defrag: fix -Wstringop-truncation warnings
misc/fuse2fs: avoid error-prone strncpy() pattern
misc/mk_hugefiles: simplify get_partition_start()
misc/mke2fs: fix Windows build
misc/mke2fs: fix a -Wunused-variable warning in PRS()
misc/tune2fs: fix setting fsuuid::fsu_len
misc/tune2fs: fix -Wunused-variable warnings in handle_fslabel()
misc/util.c: enable MinGW alarm() when building for Windows
resize2fs: remove unused variable from adjust_superblock()
Add a configuration file for GitHub Actions

.github/workflows/ci.yml | 116 ++++++
aclocal.m4 | 180 +++++----
config/install-sh | 683 ++++++++++++++++++++++++----------
configure | 105 ++++--
configure.ac | 50 ++-
e2fsck/jfs_user.h | 62 ++-
include/mingw/arpa/inet.h | 5 +
include/mingw/sys/sysmacros.h | 8 +-
lib/blkid/Android.bp | 1 -
lib/blkid/devno.c | 10 +
lib/blkid/getsize.c | 2 +-
lib/blkid/probe.c | 10 +-
lib/blkid/probe.h | 43 ---
lib/blkid/save.c | 8 +
lib/config.h.in | 100 ++++-
lib/e2p/Android.bp | 4 -
lib/e2p/fgetversion.c | 2 -
lib/e2p/fsetversion.c | 1 -
lib/e2p/getflags.c | 3 +-
lib/e2p/getversion.c | 1 -
lib/e2p/setversion.c | 1 -
lib/et/Android.bp | 3 -
lib/et/error_message.c | 10 +-
lib/ext2fs/Android.bp | 2 -
lib/ext2fs/bitops.c | 14 +-
lib/ext2fs/bitops.h | 97 -----
lib/ext2fs/ext2_io.h | 2 +
lib/ext2fs/ext_attr.c | 2 -
lib/ext2fs/gen_bitmap64.c | 6 +-
lib/ext2fs/getsectsize.c | 12 +-
lib/ext2fs/inline_data.c | 2 +-
lib/ext2fs/jfs_compat.h | 4 -
lib/ext2fs/mmp.c | 2 +-
lib/ext2fs/windows_io.c | 12 +-
lib/ss/Makefile.in | 5 +-
lib/ss/execute_cmd.c | 2 -
lib/ss/help.c | 2 -
lib/ss/pager.c | 2 -
lib/support/devname.c | 1 -
lib/support/plausible.c | 7 +-
lib/support/print_fs_flags.c | 60 +--
lib/uuid/gen_uuid.c | 21 --
misc/Android.bp | 3 -
misc/create_inode.c | 36 +-
misc/e4defrag.c | 30 +-
misc/fuse2fs.c | 5 +-
misc/mk_hugefiles.c | 134 +------
misc/mke2fs.c | 22 +-
misc/tune2fs.c | 7 +-
misc/util.c | 5 +
resize/resize2fs.c | 4 -
util/android_config.h | 1 -
util/subst.c | 4 +-
53 files changed, 1102 insertions(+), 812 deletions(-)
create mode 100644 .github/workflows/ci.yml
create mode 100644 include/mingw/arpa/inet.h


base-commit: aad34909b6648579f42dade5af5b46821aa4d845
--
2.39.0


2023-01-21 20:37:51

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 27/38] misc/create_inode: fix -Wunused-variable warnings in __populate_fs()

From: Eric Biggers <[email protected]>

These showed up when building for Windows.

Signed-off-by: Eric Biggers <[email protected]>
---
misc/create_inode.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/misc/create_inode.c b/misc/create_inode.c
index c00d54588..7ce69c2b0 100644
--- a/misc/create_inode.c
+++ b/misc/create_inode.c
@@ -813,11 +813,9 @@ static errcode_t __populate_fs(ext2_filsys fs, ext2_ino_t parent_ino,
const char *name;
struct dirent **dent;
struct stat st;
- char *ln_target = NULL;
unsigned int save_inode;
ext2_ino_t ino;
errcode_t retval = 0;
- int read_cnt;
int hdlink;
size_t cur_dir_path_len;
int i, num_dents;
@@ -900,7 +898,10 @@ static errcode_t __populate_fs(ext2_filsys fs, ext2_ino_t parent_ino,
goto out;
}
break;
- case S_IFLNK:
+ case S_IFLNK: {
+ char *ln_target;
+ int read_cnt;
+
ln_target = malloc(st.st_size + 1);
if (ln_target == NULL) {
com_err(__func__, retval,
@@ -935,7 +936,8 @@ static errcode_t __populate_fs(ext2_filsys fs, ext2_ino_t parent_ino,
goto out;
}
break;
-#endif
+ }
+#endif /* !_WIN32 */
case S_IFREG:
retval = do_write_internal(fs, parent_ino, name, name,
root);
--
2.39.0

2023-01-21 20:37:51

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 24/38] lib/support: clean up definition of flags_array

From: Eric Biggers <[email protected]>

Add braces to address the following compiler warning with gcc -Wall:

print_fs_flags.c:24:42: warning: missing braces around initializer [-Wmissing-braces]
24 | static struct flags_name flags_array[] = {
| ^

Also add 'const', and add an explicit NULL in the last entry.

Reviewed-by: Lukas Czerner <[email protected]>
Signed-off-by: Eric Biggers <[email protected]>
---
lib/support/print_fs_flags.c | 60 ++++++++++++++++++------------------
1 file changed, 30 insertions(+), 30 deletions(-)

diff --git a/lib/support/print_fs_flags.c b/lib/support/print_fs_flags.c
index e54acc04b..f47cd6653 100644
--- a/lib/support/print_fs_flags.c
+++ b/lib/support/print_fs_flags.c
@@ -21,40 +21,40 @@ struct flags_name {
const char *name;
};

-static struct flags_name flags_array[] = {
- EXT2_FLAG_RW, "EXT2_FLAG_RW",
- EXT2_FLAG_CHANGED, "EXT2_FLAG_CHANGED",
- EXT2_FLAG_DIRTY, "EXT2_FLAG_DIRTY",
- EXT2_FLAG_VALID, "EXT2_FLAG_VALID",
- EXT2_FLAG_IB_DIRTY, "EXT2_FLAG_IB_DIRTY",
- EXT2_FLAG_BB_DIRTY, "EXT2_FLAG_BB_DIRTY",
- EXT2_FLAG_SWAP_BYTES, "EXT2_FLAG_SWAP_BYTES",
- EXT2_FLAG_SWAP_BYTES_READ, "EXT2_FLAG_SWAP_BYTES_READ",
- EXT2_FLAG_SWAP_BYTES_WRITE, "EXT2_FLAG_SWAP_BYTES_WRITE",
- EXT2_FLAG_MASTER_SB_ONLY, "EXT2_FLAG_MASTER_SB_ONLY",
- EXT2_FLAG_FORCE, "EXT2_FLAG_FORCE",
- EXT2_FLAG_SUPER_ONLY, "EXT2_FLAG_SUPER_ONLY",
- EXT2_FLAG_JOURNAL_DEV_OK, "EXT2_FLAG_JOURNAL_DEV_OK",
- EXT2_FLAG_IMAGE_FILE, "EXT2_FLAG_IMAGE_FILE",
- EXT2_FLAG_EXCLUSIVE, "EXT2_FLAG_EXCLUSIVE",
- EXT2_FLAG_SOFTSUPP_FEATURES, "EXT2_FLAG_SOFTSUPP_FEATURES",
- EXT2_FLAG_NOFREE_ON_ERROR, "EXT2_FLAG_NOFREE_ON_ERROR",
- EXT2_FLAG_64BITS, "EXT2_FLAG_64BITS",
- EXT2_FLAG_PRINT_PROGRESS, "EXT2_FLAG_PRINT_PROGRESS",
- EXT2_FLAG_DIRECT_IO, "EXT2_FLAG_DIRECT_IO",
- EXT2_FLAG_SKIP_MMP, "EXT2_FLAG_SKIP_MMP",
- EXT2_FLAG_IGNORE_CSUM_ERRORS, "EXT2_FLAG_IGNORE_CSUM_ERRORS",
- EXT2_FLAG_SHARE_DUP, "EXT2_FLAG_SHARE_DUP",
- EXT2_FLAG_IGNORE_SB_ERRORS, "EXT2_FLAG_IGNORE_SB_ERRORS",
- EXT2_FLAG_BBITMAP_TAIL_PROBLEM, "EXT2_FLAG_BBITMAP_TAIL_PROBLEM",
- EXT2_FLAG_IBITMAP_TAIL_PROBLEM, "EXT2_FLAG_IBITMAP_TAIL_PROBLEM",
- EXT2_FLAG_THREADS, "EXT2_FLAG_THREADS",
- 0
+static const struct flags_name flags_array[] = {
+ { EXT2_FLAG_RW, "EXT2_FLAG_RW" },
+ { EXT2_FLAG_CHANGED, "EXT2_FLAG_CHANGED" },
+ { EXT2_FLAG_DIRTY, "EXT2_FLAG_DIRTY" },
+ { EXT2_FLAG_VALID, "EXT2_FLAG_VALID" },
+ { EXT2_FLAG_IB_DIRTY, "EXT2_FLAG_IB_DIRTY" },
+ { EXT2_FLAG_BB_DIRTY, "EXT2_FLAG_BB_DIRTY" },
+ { EXT2_FLAG_SWAP_BYTES, "EXT2_FLAG_SWAP_BYTES" },
+ { EXT2_FLAG_SWAP_BYTES_READ, "EXT2_FLAG_SWAP_BYTES_READ" },
+ { EXT2_FLAG_SWAP_BYTES_WRITE, "EXT2_FLAG_SWAP_BYTES_WRITE" },
+ { EXT2_FLAG_MASTER_SB_ONLY, "EXT2_FLAG_MASTER_SB_ONLY" },
+ { EXT2_FLAG_FORCE, "EXT2_FLAG_FORCE" },
+ { EXT2_FLAG_SUPER_ONLY, "EXT2_FLAG_SUPER_ONLY" },
+ { EXT2_FLAG_JOURNAL_DEV_OK, "EXT2_FLAG_JOURNAL_DEV_OK" },
+ { EXT2_FLAG_IMAGE_FILE, "EXT2_FLAG_IMAGE_FILE" },
+ { EXT2_FLAG_EXCLUSIVE, "EXT2_FLAG_EXCLUSIVE" },
+ { EXT2_FLAG_SOFTSUPP_FEATURES, "EXT2_FLAG_SOFTSUPP_FEATURES" },
+ { EXT2_FLAG_NOFREE_ON_ERROR, "EXT2_FLAG_NOFREE_ON_ERROR" },
+ { EXT2_FLAG_64BITS, "EXT2_FLAG_64BITS" },
+ { EXT2_FLAG_PRINT_PROGRESS, "EXT2_FLAG_PRINT_PROGRESS" },
+ { EXT2_FLAG_DIRECT_IO, "EXT2_FLAG_DIRECT_IO" },
+ { EXT2_FLAG_SKIP_MMP, "EXT2_FLAG_SKIP_MMP" },
+ { EXT2_FLAG_IGNORE_CSUM_ERRORS, "EXT2_FLAG_IGNORE_CSUM_ERRORS" },
+ { EXT2_FLAG_SHARE_DUP, "EXT2_FLAG_SHARE_DUP" },
+ { EXT2_FLAG_IGNORE_SB_ERRORS, "EXT2_FLAG_IGNORE_SB_ERRORS" },
+ { EXT2_FLAG_BBITMAP_TAIL_PROBLEM, "EXT2_FLAG_BBITMAP_TAIL_PROBLEM" },
+ { EXT2_FLAG_IBITMAP_TAIL_PROBLEM, "EXT2_FLAG_IBITMAP_TAIL_PROBLEM" },
+ { EXT2_FLAG_THREADS, "EXT2_FLAG_THREADS" },
+ { 0, NULL },
};

void print_fs_flags(FILE * f, unsigned long flags)
{
- struct flags_name *fp;
+ const struct flags_name *fp;
int first = 1, pos = 16;

for (fp = flags_array; fp->flag != 0; fp++) {
--
2.39.0

2023-01-21 20:37:50

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 04/38] configure: regenerate

From: Eric Biggers <[email protected]>

Run autoreconf.

Signed-off-by: Eric Biggers <[email protected]>
---
aclocal.m4 | 180 ++++++++++++++++++++++++++----------------------
configure | 105 +++++++++++++++++++++-------
lib/config.h.in | 100 ++++++++++++++++++++++-----
3 files changed, 262 insertions(+), 123 deletions(-)

diff --git a/aclocal.m4 b/aclocal.m4
index bd5778d57..af10b6afe 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -535,7 +535,7 @@ fi
AC_LANG_POP
])dnl AX_PTHREAD

-# gettext.m4 serial 71 (gettext-0.20.2)
+# gettext.m4 serial 72 (gettext-0.21.1)
dnl Copyright (C) 1995-2014, 2016, 2018-2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -592,22 +592,22 @@ dnl
AC_DEFUN([AM_GNU_GETTEXT],
[
dnl Argument checking.
- ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [use-libtool], ,
+ m4_if([$1], [], , [m4_if([$1], [external], , [m4_if([$1], [use-libtool], ,
[errprint([ERROR: invalid first argument to AM_GNU_GETTEXT
])])])])
- ifelse(ifelse([$1], [], [old])[]ifelse([$1], [no-libtool], [old]), [old],
+ m4_if(m4_if([$1], [], [old])[]m4_if([$1], [no-libtool], [old]), [old],
[errprint([ERROR: Use of AM_GNU_GETTEXT without [external] argument is no longer supported.
])])
- ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], ,
+ m4_if([$2], [], , [m4_if([$2], [need-ngettext], , [m4_if([$2], [need-formatstring-macros], ,
[errprint([ERROR: invalid second argument to AM_GNU_GETTEXT
])])])])
define([gt_included_intl],
- ifelse([$1], [external], [no], [yes]))
+ m4_if([$1], [external], [no], [yes]))
gt_NEEDS_INIT
AM_GNU_GETTEXT_NEED([$2])

AC_REQUIRE([AM_PO_SUBDIRS])dnl
- ifelse(gt_included_intl, yes, [
+ m4_if(gt_included_intl, yes, [
AC_REQUIRE([AM_INTL_SUBDIR])dnl
])

@@ -625,7 +625,7 @@ AC_DEFUN([AM_GNU_GETTEXT],
dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'.
dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE.
dnl Since AC_PROVIDE_IFELSE is not documented, we avoid it.
- ifelse(gt_included_intl, yes, , [
+ m4_if(gt_included_intl, yes, , [
AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
])

@@ -635,7 +635,7 @@ AC_DEFUN([AM_GNU_GETTEXT],
dnl Set USE_NLS.
AC_REQUIRE([AM_NLS])

- ifelse(gt_included_intl, yes, [
+ m4_if(gt_included_intl, yes, [
BUILD_INCLUDED_LIBINTL=no
USE_INCLUDED_LIBINTL=no
])
@@ -655,7 +655,7 @@ AC_DEFUN([AM_GNU_GETTEXT],
dnl If we use NLS figure out what method
if test "$USE_NLS" = "yes"; then
gt_use_preinstalled_gnugettext=no
- ifelse(gt_included_intl, yes, [
+ m4_if(gt_included_intl, yes, [
AC_MSG_CHECKING([whether included gettext is requested])
AC_ARG_WITH([included-gettext],
[ --with-included-gettext use the GNU gettext library included here],
@@ -711,7 +711,7 @@ return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION

if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then
dnl Sometimes libintl requires libiconv, so first search for libiconv.
- ifelse(gt_included_intl, yes, , [
+ m4_if(gt_included_intl, yes, , [
AM_ICONV_LINK
])
dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL
@@ -798,7 +798,7 @@ return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION
INCINTL=
fi

- ifelse(gt_included_intl, yes, [
+ m4_if(gt_included_intl, yes, [
if test "$gt_use_preinstalled_gnugettext" != "yes"; then
dnl GNU gettext is not found in the C library.
dnl Fall back on included GNU gettext library.
@@ -810,8 +810,8 @@ return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION
dnl Mark actions used to generate GNU NLS library.
BUILD_INCLUDED_LIBINTL=yes
USE_INCLUDED_LIBINTL=yes
- LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.la $LIBICONV $LIBTHREAD"
- LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.la $LTLIBICONV $LTLIBTHREAD"
+ LIBINTL="m4_if([$3],[],\${top_builddir}/intl,[$3])/libintl.la $LIBICONV $LIBTHREAD"
+ LTLIBINTL="m4_if([$3],[],\${top_builddir}/intl,[$3])/libintl.la $LTLIBICONV $LTLIBTHREAD"
LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
fi

@@ -878,7 +878,7 @@ return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION
POSUB=po
fi

- ifelse(gt_included_intl, yes, [
+ m4_if(gt_included_intl, yes, [
dnl In GNU gettext we have to set BUILD_INCLUDED_LIBINTL to 'yes'
dnl because some of the testsuite requires it.
BUILD_INCLUDED_LIBINTL=yes
@@ -922,8 +922,8 @@ AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
dnl Usage: AM_GNU_GETTEXT_REQUIRE_VERSION([gettext-version])
AC_DEFUN([AM_GNU_GETTEXT_REQUIRE_VERSION], [])

-# host-cpu-c-abi.m4 serial 13
-dnl Copyright (C) 2002-2020 Free Software Foundation, Inc.
+# host-cpu-c-abi.m4 serial 15
+dnl Copyright (C) 2002-2022 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -1135,7 +1135,7 @@ changequote([,])dnl
# be generating 64-bit code.
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE(
- [[#if defined __powerpc64__ || defined _ARCH_PPC64
+ [[#if defined __powerpc64__ || defined __LP64__
int ok;
#else
error fail
@@ -1306,6 +1306,9 @@ EOF
#ifndef __ia64__
#undef __ia64__
#endif
+#ifndef __loongarch64__
+#undef __loongarch64__
+#endif
#ifndef __m68k__
#undef __m68k__
#endif
@@ -1529,7 +1532,7 @@ changequote([,])dnl
# be generating 64-bit code.
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE(
- [[#if defined __powerpc64__ || defined _ARCH_PPC64
+ [[#if defined __powerpc64__ || defined __LP64__
int ok;
#else
error fail
@@ -1598,8 +1601,8 @@ changequote([,])dnl
HOST_CPU_C_ABI_32BIT="$gl_cv_host_cpu_c_abi_32bit"
])

-# iconv.m4 serial 21
-dnl Copyright (C) 2000-2002, 2007-2014, 2016-2020 Free Software Foundation,
+# iconv.m4 serial 24
+dnl Copyright (C) 2000-2002, 2007-2014, 2016-2022 Free Software Foundation,
dnl Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -1607,6 +1610,12 @@ dnl with or without modifications, as long as this notice is preserved.

dnl From Bruno Haible.

+AC_PREREQ([2.64])
+
+dnl Note: AM_ICONV is documented in the GNU gettext manual
+dnl <https://www.gnu.org/software/gettext/manual/html_node/AM_005fICONV.html>.
+dnl Don't make changes that are incompatible with that documentation!
+
AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
[
dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
@@ -1686,8 +1695,9 @@ AC_DEFUN([AM_ICONV_LINK],
#endif
]],
[[int result = 0;
- /* Test against AIX 5.1 bug: Failures are not distinguishable from successful
- returns. */
+ /* Test against AIX 5.1...7.2 bug: Failures are not distinguishable from
+ successful returns. This is even documented in
+ <https://www.ibm.com/support/knowledgecenter/ssw_aix_72/i_bostechref/iconv.html> */
{
iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
if (cd_utf8_to_88591 != (iconv_t)(-1))
@@ -1825,8 +1835,7 @@ AC_DEFUN([AM_ICONV_LINK],
AC_SUBST([LTLIBICONV])
])

-dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to
-dnl avoid warnings like
+dnl Define AM_ICONV using AC_DEFUN_ONCE, in order to avoid warnings like
dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required".
dnl This is tricky because of the way 'aclocal' is implemented:
dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN.
@@ -1834,61 +1843,50 @@ dnl Otherwise aclocal's initial scan pass would miss the macro definition.
dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions.
dnl Otherwise aclocal would emit many "Use of uninitialized value $1"
dnl warnings.
-m4_define([gl_iconv_AC_DEFUN],
- m4_version_prereq([2.64],
- [[AC_DEFUN_ONCE(
- [$1], [$2])]],
- [m4_ifdef([gl_00GNULIB],
- [[AC_DEFUN_ONCE(
- [$1], [$2])]],
- [[AC_DEFUN(
- [$1], [$2])]])]))
-gl_iconv_AC_DEFUN([AM_ICONV],
+AC_DEFUN_ONCE([AM_ICONV],
[
AM_ICONV_LINK
if test "$am_cv_func_iconv" = yes; then
- AC_MSG_CHECKING([for iconv declaration])
- AC_CACHE_VAL([am_cv_proto_iconv], [
- AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM(
- [[
+ AC_CACHE_CHECK([whether iconv is compatible with its POSIX signature],
+ [gl_cv_iconv_nonconst],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[
#include <stdlib.h>
#include <iconv.h>
extern
#ifdef __cplusplus
"C"
#endif
-#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus)
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
-#else
-size_t iconv();
-#endif
- ]],
- [[]])],
- [am_cv_proto_iconv_arg1=""],
- [am_cv_proto_iconv_arg1="const"])
- am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
- am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
- AC_MSG_RESULT([
- $am_cv_proto_iconv])
+ ]],
+ [[]])],
+ [gl_cv_iconv_nonconst=yes],
+ [gl_cv_iconv_nonconst=no])
+ ])
else
dnl When compiling GNU libiconv on a system that does not have iconv yet,
dnl pick the POSIX compliant declaration without 'const'.
- am_cv_proto_iconv_arg1=""
+ gl_cv_iconv_nonconst=yes
fi
- AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1],
+ if test $gl_cv_iconv_nonconst = yes; then
+ iconv_arg1=""
+ else
+ iconv_arg1="const"
+ fi
+ AC_DEFINE_UNQUOTED([ICONV_CONST], [$iconv_arg1],
[Define as const if the declaration of iconv() needs const.])
dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>.
m4_ifdef([gl_ICONV_H_DEFAULTS],
[AC_REQUIRE([gl_ICONV_H_DEFAULTS])
- if test -n "$am_cv_proto_iconv_arg1"; then
+ if test $gl_cv_iconv_nonconst != yes; then
ICONV_CONST="const"
fi
])
])

# intlmacosx.m4 serial 8 (gettext-0.20.2)
-dnl Copyright (C) 2004-2014, 2016, 2019-2020 Free Software Foundation, Inc.
+dnl Copyright (C) 2004-2014, 2016, 2019-2022 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -1953,8 +1951,8 @@ AC_DEFUN([gt_INTL_MACOSX],
AC_SUBST([INTL_MACOSX_LIBS])
])

-# lib-ld.m4 serial 9
-dnl Copyright (C) 1996-2003, 2009-2020 Free Software Foundation, Inc.
+# lib-ld.m4 serial 10
+dnl Copyright (C) 1996-2003, 2009-2022 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -2077,7 +2075,7 @@ else
*-*-aix*)
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE(
- [[#if defined __powerpc64__ || defined _ARCH_PPC64
+ [[#if defined __powerpc64__ || defined __LP64__
int ok;
#else
error fail
@@ -2122,8 +2120,8 @@ fi
AC_LIB_PROG_LD_GNU
])

-# lib-link.m4 serial 31
-dnl Copyright (C) 2001-2020 Free Software Foundation, Inc.
+# lib-link.m4 serial 33
+dnl Copyright (C) 2001-2022 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -2320,8 +2318,8 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
eval additional_libdir3=\"$exec_prefix/$acl_libdirstem3\"
])
AC_ARG_WITH(PACK[-prefix],
-[[ --with-]]PACK[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib
- --without-]]PACK[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]],
+[[ --with-]]PACK[[-prefix[=DIR] search for ]]PACKLIBS[[ in DIR/include and DIR/lib
+ --without-]]PACK[[-prefix don't search for ]]PACKLIBS[[ in includedir and libdir]],
[
if test "X$withval" = "Xno"; then
use_additional=no
@@ -2755,7 +2753,20 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
;;
-l*)
dnl Handle this in the next round.
- names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
+ dnl But on GNU systems, ignore -lc options, because
+ dnl - linking with libc is the default anyway,
+ dnl - linking with libc.a may produce an error
+ dnl "/usr/bin/ld: dynamic STT_GNU_IFUNC symbol `strcmp' with pointer equality in `/usr/lib/libc.a(strcmp.o)' can not be used when making an executable; recompile with -fPIE and relink with -pie"
+ dnl or may produce an executable that always crashes, see
+ dnl <https://lists.gnu.org/archive/html/grep-devel/2020-09/msg00052.html>.
+ dep=`echo "X$dep" | sed -e 's/^X-l//'`
+ if test "X$dep" != Xc \
+ || case $host_os in
+ linux* | gnu* | k*bsd*-gnu) false ;;
+ *) true ;;
+ esac; then
+ names_next_round="$names_next_round $dep"
+ fi
;;
*.la)
dnl Handle this in the next round. Throw away the .la's
@@ -2923,8 +2934,8 @@ AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
AC_SUBST([$1])
])

-# lib-prefix.m4 serial 17
-dnl Copyright (C) 2001-2005, 2008-2020 Free Software Foundation, Inc.
+# lib-prefix.m4 serial 20
+dnl Copyright (C) 2001-2005, 2008-2022 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -3099,14 +3110,14 @@ AC_DEFUN([AC_LIB_PREPARE_MULTILIB],

AC_CACHE_CHECK([for ELF binary format], [gl_cv_elf],
[AC_EGREP_CPP([Extensible Linking Format],
- [#ifdef __ELF__
+ [#if defined __ELF__ || (defined __linux__ && defined __EDG__)
Extensible Linking Format
#endif
],
[gl_cv_elf=yes],
[gl_cv_elf=no])
- ])
- if test $gl_cv_elf; then
+ ])
+ if test $gl_cv_elf = yes; then
# Extract the ELF class of a file (5th byte) in decimal.
# Cf. https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header
if od -A x < /dev/null >/dev/null 2>/dev/null; then
@@ -3123,20 +3134,23 @@ AC_DEFUN([AC_LIB_PREPARE_MULTILIB],
echo
}
fi
+ # Use 'expr', not 'test', to compare the values of func_elfclass, because on
+ # Solaris 11 OpenIndiana and Solaris 11 OmniOS, the result is 001 or 002,
+ # not 1 or 2.
changequote(,)dnl
case $HOST_CPU_C_ABI_32BIT in
yes)
# 32-bit ABI.
acl_is_expected_elfclass ()
{
- test "`func_elfclass | sed -e 's/[ ]//g'`" = 1
+ expr "`func_elfclass | sed -e 's/[ ]//g'`" = 1 > /dev/null
}
;;
no)
# 64-bit ABI.
acl_is_expected_elfclass ()
{
- test "`func_elfclass | sed -e 's/[ ]//g'`" = 2
+ expr "`func_elfclass | sed -e 's/[ ]//g'`" = 2 > /dev/null
}
;;
*)
@@ -3245,7 +3259,7 @@ changequote([,])dnl
])

# nls.m4 serial 6 (gettext-0.20.2)
-dnl Copyright (C) 1995-2003, 2005-2006, 2008-2014, 2016, 2019-2020 Free
+dnl Copyright (C) 1995-2003, 2005-2006, 2008-2014, 2016, 2019-2022 Free
dnl Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -3621,8 +3635,8 @@ AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"],
[AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])])
])dnl PKG_HAVE_DEFINE_WITH_MODULES

-# po.m4 serial 31 (gettext-0.20.2)
-dnl Copyright (C) 1995-2014, 2016, 2018-2020 Free Software Foundation, Inc.
+# po.m4 serial 32 (gettext-0.21.1)
+dnl Copyright (C) 1995-2014, 2016, 2018-2022 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -3802,7 +3816,9 @@ changequote([,])dnl
# presentlang can be used as a fallback for messages
# which are not translated in the desiredlang catalog).
case "$desiredlang" in
- "$presentlang"*) useit=yes;;
+ "$presentlang" | "$presentlang"_* | "$presentlang".* | "$presentlang"@*)
+ useit=yes
+ ;;
esac
done
if test $useit = yes; then
@@ -4002,7 +4018,9 @@ changequote([,])dnl
# presentlang can be used as a fallback for messages
# which are not translated in the desiredlang catalog).
case "$desiredlang" in
- "$presentlang"*) useit=yes;;
+ "$presentlang" | "$presentlang"_* | "$presentlang".* | "$presentlang"@*)
+ useit=yes
+ ;;
esac
done
if test $useit = yes; then
@@ -4072,8 +4090,8 @@ AC_DEFUN([AM_XGETTEXT_OPTION],
XGETTEXT_EXTRA_OPTIONS="$XGETTEXT_EXTRA_OPTIONS $1"
])

-# progtest.m4 serial 8 (gettext-0.20.2)
-dnl Copyright (C) 1996-2003, 2005, 2008-2020 Free Software Foundation, Inc.
+# progtest.m4 serial 9 (gettext-0.21.1)
+dnl Copyright (C) 1996-2003, 2005, 2008-2022 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -4090,7 +4108,7 @@ dnl They are *not* in the public domain.
dnl Authors:
dnl Ulrich Drepper <[email protected]>, 1996.

-AC_PREREQ([2.50])
+AC_PREREQ([2.53])

# Search path for a program which passes the given test.

@@ -4135,7 +4153,7 @@ AC_CACHE_VAL([ac_cv_path_$1],
;;
*)
ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR
- for ac_dir in ifelse([$5], , $PATH, [$5]); do
+ for ac_dir in m4_if([$5], , $PATH, [$5]); do
IFS="$ac_save_IFS"
test -z "$ac_dir" && ac_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
@@ -4151,12 +4169,12 @@ AC_CACHE_VAL([ac_cv_path_$1],
IFS="$ac_save_IFS"
dnl If no 4th arg is given, leave the cache variable unset,
dnl so AC_PATH_PROGS will keep looking.
-ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
+m4_if([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
])dnl
;;
esac])dnl
$1="$ac_cv_path_$1"
-if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
+if test m4_if([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
AC_MSG_RESULT([$][$1])
else
AC_MSG_RESULT([no])
diff --git a/configure b/configure
index 493542367..eaeb3d305 100755
--- a/configure
+++ b/configure
@@ -7956,31 +7956,47 @@ fi
# Check whether --enable-tdb was given.
if test ${enable_tdb+y}
then :
- enableval=$enable_tdb; if test "$enableval" = "no"
+ enableval=$enable_tdb;
+if test "$enableval" = "no"
then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Disabling tdb support" >&5
printf "%s\n" "Disabling tdb support" >&6; }
- TDB_CMT="#"
- TDB_MAN_COMMENT='.\"'
+ CONFIG_TDB=0
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Enabling tdb support" >&5
printf "%s\n" "Enabling tdb support" >&6; }
- printf "%s\n" "#define CONFIG_TDB 1" >>confdefs.h
-
- TDB_CMT=""
- TDB_MAN_COMMENT=""
+ CONFIG_TDB=1
fi

+
else $as_nop
- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Enabling mmp support by default" >&5
-printf "%s\n" "Enabling mmp support by default" >&6; }
-printf "%s\n" "#define CONFIG_TDB 1" >>confdefs.h

-TDB_CMT=""
-TDB_MAN_COMMENT=""
+case "$host_os" in
+mingw*)
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Disabling tdb support by default" >&5
+printf "%s\n" "Disabling tdb support by default" >&6; }
+ CONFIG_TDB=0
+ ;;
+*)
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Enabling tdb support by default" >&5
+printf "%s\n" "Enabling tdb support by default" >&6; }
+ CONFIG_TDB=1
+ ;;
+esac
+

fi

+if test "$CONFIG_TDB" = "1"
+then
+ printf "%s\n" "#define CONFIG_TDB 1" >>confdefs.h
+
+ TDB_CMT=""
+ TDB_MAN_COMMENT=""
+else
+ TDB_CMT="#"
+ TDB_MAN_COMMENT='.\"'
+fi



@@ -8660,7 +8676,7 @@ else $as_nop
*-*-aix*)
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#if defined __powerpc64__ || defined _ARCH_PPC64
+#if defined __powerpc64__ || defined __LP64__
int ok;
#else
error fail
@@ -8951,7 +8967,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
# be generating 64-bit code.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#if defined __powerpc64__ || defined _ARCH_PPC64
+#if defined __powerpc64__ || defined __LP64__
int ok;
#else
error fail
@@ -9058,7 +9074,7 @@ then :
else $as_nop
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#ifdef __ELF__
+#if defined __ELF__ || (defined __linux__ && defined __EDG__)
Extensible Linking Format
#endif

@@ -9076,7 +9092,7 @@ rm -rf conftest*
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_elf" >&5
printf "%s\n" "$gl_cv_elf" >&6; }
- if test $gl_cv_elf; then
+ if test $gl_cv_elf = yes; then
# Extract the ELF class of a file (5th byte) in decimal.
# Cf. https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header
if od -A x < /dev/null >/dev/null 2>/dev/null; then
@@ -9093,19 +9109,22 @@ printf "%s\n" "$gl_cv_elf" >&6; }
echo
}
fi
+ # Use 'expr', not 'test', to compare the values of func_elfclass, because on
+ # Solaris 11 OpenIndiana and Solaris 11 OmniOS, the result is 001 or 002,
+ # not 1 or 2.
case $HOST_CPU_C_ABI_32BIT in
yes)
# 32-bit ABI.
acl_is_expected_elfclass ()
{
- test "`func_elfclass | sed -e 's/[ ]//g'`" = 1
+ expr "`func_elfclass | sed -e 's/[ ]//g'`" = 1 > /dev/null
}
;;
no)
# 64-bit ABI.
acl_is_expected_elfclass ()
{
- test "`func_elfclass | sed -e 's/[ ]//g'`" = 2
+ expr "`func_elfclass | sed -e 's/[ ]//g'`" = 2 > /dev/null
}
;;
*)
@@ -9635,7 +9654,14 @@ fi
fi
;;
-l*)
- names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
+ dep=`echo "X$dep" | sed -e 's/^X-l//'`
+ if test "X$dep" != Xc \
+ || case $host_os in
+ linux* | gnu* | k*bsd*-gnu) false ;;
+ *) true ;;
+ esac; then
+ names_next_round="$names_next_round $dep"
+ fi
;;
*.la)
names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
@@ -9997,8 +10023,9 @@ int
main (void)
{
int result = 0;
- /* Test against AIX 5.1 bug: Failures are not distinguishable from successful
- returns. */
+ /* Test against AIX 5.1...7.2 bug: Failures are not distinguishable from
+ successful returns. This is even documented in
+ <https://www.ibm.com/support/knowledgecenter/ssw_aix_72/i_bostechref/iconv.html> */
{
iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
if (cd_utf8_to_88591 != (iconv_t)(-1))
@@ -10580,7 +10607,14 @@ fi
fi
;;
-l*)
- names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
+ dep=`echo "X$dep" | sed -e 's/^X-l//'`
+ if test "X$dep" != Xc \
+ || case $host_os in
+ linux* | gnu* | k*bsd*-gnu) false ;;
+ *) true ;;
+ esac; then
+ names_next_round="$names_next_round $dep"
+ fi
;;
*.la)
names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
@@ -12117,6 +12151,22 @@ then :

fi

+case "$host_os" in
+mingw*)
+ # The above checks only detect system headers, not the headers in
+ # ./include/mingw/, so explicitly define them to be available.
+ printf "%s\n" "#define HAVE_LINUX_TYPES_H 1" >>confdefs.h
+
+ printf "%s\n" "#define HAVE_SYS_STAT_H 1" >>confdefs.h
+
+ printf "%s\n" "#define HAVE_SYS_SYSMACROS_H 1" >>confdefs.h
+
+ printf "%s\n" "#define HAVE_SYS_TYPES_H 1" >>confdefs.h
+
+ printf "%s\n" "#define HAVE_UNISTD_H 1" >>confdefs.h
+
+ ;;
+esac
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a dd(1) program that supports iflag=fullblock" >&5
printf %s "checking for a dd(1) program that supports iflag=fullblock... " >&6; }
DD=
@@ -14963,6 +15013,11 @@ fi
if test -n "$WITH_DIET_LIBC" ; then
INCLUDES="$INCLUDES -D_REENTRANT"
fi
+case "$host_os" in
+mingw*)
+ INCLUDES=$INCLUDES' -I$(top_srcdir)/include/mingw'
+ ;;
+esac

if test $cross_compiling = no; then
BUILD_CFLAGS="$CFLAGS $CPPFLAGS $INCLUDES -DHAVE_CONFIG_H"
@@ -15268,7 +15323,7 @@ fi

OS_IO_FILE=""
case "$host_os" in
- cigwin*|mingw*|msys*)
+ mingw*)
OS_IO_FILE=windows_io
;;
*)
@@ -16692,7 +16747,9 @@ printf "%s\n" "$as_me: executing $ac_file commands" >&6;}
# presentlang can be used as a fallback for messages
# which are not translated in the desiredlang catalog).
case "$desiredlang" in
- "$presentlang"*) useit=yes;;
+ "$presentlang" | "$presentlang"_* | "$presentlang".* | "$presentlang"@*)
+ useit=yes
+ ;;
esac
done
if test $useit = yes; then
diff --git a/lib/config.h.in b/lib/config.h.in
index b5856bb57..cba347b49 100644
--- a/lib/config.h.in
+++ b/lib/config.h.in
@@ -220,12 +220,12 @@
/* Define to 1 if you have the `memalign' function. */
#undef HAVE_MEMALIGN

-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
/* Define to 1 if you have the `mempcpy' function. */
#undef HAVE_MEMPCPY

+/* Define to 1 if you have the <minix/config.h> header file. */
+#undef HAVE_MINIX_CONFIG_H
+
/* Define to 1 if you have the `mmap' function. */
#undef HAVE_MMAP

@@ -343,6 +343,9 @@
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H

+/* Define to 1 if you have the <stdio.h> header file. */
+#undef HAVE_STDIO_H
+
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H

@@ -478,6 +481,9 @@
/* Define to 1 if you have the `vprintf' function. */
#undef HAVE_VPRINTF

+/* Define to 1 if you have the <wchar.h> header file. */
+#undef HAVE_WCHAR_H
+
/* Define to 1 if you have the `__secure_getenv' function. */
#undef HAVE___SECURE_GETENV

@@ -524,7 +530,9 @@
/* The size of `time_t', as computed by sizeof. */
#undef SIZEOF_TIME_T

-/* Define to 1 if you have the ANSI C header files. */
+/* Define to 1 if all of the C90 standard headers exist (not just the ones
+ required in a freestanding environment). This macro is provided for
+ backward compatibility; new code need not use it. */
#undef STDC_HEADERS

/* If the compiler supports a TLS storage class define it to that here */
@@ -534,21 +542,87 @@
#ifndef _ALL_SOURCE
# undef _ALL_SOURCE
#endif
+/* Enable general extensions on macOS. */
+#ifndef _DARWIN_C_SOURCE
+# undef _DARWIN_C_SOURCE
+#endif
+/* Enable general extensions on Solaris. */
+#ifndef __EXTENSIONS__
+# undef __EXTENSIONS__
+#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# undef _GNU_SOURCE
#endif
-/* Enable threading extensions on Solaris. */
+/* Enable X/Open compliant socket functions that do not require linking
+ with -lxnet on HP-UX 11.11. */
+#ifndef _HPUX_ALT_XOPEN_SOCKET_API
+# undef _HPUX_ALT_XOPEN_SOCKET_API
+#endif
+/* Identify the host operating system as Minix.
+ This macro does not affect the system headers' behavior.
+ A future release of Autoconf may stop defining this macro. */
+#ifndef _MINIX
+# undef _MINIX
+#endif
+/* Enable general extensions on NetBSD.
+ Enable NetBSD compatibility extensions on Minix. */
+#ifndef _NETBSD_SOURCE
+# undef _NETBSD_SOURCE
+#endif
+/* Enable OpenBSD compatibility extensions on NetBSD.
+ Oddly enough, this does nothing on OpenBSD. */
+#ifndef _OPENBSD_SOURCE
+# undef _OPENBSD_SOURCE
+#endif
+/* Define to 1 if needed for POSIX-compatible behavior. */
+#ifndef _POSIX_SOURCE
+# undef _POSIX_SOURCE
+#endif
+/* Define to 2 if needed for POSIX-compatible behavior. */
+#ifndef _POSIX_1_SOURCE
+# undef _POSIX_1_SOURCE
+#endif
+/* Enable POSIX-compatible threading on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
# undef _POSIX_PTHREAD_SEMANTICS
#endif
+/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */
+#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
+# undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
+#endif
+/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */
+#ifndef __STDC_WANT_IEC_60559_BFP_EXT__
+# undef __STDC_WANT_IEC_60559_BFP_EXT__
+#endif
+/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */
+#ifndef __STDC_WANT_IEC_60559_DFP_EXT__
+# undef __STDC_WANT_IEC_60559_DFP_EXT__
+#endif
+/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */
+#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
+# undef __STDC_WANT_IEC_60559_FUNCS_EXT__
+#endif
+/* Enable extensions specified by ISO/IEC TS 18661-3:2015. */
+#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
+# undef __STDC_WANT_IEC_60559_TYPES_EXT__
+#endif
+/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */
+#ifndef __STDC_WANT_LIB_EXT2__
+# undef __STDC_WANT_LIB_EXT2__
+#endif
+/* Enable extensions specified by ISO/IEC 24747:2009. */
+#ifndef __STDC_WANT_MATH_SPEC_FUNCS__
+# undef __STDC_WANT_MATH_SPEC_FUNCS__
+#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
# undef _TANDEM_SOURCE
#endif
-/* Enable general extensions on Solaris. */
-#ifndef __EXTENSIONS__
-# undef __EXTENSIONS__
+/* Enable X/Open extensions. Define to 500 only if necessary
+ to make mbstate_t available. */
+#ifndef _XOPEN_SOURCE
+# undef _XOPEN_SOURCE
#endif


@@ -573,14 +647,4 @@
/* Define to 1 if Apple Darwin libintl workaround is needed */
#undef _INTL_REDIRECT_MACROS

-/* Define to 1 if on MINIX. */
-#undef _MINIX
-
-/* Define to 2 if the system does not provide POSIX.1 features except with
- this defined. */
-#undef _POSIX_1_SOURCE
-
-/* Define to 1 if you need to in order for `stat' and other things to work. */
-#undef _POSIX_SOURCE
-
#include <dirpaths.h>
--
2.39.0

2023-01-21 20:37:55

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 29/38] misc/e4defrag: fix -Wstringop-truncation warnings

From: Eric Biggers <[email protected]>

Fix two -Wstringop-truncation warnings in is_ext4() by simplifying how
how mnt_type is handled and by using the correct bound for mnt_fsname.

Fix a -Wstringop-truncation warning in main() by replacing the fragile
pattern 'strncpy(dst, src, strnlen(src, N))', which doesn't
null-terminate the destination string, with a standard string copy. (It
happened to work anyway because dst happens to be zero-initialized.)

These warnings showed up when building with -Wall with gcc 8 or later.

Signed-off-by: Eric Biggers <[email protected]>
---
misc/e4defrag.c | 30 +++++++++---------------------
1 file changed, 9 insertions(+), 21 deletions(-)

diff --git a/misc/e4defrag.c b/misc/e4defrag.c
index 9ec265f2e..33bd05d2c 100644
--- a/misc/e4defrag.c
+++ b/misc/e4defrag.c
@@ -258,12 +258,12 @@ static int get_mount_point(const char *devname, char *mount_point,
*
* @file: the file's name.
*/
-static int is_ext4(const char *file, char *devname)
+static int is_ext4(const char *file, char devname[PATH_MAX + 1])
{
int maxlen = 0;
int len, ret;
+ int type_is_ext4 = 0;
FILE *fp = NULL;
- char *mnt_type = NULL;
/* Refer to /etc/mtab */
const char *mtab = MOUNTED;
char file_path[PATH_MAX + 1];
@@ -307,26 +307,16 @@ static int is_ext4(const char *file, char *devname)

maxlen = len;

- mnt_type = realloc(mnt_type, strlen(mnt->mnt_type) + 1);
- if (mnt_type == NULL) {
- endmntent(fp);
- return -1;
- }
- memset(mnt_type, 0, strlen(mnt->mnt_type) + 1);
- strncpy(mnt_type, mnt->mnt_type, strlen(mnt->mnt_type));
+ type_is_ext4 = !strcmp(mnt->mnt_type, FS_EXT4);
strncpy(lost_found_dir, mnt->mnt_dir, PATH_MAX);
- strncpy(devname, mnt->mnt_fsname, strlen(mnt->mnt_fsname) + 1);
+ strncpy(devname, mnt->mnt_fsname, PATH_MAX);
}

endmntent(fp);
- if (mnt_type && strcmp(mnt_type, FS_EXT4) == 0) {
- FREE(mnt_type);
+ if (type_is_ext4)
return 0;
- } else {
- FREE(mnt_type);
- PRINT_ERR_MSG(NGMSG_EXT4);
- return -1;
- }
+ PRINT_ERR_MSG(NGMSG_EXT4);
+ return -1;
}

/*
@@ -1865,11 +1855,9 @@ int main(int argc, char *argv[])
/* fall through */
case DEVNAME:
if (arg_type == DEVNAME) {
- strncpy(lost_found_dir, dir_name,
- strnlen(dir_name, PATH_MAX));
+ strcpy(lost_found_dir, dir_name);
strncat(lost_found_dir, "/lost+found/",
- PATH_MAX - strnlen(lost_found_dir,
- PATH_MAX));
+ PATH_MAX - strlen(lost_found_dir));
}

nftw64(dir_name, calc_entry_counts, FTW_OPEN_FD, flags);
--
2.39.0

2023-01-21 20:37:56

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 19/38] lib/ext2fs: fix two compiler warnings in windows_io.c

From: Eric Biggers <[email protected]>

init_private_data() triggers a -Wstringop-truncation warning, due to a
real bug. Fix it.

windows_open() has a -Wunused-variable warning because some
macOS-specific code was copied there for no reason. Remove it.

Signed-off-by: Eric Biggers <[email protected]>
---
lib/ext2fs/windows_io.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/lib/ext2fs/windows_io.c b/lib/ext2fs/windows_io.c
index 68b5571bb..83aea68b6 100644
--- a/lib/ext2fs/windows_io.c
+++ b/lib/ext2fs/windows_io.c
@@ -499,9 +499,6 @@ static errcode_t windows_open_channel(struct windows_private_data *data,
#if defined(O_DIRECT)
if (flags & IO_FLAG_DIRECT_IO)
io->align = ext2fs_get_dio_alignment(data->dev);
-#elif defined(F_NOCACHE)
- if (flags & IO_FLAG_DIRECT_IO)
- io->align = 4096;
#endif

/*
@@ -609,7 +606,7 @@ static struct windows_private_data *init_private_data(const char *name, int flag
return NULL;

memset(data, 0, sizeof(struct windows_private_data));
- strncpy(data->name, name, sizeof(data->name));
+ strncpy(data->name, name, sizeof(data->name) - 1);
data->magic = EXT2_ET_MAGIC_WINDOWS_IO_CHANNEL;
data->io_stats.num_fields = 2;
data->flags = flags;
@@ -620,7 +617,6 @@ static struct windows_private_data *init_private_data(const char *name, int flag

static errcode_t windows_open(const char *name, int flags, io_channel *channel)
{
- int fd = -1;
int open_flags;
struct windows_private_data *data;

@@ -644,12 +640,6 @@ static errcode_t windows_open(const char *name, int flags, io_channel *channel)
return EXT2_ET_BAD_DEVICE_NAME;
}

-#if defined(F_NOCACHE) && !defined(IO_DIRECT)
- if (flags & IO_FLAG_DIRECT_IO) {
- if (fcntl(fd, F_NOCACHE, 1) < 0)
- return errno;
- }
-#endif
return windows_open_channel(data, flags, channel, windows_io_manager);
}

--
2.39.0

2023-01-21 20:38:07

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 30/38] misc/fuse2fs: avoid error-prone strncpy() pattern

From: Eric Biggers <[email protected]>

'strncpy(dst, src, strlen(src))' is usually wrong, as it doesn't copy
the null terminator. For this reason, it causes a -Wstringop-truncation
warning with gcc 8 and later.

The code happens to be correct anyway, since the destination buffer is
zero-initialized. But to avoid relying on this, let's just copy the
terminating null.

Signed-off-by: Eric Biggers <[email protected]>
---
misc/fuse2fs.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index c59572129..6d4bcf4fd 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -2508,9 +2508,10 @@ static int copy_names(char *name, char *value EXT2FS_ATTR((unused)),
size_t value_len EXT2FS_ATTR((unused)), void *data)
{
char **b = data;
+ size_t name_len = strlen(name);

- strncpy(*b, name, strlen(name));
- *b = *b + strlen(name) + 1;
+ memcpy(*b, name, name_len + 1);
+ *b = *b + name_len + 1;

return 0;
}
--
2.39.0

2023-01-21 20:38:07

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 31/38] misc/mk_hugefiles: simplify get_partition_start()

From: Eric Biggers <[email protected]>

search_sysfs_block() is causing -Wformat-truncation warnings. These
could be fixed by checking the return value of snprintf(), instead of
doing buggy checks like 'strlen(p_de->d_name) > SYSFS_PATH_LEN -
strlen(path) - 32', which has an integer underflow bug.

However, the only purpose of search_sysfs_block() is to find the sysfs
directory for a block device by device number. That can trivially be
done using /sys/dev/block/$major:$minor. So just do that instead. Also
make get_partition_start() explicitly Linux-only, as it has never worked
anywhere else.

Signed-off-by: Eric Biggers <[email protected]>
---
include/mingw/sys/sysmacros.h | 8 +-
misc/mk_hugefiles.c | 134 +++-------------------------------
2 files changed, 10 insertions(+), 132 deletions(-)

diff --git a/include/mingw/sys/sysmacros.h b/include/mingw/sys/sysmacros.h
index 18fcaaa34..a790cb2f6 100644
--- a/include/mingw/sys/sysmacros.h
+++ b/include/mingw/sys/sysmacros.h
@@ -1,11 +1,5 @@
-
#pragma once

-/*
- * Fall back to Linux's definitions of makedev and major are needed.
- * The search_sysfs_block() function is highly unlikely to work on
- * non-Linux systems anyway.
- */
#ifndef makedev
#define makedev(maj, min) (((maj) << 8) + (min))
-#endif
\ No newline at end of file
+#endif
diff --git a/misc/mk_hugefiles.c b/misc/mk_hugefiles.c
index 0280b41e7..3caaf1b68 100644
--- a/misc/mk_hugefiles.c
+++ b/misc/mk_hugefiles.c
@@ -2,13 +2,8 @@
* mk_hugefiles.c -- create huge files
*/

-#define _XOPEN_SOURCE 600 /* for inclusion of PATH_MAX in Solaris */
-#define _BSD_SOURCE /* for makedev() and major() */
-#define _DEFAULT_SOURCE /* since glibc 2.20 _BSD_SOURCE is deprecated */
-
#include "config.h"
#include <stdio.h>
-#include <stdarg.h>
#include <string.h>
#include <strings.h>
#include <fcntl.h>
@@ -68,141 +63,30 @@ static char *fn_buf;
static char *fn_numbuf;
int zero_hugefile = 1;

-#define SYSFS_PATH_LEN 300
-typedef char sysfs_path_t[SYSFS_PATH_LEN];
-
-#ifndef HAVE_SNPRINTF
-/*
- * We are very careful to avoid needing to worry about buffer
- * overflows, so we don't really need to use snprintf() except as an
- * additional safety check. So if snprintf() is not present, it's
- * safe to fall back to vsprintf(). This provides portability since
- * vsprintf() is guaranteed by C89, while snprintf() is only
- * guaranteed by C99 --- which for example, Microsoft Visual Studio
- * has *still* not bothered to implement. :-/ (Not that I expect
- * mke2fs to be ported to MS Visual Studio any time soon, but
- * libext2fs *does* get built on Microsoft platforms, and we might
- * want to move this into libext2fs some day.)
- */
-static int my_snprintf(char *str, size_t size, const char *format, ...)
-{
- va_list ap;
- int ret;
-
- va_start(ap, format);
- ret = vsprintf(str, format, ap);
- va_end(ap);
- return ret;
-}
-
-#define snprintf my_snprintf
-#endif
-
-/*
- * Fall back to Linux's definitions of makedev and major are needed.
- * The search_sysfs_block() function is highly unlikely to work on
- * non-Linux systems anyway.
- */
-#ifndef makedev
-#define makedev(maj, min) (((maj) << 8) + (min))
-#endif
-
-static char *search_sysfs_block(dev_t devno, sysfs_path_t ret_path)
-{
- struct dirent *de, *p_de;
- DIR *dir = NULL, *p_dir = NULL;
- FILE *f;
- sysfs_path_t path, p_path;
- unsigned int major, minor;
- char *ret = ret_path;
-
- ret_path[0] = 0;
- if ((dir = opendir("/sys/block")) == NULL)
- return NULL;
- while ((de = readdir(dir)) != NULL) {
- if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..") ||
- strlen(de->d_name) > sizeof(path)-32)
- continue;
- snprintf(path, SYSFS_PATH_LEN,
- "/sys/block/%s/dev", de->d_name);
- f = fopen(path, "r");
- if (f &&
- (fscanf(f, "%u:%u", &major, &minor) == 2)) {
- fclose(f); f = NULL;
- if (makedev(major, minor) == devno) {
- snprintf(ret_path, SYSFS_PATH_LEN,
- "/sys/block/%s", de->d_name);
- goto success;
- }
-#ifdef major
- if (major(devno) != major)
- continue;
-#endif
- }
- if (f)
- fclose(f);
-
- snprintf(path, SYSFS_PATH_LEN, "/sys/block/%s", de->d_name);
-
- if (p_dir)
- closedir(p_dir);
- if ((p_dir = opendir(path)) == NULL)
- continue;
- while ((p_de = readdir(p_dir)) != NULL) {
- if (!strcmp(p_de->d_name, ".") ||
- !strcmp(p_de->d_name, "..") ||
- (strlen(p_de->d_name) >
- SYSFS_PATH_LEN - strlen(path) - 32))
- continue;
- snprintf(p_path, SYSFS_PATH_LEN, "%s/%s/dev",
- path, p_de->d_name);
-
- f = fopen(p_path, "r");
- if (f &&
- (fscanf(f, "%u:%u", &major, &minor) == 2) &&
- (((major << 8) + minor) == devno)) {
- fclose(f);
- snprintf(ret_path, SYSFS_PATH_LEN, "%s/%s",
- path, p_de->d_name);
- goto success;
- }
- if (f)
- fclose(f);
- }
- }
- ret = NULL;
-success:
- if (dir)
- closedir(dir);
- if (p_dir)
- closedir(p_dir);
- return ret;
-}
-
-static blk64_t get_partition_start(const char *device_name)
+static blk64_t
+get_partition_start(const char *device_name EXT2FS_ATTR((unused)))
{
+#ifdef __linux__
unsigned long long start;
- sysfs_path_t path;
+ char path[128];
struct stat st;
FILE *f;
- char *cp;
int n;

if ((stat(device_name, &st) < 0) || !S_ISBLK(st.st_mode))
return 0;

- cp = search_sysfs_block(st.st_rdev, path);
- if (!cp)
- return 0;
- if (strlen(path) > SYSFS_PATH_LEN - sizeof("/start"))
- return 0;
- strcat(path, "/start");
+ sprintf(path, "/sys/dev/block/%d:%d/start",
+ major(st.st_rdev), minor(st.st_rdev));
f = fopen(path, "r");
if (!f)
return 0;
n = fscanf(f, "%llu", &start);
fclose(f);
return (n == 1) ? start : 0;
+#else
+ return 0;
+#endif
}

static errcode_t create_directory(ext2_filsys fs, char *dir,
--
2.39.0

2023-01-21 20:38:09

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 33/38] misc/mke2fs: fix a -Wunused-variable warning in PRS()

From: Eric Biggers <[email protected]>

This showed up when building for Windows.

Signed-off-by: Eric Biggers <[email protected]>
---
misc/mke2fs.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 24cc14750..7028d3935 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -1598,7 +1598,6 @@ static void PRS(int argc, char *argv[])
* Finally, we complain about fs_blocks_count > 2^32 on a non-64bit fs.
*/
blk64_t fs_blocks_count = 0;
- long sysval;
int s_opt = -1, r_opt = -1;
char *fs_features = 0;
int fs_features_size = 0;
@@ -1632,9 +1631,12 @@ static void PRS(int argc, char *argv[])
#define _SC_PAGESIZE _SC_PAGE_SIZE
#endif
#ifdef _SC_PAGESIZE
- sysval = sysconf(_SC_PAGESIZE);
- if (sysval > 0)
- sys_page_size = sysval;
+ {
+ long sysval = sysconf(_SC_PAGESIZE);
+
+ if (sysval > 0)
+ sys_page_size = sysval;
+ }
#endif /* _SC_PAGESIZE */
#endif /* HAVE_SYSCONF */

--
2.39.0

2023-01-21 20:38:15

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 23/38] lib/support: remove unused label in get_devname()

From: Eric Biggers <[email protected]>

Address the following compiler warning with gcc -Wall:

devname.c: In function ‘get_devname’:
devname.c:61:1: warning: label ‘out_strdup’ defined but not used [-Wunused-label]
61 | out_strdup:
| ^~~~~~~~~~

Reviewed-by: Lukas Czerner <[email protected]>
Signed-off-by: Eric Biggers <[email protected]>
---
lib/support/devname.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/lib/support/devname.c b/lib/support/devname.c
index 8c2349a32..e0306ddfb 100644
--- a/lib/support/devname.c
+++ b/lib/support/devname.c
@@ -58,7 +58,6 @@ char *get_devname(blkid_cache cache, const char *token, const char *value)
goto out;
}

-out_strdup:
if (is_file)
ret = strdup(token);
out:
--
2.39.0

2023-01-21 20:38:17

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 06/38] lib, misc: eliminate dependency on Winsock

From: Eric Biggers <[email protected]>

Currently Windows builds of e2fsprogs rely on the Windows Socket API
(Winsock) to provide htonl() and ntohl(). For this to actually work,
though, HAVE_WINSOCK_H needs to be defined, and the binaries need to be
linked to -lws2_32. The Android.bp files do this; however, the
autotools-based build system does not.

Since htonl() and ntohl() are trivial, let's instead just add a file
include/mingw/arpa/inet.h with definitions for these.

Signed-off-by: Eric Biggers <[email protected]>
---
include/mingw/arpa/inet.h | 5 +++++
lib/e2p/Android.bp | 4 ----
lib/ext2fs/Android.bp | 2 --
lib/ext2fs/jfs_compat.h | 4 ----
misc/Android.bp | 1 -
util/android_config.h | 1 -
6 files changed, 5 insertions(+), 12 deletions(-)
create mode 100644 include/mingw/arpa/inet.h

diff --git a/include/mingw/arpa/inet.h b/include/mingw/arpa/inet.h
new file mode 100644
index 000000000..55dfa3691
--- /dev/null
+++ b/include/mingw/arpa/inet.h
@@ -0,0 +1,5 @@
+#pragma once
+
+/* Windows is always little endian. */
+#define htonl __builtin_bswap32
+#define ntohl __builtin_bswap32
diff --git a/lib/e2p/Android.bp b/lib/e2p/Android.bp
index 6f0620af0..050d869b3 100644
--- a/lib/e2p/Android.bp
+++ b/lib/e2p/Android.bp
@@ -59,10 +59,6 @@ cc_library {
"-Wno-unused-variable",
"-Wno-error=typedef-redefinition",
],
-
- host_ldlibs: [
- "-lws2_32",
- ],
},
},

diff --git a/lib/ext2fs/Android.bp b/lib/ext2fs/Android.bp
index 365ca709f..eb4482d79 100644
--- a/lib/ext2fs/Android.bp
+++ b/lib/ext2fs/Android.bp
@@ -126,8 +126,6 @@ cc_library {
"-Wno-unused-variable",
"-Wno-error=typedef-redefinition",
],
-
- host_ldlibs: ["-lws2_32"],
},
},

diff --git a/lib/ext2fs/jfs_compat.h b/lib/ext2fs/jfs_compat.h
index e11cf494e..0e96b56c1 100644
--- a/lib/ext2fs/jfs_compat.h
+++ b/lib/ext2fs/jfs_compat.h
@@ -7,11 +7,7 @@
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
-#ifdef HAVE_WINSOCK_H
-#include <winsock.h>
-#else
#include <arpa/inet.h>
-#endif
#include <stdbool.h>

#define printk printf
diff --git a/misc/Android.bp b/misc/Android.bp
index 78e18e420..2baeac2ad 100644
--- a/misc/Android.bp
+++ b/misc/Android.bp
@@ -91,7 +91,6 @@ cc_binary {
"-Wno-error"
],
ldflags: ["-static"],
- host_ldlibs: ["-lws2_32"],
enabled: true
},
android: {
diff --git a/util/android_config.h b/util/android_config.h
index 6ac16fec1..90b8f8a8f 100644
--- a/util/android_config.h
+++ b/util/android_config.h
@@ -36,7 +36,6 @@

#if defined(_WIN32)
# define HAVE_LINUX_TYPES_H 1
-# define HAVE_WINSOCK_H 1
#endif
#if defined(__APPLE__) || defined(__linux__)
# define HAVE_FCNTL 1
--
2.39.0

2023-01-21 20:38:19

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 38/38] Add a configuration file for GitHub Actions

From: Eric Biggers <[email protected]>

Add a workflow file for GitHub Actions, with jobs that build and test
e2fsprogs on various platforms with various options.

The workflow is configured to run on pushes only, since e2fsprogs does
not use GitHub pull requests.

This will work on any e2fsprogs fork on Github that has GitHub Actions
enabled. For example, the results for the testing I've been doing are
at https://github.com/ebiggers/e2fsprogs/actions.

Signed-off-by: Eric Biggers <[email protected]>
---
.github/workflows/ci.yml | 116 +++++++++++++++++++++++++++++++++++++++
1 file changed, 116 insertions(+)
create mode 100644 .github/workflows/ci.yml

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 000000000..29482178d
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,116 @@
+name: CI
+on: [push]
+env:
+ DEF_CFLAGS: -O2 -g -Wall
+
+jobs:
+ gcc-build-and-test:
+ name: Build and test with gcc
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - run: ./configure CC=gcc CFLAGS="$DEF_CFLAGS"
+ - run: make -j8 check V=1 CFLAGS="$DEF_CFLAGS -Werror"
+ - run: make -j8 install V=1 DESTDIR=$PWD/installdir
+ - run: make -j8 uninstall V=1 DESTDIR=$PWD/installdir
+
+ clang-build-and-test:
+ name: Build and test with clang
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Install dependencies
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y clang
+ - run: ./configure CC=clang CFLAGS="$DEF_CFLAGS"
+ - run: make -j8 check V=1 CFLAGS="$DEF_CFLAGS -Werror"
+ - run: make -j8 install V=1 DESTDIR=$PWD/installdir
+ - run: make -j8 uninstall V=1 DESTDIR=$PWD/installdir
+
+ i386-build-and-test:
+ name: Build and test with gcc -m32
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Install dependencies
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y gcc-multilib
+ - run: ./configure CC=gcc CFLAGS="$DEF_CFLAGS -m32" LDFLAGS="-m32"
+ - run: make -j8 check V=1 CFLAGS="$DEF_CFLAGS -m32 -Werror"
+ - run: make -j8 install V=1 DESTDIR=$PWD/installdir
+ - run: make -j8 uninstall V=1 DESTDIR=$PWD/installdir
+
+ asan-build-and-test:
+ name: Build and test with ASAN enabled
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Install dependencies
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y clang
+ - run: echo "ASAN_CFLAGS=$DEF_CFLAGS -fsanitize=address -fno-sanitize-recover=address" >> $GITHUB_ENV
+ - run: ./configure CC=clang CFLAGS="$ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS"
+ - run: make -j8 check V=1 CFLAGS="$ASAN_CFLAGS -Werror"
+
+ ubsan-build-and-test:
+ name: Build and test with UBSAN enabled
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Install dependencies
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y clang
+ - run: echo "UBSAN_CFLAGS=$DEF_CFLAGS -fsanitize=undefined -fno-sanitize-recover=undefined" >> $GITHUB_ENV
+ - run: ./configure CC=clang CFLAGS="$UBSAN_CFLAGS" LDFLAGS="$UBSAN_CFLAGS"
+ - run: make -j8 check V=1 CFLAGS="$UBSAN_CFLAGS -Werror"
+
+ macos-build-and-test:
+ name: Build and test on macOS
+ runs-on: macos-latest
+ steps:
+ - uses: actions/checkout@v2
+ - run: ./configure CFLAGS="$DEF_CFLAGS"
+ # -Wno-error=deprecated-declarations is needed to suppress known warnings
+ # due to e2fsprogs' use of sbrk(0) and daemon().
+ - run: make -j8 check V=1 CFLAGS="$DEF_CFLAGS -Werror -Wno-error=deprecated-declarations"
+ - run: make -j8 install DESTDIR=$PWD/installdir
+ - run: make -j8 uninstall DESTDIR=$PWD/installdir
+
+ windows-msys2-build:
+ name: Build mke2fs on Windows with ${{matrix.sys}}
+ runs-on: windows-latest
+ strategy:
+ matrix:
+ include:
+ - { sys: mingw32, env: i686 }
+ - { sys: mingw64, env: x86_64 }
+ defaults:
+ run:
+ shell: msys2 {0}
+ steps:
+ - uses: actions/checkout@v2
+ - uses: msys2/setup-msys2@v2
+ with:
+ msystem: ${{matrix.sys}}
+ update: true
+ install: >
+ make
+ mingw-w64-${{matrix.env}}-cc
+ # For now the only parts that actually build for Windows are mke2fs and its
+ # dependencies: all libraries except libss. The build system doesn't want
+ # to build just those parts, though, so do it one step at a time...
+ - run: ./configure CFLAGS="$DEF_CFLAGS"
+ - run: make -j8 subs V=1 CFLAGS="$DEF_CFLAGS -Werror"
+ - run: make -j8 -C lib/et/ all V=1 CFLAGS="$DEF_CFLAGS -Werror"
+ - run: make -j8 -C lib/uuid/ all V=1 CFLAGS="$DEF_CFLAGS -Werror"
+ - run: make -j8 -C lib/blkid/ all V=1 CFLAGS="$DEF_CFLAGS -Werror"
+ - run: make -j8 -C lib/ext2fs/ all V=1 CFLAGS="$DEF_CFLAGS -Werror"
+ - run: make -j8 -C lib/support/ all V=1 CFLAGS="$DEF_CFLAGS -Werror"
+ - run: make -j8 -C lib/e2p/ all V=1 CFLAGS="$DEF_CFLAGS -Werror"
+ - run: make -j8 -C misc/ mke2fs V=1 CFLAGS="$DEF_CFLAGS -Werror"
+ - run: touch image.ext4
+ - run: misc/mke2fs.exe -T ext4 image.ext4 128M
--
2.39.0

2023-01-21 20:38:27

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 20/38] lib/ext2fs: fix a -Wpointer-sign warning in ext2fs_mmp_start()

From: Eric Biggers <[email protected]>

This showed up when building for Windows.

Signed-off-by: Eric Biggers <[email protected]>
---
lib/ext2fs/mmp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/ext2fs/mmp.c b/lib/ext2fs/mmp.c
index 7970aac27..9491fbd5c 100644
--- a/lib/ext2fs/mmp.c
+++ b/lib/ext2fs/mmp.c
@@ -356,7 +356,7 @@ clean_seq:
#ifdef HAVE_GETHOSTNAME
gethostname((char *) mmp_s->mmp_nodename, sizeof(mmp_s->mmp_nodename));
#else
- strcpy(mmp_s->mmp_nodename, "unknown host");
+ strcpy((char *) mmp_s->mmp_nodename, "unknown host");
#endif
strncpy((char *) mmp_s->mmp_bdevname, fs->device_name,
sizeof(mmp_s->mmp_bdevname));
--
2.39.0

2023-01-21 20:38:27

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 21/38] lib/{ext2fs,support}: fix 32-bit Windows build

From: Eric Biggers <[email protected]>

_WIN32 is the standard macro to detect (native) Windows, regardless of
32-bit or 64-bit. _WIN64 is for 64-bit Windows only. Use _WIN32 where
_WIN64 was incorrectly being used.

This fixes several 32-bit Windows build errors, for example this one:

plausible.c: In function ‘print_ext2_info’:
plausible.c:109:31: error: ‘unix_io_manager’ undeclared (first use in this function); did you mean ‘undo_io_manager’?
109 | unix_io_manager,
| ^~~~~~~~~~~~~~~
| undo_io_manager

Fixes: 86b6db9f5a43 ("libext2fs: code adaptation to use the Windows IO manager")
Cc: Paulo Antonio Alvarez <[email protected]>
Signed-off-by: Eric Biggers <[email protected]>
---
lib/ext2fs/getsectsize.c | 12 ++++++------
lib/support/plausible.c | 2 +-
util/subst.c | 4 ++--
3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/ext2fs/getsectsize.c b/lib/ext2fs/getsectsize.c
index 3a461eb9c..bd978c530 100644
--- a/lib/ext2fs/getsectsize.c
+++ b/lib/ext2fs/getsectsize.c
@@ -51,10 +51,10 @@
*/
errcode_t ext2fs_get_device_sectsize(const char *file, int *sectsize)
{
-#ifdef _WIN64
+#ifdef _WIN32
*sectsize = 512; // just guessing
return 0;
-#else // not _WIN64
+#else // not _WIN32

int fd;

@@ -78,7 +78,7 @@ errcode_t ext2fs_get_device_sectsize(const char *file, int *sectsize)
close(fd);
return 0;

-#endif // ifdef _WIN64
+#endif // ifdef _WIN32
}

/*
@@ -117,11 +117,11 @@ int ext2fs_get_dio_alignment(int fd)
*/
errcode_t ext2fs_get_device_phys_sectsize(const char *file, int *sectsize)
{
-#ifdef _WIN64
+#ifdef _WIN32

return ext2fs_get_device_sectsize(file, sectsize);

-#else // not _WIN64
+#else // not _WIN32

int fd;

@@ -147,5 +147,5 @@ errcode_t ext2fs_get_device_phys_sectsize(const char *file, int *sectsize)
close(fd);
return 0;

-#endif // ifdef _WIN64
+#endif // ifdef _WIN32
}
diff --git a/lib/support/plausible.c b/lib/support/plausible.c
index bbed2a70a..349aa2c4f 100644
--- a/lib/support/plausible.c
+++ b/lib/support/plausible.c
@@ -103,7 +103,7 @@ static void print_ext2_info(const char *device)
time_t tm;

retval = ext2fs_open2(device, 0, EXT2_FLAG_64BITS, 0, 0,
-#ifdef _WIN64
+#ifdef _WIN32
windows_io_manager,
#else
unix_io_manager,
diff --git a/util/subst.c b/util/subst.c
index c0eda5cf8..be2a0dda4 100644
--- a/util/subst.c
+++ b/util/subst.c
@@ -434,7 +434,7 @@ int main(int argc, char **argv)
printf("Using original atime\n");
set_utimes(outfn, fileno(old), tv);
}
-#ifndef _WIN64
+#ifndef _WIN32
if (ofd >= 0)
(void) fchmod(ofd, 0444);
#endif
@@ -444,7 +444,7 @@ int main(int argc, char **argv)
} else {
if (verbose)
printf("Creating or replacing %s.\n", outfn);
-#ifndef _WIN64
+#ifndef _WIN32
if (ofd >= 0)
(void) fchmod(ofd, 0444);
#endif
--
2.39.0

2023-01-21 20:38:27

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 11/38] lib/blkid: suppress -Wstringop-truncation warning in blkid_strndup()

From: Eric Biggers <[email protected]>

Unfortunately, gcc gets confused by blkid_strndup() and incorrectly
thinks the destination string is not being null-terminated. This is
part of -Wstringop-truncation, enabled automatically by -Wall in gcc 8
and later. Let's just suppress this warning here.

Signed-off-by: Eric Biggers <[email protected]>
---
lib/blkid/devno.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/lib/blkid/devno.c b/lib/blkid/devno.c
index 34ceb3c48..b1cadc9df 100644
--- a/lib/blkid/devno.c
+++ b/lib/blkid/devno.c
@@ -37,6 +37,12 @@

#include "blkidP.h"

+#if defined(__GNUC__) && __GNUC__ >= 8
+/* gcc incorrectly thinks the destination string is not being null-terminated */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-truncation"
+#endif
+
char *blkid_strndup(const char *s, int length)
{
char *ret;
@@ -55,6 +61,10 @@ char *blkid_strndup(const char *s, int length)
return ret;
}

+#if defined(__GNUC__) && __GNUC__ >= 8
+#pragma GCC diagnostic pop
+#endif
+
char *blkid_strdup(const char *s)
{
return blkid_strndup(s, 0);
--
2.39.0

2023-01-21 20:38:27

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 26/38] e2fsck: use real functions for kernel slab functions

From: Eric Biggers <[email protected]>

The macros that e2fsck uses to implement kmalloc et al. use only some of
their arguments, so unlike standard function calls, they can cause
compiler warnings like:

./../e2fsck/revoke.c:141:8: warning: variable 'gfp_mask' set but not used [-Wunused-but-set-variable]

Fix this by providing a proper definition for each function, making sure
to match the function prototypes used in the kernel.

Remove the kmem_cache_t typedef, as it doesn't exist in the kernel.

Signed-off-by: Eric Biggers <[email protected]>
---
e2fsck/jfs_user.h | 62 ++++++++++++++++++++++++++++++++++-------------
1 file changed, 45 insertions(+), 17 deletions(-)

diff --git a/e2fsck/jfs_user.h b/e2fsck/jfs_user.h
index 969cd1b92..1167c80d3 100644
--- a/e2fsck/jfs_user.h
+++ b/e2fsck/jfs_user.h
@@ -82,16 +82,9 @@ struct kdev_s {
#define buffer_req(bh) 1
#define do_readahead(journal, start) do {} while (0)

-typedef struct kmem_cache {
- int object_length;
-} kmem_cache_t;
-
-#define kmem_cache_alloc(cache, flags) malloc((cache)->object_length)
-#define kmem_cache_free(cache, obj) free(obj)
-#define kmem_cache_create(name, len, a, b, c) do_cache_create(len)
-#define kmem_cache_destroy(cache) do_cache_destroy(cache)
-#define kmalloc(len, flags) malloc(len)
-#define kfree(p) free(p)
+struct kmem_cache {
+ unsigned int object_size;
+};

#define cond_resched() do { } while (0)

@@ -107,8 +100,16 @@ typedef struct kmem_cache {
* functions.
*/
#ifdef NO_INLINE_FUNCS
-extern kmem_cache_t *do_cache_create(int len);
-extern void do_cache_destroy(kmem_cache_t *cache);
+extern struct kmem_cache *kmem_cache_create(const char *name,
+ unsigned int size,
+ unsigned int align,
+ unsigned int flags,
+ void (*ctor)(void *));
+extern void kmem_cache_destroy(struct kmem_cache *s);
+extern void *kmem_cache_alloc(struct kmem_cache *cachep, gfp_t flags);
+extern void kmem_cache_free(struct kmem_cache *s, void *objp);
+extern void *kmalloc(size_t size, gfp_t flags);
+extern void kfree(const void *objp);
extern size_t journal_tag_bytes(journal_t *journal);
extern __u32 __hash_32(__u32 val);
extern __u32 hash_32(__u32 val, unsigned int bits);
@@ -139,19 +140,46 @@ extern void jbd2_descriptor_block_csum_set(journal_t *j,
#endif /* __STDC_VERSION__ >= 199901L */
#endif /* E2FSCK_INCLUDE_INLINE_FUNCS */

-_INLINE_ kmem_cache_t *do_cache_create(int len)
+_INLINE_ struct kmem_cache *
+kmem_cache_create(const char *name EXT2FS_ATTR((unused)),
+ unsigned int size,
+ unsigned int align EXT2FS_ATTR((unused)),
+ unsigned int flags EXT2FS_ATTR((unused)),
+ void (*ctor)(void *) EXT2FS_ATTR((unused)))
{
- kmem_cache_t *new_cache;
+ struct kmem_cache *new_cache;

new_cache = malloc(sizeof(*new_cache));
if (new_cache)
- new_cache->object_length = len;
+ new_cache->object_size = size;
return new_cache;
}

-_INLINE_ void do_cache_destroy(kmem_cache_t *cache)
+_INLINE_ void kmem_cache_destroy(struct kmem_cache *s)
+{
+ free(s);
+}
+
+_INLINE_ void *kmem_cache_alloc(struct kmem_cache *cachep,
+ gfp_t flags EXT2FS_ATTR((unused)))
+{
+ return malloc(cachep->object_size);
+}
+
+_INLINE_ void kmem_cache_free(struct kmem_cache *s EXT2FS_ATTR((unused)),
+ void *objp)
+{
+ free(objp);
+}
+
+_INLINE_ void *kmalloc(size_t size, gfp_t flags EXT2FS_ATTR((unused)))
+{
+ return malloc(size);
+}
+
+_INLINE_ void kfree(const void *objp)
{
- free(cache);
+ free((void *)objp);
}

/* generic hashing taken from the Linux kernel */
--
2.39.0

2023-01-21 20:38:27

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 28/38] misc/create_inode: simplify logic in scandir()

From: Eric Biggers <[email protected]>

The control flow in scandir() (only used on Windows) confuses gcc into
thinking that *name_list is not always set on success, which causes a
-Wmaybe-uninitialized warning in __populate_fs(). As far as I can tell
it's a false positive; however, avoid it by cleanly separating the
success and failure cases in scandir().

Signed-off-by: Eric Biggers <[email protected]>
---
misc/create_inode.c | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/misc/create_inode.c b/misc/create_inode.c
index 7ce69c2b0..6e61d98e6 100644
--- a/misc/create_inode.c
+++ b/misc/create_inode.c
@@ -763,39 +763,33 @@ static int scandir(const char *dir_name, struct dirent ***name_list,
size_t new_list_size = temp_list_size + 32;
struct dirent **new_list = (struct dirent**)realloc(
temp_list, new_list_size * sizeof(struct dirent*));
- if (new_list == NULL) {
- goto out;
- }
+ if (new_list == NULL)
+ goto out_err;
temp_list_size = new_list_size;
temp_list = new_list;
}
// add the copy of dirent to the list
temp_list[num_dent] = (struct dirent*)malloc((dent->d_reclen + 3) & ~3);
if (!temp_list[num_dent])
- goto out;
+ goto out_err;
memcpy(temp_list[num_dent], dent, dent->d_reclen);
num_dent++;
}
+ closedir(dir);

if (compar != NULL) {
qsort(temp_list, num_dent, sizeof(struct dirent*),
(int (*)(const void*, const void*))compar);
}
-
- // release the temp list
*name_list = temp_list;
- temp_list = NULL;
+ return num_dent;

-out:
- if (temp_list != NULL) {
- while (num_dent > 0) {
- free(temp_list[--num_dent]);
- }
- free(temp_list);
- num_dent = -1;
- }
+out_err:
closedir(dir);
- return num_dent;
+ while (num_dent > 0)
+ free(temp_list[--num_dent]);
+ free(temp_list);
+ return -1;
}

static int alphasort(const struct dirent **a, const struct dirent **b) {
--
2.39.0

2023-01-21 20:38:27

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 03/38] configure.ac: automatically add include/mingw/ headers

From: Eric Biggers <[email protected]>

Since the include/mingw/ directory needs to be on the include path when
building for Windows with MinGW, add it to INCLUDES automatically, and
AC_DEFINE the corresponding HAVE_*_H constants.

Signed-off-by: Eric Biggers <[email protected]>
---
configure.ac | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

diff --git a/configure.ac b/configure.ac
index e3884db60..d62d99dc8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1036,6 +1036,17 @@ AC_CHECK_HEADERS(m4_flatten([
sys/wait.h
sys/xattr.h
]))
+case "$host_os" in
+mingw*)
+ # The above checks only detect system headers, not the headers in
+ # ./include/mingw/, so explicitly define them to be available.
+ AC_DEFINE(HAVE_LINUX_TYPES_H, 1)
+ AC_DEFINE(HAVE_SYS_STAT_H, 1)
+ AC_DEFINE(HAVE_SYS_SYSMACROS_H, 1)
+ AC_DEFINE(HAVE_SYS_TYPES_H, 1)
+ AC_DEFINE(HAVE_UNISTD_H, 1)
+ ;;
+esac
dnl Check where to find a dd(1) that supports iflag=fullblock
dnl and oflag=append
AC_MSG_CHECKING([for a dd(1) program that supports iflag=fullblock])
@@ -1710,6 +1721,11 @@ fi
if test -n "$WITH_DIET_LIBC" ; then
INCLUDES="$INCLUDES -D_REENTRANT"
fi
+case "$host_os" in
+mingw*)
+ INCLUDES=$INCLUDES' -I$(top_srcdir)/include/mingw'
+ ;;
+esac
AC_SUBST(INCLUDES)
dnl
dnl Build CFLAGS
--
2.39.0

2023-01-21 20:38:27

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 17/38] lib/ext2fs: remove unused variable in ext2fs_xattrs_read_inode()

From: Eric Biggers <[email protected]>

Address the following compiler warning with gcc -Wall:

ext_attr.c: In function ‘ext2fs_xattrs_read_inode’:
ext_attr.c:1000:16: warning: unused variable ‘i’ [-Wunused-variable]
1000 | size_t i;
| ^

Cc: Andreas Dilger <[email protected]>
Reviewed-by: Lukas Czerner <[email protected]>
Signed-off-by: Eric Biggers <[email protected]>
---
lib/ext2fs/ext_attr.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/lib/ext2fs/ext_attr.c b/lib/ext2fs/ext_attr.c
index d36fe68dd..359c8e3cb 100644
--- a/lib/ext2fs/ext_attr.c
+++ b/lib/ext2fs/ext_attr.c
@@ -991,13 +991,11 @@ static void xattrs_free_keys(struct ext2_xattr_handle *h)
errcode_t ext2fs_xattrs_read_inode(struct ext2_xattr_handle *handle,
struct ext2_inode_large *inode)
{
-
struct ext2_ext_attr_header *header;
__u32 ea_inode_magic;
unsigned int storage_size;
char *start, *block_buf = NULL;
blk64_t blk;
- size_t i;
errcode_t err = 0;

EXT2_CHECK_MAGIC(handle, EXT2_ET_MAGIC_EA_HANDLE);
--
2.39.0

2023-01-21 20:38:27

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 09/38] lib/blkid: fix -Wunused-variable warning in blkid_get_dev_size()

From: Eric Biggers <[email protected]>

This showed up when building for Windows. It's hard to conditionally
define this variable, so use the 'unused' attribute.

Signed-off-by: Eric Biggers <[email protected]>
---
lib/blkid/Android.bp | 1 -
lib/blkid/getsize.c | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/blkid/Android.bp b/lib/blkid/Android.bp
index a40113193..f5d25da4f 100644
--- a/lib/blkid/Android.bp
+++ b/lib/blkid/Android.bp
@@ -42,7 +42,6 @@ cc_library {
include_dirs: ["external/e2fsprogs/include/mingw"],
cflags: [
"-Wno-pointer-to-int-cast",
- "-Wno-unused-variable",
"-Wno-error=typedef-redefinition",
],

diff --git a/lib/blkid/getsize.c b/lib/blkid/getsize.c
index 75f21d5c1..7a6e6fd86 100644
--- a/lib/blkid/getsize.c
+++ b/lib/blkid/getsize.c
@@ -75,7 +75,7 @@ static int valid_offset(int fd, blkid_loff_t offset)
*/
blkid_loff_t blkid_get_dev_size(int fd)
{
- unsigned long long size64;
+ unsigned long long size64 __BLKID_ATTR((unused));
blkid_loff_t high, low;

#if defined DKIOCGETBLOCKCOUNT && defined DKIOCGETBLOCKSIZE /* For Apple Darwin */
--
2.39.0

2023-01-21 20:38:27

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 22/38] lib/ss: fix 'make install' by creating man1dir

From: Eric Biggers <[email protected]>

'make install' does not work because libss tries to install a man page
without creating the directory first. Fix this.

Signed-off-by: Eric Biggers <[email protected]>
---
lib/ss/Makefile.in | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/ss/Makefile.in b/lib/ss/Makefile.in
index 40294db0b..bb5041893 100644
--- a/lib/ss/Makefile.in
+++ b/lib/ss/Makefile.in
@@ -125,10 +125,11 @@ ss.pc: $(srcdir)/ss.pc.in $(top_builddir)/config.status
$(Q) cd $(top_builddir); CONFIG_FILES=lib/ss/ss.pc ./config.status

installdirs::
- $(E) " MKDIR_P $(libdir) $(includedir)/ss $(datadir)/ss $(bindir)"
+ $(E) " MKDIR_P $(libdir) $(includedir)/ss $(datadir)/ss $(bindir) $(pkgconfigdir) $(man1dir)"
$(Q) $(MKDIR_P) $(DESTDIR)$(libdir) \
$(DESTDIR)$(includedir)/ss $(DESTDIR)$(datadir)/ss \
- $(DESTDIR)$(bindir) $(DESTDIR)$(pkgconfigdir)
+ $(DESTDIR)$(bindir) $(DESTDIR)$(pkgconfigdir) \
+ $(DESTDIR)$(man1dir)

install:: libss.a $(INSTALL_HFILES) installdirs ss_err.h mk_cmds ss.pc
$(E) " INSTALL_DATA $(DESTDIR)$(libdir)/libss.a"
--
2.39.0

2023-01-21 20:38:27

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 13/38] lib/{e2p,ss}: remove manual declarations of errno

From: Eric Biggers <[email protected]>

As per 'man 3 errno':

On some ancient systems, <errno.h> was not present or did not
declare errno, so that it was necessary to declare errno manually
(i.e., extern int errno). **Do not do this**. It long ago ceased
to be necessary, and it will cause problems with modern versions of
the C library.

One of the platforms it causes a problem on is Windows:

In file included from fgetversion.c:28:
fgetversion.c: In function ‘fgetversion’:
fgetversion.c:68:20: warning: ‘_errno’ redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
68 | extern int errno;
| ^~~~~

Just remove these obsolete manual declarations of errno.

Signed-off-by: Eric Biggers <[email protected]>
---
lib/e2p/fgetversion.c | 2 --
lib/e2p/fsetversion.c | 1 -
lib/e2p/getversion.c | 1 -
lib/e2p/setversion.c | 1 -
lib/ss/execute_cmd.c | 2 --
lib/ss/help.c | 2 --
lib/ss/pager.c | 2 --
7 files changed, 11 deletions(-)

diff --git a/lib/e2p/fgetversion.c b/lib/e2p/fgetversion.c
index a65e9a5c5..f3a5b4cdf 100644
--- a/lib/e2p/fgetversion.c
+++ b/lib/e2p/fgetversion.c
@@ -65,8 +65,6 @@ int fgetversion(const char *name, unsigned long *version)
rc = syscall(SYS_fsctl, name, EXT2_IOC_GETVERSION, &ver, 0);
# endif /* !APPLE_DARWIN */
#else /* ! HAVE_EXT2_IOCTLS */
- extern int errno;
-
errno = EOPNOTSUPP;
#endif /* ! HAVE_EXT2_IOCTLS */
if (rc == 0)
diff --git a/lib/e2p/fsetversion.c b/lib/e2p/fsetversion.c
index c2e045591..5f844b55e 100644
--- a/lib/e2p/fsetversion.c
+++ b/lib/e2p/fsetversion.c
@@ -65,7 +65,6 @@ int fsetversion (const char * name, unsigned long version)
return syscall(SYS_fsctl, name, EXT2_IOC_SETVERSION, &ver, 0);
#endif
#else /* ! HAVE_EXT2_IOCTLS */
- extern int errno;
errno = EOPNOTSUPP;
return -1;
#endif /* ! HAVE_EXT2_IOCTLS */
diff --git a/lib/e2p/getversion.c b/lib/e2p/getversion.c
index 9f719b4a9..d374a0ea7 100644
--- a/lib/e2p/getversion.c
+++ b/lib/e2p/getversion.c
@@ -35,7 +35,6 @@ int getversion (int fd, unsigned long * version)
*version = ver;
return r;
#else /* ! HAVE_EXT2_IOCTLS */
- extern int errno;
errno = EOPNOTSUPP;
return -1;
#endif /* ! HAVE_EXT2_IOCTLS */
diff --git a/lib/e2p/setversion.c b/lib/e2p/setversion.c
index 2bc933749..dd4a3f06b 100644
--- a/lib/e2p/setversion.c
+++ b/lib/e2p/setversion.c
@@ -34,7 +34,6 @@ int setversion (int fd, unsigned long version)
ver = (int) version;
return ioctl (fd, EXT2_IOC_SETVERSION, &ver);
#else /* ! HAVE_EXT2_IOCTLS */
- extern int errno;
errno = EOPNOTSUPP;
return -1;
#endif /* ! HAVE_EXT2_IOCTLS */
diff --git a/lib/ss/execute_cmd.c b/lib/ss/execute_cmd.c
index 2e2c8cfa0..d092134a3 100644
--- a/lib/ss/execute_cmd.c
+++ b/lib/ss/execute_cmd.c
@@ -17,8 +17,6 @@
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
-#else
-extern int errno;
#endif
#include "ss_internal.h"
#include <stdio.h>
diff --git a/lib/ss/help.c b/lib/ss/help.c
index a22b40178..54c78f239 100644
--- a/lib/ss/help.c
+++ b/lib/ss/help.c
@@ -20,8 +20,6 @@
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
-#else
-extern int errno;
#endif
#include <fcntl.h>
#include <sys/param.h>
diff --git a/lib/ss/pager.c b/lib/ss/pager.c
index b9b889962..ba32b2019 100644
--- a/lib/ss/pager.c
+++ b/lib/ss/pager.c
@@ -20,8 +20,6 @@
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
-#else
-extern int errno;
#endif

#include "ss_internal.h"
--
2.39.0

2023-01-21 20:38:27

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 32/38] misc/mke2fs: fix Windows build

From: Eric Biggers <[email protected]>

unix_io_manager is no longer available on Windows. windows_io_manager
must be used instead.

Fixes: 86b6db9f5a43 ("libext2fs: code adaptation to use the Windows IO manager")
Cc: Paulo Antonio Alvarez <[email protected]>
Signed-off-by: Eric Biggers <[email protected]>
---
lib/ext2fs/ext2_io.h | 2 ++
lib/support/plausible.c | 7 +------
misc/mke2fs.c | 12 ++++++------
3 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/lib/ext2fs/ext2_io.h b/lib/ext2fs/ext2_io.h
index 8fe5b3235..679184e39 100644
--- a/lib/ext2fs/ext2_io.h
+++ b/lib/ext2fs/ext2_io.h
@@ -145,10 +145,12 @@ extern errcode_t io_channel_cache_readahead(io_channel io,
#ifdef _WIN32
/* windows_io.c */
extern io_manager windows_io_manager;
+#define default_io_manager windows_io_manager
#else
/* unix_io.c */
extern io_manager unix_io_manager;
extern io_manager unixfd_io_manager;
+#define default_io_manager unix_io_manager
#endif

/* sparse_io.c */
diff --git a/lib/support/plausible.c b/lib/support/plausible.c
index 349aa2c4f..65a6b2e14 100644
--- a/lib/support/plausible.c
+++ b/lib/support/plausible.c
@@ -103,12 +103,7 @@ static void print_ext2_info(const char *device)
time_t tm;

retval = ext2fs_open2(device, 0, EXT2_FLAG_64BITS, 0, 0,
-#ifdef _WIN32
- windows_io_manager,
-#else
- unix_io_manager,
-#endif
- &fs);
+ default_io_manager, &fs);
if (retval)
return;
sb = fs->super;
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index bde1e582e..24cc14750 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -1950,10 +1950,10 @@ profile_error:
#ifdef CONFIG_TESTIO_DEBUG
if (getenv("TEST_IO_FLAGS") || getenv("TEST_IO_BLOCK")) {
io_ptr = test_io_manager;
- test_io_backing_manager = unix_io_manager;
+ test_io_backing_manager = default_io_manager;
} else
#endif
- io_ptr = unix_io_manager;
+ io_ptr = default_io_manager;
retval = ext2fs_open(journal_device,
EXT2_FLAG_JOURNAL_DEV_OK, 0,
0, io_ptr, &jfs);
@@ -2736,7 +2736,7 @@ static int should_do_undo(const char *name)
io_channel channel;
__u16 s_magic;
struct ext2_super_block super;
- io_manager manager = unix_io_manager;
+ io_manager manager = default_io_manager;
int csum_flag, force_undo;

csum_flag = ext2fs_has_feature_metadata_csum(&fs_param) ||
@@ -3041,10 +3041,10 @@ int main (int argc, char *argv[])
#ifdef CONFIG_TESTIO_DEBUG
if (getenv("TEST_IO_FLAGS") || getenv("TEST_IO_BLOCK")) {
io_ptr = test_io_manager;
- test_io_backing_manager = unix_io_manager;
+ test_io_backing_manager = default_io_manager;
} else
#endif
- io_ptr = unix_io_manager;
+ io_ptr = default_io_manager;

if (undo_file != NULL || should_do_undo(device_name)) {
retval = mke2fs_setup_tdb(device_name, &io_ptr);
@@ -3449,7 +3449,7 @@ int main (int argc, char *argv[])

retval = ext2fs_open(journal_device, EXT2_FLAG_RW|
EXT2_FLAG_JOURNAL_DEV_OK, 0,
- fs->blocksize, unix_io_manager, &jfs);
+ fs->blocksize, default_io_manager, &jfs);
if (retval) {
com_err(program_name, retval,
_("while trying to open journal device %s\n"),
--
2.39.0

2023-01-21 20:38:27

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 07/38] lib/blkid: remove 32-bit x86 byteswap assembly

From: Eric Biggers <[email protected]>

libblkid contains 32-bit x86 assembly language implementations of 16-bit
and 32-bit byteswaps. However, modern compilers can easily generate the
bswap instruction automatically from the corresponding C expression.
And no one ever bothered to add assembly for x86_64 or other
architectures, anyway. So let's just remove this outdated code, which
was maybe useful in the 90s, but is no longer useful.

Signed-off-by: Eric Biggers <[email protected]>
---
lib/blkid/probe.h | 43 -------------------------------------------
1 file changed, 43 deletions(-)

diff --git a/lib/blkid/probe.h b/lib/blkid/probe.h
index dea4081d0..063a5b5c0 100644
--- a/lib/blkid/probe.h
+++ b/lib/blkid/probe.h
@@ -814,46 +814,6 @@ struct exfat_entry_label {
#define _INLINE_ static inline
#endif

-static __u16 blkid_swab16(__u16 val);
-static __u32 blkid_swab32(__u32 val);
-static __u64 blkid_swab64(__u64 val);
-
-#if ((defined __GNUC__) && \
- (defined(__i386__) || defined(__i486__) || defined(__i586__)))
-
-#define _BLKID_HAVE_ASM_BITOPS_
-
-_INLINE_ __u32 blkid_swab32(__u32 val)
-{
-#ifdef EXT2FS_REQUIRE_486
- __asm__("bswap %0" : "=r" (val) : "0" (val));
-#else
- __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */
- "rorl $16,%0\n\t" /* swap words */
- "xchgb %b0,%h0" /* swap higher bytes */
- :"=q" (val)
- : "0" (val));
-#endif
- return val;
-}
-
-_INLINE_ __u16 blkid_swab16(__u16 val)
-{
- __asm__("xchgb %b0,%h0" /* swap bytes */ \
- : "=q" (val) \
- : "0" (val)); \
- return val;
-}
-
-_INLINE_ __u64 blkid_swab64(__u64 val)
-{
- return (blkid_swab32(val >> 32) |
- (((__u64) blkid_swab32(val & 0xFFFFFFFFUL)) << 32));
-}
-#endif
-
-#if !defined(_BLKID_HAVE_ASM_BITOPS_)
-
_INLINE_ __u16 blkid_swab16(__u16 val)
{
return (val >> 8) | (val << 8);
@@ -870,9 +830,6 @@ _INLINE_ __u64 blkid_swab64(__u64 val)
return (blkid_swab32(val >> 32) |
(((__u64) blkid_swab32(val & 0xFFFFFFFFUL)) << 32));
}
-#endif
-
-

#ifdef WORDS_BIGENDIAN
#define blkid_le16(x) blkid_swab16(x)
--
2.39.0

2023-01-21 20:38:27

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 05/38] config/install-sh: update to latest version

From: Eric Biggers <[email protected]>

The version of install-sh in the source tree is extremely old and
doesn't work when passed multiple path arguments, which breaks
'make install' on macOS.

Therefore, delete this file and run 'autoreconf -i' to update it to the
latest version.

Signed-off-by: Eric Biggers <[email protected]>
---
config/install-sh | 683 +++++++++++++++++++++++++++++++++-------------
1 file changed, 493 insertions(+), 190 deletions(-)

diff --git a/config/install-sh b/config/install-sh
index 89fc9b098..ec298b537 100755
--- a/config/install-sh
+++ b/config/install-sh
@@ -1,238 +1,541 @@
-#! /bin/sh
-#
+#!/bin/sh
# install - install a program, script, or datafile
-# This comes from X11R5.
+
+scriptversion=2020-11-14.01; # UTC
+
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
+# 'make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
-#

+tab=' '
+nl='
+'
+IFS=" $tab$nl"
+
+# Set DOITPROG to "echo" to test this script.
+
+doit=${DOITPROG-}
+doit_exec=${doit:-exec}

-# set DOITPROG to echo to test this script
+# Put in absolute file names if you don't have them in your path;
+# or use environment vars.

-# Don't use :- since 4.3BSD and earlier shells don't like it.
-doit="${DOITPROG-}"
+chgrpprog=${CHGRPPROG-chgrp}
+chmodprog=${CHMODPROG-chmod}
+chownprog=${CHOWNPROG-chown}
+cmpprog=${CMPPROG-cmp}
+cpprog=${CPPROG-cp}
+mkdirprog=${MKDIRPROG-mkdir}
+mvprog=${MVPROG-mv}
+rmprog=${RMPROG-rm}
+stripprog=${STRIPPROG-strip}

+posix_mkdir=

-# put in absolute paths if you don't have them in your path; or use env. vars.
+# Desired mode of installed file.
+mode=0755

-mvprog="${MVPROG-mv}"
-cpprog="${CPPROG-cp}"
-chmodprog="${CHMODPROG-chmod}"
-chownprog="${CHOWNPROG-chown}"
-chgrpprog="${CHGRPPROG-chgrp}"
-stripprog="${STRIPPROG-strip}"
-rmprog="${RMPROG-rm}"
-mkdirprog="${MKDIRPROG-mkdir}"
+# Create dirs (including intermediate dirs) using mode 755.
+# This is like GNU 'install' as of coreutils 8.32 (2020).
+mkdir_umask=22

-tranformbasename=""
-transform_arg=""
-instcmd="$mvprog"
-chmodcmd="$chmodprog 0755"
-chowncmd=""
-chgrpcmd=""
-stripcmd=""
+backupsuffix=
+chgrpcmd=
+chmodcmd=$chmodprog
+chowncmd=
+mvcmd=$mvprog
rmcmd="$rmprog -f"
-mvcmd="$mvprog"
-src=""
-dst=""
-dir_arg=""
-
-while [ x"$1" != x ]; do
- case $1 in
- -c) instcmd="$cpprog"
- shift
- continue;;
-
- -d) dir_arg=true
- shift
- continue;;
-
- -m) chmodcmd="$chmodprog $2"
- shift
- shift
- continue;;
-
- -o) chowncmd="$chownprog $2"
- shift
- shift
- continue;;
-
- -g) chgrpcmd="$chgrpprog $2"
- shift
- shift
- continue;;
-
- -s) stripcmd="$stripprog"
- shift
- continue;;
-
- -t=*) transformarg=`echo $1 | sed 's/-t=//'`
- shift
- continue;;
-
- -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
- shift
- continue;;
-
- *) if [ x"$src" = x ]
- then
- src=$1
- else
- # this colon is to work around a 386BSD /bin/sh bug
- :
- dst=$1
- fi
- shift
- continue;;
- esac
-done
+stripcmd=

-if [ x"$src" = x ]
-then
- echo "install: no input file specified"
- exit 1
-else
- true
-fi
+src=
+dst=
+dir_arg=
+dst_arg=

-if [ x"$dir_arg" != x ]; then
- dst=$src
- src=""
-
- if [ -d $dst ]; then
- instcmd=:
- else
- instcmd=mkdir
- fi
-else
+copy_on_change=false
+is_target_a_directory=possibly

-# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-# might cause directories to be created, which would be especially bad
-# if $src (and thus $dsttmp) contains '*'.
+usage="\
+Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+ or: $0 [OPTION]... SRCFILES... DIRECTORY
+ or: $0 [OPTION]... -t DIRECTORY SRCFILES...
+ or: $0 [OPTION]... -d DIRECTORIES...

- if [ -f $src -o -d $src ]
- then
- true
- else
- echo "install: $src does not exist"
- exit 1
- fi
-
- if [ x"$dst" = x ]
- then
- echo "install: no destination specified"
- exit 1
- else
- true
- fi
+In the 1st form, copy SRCFILE to DSTFILE.
+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
+In the 4th, create DIRECTORIES.

-# If destination is a directory, append the input filename; if your system
-# does not like double slashes in filenames, you may need to add some logic
+Options:
+ --help display this help and exit.
+ --version display version info and exit.

- if [ -d $dst ]
- then
- dst="$dst"/`basename $src`
- else
- true
- fi
-fi
+ -c (ignored)
+ -C install only if different (preserve data modification time)
+ -d create directories instead of installing files.
+ -g GROUP $chgrpprog installed files to GROUP.
+ -m MODE $chmodprog installed files to MODE.
+ -o USER $chownprog installed files to USER.
+ -p pass -p to $cpprog.
+ -s $stripprog installed files.
+ -S SUFFIX attempt to back up existing files, with suffix SUFFIX.
+ -t DIRECTORY install into DIRECTORY.
+ -T report an error if DSTFILE is a directory.

-## this sed command emulates the dirname command
-dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+Environment variables override the default commands:
+ CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
+ RMPROG STRIPPROG

-# Make sure that the destination directory exists.
-# this part is taken from Noah Friedman's mkinstalldirs script
+By default, rm is invoked with -f; when overridden with RMPROG,
+it's up to you to specify -f if you want it.

-# Skip lots of stat calls in the usual case.
-if [ ! -d "$dstdir" ]; then
-defaultIFS='
-'
-IFS="${IFS-${defaultIFS}}"
+If -S is not specified, no backups are attempted.

-oIFS="${IFS}"
-# Some sh's can't handle IFS=/ for some reason.
-IFS='%'
-set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
-IFS="${oIFS}"
+Email bug reports to [email protected].
+Automake home page: https://www.gnu.org/software/automake/
+"

-pathcomp=''
+while test $# -ne 0; do
+ case $1 in
+ -c) ;;

-while [ $# -ne 0 ] ; do
- pathcomp="${pathcomp}${1}"
- shift
+ -C) copy_on_change=true;;

- if [ ! -d "${pathcomp}" ] ;
- then
- $mkdirprog "${pathcomp}"
- else
- true
- fi
+ -d) dir_arg=true;;

- pathcomp="${pathcomp}/"
-done
-fi
+ -g) chgrpcmd="$chgrpprog $2"
+ shift;;

-if [ x"$dir_arg" != x ]
-then
- $doit $instcmd $dst &&
+ --help) echo "$usage"; exit $?;;

- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
-else
+ -m) mode=$2
+ case $mode in
+ *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
+ echo "$0: invalid mode: $mode" >&2
+ exit 1;;
+ esac
+ shift;;

-# If we're going to rename the final executable, determine the name now.
+ -o) chowncmd="$chownprog $2"
+ shift;;

- if [ x"$transformarg" = x ]
- then
- dstfile=`basename $dst`
- else
- dstfile=`basename $dst $transformbasename |
- sed $transformarg`$transformbasename
- fi
+ -p) cpprog="$cpprog -p";;

-# don't allow the sed command to completely eliminate the filename
+ -s) stripcmd=$stripprog;;

- if [ x"$dstfile" = x ]
- then
- dstfile=`basename $dst`
- else
- true
- fi
+ -S) backupsuffix="$2"
+ shift;;

-# Make a temp file name in the proper directory.
+ -t)
+ is_target_a_directory=always
+ dst_arg=$2
+ # Protect names problematic for 'test' and other utilities.
+ case $dst_arg in
+ -* | [=\(\)!]) dst_arg=./$dst_arg;;
+ esac
+ shift;;

- dsttmp=$dstdir/#inst.$$#
+ -T) is_target_a_directory=never;;

-# Move or copy the file name to the temp name
+ --version) echo "$0 $scriptversion"; exit $?;;

- $doit $instcmd $src $dsttmp &&
+ --) shift
+ break;;

- trap "rm -f ${dsttmp}" 0 &&
+ -*) echo "$0: invalid option: $1" >&2
+ exit 1;;

-# and set any options; do chmod last to preserve setuid bits
+ *) break;;
+ esac
+ shift
+done

-# If any of these fail, we abort the whole thing. If we want to
-# ignore errors from any of these, just make sure not to ignore
-# errors from the above "$doit $instcmd $src $dsttmp" command.
+# We allow the use of options -d and -T together, by making -d
+# take the precedence; this is for compatibility with GNU install.

- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
+if test -n "$dir_arg"; then
+ if test -n "$dst_arg"; then
+ echo "$0: target directory not allowed when installing a directory." >&2
+ exit 1
+ fi
+fi

-# Now rename the file to the real destination.
+if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
+ # When -d is used, all remaining arguments are directories to create.
+ # When -t is used, the destination is already specified.
+ # Otherwise, the last argument is the destination. Remove it from $@.
+ for arg
+ do
+ if test -n "$dst_arg"; then
+ # $@ is not empty: it contains at least $arg.
+ set fnord "$@" "$dst_arg"
+ shift # fnord
+ fi
+ shift # arg
+ dst_arg=$arg
+ # Protect names problematic for 'test' and other utilities.
+ case $dst_arg in
+ -* | [=\(\)!]) dst_arg=./$dst_arg;;
+ esac
+ done
+fi

- $doit $rmcmd -f $dstdir/$dstfile &&
- $doit $mvcmd $dsttmp $dstdir/$dstfile
+if test $# -eq 0; then
+ if test -z "$dir_arg"; then
+ echo "$0: no input file specified." >&2
+ exit 1
+ fi
+ # It's OK to call 'install-sh -d' without argument.
+ # This can happen when creating conditional directories.
+ exit 0
+fi

-fi &&
+if test -z "$dir_arg"; then
+ if test $# -gt 1 || test "$is_target_a_directory" = always; then
+ if test ! -d "$dst_arg"; then
+ echo "$0: $dst_arg: Is not a directory." >&2
+ exit 1
+ fi
+ fi
+fi
+
+if test -z "$dir_arg"; then
+ do_exit='(exit $ret); exit $ret'
+ trap "ret=129; $do_exit" 1
+ trap "ret=130; $do_exit" 2
+ trap "ret=141; $do_exit" 13
+ trap "ret=143; $do_exit" 15
+
+ # Set umask so as not to create temps with too-generous modes.
+ # However, 'strip' requires both read and write access to temps.
+ case $mode in
+ # Optimize common cases.
+ *644) cp_umask=133;;
+ *755) cp_umask=22;;
+
+ *[0-7])
+ if test -z "$stripcmd"; then
+ u_plus_rw=
+ else
+ u_plus_rw='% 200'
+ fi
+ cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
+ *)
+ if test -z "$stripcmd"; then
+ u_plus_rw=
+ else
+ u_plus_rw=,u+rw
+ fi
+ cp_umask=$mode$u_plus_rw;;
+ esac
+fi

+for src
+do
+ # Protect names problematic for 'test' and other utilities.
+ case $src in
+ -* | [=\(\)!]) src=./$src;;
+ esac
+
+ if test -n "$dir_arg"; then
+ dst=$src
+ dstdir=$dst
+ test -d "$dstdir"
+ dstdir_status=$?
+ # Don't chown directories that already exist.
+ if test $dstdir_status = 0; then
+ chowncmd=""
+ fi
+ else
+
+ # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
+ # might cause directories to be created, which would be especially bad
+ # if $src (and thus $dsttmp) contains '*'.
+ if test ! -f "$src" && test ! -d "$src"; then
+ echo "$0: $src does not exist." >&2
+ exit 1
+ fi
+
+ if test -z "$dst_arg"; then
+ echo "$0: no destination specified." >&2
+ exit 1
+ fi
+ dst=$dst_arg
+
+ # If destination is a directory, append the input filename.
+ if test -d "$dst"; then
+ if test "$is_target_a_directory" = never; then
+ echo "$0: $dst_arg: Is a directory" >&2
+ exit 1
+ fi
+ dstdir=$dst
+ dstbase=`basename "$src"`
+ case $dst in
+ */) dst=$dst$dstbase;;
+ *) dst=$dst/$dstbase;;
+ esac
+ dstdir_status=0
+ else
+ dstdir=`dirname "$dst"`
+ test -d "$dstdir"
+ dstdir_status=$?
+ fi
+ fi
+
+ case $dstdir in
+ */) dstdirslash=$dstdir;;
+ *) dstdirslash=$dstdir/;;
+ esac
+
+ obsolete_mkdir_used=false
+
+ if test $dstdir_status != 0; then
+ case $posix_mkdir in
+ '')
+ # With -d, create the new directory with the user-specified mode.
+ # Otherwise, rely on $mkdir_umask.
+ if test -n "$dir_arg"; then
+ mkdir_mode=-m$mode
+ else
+ mkdir_mode=
+ fi
+
+ posix_mkdir=false
+ # The $RANDOM variable is not portable (e.g., dash). Use it
+ # here however when possible just to lower collision chance.
+ tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+
+ trap '
+ ret=$?
+ rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null
+ exit $ret
+ ' 0
+
+ # Because "mkdir -p" follows existing symlinks and we likely work
+ # directly in world-writeable /tmp, make sure that the '$tmpdir'
+ # directory is successfully created first before we actually test
+ # 'mkdir -p'.
+ if (umask $mkdir_umask &&
+ $mkdirprog $mkdir_mode "$tmpdir" &&
+ exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
+ then
+ if test -z "$dir_arg" || {
+ # Check for POSIX incompatibilities with -m.
+ # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+ # other-writable bit of parent directory when it shouldn't.
+ # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+ test_tmpdir="$tmpdir/a"
+ ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
+ case $ls_ld_tmpdir in
+ d????-?r-*) different_mode=700;;
+ d????-?--*) different_mode=755;;
+ *) false;;
+ esac &&
+ $mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
+ ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
+ test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+ }
+ }
+ then posix_mkdir=:
+ fi
+ rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
+ else
+ # Remove any dirs left behind by ancient mkdir implementations.
+ rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
+ fi
+ trap '' 0;;
+ esac
+
+ if
+ $posix_mkdir && (
+ umask $mkdir_umask &&
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+ )
+ then :
+ else
+
+ # mkdir does not conform to POSIX,
+ # or it failed possibly due to a race condition. Create the
+ # directory the slow way, step by step, checking for races as we go.
+
+ case $dstdir in
+ /*) prefix='/';;
+ [-=\(\)!]*) prefix='./';;
+ *) prefix='';;
+ esac
+
+ oIFS=$IFS
+ IFS=/
+ set -f
+ set fnord $dstdir
+ shift
+ set +f
+ IFS=$oIFS
+
+ prefixes=
+
+ for d
+ do
+ test X"$d" = X && continue
+
+ prefix=$prefix$d
+ if test -d "$prefix"; then
+ prefixes=
+ else
+ if $posix_mkdir; then
+ (umask $mkdir_umask &&
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+ # Don't fail if two instances are running concurrently.
+ test -d "$prefix" || exit 1
+ else
+ case $prefix in
+ *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) qprefix=$prefix;;
+ esac
+ prefixes="$prefixes '$qprefix'"
+ fi
+ fi
+ prefix=$prefix/
+ done
+
+ if test -n "$prefixes"; then
+ # Don't fail if two instances are running concurrently.
+ (umask $mkdir_umask &&
+ eval "\$doit_exec \$mkdirprog $prefixes") ||
+ test -d "$dstdir" || exit 1
+ obsolete_mkdir_used=true
+ fi
+ fi
+ fi
+
+ if test -n "$dir_arg"; then
+ { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
+ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
+ { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
+ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
+ else
+
+ # Make a couple of temp file names in the proper directory.
+ dsttmp=${dstdirslash}_inst.$$_
+ rmtmp=${dstdirslash}_rm.$$_
+
+ # Trap to clean up those temp files at exit.
+ trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
+
+ # Copy the file name to the temp name.
+ (umask $cp_umask &&
+ { test -z "$stripcmd" || {
+ # Create $dsttmp read-write so that cp doesn't create it read-only,
+ # which would cause strip to fail.
+ if test -z "$doit"; then
+ : >"$dsttmp" # No need to fork-exec 'touch'.
+ else
+ $doit touch "$dsttmp"
+ fi
+ }
+ } &&
+ $doit_exec $cpprog "$src" "$dsttmp") &&
+
+ # and set any options; do chmod last to preserve setuid bits.
+ #
+ # If any of these fail, we abort the whole thing. If we want to
+ # ignore errors from any of these, just make sure not to ignore
+ # errors from the above "$doit $cpprog $src $dsttmp" command.
+ #
+ { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
+ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
+ { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
+ { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
+
+ # If -C, don't bother to copy if it wouldn't change the file.
+ if $copy_on_change &&
+ old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
+ new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
+ set -f &&
+ set X $old && old=:$2:$4:$5:$6 &&
+ set X $new && new=:$2:$4:$5:$6 &&
+ set +f &&
+ test "$old" = "$new" &&
+ $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
+ then
+ rm -f "$dsttmp"
+ else
+ # If $backupsuffix is set, and the file being installed
+ # already exists, attempt a backup. Don't worry if it fails,
+ # e.g., if mv doesn't support -f.
+ if test -n "$backupsuffix" && test -f "$dst"; then
+ $doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null
+ fi
+
+ # Rename the file to the real destination.
+ $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
+
+ # The rename failed, perhaps because mv can't rename something else
+ # to itself, or perhaps because mv is so ancient that it does not
+ # support -f.
+ {
+ # Now remove or move aside any old file at destination location.
+ # We try this two ways since rm can't unlink itself on some
+ # systems and the destination file might be busy for other
+ # reasons. In this case, the final cleanup might fail but the new
+ # file should still install successfully.
+ {
+ test ! -f "$dst" ||
+ $doit $rmcmd "$dst" 2>/dev/null ||
+ { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+ { $doit $rmcmd "$rmtmp" 2>/dev/null; :; }
+ } ||
+ { echo "$0: cannot unlink or rename $dst" >&2
+ (exit 1); exit 1
+ }
+ } &&
+
+ # Now rename the file to the real destination.
+ $doit $mvcmd "$dsttmp" "$dst"
+ }
+ fi || exit 1
+
+ trap '' 0
+ fi
+done

-exit 0
+# Local variables:
+# eval: (add-hook 'before-save-hook 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC0"
+# time-stamp-end: "; # UTC"
+# End:
--
2.39.0

2023-01-21 20:38:33

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 35/38] misc/tune2fs: fix -Wunused-variable warnings in handle_fslabel()

From: Eric Biggers <[email protected]>

These warnings show up in non-Linux builds. To fix them, only declare
local variables when they are needed.

While we're here, also make handle_fslabel() static.

Signed-off-by: Eric Biggers <[email protected]>
---
misc/tune2fs.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index 7937b8b56..d3258149e 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -3082,14 +3082,15 @@ fs_update_journal_user(struct ext2_super_block *sb, __u8 old_uuid[UUID_SIZE])
* 1 on error
* -1 when the old method should be used
*/
-int handle_fslabel(int setlabel) {
+static int handle_fslabel(int setlabel)
+{
+#ifdef __linux__
errcode_t ret;
int mnt_flags, fd;
char label[FSLABEL_MAX];
int maxlen = FSLABEL_MAX - 1;
char mntpt[PATH_MAX + 1];

-#ifdef __linux__
ret = ext2fs_check_mount_point(device_name, &mnt_flags,
mntpt, sizeof(mntpt));
if (ret) {
--
2.39.0

2023-01-21 20:38:33

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 34/38] misc/tune2fs: fix setting fsuuid::fsu_len

From: Eric Biggers <[email protected]>

Minus does not mean equals.

Besides fixing an obvious bug, this avoids the following compiler
warning with clang -Wall:

tune2fs.c:3625:20: warning: expression result unused [-Wunused-value]
fsuuid->fsu_len - UUID_SIZE;
~~~~~~~~~~~~~~~ ^ ~~~~~~~~~

Fixes: a83e199da0ca ("tune2fs: Add support for get/set UUID ioctls.")
Reviewed-by: Jeremy Bongio <[email protected]>
Reviewed-by: Lukas Czerner <[email protected]>
Signed-off-by: Eric Biggers <[email protected]>
---
misc/tune2fs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index 088f87e53..7937b8b56 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -3622,7 +3622,7 @@ _("Warning: The journal is dirty. You may wish to replay the journal like:\n\n"
ret = -1;
#ifdef __linux__
if (fsuuid) {
- fsuuid->fsu_len - UUID_SIZE;
+ fsuuid->fsu_len = UUID_SIZE;
fsuuid->fsu_flags = 0;
memcpy(&fsuuid->fsu_uuid, new_uuid, UUID_SIZE);
ret = ioctl(fd, EXT4_IOC_SETFSUUID, fsuuid);
--
2.39.0

2023-01-21 20:38:35

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 36/38] misc/util.c: enable MinGW alarm() when building for Windows

From: Eric Biggers <[email protected]>

To compile for Windows, this file needs MinGW's implementation of
alarm(). To expose that definition, some macros must be defined before
including the system headers. This was done in Android.bp, but it was
not done in the autotools-based build system. Define these macros in
the source file itself so that all build systems work.

Signed-off-by: Eric Biggers <[email protected]>
---
misc/Android.bp | 2 --
misc/util.c | 5 +++++
2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/misc/Android.bp b/misc/Android.bp
index 2baeac2ad..2b1620ac6 100644
--- a/misc/Android.bp
+++ b/misc/Android.bp
@@ -83,8 +83,6 @@ cc_binary {
windows: {
include_dirs: [ "external/e2fsprogs/include/mingw" ],
cflags: [
- "-D_POSIX",
- "-D__USE_MINGW_ALARM",
// mke2fs.c has a warning from gcc which cannot be suppressed:
// passing argument 3 of 'ext2fs_get_device_size' from
// incompatible pointer type
diff --git a/misc/util.c b/misc/util.c
index e84ebab5b..3e83169f1 100644
--- a/misc/util.c
+++ b/misc/util.c
@@ -16,6 +16,11 @@
#define _LARGEFILE64_SOURCE
#endif

+#ifdef _WIN32
+#define _POSIX
+#define __USE_MINGW_ALARM
+#endif
+
#include "config.h"
#include <fcntl.h>
#include <setjmp.h>
--
2.39.0

2023-01-21 20:38:40

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 37/38] resize2fs: remove unused variable from adjust_superblock()

From: Eric Biggers <[email protected]>

In adjust_superblock(), the 'group_block' variable is declared and set,
but it is never actually used. Remove it.

This addresses the following compiler warning with clang -Wall:

resize2fs.c:1119:11: warning: variable 'group_block' set but not used [-Wunused-but-set-variable]
blk64_t group_block;
^
Reviewed-by: Lukas Czerner <[email protected]>
Signed-off-by: Eric Biggers <[email protected]>
---
resize/resize2fs.c | 4 ----
1 file changed, 4 deletions(-)

diff --git a/resize/resize2fs.c b/resize/resize2fs.c
index 243cd777d..5eeb7d446 100644
--- a/resize/resize2fs.c
+++ b/resize/resize2fs.c
@@ -1116,7 +1116,6 @@ static errcode_t adjust_superblock(ext2_resize_t rfs, blk64_t new_size)
ext2_filsys fs = rfs->new_fs;
int adj = 0;
errcode_t retval;
- blk64_t group_block;
unsigned long i;
unsigned long max_group;

@@ -1181,8 +1180,6 @@ static errcode_t adjust_superblock(ext2_resize_t rfs, blk64_t new_size)
goto errout;

memset(rfs->itable_buf, 0, fs->blocksize * fs->inode_blocks_per_group);
- group_block = ext2fs_group_first_block2(fs,
- rfs->old_fs->group_desc_count);
adj = rfs->old_fs->group_desc_count;
max_group = fs->group_desc_count - adj;
if (rfs->progress) {
@@ -1209,7 +1206,6 @@ static errcode_t adjust_superblock(ext2_resize_t rfs, blk64_t new_size)
if (retval)
goto errout;
}
- group_block += fs->super->s_blocks_per_group;
}
io_channel_flush(fs->io);
retval = 0;
--
2.39.0

2023-01-24 18:21:33

by Andreas Dilger

[permalink] [raw]
Subject: Re: [PATCH 07/38] lib/blkid: remove 32-bit x86 byteswap assembly

On Jan 21, 2023, at 1:31 PM, Eric Biggers <[email protected]> wrote:
>
> From: Eric Biggers <[email protected]>
>
> libblkid contains 32-bit x86 assembly language implementations of 16-bit
> and 32-bit byteswaps. However, modern compilers can easily generate the
> bswap instruction automatically from the corresponding C expression.
> And no one ever bothered to add assembly for x86_64 or other
> architectures, anyway. So let's just remove this outdated code, which
> was maybe useful in the 90s, but is no longer useful.

I'm not sure what Ted thinks about this, but it might be time to remove
the libblkid implementation in e2fsprogs, and instead depend on the
newer version in util-linux? However, removing it from e2fsprogs
would add an external dependency on util-linux for non-linux platforms,
though AFAIK it should still be possible to build e2fsprogs without it.

That said, I think the current patch looks fine, and you can add:

Reviewed-by: Andreas Dilger <[email protected]>

Cheers, Andreas

>
> Signed-off-by: Eric Biggers <[email protected]>
> ---
> lib/blkid/probe.h | 43 -------------------------------------------
> 1 file changed, 43 deletions(-)
>
> diff --git a/lib/blkid/probe.h b/lib/blkid/probe.h
> index dea4081d0..063a5b5c0 100644
> --- a/lib/blkid/probe.h
> +++ b/lib/blkid/probe.h
> @@ -814,46 +814,6 @@ struct exfat_entry_label {
> #define _INLINE_ static inline
> #endif
>
> -static __u16 blkid_swab16(__u16 val);
> -static __u32 blkid_swab32(__u32 val);
> -static __u64 blkid_swab64(__u64 val);
> -
> -#if ((defined __GNUC__) && \
> - (defined(__i386__) || defined(__i486__) || defined(__i586__)))
> -
> -#define _BLKID_HAVE_ASM_BITOPS_
> -
> -_INLINE_ __u32 blkid_swab32(__u32 val)
> -{
> -#ifdef EXT2FS_REQUIRE_486
> - __asm__("bswap %0" : "=r" (val) : "0" (val));
> -#else
> - __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */
> - "rorl $16,%0\n\t" /* swap words */
> - "xchgb %b0,%h0" /* swap higher bytes */
> - :"=q" (val)
> - : "0" (val));
> -#endif
> - return val;
> -}
> -
> -_INLINE_ __u16 blkid_swab16(__u16 val)
> -{
> - __asm__("xchgb %b0,%h0" /* swap bytes */ \
> - : "=q" (val) \
> - : "0" (val)); \
> - return val;
> -}
> -
> -_INLINE_ __u64 blkid_swab64(__u64 val)
> -{
> - return (blkid_swab32(val >> 32) |
> - (((__u64) blkid_swab32(val & 0xFFFFFFFFUL)) << 32));
> -}
> -#endif
> -
> -#if !defined(_BLKID_HAVE_ASM_BITOPS_)
> -
> _INLINE_ __u16 blkid_swab16(__u16 val)
> {
> return (val >> 8) | (val << 8);
> @@ -870,9 +830,6 @@ _INLINE_ __u64 blkid_swab64(__u64 val)
> return (blkid_swab32(val >> 32) |
> (((__u64) blkid_swab32(val & 0xFFFFFFFFUL)) << 32));
> }
> -#endif
> -
> -
>
> #ifdef WORDS_BIGENDIAN
> #define blkid_le16(x) blkid_swab16(x)
> --
> 2.39.0
>


Cheers, Andreas






Attachments:
signature.asc (873.00 B)
Message signed with OpenPGP

2023-01-24 20:59:24

by Andreas Dilger

[permalink] [raw]
Subject: Re: [PATCH 00/38] e2fsprogs: misc fixes, and add a GitHub Actions file

On Jan 21, 2023, at 1:31 PM, Eric Biggers <[email protected]> wrote:
>
> The last patch of this series adds a workflow file for GitHub Actions
> that builds and tests e2fsprogs on Ubuntu, macOS, and Windows. It's
> enforced that the build does not produce warnings with -Wall.
>
> (For now, the Windows build is much more basic than the others; only
> mke2fs is built, and the unit tests are not run.)
>
> The workflow will run on pushes to any fork of e2fsprogs that has GitHub
> Actions enabled. I'm hoping that Ted will enable it for the "official"
> fork at https://github.com/tytso/e2fsprogs, but anyone can use it in
> their own fork too. The results for this patch series are at
> https://github.com/ebiggers/e2fsprogs/actions/runs/3976382057
>
> As a prerequisite to actually getting everything to pass, patches 1-37
> of this series fix a large number of miscellaneous issues, mainly
> pertaining to warnings with -Wall or to the Windows build.

Thanks in advance for this patch series. I have a kick at the cat for
e2fsprogs build/test warnings occasionally, but getting this into a
Github CI setup should keep them out of the woodwork.

I'll try to have a pass through all of the patches, but most of them
seem pretty straight forward.

Cheers, Andreas

> Some patches in this series I've already sent out individually. This
> series supersedes all my previous patches.
>
> Eric Biggers (38):
> configure.ac: only use Windows I/O manager on native Windows
> configure.ac: disable tdb by default on Windows
> configure.ac: automatically add include/mingw/ headers
> configure: regenerate
> config/install-sh: update to latest version
> lib, misc: eliminate dependency on Winsock
> lib/blkid: remove 32-bit x86 byteswap assembly
> lib/blkid: fix unaligned access to hfs_mdb
> lib/blkid: fix -Wunused-variable warning in blkid_get_dev_size()
> lib/blkid: suppress -Wunused-result warning in blkid_flush_cache()
> lib/blkid: suppress -Wstringop-truncation warning in blkid_strndup()
> lib/e2p: fix a -Wunused-variable warning in getflags()
> lib/{e2p,ss}: remove manual declarations of errno
> lib/et: fix "unused variable" warnings when !HAVE_FCNTL
> lib/ext2fs: remove 32-bit x86 bitops assembly
> lib/ext2fs: consistently use #ifdefs in ext2fs_print_bmap_statistics()
> lib/ext2fs: remove unused variable in ext2fs_xattrs_read_inode()
> lib/ext2fs: fix a printf format specifier in file_test()
> lib/ext2fs: fix two compiler warnings in windows_io.c
> lib/ext2fs: fix a -Wpointer-sign warning in ext2fs_mmp_start()
> lib/{ext2fs,support}: fix 32-bit Windows build
> lib/ss: fix 'make install' by creating man1dir
> lib/support: remove unused label in get_devname()
> lib/support: clean up definition of flags_array
> lib/uuid: remove conflicting Windows implementation of gettimeofday()
> e2fsck: use real functions for kernel slab functions
> misc/create_inode: fix -Wunused-variable warnings in __populate_fs()
> misc/create_inode: simplify logic in scandir()
> misc/e4defrag: fix -Wstringop-truncation warnings
> misc/fuse2fs: avoid error-prone strncpy() pattern
> misc/mk_hugefiles: simplify get_partition_start()
> misc/mke2fs: fix Windows build
> misc/mke2fs: fix a -Wunused-variable warning in PRS()
> misc/tune2fs: fix setting fsuuid::fsu_len
> misc/tune2fs: fix -Wunused-variable warnings in handle_fslabel()
> misc/util.c: enable MinGW alarm() when building for Windows
> resize2fs: remove unused variable from adjust_superblock()
> Add a configuration file for GitHub Actions
>
> .github/workflows/ci.yml | 116 ++++++
> aclocal.m4 | 180 +++++----
> config/install-sh | 683 ++++++++++++++++++++++++----------
> configure | 105 ++++--
> configure.ac | 50 ++-
> e2fsck/jfs_user.h | 62 ++-
> include/mingw/arpa/inet.h | 5 +
> include/mingw/sys/sysmacros.h | 8 +-
> lib/blkid/Android.bp | 1 -
> lib/blkid/devno.c | 10 +
> lib/blkid/getsize.c | 2 +-
> lib/blkid/probe.c | 10 +-
> lib/blkid/probe.h | 43 ---
> lib/blkid/save.c | 8 +
> lib/config.h.in | 100 ++++-
> lib/e2p/Android.bp | 4 -
> lib/e2p/fgetversion.c | 2 -
> lib/e2p/fsetversion.c | 1 -
> lib/e2p/getflags.c | 3 +-
> lib/e2p/getversion.c | 1 -
> lib/e2p/setversion.c | 1 -
> lib/et/Android.bp | 3 -
> lib/et/error_message.c | 10 +-
> lib/ext2fs/Android.bp | 2 -
> lib/ext2fs/bitops.c | 14 +-
> lib/ext2fs/bitops.h | 97 -----
> lib/ext2fs/ext2_io.h | 2 +
> lib/ext2fs/ext_attr.c | 2 -
> lib/ext2fs/gen_bitmap64.c | 6 +-
> lib/ext2fs/getsectsize.c | 12 +-
> lib/ext2fs/inline_data.c | 2 +-
> lib/ext2fs/jfs_compat.h | 4 -
> lib/ext2fs/mmp.c | 2 +-
> lib/ext2fs/windows_io.c | 12 +-
> lib/ss/Makefile.in | 5 +-
> lib/ss/execute_cmd.c | 2 -
> lib/ss/help.c | 2 -
> lib/ss/pager.c | 2 -
> lib/support/devname.c | 1 -
> lib/support/plausible.c | 7 +-
> lib/support/print_fs_flags.c | 60 +--
> lib/uuid/gen_uuid.c | 21 --
> misc/Android.bp | 3 -
> misc/create_inode.c | 36 +-
> misc/e4defrag.c | 30 +-
> misc/fuse2fs.c | 5 +-
> misc/mk_hugefiles.c | 134 +------
> misc/mke2fs.c | 22 +-
> misc/tune2fs.c | 7 +-
> misc/util.c | 5 +
> resize/resize2fs.c | 4 -
> util/android_config.h | 1 -
> util/subst.c | 4 +-
> 53 files changed, 1102 insertions(+), 812 deletions(-)
> create mode 100644 .github/workflows/ci.yml
> create mode 100644 include/mingw/arpa/inet.h
>
>
> base-commit: aad34909b6648579f42dade5af5b46821aa4d845
> --
> 2.39.0
>


Cheers, Andreas






Attachments:
signature.asc (873.00 B)
Message signed with OpenPGP