Util-Linux package development
 help / color / mirror / Atom feed
* [PATCH 00/15] portability fixes in the mix (OSX)
@ 2016-02-18 13:12 Ruediger Meier
  2016-02-18 13:12 ` [PATCH 01/15] travis: minor cleanup Ruediger Meier
                   ` (14 more replies)
  0 siblings, 15 replies; 20+ messages in thread
From: Ruediger Meier @ 2016-02-18 13:12 UTC (permalink / raw)
  To: util-linux

From: Ruediger Meier <ruediger.meier@ga-group.nl>

also see github pull request #282
https://github.com/karelzak/util-linux/pull/282

This is a the first chunk of arbitrary cleanups and build fixes
mainly tested on OSX and FreeBSD.

FYI here I have some OSX build logs (with some more hacks included).
Maybe there are some interesting warnings to fix.
https://travis-ci.org/rudimeier/util-linux/builds/110071732

Ruediger Meier (15):
  travis: minor cleanup
  build-sys: portable usage of find command
  build-sys: check linker support for version scripts
  build-sys: fix [g]libtoolize version for OSX
  tests: fix ts_option helpers
  lib: rename strmode() and setmode()
  include: provide MAP_ANONYMOUS on OSX
  lib: define LOGIN_NAME_MAX fallback
  include: check for sys/sysmacros.h
  include: remove unused mntent.h
  lsns: use xcalloc()
  lib: remove unused variable
  lib: fix ismounted includes for FreeBSD
  libblkid: don't include endian.h
  include: fix sys/sysinfo.h

 .travis-functions.sh                  |  31 +++-----
 .travis.yml                           |   2 +
 autogen.sh                            |   2 +-
 configure.ac                          |   6 ++
 disk-utils/fsck.cramfs.c              |  10 +++
 disk-utils/fsck.minix.c               |   1 -
 disk-utils/mkfs.cramfs.c              |   8 ++
 disk-utils/mkfs.minix.c               |   1 -
 disk-utils/mkswap.c                   |   1 -
 disk-utils/raw.c                      |   2 +
 include/strutils.h                    |   2 +-
 lib/blkdev.c                          |   1 -
 lib/idcache.c                         |   4 +
 lib/ismounted.c                       |  11 ++-
 lib/monotonic.c                       |   2 +
 lib/strutils.c                        |   2 +-
 lib/timer.c                           |   1 -
 libblkid/src/Makemodule.am            |   4 +-
 libblkid/src/superblocks/drbdmanage.c |   2 +-
 libfdisk/src/Makemodule.am            |   4 +-
 libmount/src/Makemodule.am            |   4 +-
 libsmartcols/samples/tree.c           |   2 +-
 libsmartcols/src/Makemodule.am        |   4 +-
 libuuid/src/Makemodule.am             |   4 +-
 login-utils/login.c                   |   2 +
 login-utils/sulogin.c                 |   9 +++
 m4/ax_check_vscript.m4                | 142 ++++++++++++++++++++++++++++++++++
 misc-utils/lsblk.c                    |   2 +-
 misc-utils/namei.c                    |   6 +-
 sys-utils/lsipc.c                     |   6 +-
 sys-utils/lsns.c                      |   4 +-
 tests/functions.sh                    |   6 +-
 tests/run.sh                          |  11 ++-
 tests/ts/build-sys/config             |   2 +-
 tests/ts/cramfs/mkfs                  |   2 +-
 text-utils/ul.c                       |  10 +--
 tools/checkmans.sh                    |   2 +-
 37 files changed, 253 insertions(+), 62 deletions(-)
 create mode 100644 m4/ax_check_vscript.m4

-- 
1.8.4.5


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 01/15] travis: minor cleanup
  2016-02-18 13:12 [PATCH 00/15] portability fixes in the mix (OSX) Ruediger Meier
@ 2016-02-18 13:12 ` Ruediger Meier
  2016-02-18 13:12 ` [PATCH 02/15] build-sys: portable usage of find command Ruediger Meier
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Ruediger Meier @ 2016-02-18 13:12 UTC (permalink / raw)
  To: util-linux

From: Ruediger Meier <ruediger.meier@ga-group.nl>

 - print env for debugging
 - remove unused builddir stuff
 - avoid non-portable find/xargs usage

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
 .travis-functions.sh | 31 ++++++++++---------------------
 .travis.yml          |  2 ++
 2 files changed, 12 insertions(+), 21 deletions(-)

diff --git a/.travis-functions.sh b/.travis-functions.sh
index bef4597..3315a91 100755
--- a/.travis-functions.sh
+++ b/.travis-functions.sh
@@ -11,23 +11,14 @@ if [ ! -f "configure.ac" ]; then
 	return 1 || exit 1
 fi
 
-# some config settings
-MAKE="make -j4"
+## some config settings
+# travis docs say we get 1.5 CPUs
+MAKE="make -j2"
 DUMP_CONFIG_LOG="short"
 
