From 60ada63e59393d1e82494bf07436887241f52644 Mon Sep 17 00:00:00 2001 From: Andrew Price Date: May 13 2022 16:52:57 +0000 Subject: [PATCH 1/6] gfs2l: Remove redundant #include Signed-off-by: Andrew Price --- diff --git a/gfs2/libgfs2/lang.c b/gfs2/libgfs2/lang.c index 0570d8d..96ba014 100644 --- a/gfs2/libgfs2/lang.c +++ b/gfs2/libgfs2/lang.c @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include From 4503ce87bf90179bd5fe43387fd30931545f5251 Mon Sep 17 00:00:00 2001 From: Andrew Price Date: May 13 2022 16:55:31 +0000 Subject: [PATCH 2/6] Don't use glibc internal symbols Improve portability by removing uses of some non-standard symbols. Signed-off-by: Andrew Price --- diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h index fc1b273..77753bf 100644 --- a/gfs2/libgfs2/libgfs2.h +++ b/gfs2/libgfs2/libgfs2.h @@ -17,7 +17,9 @@ #include "osi_list.h" #include "osi_tree.h" -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #if __BYTE_ORDER == __BIG_ENDIAN @@ -795,6 +797,8 @@ extern void lgfs2_dirent_out(struct lgfs2_dirent *d, void *dep); extern void lgfs2_leaf_in(struct lgfs2_leaf *lf, void *lfp); extern void lgfs2_leaf_out(struct lgfs2_leaf *lf, void *lfp); -__END_DECLS +#ifdef __cplusplus +} +#endif #endif /* __LIBGFS2_DOT_H__ */ diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c index 524efe1..66081a2 100644 --- a/gfs2/mkfs/main_grow.c +++ b/gfs2/mkfs/main_grow.c @@ -45,7 +45,7 @@ extern int rename2system(struct lgfs2_sbd *sdp, char *new_dir, char *new_name); static int discard_blocks(int fd, uint64_t start, uint64_t len) { - __uint64_t range[2] = { start, len }; + uint64_t range[2] = { start, len }; if (ioctl(fd, BLKDISCARD, &range) < 0) return errno; From cdf28ff04c5b023102415346b2cd9be772669e78 Mon Sep 17 00:00:00 2001 From: Andrew Price Date: May 13 2022 17:00:50 +0000 Subject: [PATCH 3/6] Add LTLIBINTL to LDADD where needed In environments that require explicit linking to libintl, $(LTLIBINTL) expands to the appropriate library. Signed-off-by: Andrew Price --- diff --git a/gfs2/convert/Makefile.am b/gfs2/convert/Makefile.am index 2f54590..88dfea9 100644 --- a/gfs2/convert/Makefile.am +++ b/gfs2/convert/Makefile.am @@ -9,6 +9,7 @@ gfs2_convert_CPPFLAGS = \ gfs2_convert_LDADD = \ $(top_builddir)/gfs2/libgfs2/libgfs2.la \ + $(LTLIBINTL) \ $(uuid_LIBS) if HAVE_CHECK diff --git a/gfs2/fsck/Makefile.am b/gfs2/fsck/Makefile.am index eeae16b..05aaedc 100644 --- a/gfs2/fsck/Makefile.am +++ b/gfs2/fsck/Makefile.am @@ -38,6 +38,7 @@ fsck_gfs2_CPPFLAGS = \ fsck_gfs2_LDADD = \ $(top_builddir)/gfs2/libgfs2/libgfs2.la \ + $(LTLIBINTL) \ $(uuid_LIBS) if HAVE_CHECK diff --git a/gfs2/mkfs/Makefile.am b/gfs2/mkfs/Makefile.am index 41c535c..aed45b7 100644 --- a/gfs2/mkfs/Makefile.am +++ b/gfs2/mkfs/Makefile.am @@ -29,6 +29,7 @@ mkfs_gfs2_CFLAGS = \ $(uuid_CFLAGS) mkfs_gfs2_LDADD = \ $(top_builddir)/gfs2/libgfs2/libgfs2.la \ + $(LTLIBINTL) \ $(blkid_LIBS) \ $(uuid_LIBS) @@ -40,6 +41,7 @@ gfs2_grow_CPPFLAGS = $(COMMON_CPPFLAGS) gfs2_grow_CFLAGS = $(blkid_CFLAGS) gfs2_grow_LDADD = \ $(top_builddir)/gfs2/libgfs2/libgfs2.la \ + $(LTLIBINTL) \ $(blkid_LIBS) \ $(uuid_LIBS) @@ -50,6 +52,7 @@ gfs2_jadd_SOURCES = \ gfs2_jadd_CPPFLAGS = $(COMMON_CPPFLAGS) gfs2_jadd_LDADD = \ $(top_builddir)/gfs2/libgfs2/libgfs2.la \ + $(LTLIBINTL) \ $(uuid_LIBS) if HAVE_CHECK diff --git a/gfs2/tune/Makefile.am b/gfs2/tune/Makefile.am index 6c4bbe1..62f6a63 100644 --- a/gfs2/tune/Makefile.am +++ b/gfs2/tune/Makefile.am @@ -15,6 +15,7 @@ tunegfs2_CFLAGS = \ $(uuid_CFLAGS) tunegfs2_LDADD = \ $(top_builddir)/gfs2/libgfs2/libgfs2.la \ + $(LTLIBINTL) \ $(uuid_LIBS) if HAVE_CHECK From 99ba04bcc3224401e52762267cd749995434e4c5 Mon Sep 17 00:00:00 2001 From: Andrew Price Date: May 13 2022 17:03:13 +0000 Subject: [PATCH 4/6] fsck.gfs2: Use atexit() where on_exit() is not available atexit() is standard and on_exit() is not, but atexit() doesn't allow us to access the exit status, so use atexit() only where on_exit() is not available. Signed-off-by: Andrew Price --- diff --git a/configure.ac b/configure.ac index ba80c2a..03a9e73 100644 --- a/configure.ac +++ b/configure.ac @@ -100,6 +100,7 @@ AC_ARG_ENABLE([gprof], AC_HELP_STRING([--enable-gprof],[enable profiling instrumentation [default=no]]), [], [enable_gprof="no"]) +AC_CHECK_FUNCS([on_exit]) # We use the Check framework for unit tests PKG_CHECK_MODULES([check], [check >= 0.10.0], diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c index ed61449..ed6b068 100644 --- a/gfs2/fsck/main.c +++ b/gfs2/fsck/main.c @@ -258,10 +258,21 @@ static int fsck_pass(const struct fsck_pass *p, struct lgfs2_sbd *sdp) return 0; } +/* + * on_exit() is non-standard but useful for reporting the exit status if it's + * available. + */ +#ifdef HAVE_ON_EXIT static void exitlog(int status, void *unused) { syslog(LOG_INFO, "exit: %d", status); } +#else +static void exitlog(void) +{ + syslog(LOG_INFO, "exit."); +} +#endif static void startlog(int argc, char **argv) { @@ -304,7 +315,11 @@ int main(int argc, char **argv) openlog("fsck.gfs2", LOG_CONS|LOG_PID, LOG_USER); startlog(argc - 1, &argv[1]); +#ifdef HAVE_ON_EXIT on_exit(exitlog, NULL); +#else + atexit(exitlog); +#endif memset(sdp, 0, sizeof(*sdp)); From 1ca1b4870e1a1f96bc20d49d30a8e475ba2425ff Mon Sep 17 00:00:00 2001 From: Andrew Price Date: May 13 2022 17:07:24 +0000 Subject: [PATCH 5/6] mkfs.gfs2: Use realpath() instead of canonicalize_file_name() canonicalize_file_name() is non-standard. Signed-off-by: Andrew Price --- diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c index 07e0bef..37ed5d0 100644 --- a/gfs2/mkfs/main_mkfs.c +++ b/gfs2/mkfs/main_mkfs.c @@ -667,7 +667,7 @@ static int warn_of_destruction(const char *path) return -1; } if (S_ISLNK(lnkstat.st_mode)) { - abspath = canonicalize_file_name(path); + abspath = realpath(path, NULL); if (abspath == NULL) { perror(_("Could not find the absolute path of the device")); return -1; From aa713bc533ef187e293559b76126140cd859d0c8 Mon Sep 17 00:00:00 2001 From: Andrew Price Date: May 16 2022 13:49:37 +0000 Subject: [PATCH 6/6] Configure script updates Fixes some complaints about obsolete autoconf symbols. We still get: configure.ac:56: warning: The macro `AC_PROG_CC_C99' is obsolete. Using AC_PROG_CC only is meant to replace this but removing the AC_PROG_CC_C99 breaks the build on RHEL7 so it's going to stay for now. Signed-off-by: Andrew Price --- diff --git a/configure.ac b/configure.ac index 03a9e73..8774b15 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ # Process this file with autoconf to produce a configure script. -AC_PREREQ([2.63]) +AC_PREREQ([2.69]) AC_INIT([gfs2-utils], [3.4.1.1.dev], [cluster-devel@redhat.com]) AM_INIT_AUTOMAKE([-Wno-portability]) AM_SILENT_RULES([yes]) @@ -13,13 +13,13 @@ AC_CONFIG_SRCDIR([gfs2/libgfs2/libgfs2.h]) AC_CONFIG_HEADERS([make/clusterautoconfig.h]) AC_CANONICAL_HOST -AC_PROG_LIBTOOL +LT_INIT AC_LANG([C]) #i18n support AM_GNU_GETTEXT([external]) -AM_GNU_GETTEXT_VERSION([0.18]) +AM_GNU_GETTEXT_VERSION([0.19]) # Sanitize path @@ -61,7 +61,7 @@ AM_PROG_CC_C_O AC_PROG_LN_S AC_PROG_INSTALL AC_PROG_MAKE_SET -AC_PROG_LEX +AC_PROG_LEX([noyywrap]) test "$LEX" != "flex" && AC_MSG_ERROR([flex not found]) AC_CHECK_PROG([YACC], [bison], [bison -y]) test x"$YACC" = x && AC_MSG_ERROR([bison not found]) @@ -91,13 +91,13 @@ check_lib_no_libs() { # local options AC_ARG_ENABLE([debug], - AC_HELP_STRING([--enable-debug],[enable debug build [default=no]]), + AS_HELP_STRING([--enable-debug],[enable debug build [default=no]]), [], [enable_debug="no"]) AC_ARG_ENABLE([gcov], - AC_HELP_STRING([--enable-gcov],[enable coverage instrumentation [default=no]]), + AS_HELP_STRING([--enable-gcov],[enable coverage instrumentation [default=no]]), [], [enable_gcov="no"]) AC_ARG_ENABLE([gprof], - AC_HELP_STRING([--enable-gprof],[enable profiling instrumentation [default=no]]), + AS_HELP_STRING([--enable-gprof],[enable profiling instrumentation [default=no]]), [], [enable_gprof="no"]) AC_CHECK_FUNCS([on_exit])