-# We could test (exotic) out-of-tree build dirs using relative or abs paths.
-# After sourcing this script we are living in build dir. Tasks for source dir
-# have to use $SOURCE_DIR.
-SOURCE_DIR="."
-BUILD_DIR="."
-CONFIGURE="$SOURCE_DIR/configure"
-
-mkdir -p "$BUILD_DIR"
-cd "$BUILD_DIR" || return 1 || exit 1
-
-function configure_travis
+function xconfigure
 {
-	"$CONFIGURE" "$@"
+	./configure "$@"
 	err=$?
 	if [ "$DUMP_CONFIG_LOG" = "short" ]; then
 		grep -B1 -A10000 "^## Output variables" config.log | grep -v "_FALSE="
@@ -41,7 +32,7 @@ function check_nonroot
 {
 	local opts="$MAKE_CHECK_OPTS"
 
-	configure_travis \
+	xconfigure \
 		--disable-use-tty-group \
 		--with-python \
 		--enable-all-programs \
@@ -56,7 +47,7 @@ function check_root
 {
 	local opts="$MAKE_CHECK_OPTS --parallel=1"
 
-	configure_travis \
+	xconfigure \
 		--with-python \
 		--enable-all-programs \
 		|| return
@@ -68,7 +59,7 @@ function check_root
 
 function check_dist
 {
-	configure_travis \
+	xconfigure \
 		|| return
 	$MAKE distcheck || return
 }
@@ -98,14 +89,12 @@ function travis_install_script
 
 function travis_before_script
 {
-	pushd "$SOURCE_DIR" || return
 	set -o xtrace
 
 	./autogen.sh
 	ret=$?
 
 	set +o xtrace
-	popd
 	return $ret
 }
 
@@ -142,10 +131,10 @@ function travis_after_script
 	local tmp
 
 	# find diff dir from check as well as from distcheck
-	diff_dir=$(find -type d -a -name "diff" | grep "tests/diff" | head -n 1)
+	diff_dir=$(find . -type d -name "diff" | grep "tests/diff" | head -n 1)
 	if [ -d "$diff_dir" ]; then
 		tmp=$(find "$diff_dir" -type f | sort)
 		echo -en "dump test diffs:\n${tmp}\n"
-		echo "$tmp" | xargs -r cat
+		echo "$tmp" | xargs cat
 	fi
 }
diff --git a/.travis.yml b/.travis.yml
index 85a753d..e27adc4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -19,6 +19,8 @@ branches:
     - /^travis.*/
 
 before_install:
+  # print some host info
+  - env | grep -v "encrypted" | LC_ALL=C sort
   - $CC --version
   - which $CC
   # workaround clang not system wide, fail on sudo make install
-- 
1.8.4.5


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 02/15] build-sys: portable usage of find command
  2016-02-18 13:12 [PATCH 00/15] portability fixes in the mix (OSX) Ruediger Meier
  2016-02-18 13:12 ` [PATCH 01/15] travis: minor cleanup Ruediger Meier
@ 2016-02-18 13:12 ` Ruediger Meier
  2016-02-18 13:12 ` [PATCH 03/15] build-sys: check linker support for version scripts Ruediger Meier
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Ruediger Meier @ 2016-02-18 13:12 UTC (permalink / raw)
  To: util-linux

From: Ruediger Meier <ruediger.meier@ga-group.nl>

 - use dot instead of skipping search-path
 - avoid -perm /a+x
 - avoid -path

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
 tests/run.sh              | 11 +++++++++--
 tests/ts/build-sys/config |  2 +-
 tests/ts/cramfs/mkfs      |  2 +-
 tools/checkmans.sh        |  2 +-
 4 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/tests/run.sh b/tests/run.sh
index dca9c6c..03cd9f5 100755
--- a/tests/run.sh
+++ b/tests/run.sh
@@ -34,6 +34,13 @@ function num_cpus()
 	fi
 }
 
+function find_test_scripts()
+{
+	local searchdir="$1"
+	find "$searchdir" -type f -regex ".*/[^\.~]*" \
+		\( -perm -u=x -o -perm -g=x -o -perm -o=x \)
+}
+
 while [ -n "$1" ]; do
 	case "$1" in
 	--force)
@@ -117,7 +124,7 @@ if [ -n "$SUBTESTS" ]; then
 	# selected tests only
 	for s in $SUBTESTS; do
 		if [ -d "$top_srcdir/tests/ts/$s" ]; then
-			comps+=( $(find $top_srcdir/tests/ts/$s -type f -perm /a+x -regex ".*/[^\.~]*") )
+			comps+=( $(find_test_scripts "$top_srcdir/tests/ts/$s") ) || exit 1
 		else
 			echo "Unknown test component '$s'"
 			exit 1
@@ -129,7 +136,7 @@ else
 		exit 1
 	fi
 
-	comps=( $(find $top_srcdir/tests/ts/ -type f -perm /a+x -regex ".*/[^\.~]*") )
+	comps=( $(find_test_scripts "$top_srcdir/tests/ts") ) || exit 1
 fi
 
 if [ -n "$EXCLUDETESTS" ]; then
diff --git a/tests/ts/build-sys/config b/tests/ts/build-sys/config
index 15b3551..bc48c50 100755
--- a/tests/ts/build-sys/config
+++ b/tests/ts/build-sys/config
@@ -32,7 +32,7 @@ for conf in $config_gen_dir/config-gen.d/*.conf; do
 	./configure $opts &> /dev/null
 	make -j &> /dev/null
 
-	bins=$(find . -type f -perm /a+x | sort)
+	bins=$(find . -type f \( -perm -u=x -o -perm -g=x -o -perm -o=x \) | sort)
 	for b in $bins; do
 		libs=$(readelf --dynamic $b 2> /dev/null   | \
 			awk '/NEEDED/ { print $5 }' | \
diff --git a/tests/ts/cramfs/mkfs b/tests/ts/cramfs/mkfs
index 78e5c17..07f703f 100755
--- a/tests/ts/cramfs/mkfs
+++ b/tests/ts/cramfs/mkfs
@@ -66,7 +66,7 @@ fi
 ts_cd "$IMAGE_SRC"
 
 ts_log "list checksums from original data"
-find -type f -exec md5sum {} \; | sort >> $TS_OUTPUT
+find . -type f -exec md5sum {} \; | sort >> $TS_OUTPUT
 echo >> $TS_OUTPUT
 
 ts_log "create cramfs image"
diff --git a/tools/checkmans.sh b/tools/checkmans.sh
index 9a13778..63da3d7 100755
--- a/tools/checkmans.sh
+++ b/tools/checkmans.sh
@@ -70,7 +70,7 @@ remove_repeats()
 cd $(git rev-parse --show-toplevel)
 
 for I in $(
-	find -path './autom4te.cache' -prune -o -path './.libs' -prune -o -name '*[[:alpha:]].[1-8]' -print
+	find . -type f -name '*[[:alpha:]].[1-8]' |grep -v "autom4te.cache\|\.libs/"
 ); do
 	MAN_FILE=${I##*/}
 	MAN_LIST[${MAN_FILE%%.[0-9]}]=1
-- 
1.8.4.5


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 03/15] build-sys: check linker support for version scripts
  2016-02-18 13:12 [PATCH 00/15] portability fixes in the mix (OSX) Ruediger Meier
  2016-02-18 13:12 ` [PATCH 01/15] travis: minor cleanup Ruediger Meier
  2016-02-18 13:12 ` [PATCH 02/15] build-sys: portable usage of find command Ruediger Meier
@ 2016-02-18 13:12 ` Ruediger Meier
  2016-02-18 13:12 ` [PATCH 04/15] build-sys: fix [g]libtoolize version for OSX Ruediger Meier
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Ruediger Meier @ 2016-02-18 13:12 UTC (permalink / raw)
  To: util-linux

From: Ruediger Meier <ruediger.meier@ga-group.nl>

The macro AX_CHECK_VSCRIPT was taken from gnu autoconf archive.
http://www.gnu.org/software/autoconf-archive/

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
 configure.ac                   |   3 +
 libblkid/src/Makemodule.am     |   4 +-
 libfdisk/src/Makemodule.am     |   4 +-
 libmount/src/Makemodule.am     |   4 +-
 libsmartcols/src/Makemodule.am |   4 +-
 libuuid/src/Makemodule.am      |   4 +-
 m4/ax_check_vscript.m4         | 142 +++++++++++++++++++++++++++++++++++++++++
 7 files changed, 160 insertions(+), 5 deletions(-)
 create mode 100644 m4/ax_check_vscript.m4

diff --git a/configure.ac b/configure.ac
index 4559573..17917af 100644
--- a/configure.ac
+++ b/configure.ac
@@ -138,6 +138,9 @@ AC_SUBST([BSD_WARN_CFLAGS])
 dnl libtool-2
 LT_INIT
 
+dnl check supported linker flags
+AX_CHECK_VSCRIPT
+
 m4_ifndef([PKG_PROG_PKG_CONFIG],
   [m4_fatal([Could not locate the pkg-config autoconf
     macros. These are usually located in /usr/share/aclocal/pkg.m4.
diff --git a/libblkid/src/Makemodule.am b/libblkid/src/Makemodule.am
index 52d0b0a..1d03d92 100644
--- a/libblkid/src/Makemodule.am
+++ b/libblkid/src/Makemodule.am
@@ -129,7 +129,9 @@ endif
 
 libblkid_la_LDFLAGS = \
 	$(SOLIB_LDFLAGS) \
-	-Wl,--version-script=$(top_srcdir)/libblkid/src/libblkid.sym \
+if HAVE_VSCRIPT
+	$(VSCRIPT_LDFLAGS),$(top_srcdir)/libblkid/src/libblkid.sym \
+endif
 	-version-info $(LIBBLKID_VERSION_INFO)
 
 EXTRA_DIST += \
diff --git a/libfdisk/src/Makemodule.am b/libfdisk/src/Makemodule.am
index 00c3d9f..69a3f3e 100644
--- a/libfdisk/src/Makemodule.am
+++ b/libfdisk/src/Makemodule.am
@@ -48,7 +48,9 @@ libfdisk_la_DEPENDENCIES = \
 
 libfdisk_la_LDFLAGS = \
 	$(SOLIB_LDFLAGS) \
-	-Wl,--version-script=$(top_srcdir)/libfdisk/src/libfdisk.sym \
+if HAVE_VSCRIPT
+	$(VSCRIPT_LDFLAGS),$(top_srcdir)/libfdisk/src/libfdisk.sym \
+endif
 	-version-info $(LIBFDISK_VERSION_INFO)
 
 if BUILD_LIBBLKID
diff --git a/libmount/src/Makemodule.am b/libmount/src/Makemodule.am
index 3a89d0d..36bb00c 100644
--- a/libmount/src/Makemodule.am
+++ b/libmount/src/Makemodule.am
@@ -61,7 +61,9 @@ libmount_la_DEPENDENCIES = \
 
 libmount_la_LDFLAGS = \
 	$(SOLIB_LDFLAGS) \
-	-Wl,--version-script=$(top_srcdir)/libmount/src/libmount.sym \
+if HAVE_VSCRIPT
+	$(VSCRIPT_LDFLAGS),$(top_srcdir)/libmount/src/libmount.sym \
+endif
 	-version-info $(LIBMOUNT_VERSION_INFO)
 
 EXTRA_DIST += \
diff --git a/libsmartcols/src/Makemodule.am b/libsmartcols/src/Makemodule.am
index c2ec515..257d46d 100644
--- a/libsmartcols/src/Makemodule.am
+++ b/libsmartcols/src/Makemodule.am
@@ -36,7 +36,9 @@ libsmartcols_la_DEPENDENCIES = \
 
 libsmartcols_la_LDFLAGS = \
 	$(SOLIB_LDFLAGS) \
-	-Wl,--version-script=$(top_srcdir)/libsmartcols/src/libsmartcols.sym \
+if HAVE_VSCRIPT
+	$(VSCRIPT_LDFLAGS),$(top_srcdir)/libsmartcols/src/libsmartcols.sym \
+endif
 	-version-info $(LIBSMARTCOLS_VERSION_INFO)
 
 EXTRA_DIST += \
diff --git a/libuuid/src/Makemodule.am b/libuuid/src/Makemodule.am
index 180ac01..dc8d867 100644
--- a/libuuid/src/Makemodule.am
+++ b/libuuid/src/Makemodule.am
@@ -37,7 +37,9 @@ libuuid_la_CFLAGS = \
 
 libuuid_la_LDFLAGS = \
 	$(SOLIB_LDFLAGS) \
-	-Wl,--version-script=$(top_srcdir)/libuuid/src/libuuid.sym \
+if HAVE_VSCRIPT
+	libuuid_la_LDFLAGS += $(VSCRIPT_LDFLAGS),$(top_srcdir)/libuuid/src/libuuid.sym \
+endif
 	-version-info $(LIBUUID_VERSION_INFO)
 
 EXTRA_DIST += libuuid/src/libuuid.sym
diff --git a/m4/ax_check_vscript.m4 b/m4/ax_check_vscript.m4
new file mode 100644
index 0000000..219ad22
--- /dev/null
+++ b/m4/ax_check_vscript.m4
@@ -0,0 +1,142 @@
+# ===========================================================================
+#     http://www.gnu.org/software/autoconf-archive/ax_check_vscript.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_CHECK_VSCRIPT
+#
+# DESCRIPTION
+#
+#   Check whether the linker supports version scripts.  Version scripts are
+#   used when building shared libraries to bind symbols to version nodes
+#   (helping to detect incompatibilities) or to limit the visibility of
+#   non-public symbols.
+#
+#   Output:
+#
+#   If version scripts are supported, VSCRIPT_LDFLAGS will contain the
+#   appropriate flag to pass to the linker.  On GNU systems this would
+#   typically be "-Wl,--version-script", and on Solaris it would typically
+#   be "-Wl,-M".
+#
+#   Two Automake conditionals are also set:
+#
+#    HAVE_VSCRIPT is true if the linker supports version scripts with
+#    entries that use simple wildcards, like "local: *".
+#
+#    HAVE_VSCRIPT_COMPLEX is true if the linker supports version scripts with
+#    pattern matching wildcards, like "global: Java_*".
+#
+#   On systems that do not support symbol versioning, such as Mac OS X, both
+#   conditionals will be false.  They will also be false if the user passes
+#   "--disable-symvers" on the configure command line.
+#
+#   Example:
+#
+#    configure.ac:
+#
+#     AX_CHECK_VSCRIPT
+#
+#    Makefile.am:
+#
+#     if HAVE_VSCRIPT
+#     libfoo_la_LDFLAGS += $(VSCRIPT_LDFLAGS),@srcdir@/libfoo.map
+#     endif
+#
+#     if HAVE_VSCRIPT_COMPLEX
+#     libbar_la_LDFLAGS += $(VSCRIPT_LDFLAGS),@srcdir@/libbar.map
+#     endif
+#
+# LICENSE
+#
+#   Copyright (c) 2014 Kevin Cernekee <cernekee@gmail.com>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 1
+
+# _AX_CHECK_VSCRIPT(flag, global-sym, action-if-link-succeeds, [junk-file=no])
+AC_DEFUN([_AX_CHECK_VSCRIPT], [
+  AC_LANG_PUSH([C])
+  ax_check_vscript_save_flags="$LDFLAGS"
+  echo "V1 { global: $2; local: *; };" > conftest.map
+  AS_IF([test x$4 = xyes], [
+    echo "{" >> conftest.map
+  ])
+  LDFLAGS="$LDFLAGS -Wl,$1,conftest.map"
+  AC_LINK_IFELSE([AC_LANG_PROGRAM([[int show, hide;]], [])], [$3])
+  LDFLAGS="$ax_check_vscript_save_flags"
+  rm -f conftest.map
+  AC_LANG_POP([C])
+]) dnl _AX_CHECK_VSCRIPT
+
+AC_DEFUN([AX_CHECK_VSCRIPT], [
+
+  AC_ARG_ENABLE([symvers],
+    AS_HELP_STRING([--disable-symvers],
+                   [disable library symbol versioning [default=auto]]),
+    [want_symvers=$enableval],
+    [want_symvers=yes]
+  )
+
+  AS_IF([test x$want_symvers = xyes], [
+
+    dnl First test --version-script and -M with a simple wildcard.
+
+    AC_CACHE_CHECK([linker version script flag], ax_cv_check_vscript_flag, [
+      ax_cv_check_vscript_flag=unsupported
+      _AX_CHECK_VSCRIPT([--version-script], [show], [
+        ax_cv_check_vscript_flag=--version-script
+      ])
+      AS_IF([test x$ax_cv_check_vscript_flag = xunsupported], [
+        _AX_CHECK_VSCRIPT([-M], [show], [ax_cv_check_vscript_flag=-M])
+      ])
+
+      dnl The linker may interpret -M (no argument) as "produce a load map."
+      dnl If "-M conftest.map" doesn't fail when conftest.map contains
+      dnl obvious syntax errors, assume this is the case.
+
+      AS_IF([test x$ax_cv_check_vscript_flag != xunsupported], [
+        _AX_CHECK_VSCRIPT([$ax_cv_check_vscript_flag], [show],
+	                  [ax_cv_check_vscript_flag=unsupported], [yes])
+      ])
+    ])
+
+    dnl If the simple wildcard worked, retest with a complex wildcard.
+
+    AS_IF([test x$ax_cv_check_vscript_flag != xunsupported], [
+      ax_check_vscript_flag=$ax_cv_check_vscript_flag
+      AC_CACHE_CHECK([if version scripts can use complex wildcards],
+                     ax_cv_check_vscript_complex_wildcards, [
+        ax_cv_check_vscript_complex_wildcards=no
+        _AX_CHECK_VSCRIPT([$ax_cv_check_vscript_flag], [sh*], [
+        ax_cv_check_vscript_complex_wildcards=yes])
+      ])
+      ax_check_vscript_complex_wildcards="$ax_cv_check_vscript_complex_wildcards"
+    ], [
+      ax_check_vscript_flag=
+      ax_check_vscript_complex_wildcards=no
+    ])
+  ], [
+    AC_MSG_CHECKING([linker version script flag])
+    AC_MSG_RESULT([disabled])
+
+    ax_check_vscript_flag=
+    ax_check_vscript_complex_wildcards=no
+  ])
+
+  AS_IF([test x$ax_check_vscript_flag != x], [
+    VSCRIPT_LDFLAGS="-Wl,$ax_check_vscript_flag"
+    AC_SUBST([VSCRIPT_LDFLAGS])
+  ])
+
+  AM_CONDITIONAL([HAVE_VSCRIPT],
+    [test x$ax_check_vscript_flag != x])
+  AM_CONDITIONAL([HAVE_VSCRIPT_COMPLEX],
+    [test x$ax_check_vscript_complex_wildcards = xyes])
+
+]) dnl AX_CHECK_VSCRIPT
-- 
1.8.4.5


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 04/15] build-sys: fix [g]libtoolize version for OSX
  2016-02-18 13:12 [PATCH 00/15] portability fixes in the mix (OSX) Ruediger Meier
                   ` (2 preceding siblings ...)
  2016-02-18 13:12 ` [PATCH 03/15] build-sys: check linker support for version scripts Ruediger Meier
@ 2016-02-18 13:12 ` Ruediger Meier
  2016-02-18 13:12 ` [PATCH 05/15] tests: fix ts_option helpers Ruediger Meier
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Ruediger Meier @ 2016-02-18 13:12 UTC (permalink / raw)
  To: util-linux

From: Ruediger Meier <ruediger.meier@ga-group.nl>

follow-up 0024583c

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
 autogen.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/autogen.sh b/autogen.sh
index bfa46fe..116885b 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -75,7 +75,7 @@ if ! ($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1; then
 	echo
 	DIE=1
 else
-	ltver=$($LIBTOOLIZE --version | awk '/^libtoolize/ { print $4 }')
+	ltver=$($LIBTOOLIZE --version | awk '/^[g]*libtoolize/ { print $4 }')
 	ltver=${ltver:-"none"}
 	test ${ltver##2.} = "$ltver" && {
 		echo
-- 
1.8.4.5


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 05/15] tests: fix ts_option helpers
  2016-02-18 13:12 [PATCH 00/15] portability fixes in the mix (OSX) Ruediger Meier
                   ` (3 preceding siblings ...)
  2016-02-18 13:12 ` [PATCH 04/15] build-sys: fix [g]libtoolize version for OSX Ruediger Meier
@ 2016-02-18 13:12 ` Ruediger Meier
  2016-02-18 13:12 ` [PATCH 06/15] lib: rename strmode() and setmode() Ruediger Meier
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Ruediger Meier @ 2016-02-18 13:12 UTC (permalink / raw)
  To: util-linux

From: Ruediger Meier <ruediger.meier@ga-group.nl>

These two problems should be fixed now:
  - BSD awk only accepts 1-char field seperator
  - ts_has_option() did not returned "yes" if an option was given
    multiple times

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
 tests/functions.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tests/functions.sh b/tests/functions.sh
index d3367e1..e639e73 100644
--- a/tests/functions.sh
+++ b/tests/functions.sh
@@ -158,13 +158,15 @@ function ts_has_option {
 	fi
 
 	# or just check the global command line options
-	echo -n $ALL | sed 's/ //g' | awk 'BEGIN { FS="="; RS="--" } /('$NAME'$|'$NAME'=)/ { print "yes" }'
+	if [[ $ALL =~ ([$' \t\n']|^)--$NAME([$'= \t\n']|$) ]]; then echo yes; fi
 }
 
 function ts_option_argument {
 	NAME="$1"
 	ALL="$2"
-	echo -n $ALL | sed 's/ //g' | awk 'BEGIN { FS="="; RS="--" } /'$NAME'=/ { print $2 }'
+
+	# last option wins!
+	echo "$ALL" | sed -n "s/.*[ \t\n]--$NAME=\([^ \t\n]*\).*/\1/p" | tail -n 1
 }
 
 function ts_init_core_env {
-- 
1.8.4.5


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 06/15] lib: rename strmode() and setmode()
  2016-02-18 13:12 [PATCH 00/15] portability fixes in the mix (OSX) Ruediger Meier
                   ` (4 preceding siblings ...)
  2016-02-18 13:12 ` [PATCH 05/15] tests: fix ts_option helpers Ruediger Meier
@ 2016-02-18 13:12 ` Ruediger Meier
  2016-02-18 13:12 ` [PATCH 07/15] include: provide MAP_ANONYMOUS on OSX Ruediger Meier
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Ruediger Meier @ 2016-02-18 13:12 UTC (permalink / raw)
  To: util-linux

From: Ruediger Meier <ruediger.meier@ga-group.nl>

On BSD they are part of the standard C library.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
 include/strutils.h          |  2 +-
 lib/strutils.c              |  2 +-
 libsmartcols/samples/tree.c |  2 +-
 misc-utils/lsblk.c          |  2 +-
 misc-utils/namei.c          |  2 +-
 sys-utils/lsipc.c           |  6 +++---
 text-utils/ul.c             | 10 +++++-----
 7 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/include/strutils.h b/include/strutils.h
index ec2a8ac..4bb3b2d 100644
--- a/include/strutils.h
+++ b/include/strutils.h
@@ -78,7 +78,7 @@ static inline char *strdup_to_offset(void *stru, size_t offset, const char *str)
 #define strdup_to_struct_member(_s, _m, _str) \
 		strdup_to_offset((void *) _s, offsetof(__typeof__(*(_s)), _m), _str)
 
-extern void strmode(mode_t mode, char *str);
+extern void xstrmode(mode_t mode, char *str);
 
 /* Options for size_to_human_string() */
 enum
diff --git a/lib/strutils.c b/lib/strutils.c
index ac59de8..ef81ebd 100644
--- a/lib/strutils.c
+++ b/lib/strutils.c
@@ -425,7 +425,7 @@ void strtotimeval_or_err(const char *str, struct timeval *tv, const char *errmes
  * Converts stat->st_mode to ls(1)-like mode string. The size of "str" must
  * be 11 bytes.
  */
-void strmode(mode_t mode, char *str)
+void xstrmode(mode_t mode, char *str)
 {
 	unsigned short i = 0;
 
diff --git a/libsmartcols/samples/tree.c b/libsmartcols/samples/tree.c
index 7f41f9e..52be7fb 100644
--- a/libsmartcols/samples/tree.c
+++ b/libsmartcols/samples/tree.c
@@ -59,7 +59,7 @@ static int add_line_from_stat(struct libscols_table *tb,
 		err(EXIT_FAILURE, "failed to create output line");
 
 	/* MODE; local buffer, use scols_line_set_data() that calls strdup() */
-	strmode(mode, modbuf);
+	xstrmode(mode, modbuf);
 	if (scols_line_set_data(ln, COL_MODE, modbuf))
 		goto fail;
 
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
index 1162d07..5c065a9 100644
--- a/misc-utils/lsblk.c
+++ b/misc-utils/lsblk.c
@@ -911,7 +911,7 @@ static void set_scols_data(struct blkdev_cxt *cxt, int col, int id, struct libsc
 		char md[11];
 
 		if (!st_rc) {
-			strmode(cxt->st.st_mode, md);
+			xstrmode(cxt->st.st_mode, md);
 			str = xstrdup(md);
 		}
 		break;
diff --git a/misc-utils/namei.c b/misc-utils/namei.c
index 41557ca..576e3ef 100644
--- a/misc-utils/namei.c
+++ b/misc-utils/namei.c
@@ -288,7 +288,7 @@ print_namei(struct namei *nm, char *path)
 			return -1;
 		}
 
-		strmode(nm->st.st_mode, md);
+		xstrmode(nm->st.st_mode, md);
 
 		if (nm->mountpoint)
 			md[0] = 'D';
diff --git a/sys-utils/lsipc.c b/sys-utils/lsipc.c
index 523859c..9e34e6b 100644
--- a/sys-utils/lsipc.c
+++ b/sys-utils/lsipc.c
@@ -579,7 +579,7 @@ static void do_sem(int id, struct lsipc_control *ctl, struct libscols_table *tb)
 					xasprintf(&arg, "%#o", semdsp->sem_perm.mode & 0777);
 				else {
 					arg = xmalloc(11);
-					strmode(semdsp->sem_perm.mode & 0777, arg);
+					xstrmode(semdsp->sem_perm.mode & 0777, arg);
 				}
 				rc = scols_line_refer_data(ln, n, arg);
 				break;
@@ -776,7 +776,7 @@ static void do_msg(int id, struct lsipc_control *ctl, struct libscols_table *tb)
 					xasprintf(&arg, "%#o", msgdsp->msg_perm.mode & 0777);
 				else {
 					arg = xmalloc(11);
-					strmode(msgdsp->msg_perm.mode & 0777, arg);
+					xstrmode(msgdsp->msg_perm.mode & 0777, arg);
 					rc = scols_line_refer_data(ln, n, arg);
 				}
 				break;
@@ -928,7 +928,7 @@ static void do_shm(int id, struct lsipc_control *ctl, struct libscols_table *tb)
 					xasprintf(&arg, "%#o", shmdsp->shm_perm.mode & 0777);
 				else {
 					arg = xmalloc(11);
-					strmode(shmdsp->shm_perm.mode & 0777, arg);
+					xstrmode(shmdsp->shm_perm.mode & 0777, arg);
 				}
 				rc = scols_line_refer_data(ln, n, arg);
 				break;
diff --git a/text-utils/ul.c b/text-utils/ul.c
index 7765b57..115b882 100644
--- a/text-utils/ul.c
+++ b/text-utils/ul.c
@@ -81,7 +81,7 @@ static void fwd(void);
 static void reverse(void);
 static void initinfo(void);
 static void outc(wint_t c, int width);
-static void setmode(int newmode);
+static void xsetmode(int newmode);
 static void setcol(int newcol);
 static void needcol(int col);
 static void sig_handler(int signo);
@@ -368,7 +368,7 @@ static void flushln(void)
 	for (i = 0; i < maxcol; i++) {
 		if (obuf[i].c_mode != lastmode) {
 			hadmodes++;
-			setmode(obuf[i].c_mode);
+			xsetmode(obuf[i].c_mode);
 			lastmode = obuf[i].c_mode;
 		}
 		if (obuf[i].c_char == '\0') {
@@ -382,7 +382,7 @@ static void flushln(void)
 			i += obuf[i].c_width - 1;
 	}
 	if (lastmode != NORMAL) {
-		setmode(0);
+		xsetmode(0);
 	}
 	if (must_overstrike && hadmodes)
 		overstrike();
@@ -560,11 +560,11 @@ static void outc(wint_t c, int width) {
 	}
 }
 
-static void setmode(int newmode)
+static void xsetmode(int newmode)
 {
 	if (!iflag) {
 		if (curmode != NORMAL && newmode != NORMAL)
-			setmode(NORMAL);
+			xsetmode(NORMAL);
 		switch (newmode) {
 		case NORMAL:
 			switch (curmode) {
-- 
1.8.4.5


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 07/15] include: provide MAP_ANONYMOUS on OSX
  2016-02-18 13:12 [PATCH 00/15] portability fixes in the mix (OSX) Ruediger Meier
                   ` (5 preceding siblings ...)
  2016-02-18 13:12 ` [PATCH 06/15] lib: rename strmode() and setmode() Ruediger Meier
@ 2016-02-18 13:12 ` Ruediger Meier
  2016-02-18 13:21   ` Karel Zak
  2016-02-18 15:51   ` [PATCH v2 " Ruediger Meier
  2016-02-18 13:12 ` [PATCH 08/15] lib: define LOGIN_NAME_MAX fallback Ruediger Meier
                   ` (7 subsequent siblings)
  14 siblings, 2 replies; 20+ messages in thread
From: Ruediger Meier @ 2016-02-18 13:12 UTC (permalink / raw)
  To: util-linux

From: Ruediger Meier <ruediger.meier@ga-group.nl>

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
 disk-utils/fsck.cramfs.c | 8 ++++++++
 disk-utils/mkfs.cramfs.c | 8 ++++++++
 login-utils/sulogin.c    | 9 +++++++++
 3 files changed, 25 insertions(+)

diff --git a/disk-utils/fsck.cramfs.c b/disk-utils/fsck.cramfs.c
index d5d3790..6ca6094 100644
--- a/disk-utils/fsck.cramfs.c
+++ b/disk-utils/fsck.cramfs.c
@@ -33,6 +33,10 @@
  *                            use read if mmap fails, standardize messages)
  */
 
+#if defined __APPLE__
+# define _DARWIN_C_SOURCE
+#endif
+
 #include <stdio.h>
 #include <stdarg.h>
 #include <stdint.h>
@@ -62,6 +66,10 @@
 #define XALLOC_EXIT_CODE FSCK_EX_ERROR
 #include "xalloc.h"
 
+#if !defined MAP_ANONYMOUS && defined MAP_ANON
+# define MAP_ANONYMOUS  (MAP_ANON)
+#endif
+
 static int fd;			/* ROM image file descriptor */
 static char *filename;		/* ROM image filename */
 struct cramfs_super super;	/* just find the cramfs superblock once */
diff --git a/disk-utils/mkfs.cramfs.c b/disk-utils/mkfs.cramfs.c
index 0096cd4..d6fb646 100644
--- a/disk-utils/mkfs.cramfs.c
+++ b/disk-utils/mkfs.cramfs.c
@@ -23,6 +23,10 @@
  * files one by one instaed of all simultaneously. - aeb, 2002-11-01
  */
 
+#if defined __APPLE__
+# define _DARWIN_C_SOURCE
+#endif
+
 #include <sys/types.h>
 #include <stdio.h>
 #include <sys/stat.h>
@@ -48,6 +52,10 @@
 #define XALLOC_EXIT_CODE MKFS_EX_ERROR
 #include "xalloc.h"
 
+#if !defined MAP_ANONYMOUS && defined MAP_ANON
+# define MAP_ANONYMOUS  (MAP_ANON)
+#endif
+
 /* The kernel only supports PAD_SIZE of 0 and 512. */
 #define PAD_SIZE 512
 
diff --git a/login-utils/sulogin.c b/login-utils/sulogin.c
index 643712f..c83ce6d 100644
--- a/login-utils/sulogin.c
+++ b/login-utils/sulogin.c
@@ -24,6 +24,11 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
+
+#if defined __APPLE__
+# define _DARWIN_C_SOURCE
+#endif
+
 #include <sys/mman.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -63,6 +68,10 @@
 #include "sulogin-consoles.h"
 #define CONMAX		16
 
+#if !defined MAP_ANONYMOUS && defined MAP_ANON
+# define MAP_ANONYMOUS  (MAP_ANON)
+#endif
+
 static unsigned int timeout;
 static int profile;
 static volatile uint32_t openfd;		/* Remember higher file descriptors */
-- 
1.8.4.5


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 08/15] lib: define LOGIN_NAME_MAX fallback
  2016-02-18 13:12 [PATCH 00/15] portability fixes in the mix (OSX) Ruediger Meier
                   ` (6 preceding siblings ...)
  2016-02-18 13:12 ` [PATCH 07/15] include: provide MAP_ANONYMOUS on OSX Ruediger Meier
@ 2016-02-18 13:12 ` Ruediger Meier
  2016-02-18 13:12 ` [PATCH 09/15] include: check for sys/sysmacros.h Ruediger Meier
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Ruediger Meier @ 2016-02-18 13:12 UTC (permalink / raw)
  To: util-linux

From: Ruediger Meier <ruediger.meier@ga-group.nl>

LOGIN_NAME_MAX was unused in misc-utils/namei.c since 04a5cb58.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
 lib/idcache.c      | 4 ++++
 misc-utils/namei.c | 4 ----
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/idcache.c b/lib/idcache.c
index 4cb20fd..3c358b8 100644
--- a/lib/idcache.c
+++ b/lib/idcache.c
@@ -7,6 +7,10 @@
 #include "c.h"
 #include "idcache.h"
 
+#ifndef LOGIN_NAME_MAX
+#define LOGIN_NAME_MAX 256
+#endif
+
 struct identry *get_id(struct idcache *ic, unsigned long int id)
 {
 	struct identry *ent;
diff --git a/misc-utils/namei.c b/misc-utils/namei.c
index 576e3ef..df678e0 100644
--- a/misc-utils/namei.c
+++ b/misc-utils/namei.c
@@ -44,10 +44,6 @@
 #define MAXSYMLINKS 256
 #endif
 
-#ifndef LOGIN_NAME_MAX
-#define LOGIN_NAME_MAX 256
-#endif
-
 #define NAMEI_NOLINKS	(1 << 1)
 #define NAMEI_MODES	(1 << 2)
 #define NAMEI_MNTS	(1 << 3)
-- 
1.8.4.5


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 09/15] include: check for sys/sysmacros.h
  2016-02-18 13:12 [PATCH 00/15] portability fixes in the mix (OSX) Ruediger Meier
                   ` (7 preceding siblings ...)
  2016-02-18 13:12 ` [PATCH 08/15] lib: define LOGIN_NAME_MAX fallback Ruediger Meier
@ 2016-02-18 13:12 ` Ruediger Meier
  2016-02-18 13:22 ` [PATCH 10/15] include: remove unused mntent.h Ruediger Meier
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Ruediger Meier @ 2016-02-18 13:12 UTC (permalink / raw)
  To: util-linux

From: Ruediger Meier <ruediger.meier@ga-group.nl>

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
 configure.ac             | 1 +
 disk-utils/fsck.cramfs.c | 2 ++
 disk-utils/raw.c         | 2 ++
 login-utils/login.c      | 2 ++
 4 files changed, 7 insertions(+)

diff --git a/configure.ac b/configure.ac
index 17917af..969c2cc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -238,6 +238,7 @@ AC_CHECK_HEADERS([ \
 	sys/socket.h \
 	sys/sockio.h \
 	sys/stat.h \
+	sys/sysmacros.h \
 	sys/swap.h \
 	sys/syscall.h \
 	sys/time.h \
diff --git a/disk-utils/fsck.cramfs.c b/disk-utils/fsck.cramfs.c
index 6ca6094..7df5390 100644
--- a/disk-utils/fsck.cramfs.c
+++ b/disk-utils/fsck.cramfs.c
@@ -53,7 +53,9 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
+#ifdef HAVE_SYS_SYSMACROS_H
 #include <sys/sysmacros.h>	/* for major, minor */
+#endif
 
 #include "cramfs.h"
 #include "nls.h"
diff --git a/disk-utils/raw.c b/disk-utils/raw.c
index d29ff1b..6c4b6de 100644
--- a/disk-utils/raw.c
+++ b/disk-utils/raw.c
@@ -20,7 +20,9 @@
 #include <string.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
+#ifdef HAVE_SYS_SYSMACROS_H
 #include <sys/sysmacros.h>
+#endif
 #include <unistd.h>
 
 #include "c.h"
diff --git a/login-utils/login.c b/login-utils/login.c
index 6f51039..e1f11eb 100644
--- a/login-utils/login.c
+++ b/login-utils/login.c
@@ -48,7 +48,9 @@
 #include <utmp.h>
 #include <stdlib.h>
 #include <sys/syslog.h>
+#ifdef HAVE_SYS_SYSMACROS_H
 #include <sys/sysmacros.h>
+#endif
 #ifdef HAVE_LINUX_MAJOR_H
 # include <linux/major.h>
 #endif
-- 
1.8.4.5


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH 07/15] include: provide MAP_ANONYMOUS on OSX
  2016-02-18 13:12 ` [PATCH 07/15] include: provide MAP_ANONYMOUS on OSX Ruediger Meier
@ 2016-02-18 13:21   ` Karel Zak
  2016-02-18 14:10     ` Ruediger Meier
  2016-02-18 15:51   ` [PATCH v2 " Ruediger Meier
  1 sibling, 1 reply; 20+ messages in thread
From: Karel Zak @ 2016-02-18 13:21 UTC (permalink / raw)
  To: Ruediger Meier; +Cc: util-linux

On Thu, Feb 18, 2016 at 02:12:47PM +0100, Ruediger Meier wrote:
> +#if defined __APPLE__
> +# define _DARWIN_C_SOURCE
> +#endif
> +
>  #include <stdio.h>
>  #include <stdarg.h>
>  #include <stdint.h>
> @@ -62,6 +66,10 @@
>  #define XALLOC_EXIT_CODE FSCK_EX_ERROR
>  #include "xalloc.h"
>  
> +#if !defined MAP_ANONYMOUS && defined MAP_ANON
> +# define MAP_ANONYMOUS  (MAP_ANON)
> +#endif

What about to move this to include/c.h where we already have some
portability ifdefs?

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 10/15] include: remove unused mntent.h
  2016-02-18 13:12 [PATCH 00/15] portability fixes in the mix (OSX) Ruediger Meier
                   ` (8 preceding siblings ...)
  2016-02-18 13:12 ` [PATCH 09/15] include: check for sys/sysmacros.h Ruediger Meier
@ 2016-02-18 13:22 ` Ruediger Meier
  2016-02-18 13:22 ` [PATCH 11/15] lsns: use xcalloc() Ruediger Meier
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Ruediger Meier @ 2016-02-18 13:22 UTC (permalink / raw)
  To: util-linux

From: Ruediger Meier <ruediger.meier@ga-group.nl>

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
 disk-utils/fsck.minix.c | 1 -
 disk-utils/mkfs.minix.c | 1 -
 disk-utils/mkswap.c     | 1 -
 3 files changed, 3 deletions(-)

diff --git a/disk-utils/fsck.minix.c b/disk-utils/fsck.minix.c
index 3d73d49..2058a97 100644
--- a/disk-utils/fsck.minix.c
+++ b/disk-utils/fsck.minix.c
@@ -87,7 +87,6 @@
 #include <ctype.h>
 #include <stdlib.h>
 #include <termios.h>
-#include <mntent.h>
 #include <sys/stat.h>
 #include <signal.h>
 #include <getopt.h>
diff --git a/disk-utils/mkfs.minix.c b/disk-utils/mkfs.minix.c
index 4712772..b472242 100644
--- a/disk-utils/mkfs.minix.c
+++ b/disk-utils/mkfs.minix.c
@@ -64,7 +64,6 @@
 #include <stdlib.h>
 #include <termios.h>
 #include <sys/stat.h>
-#include <mntent.h>
 #include <getopt.h>
 #include <err.h>
 
diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c
index 22999da..ae02de5 100644
--- a/disk-utils/mkswap.c
+++ b/disk-utils/mkswap.c
@@ -14,7 +14,6 @@
 #include <fcntl.h>
 #include <stdlib.h>
 #include <limits.h>
-#include <mntent.h>
 #include <sys/utsname.h>
 #include <sys/stat.h>
 #include <errno.h>
-- 
1.8.4.5


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 11/15] lsns: use xcalloc()
  2016-02-18 13:12 [PATCH 00/15] portability fixes in the mix (OSX) Ruediger Meier
                   ` (9 preceding siblings ...)
  2016-02-18 13:22 ` [PATCH 10/15] include: remove unused mntent.h Ruediger Meier
@ 2016-02-18 13:22 ` Ruediger Meier
  2016-02-18 13:22 ` [PATCH 12/15] lib: remove unused variable Ruediger Meier
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Ruediger Meier @ 2016-02-18 13:22 UTC (permalink / raw)
  To: util-linux

From: Ruediger Meier <ruediger.meier@ga-group.nl>

... found by tools/checkxalloc.sh

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
 sys-utils/lsns.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys-utils/lsns.c b/sys-utils/lsns.c
index 7b8f17d..71ae3f9 100644
--- a/sys-utils/lsns.c
+++ b/sys-utils/lsns.c
@@ -233,7 +233,7 @@ static int read_process(struct lsns *ls, pid_t pid)
 	if (!dir)
 		return -errno;
 
-	p = calloc(1, sizeof(*p));
+	p = xcalloc(1, sizeof(*p));
 	if (!p) {
 		rc = -ENOMEM;
 		goto done;
@@ -338,7 +338,7 @@ static int namespace_has_process(struct lsns_namespace *ns, pid_t pid)
 
 static struct lsns_namespace *add_namespace(struct lsns *ls, int type, ino_t ino)
 {
-	struct lsns_namespace *ns = calloc(1, sizeof(*ns));
+	struct lsns_namespace *ns = xcalloc(1, sizeof(*ns));
 
 	if (!ns)
 		return NULL;
-- 
1.8.4.5


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 12/15] lib: remove unused variable
  2016-02-18 13:12 [PATCH 00/15] portability fixes in the mix (OSX) Ruediger Meier
                   ` (10 preceding siblings ...)
  2016-02-18 13:22 ` [PATCH 11/15] lsns: use xcalloc() Ruediger Meier
@ 2016-02-18 13:22 ` Ruediger Meier
  2016-02-18 13:23 ` [PATCH 13/15] lib: fix ismounted includes for FreeBSD Ruediger Meier
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Ruediger Meier @ 2016-02-18 13:22 UTC (permalink / raw)
  To: util-linux

From: Ruediger Meier <ruediger.meier@ga-group.nl>

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
 lib/blkdev.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lib/blkdev.c b/lib/blkdev.c
index f6df92d..403e9e4 100644
--- a/lib/blkdev.c
+++ b/lib/blkdev.c
@@ -150,7 +150,6 @@ blkdev_get_size(int fd, unsigned long long *bytes)
 		int part = -1;
 		struct disklabel lab;
 		struct partition *pp;
-		char ch;
 		struct stat st;
 
 		if ((fstat(fd, &st) >= 0) &&
-- 
1.8.4.5


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 13/15] lib: fix ismounted includes for FreeBSD
  2016-02-18 13:12 [PATCH 00/15] portability fixes in the mix (OSX) Ruediger Meier
                   ` (11 preceding siblings ...)
  2016-02-18 13:22 ` [PATCH 12/15] lib: remove unused variable Ruediger Meier
@ 2016-02-18 13:23 ` Ruediger Meier
  2016-02-18 13:23 ` [PATCH 14/15] libblkid: don't include endian.h Ruediger Meier
  2016-02-18 13:23 ` [PATCH 15/15] include: fix sys/sysinfo.h Ruediger Meier
  14 siblings, 0 replies; 20+ messages in thread
From: Ruediger Meier @ 2016-02-18 13:23 UTC (permalink / raw)
  To: util-linux

From: Ruediger Meier <ruediger.meier@ga-group.nl>

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
 configure.ac    |  2 ++
 lib/ismounted.c | 11 ++++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 969c2cc..c42e475 100644
--- a/configure.ac
+++ b/configure.ac
@@ -231,6 +231,7 @@ AC_CHECK_HEADERS([ \
 	sys/ioccom.h \
 	sys/ioctl.h \
 	sys/mkdev.h \
+	sys/mount.h \
 	sys/param.h \
 	sys/prctl.h \
 	sys/queue.h \
@@ -245,6 +246,7 @@ AC_CHECK_HEADERS([ \
 	sys/timex.h \
 	sys/ttydefaults.h \
 	sys/types.h \
+	sys/ucred.h \
 	sys/un.h \
 	unistd.h \
 ])
diff --git a/lib/ismounted.c b/lib/ismounted.c
index 9095290..f83be65 100644
--- a/lib/ismounted.c
+++ b/lib/ismounted.c
@@ -18,9 +18,14 @@
 #include <sys/stat.h>
 #include <ctype.h>
 #include <sys/param.h>
-#ifdef __APPLE__
-#include <sys/ucred.h>
-#include <sys/mount.h>
+
+#ifndef __linux__
+# ifdef HAVE_SYS_UCRED_H
+#  include <sys/ucred.h>
+# endif
+# ifdef HAVE_SYS_MOUNT_H
+#  include <sys/mount.h>
+# endif
 #endif
 
 #include "pathnames.h"
-- 
1.8.4.5


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 14/15] libblkid: don't include endian.h
  2016-02-18 13:12 [PATCH 00/15] portability fixes in the mix (OSX) Ruediger Meier
                   ` (12 preceding siblings ...)
  2016-02-18 13:23 ` [PATCH 13/15] lib: fix ismounted includes for FreeBSD Ruediger Meier
@ 2016-02-18 13:23 ` Ruediger Meier
  2016-02-18 13:23 ` [PATCH 15/15] include: fix sys/sysinfo.h Ruediger Meier
  14 siblings, 0 replies; 20+ messages in thread
From: Ruediger Meier @ 2016-02-18 13:23 UTC (permalink / raw)
  To: util-linux

From: Ruediger Meier <ruediger.meier@ga-group.nl>

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
 libblkid/src/superblocks/drbdmanage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libblkid/src/superblocks/drbdmanage.c b/libblkid/src/superblocks/drbdmanage.c
index d7384df..e84efa3 100644
--- a/libblkid/src/superblocks/drbdmanage.c
+++ b/libblkid/src/superblocks/drbdmanage.c
@@ -11,7 +11,6 @@
  * (a DRBDmanage "cluster"); this file detects its control volume,
  * which is replicated (via DRBD 9) on some of the nodes.
  */
-#include <endian.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -21,6 +20,7 @@
 #include <inttypes.h>
 #include <stddef.h>
 
+#include "bitops.h"
 #include "superblocks.h"
 
 struct drbdmanage_hdr {
-- 
1.8.4.5


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 15/15] include: fix sys/sysinfo.h
  2016-02-18 13:12 [PATCH 00/15] portability fixes in the mix (OSX) Ruediger Meier
                   ` (13 preceding siblings ...)
  2016-02-18 13:23 ` [PATCH 14/15] libblkid: don't include endian.h Ruediger Meier
@ 2016-02-18 13:23 ` Ruediger Meier
  14 siblings, 0 replies; 20+ messages in thread
From: Ruediger Meier @ 2016-02-18 13:23 UTC (permalink / raw)
  To: util-linux

From: Ruediger Meier <ruediger.meier@ga-group.nl>

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
 lib/monotonic.c | 2 ++
 lib/timer.c     | 1 -
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/monotonic.c b/lib/monotonic.c
index 372cc9c..bb58e15 100644
--- a/lib/monotonic.c
+++ b/lib/monotonic.c
@@ -4,7 +4,9 @@
  */
 #include <time.h>
 #include <signal.h>
+#ifdef HAVE_SYSINFO
 #include <sys/sysinfo.h>
+#endif
 #include <sys/time.h>
 
 #include "c.h"
diff --git a/lib/timer.c b/lib/timer.c
index 0ad0cad..6265693 100644
--- a/lib/timer.c
+++ b/lib/timer.c
@@ -5,7 +5,6 @@
  */
 #include <time.h>
 #include <signal.h>
-#include <sys/sysinfo.h>
 #include <sys/time.h>
 
 #include "c.h"
-- 
1.8.4.5


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH 07/15] include: provide MAP_ANONYMOUS on OSX
  2016-02-18 13:21   ` Karel Zak
@ 2016-02-18 14:10     ` Ruediger Meier
  2016-02-18 14:28       ` Karel Zak
  0 siblings, 1 reply; 20+ messages in thread
From: Ruediger Meier @ 2016-02-18 14:10 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

On Thursday 18 February 2016, Karel Zak wrote:
> On Thu, Feb 18, 2016 at 02:12:47PM +0100, Ruediger Meier wrote:
> > +#if defined __APPLE__
> > +# define _DARWIN_C_SOURCE
> > +#endif
> > +

This one is needed before including sys/mman.h. Don't know whether it 
would be better to define _DARWIN_C_SOURCE globally in compiler 
commandline (via configure for systems where it's needed)!?

> >  #include <stdio.h>
> >  #include <stdarg.h>
> >  #include <stdint.h>
> > @@ -62,6 +66,10 @@
> >  #define XALLOC_EXIT_CODE FSCK_EX_ERROR
> >  #include "xalloc.h"
> >
> > +#if !defined MAP_ANONYMOUS && defined MAP_ANON
> > +# define MAP_ANONYMOUS  (MAP_ANON)
> > +#endif
>
> What about to move this to include/c.h where we already have some
> portability ifdefs?

Would be nice to hide MAP_ANONYMOUS definition to include/c.h. But as 
long as _DARWIN_C_SOURCE will not be globally defined we would also 
need to include sys/mman.h there, right?

BTW here is how "dateutils" does it. Using a macro CHECK_MAP_ANON to get 
defines MAP_ANON_NEEDS_DARWIN_SOURCE and MAP_ANON_NEEDS_ALL_SOURCE
https://github.com/hroptatyr/dateutils/blob/master/m4/sxe-mmap.m4
https://github.com/hroptatyr/dateutils/blob/master/src/prchunk.c

cu,
Rudi

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 07/15] include: provide MAP_ANONYMOUS on OSX
  2016-02-18 14:10     ` Ruediger Meier
@ 2016-02-18 14:28       ` Karel Zak
  0 siblings, 0 replies; 20+ messages in thread
From: Karel Zak @ 2016-02-18 14:28 UTC (permalink / raw)
  To: Ruediger Meier; +Cc: util-linux

On Thu, Feb 18, 2016 at 03:10:19PM +0100, Ruediger Meier wrote:
> On Thursday 18 February 2016, Karel Zak wrote:
> > On Thu, Feb 18, 2016 at 02:12:47PM +0100, Ruediger Meier wrote:
> > > +#if defined __APPLE__
> > > +# define _DARWIN_C_SOURCE
> > > +#endif
> > > +
> 
> This one is needed before including sys/mman.h. Don't know whether it 
> would be better to define _DARWIN_C_SOURCE globally in compiler 
> commandline (via configure for systems where it's needed)!?

config.h is always included before anything else, so if
_DARWIN_C_SOURCE has no any side effect then it seems like a good
solution. For example we use config.h to define _GNU_SOURCE etc.
(see AC_USE_SYSTEM_EXTENSIONS aitoconf macro).

> > >  #include <stdio.h>
> > >  #include <stdarg.h>
> > >  #include <stdint.h>
> > > @@ -62,6 +66,10 @@
> > >  #define XALLOC_EXIT_CODE FSCK_EX_ERROR
> > >  #include "xalloc.h"
> > >
> > > +#if !defined MAP_ANONYMOUS && defined MAP_ANON
> > > +# define MAP_ANONYMOUS  (MAP_ANON)
> > > +#endif
> >
> > What about to move this to include/c.h where we already have some
> > portability ifdefs?
> 
> Would be nice to hide MAP_ANONYMOUS definition to include/c.h. But as 
> long as _DARWIN_C_SOURCE will not be globally defined we would also 
> need to include sys/mman.h there, right?
> 
> BTW here is how "dateutils" does it. Using a macro CHECK_MAP_ANON to get 
> defines MAP_ANON_NEEDS_DARWIN_SOURCE and MAP_ANON_NEEDS_ALL_SOURCE
> https://github.com/hroptatyr/dateutils/blob/master/m4/sxe-mmap.m4
> https://github.com/hroptatyr/dateutils/blob/master/src/prchunk.c

seems also as possible way

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH v2 07/15] include: provide MAP_ANONYMOUS on OSX
  2016-02-18 13:12 ` [PATCH 07/15] include: provide MAP_ANONYMOUS on OSX Ruediger Meier
  2016-02-18 13:21   ` Karel Zak
@ 2016-02-18 15:51   ` Ruediger Meier
  1 sibling, 0 replies; 20+ messages in thread
From: Ruediger Meier @ 2016-02-18 15:51 UTC (permalink / raw)
  To: util-linux

From: Ruediger Meier <ruediger.meier@ga-group.nl>

Hope there are no side effect when defining _DARWIN_C_SOURCE
globally.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
 configure.ac | 6 ++++++
 include/c.h  | 8 ++++++++
 2 files changed, 14 insertions(+)

diff --git a/configure.ac b/configure.ac
index e9c8ef5..dbdcea4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -158,11 +158,17 @@ bsd_os=no
 AS_CASE([${host_os}],
   [*linux*],
      [linux_os=yes],
+  [*darwin*],
+     [darwin_os=yes],
   [*bsd*],
      [bsd_os=yes])
 AM_CONDITIONAL([LINUX], [test "x$linux_os" = xyes])
+AM_CONDITIONAL([DARWIN], [test "x$darwin_os" = xyes])
 AM_CONDITIONAL([BSD], [test "x$bsd_os" = xyes])
 
+AS_IF([test  "x$darwin_os" = xyes], [
+  AC_DEFINE([_DARWIN_C_SOURCE], [1], [Enable MAP_ANON in sys/mman.h on Mac OS X])
+])
 
 dnl define ARCH_<NAME> conditionals
 UL_SET_ARCH([I86], [i?86-*])
diff --git a/include/c.h b/include/c.h
index ca028ba..aec3439 100644
--- a/include/c.h
+++ b/include/c.h
@@ -355,4 +355,12 @@ static inline int xusleep(useconds_t usec)
  */
 #define UL_GETPW_BUFSIZ	(16 * 1024)
 
+/*
+ * Darwin or other BSDs may only have MAP_ANON. To get it on Darwin we must
+ * define _DARWIN_C_SOURCE before including sys/mman.h. We do this in config.h.
+ */
+#if !defined MAP_ANONYMOUS && defined MAP_ANON
+# define MAP_ANONYMOUS  (MAP_ANON)
+#endif
+
 #endif /* UTIL_LINUX_C_H */
-- 
1.8.4.5


^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2016-02-18 15:51 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-18 13:12 [PATCH 00/15] portability fixes in the mix (OSX) Ruediger Meier
2016-02-18 13:12 ` [PATCH 01/15] travis: minor cleanup Ruediger Meier
2016-02-18 13:12 ` [PATCH 02/15] build-sys: portable usage of find command Ruediger Meier
2016-02-18 13:12 ` [PATCH 03/15] build-sys: check linker support for version scripts Ruediger Meier
2016-02-18 13:12 ` [PATCH 04/15] build-sys: fix [g]libtoolize version for OSX Ruediger Meier
2016-02-18 13:12 ` [PATCH 05/15] tests: fix ts_option helpers Ruediger Meier
2016-02-18 13:12 ` [PATCH 06/15] lib: rename strmode() and setmode() Ruediger Meier
2016-02-18 13:12 ` [PATCH 07/15] include: provide MAP_ANONYMOUS on OSX Ruediger Meier
2016-02-18 13:21   ` Karel Zak
2016-02-18 14:10     ` Ruediger Meier
2016-02-18 14:28       ` Karel Zak
2016-02-18 15:51   ` [PATCH v2 " Ruediger Meier
2016-02-18 13:12 ` [PATCH 08/15] lib: define LOGIN_NAME_MAX fallback Ruediger Meier
2016-02-18 13:12 ` [PATCH 09/15] include: check for sys/sysmacros.h Ruediger Meier
2016-02-18 13:22 ` [PATCH 10/15] include: remove unused mntent.h Ruediger Meier
2016-02-18 13:22 ` [PATCH 11/15] lsns: use xcalloc() Ruediger Meier
2016-02-18 13:22 ` [PATCH 12/15] lib: remove unused variable Ruediger Meier
2016-02-18 13:23 ` [PATCH 13/15] lib: fix ismounted includes for FreeBSD Ruediger Meier
2016-02-18 13:23 ` [PATCH 14/15] libblkid: don't include endian.h Ruediger Meier
2016-02-18 13:23 ` [PATCH 15/15] include: fix sys/sysinfo.h Ruediger Meier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox