diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/grep/PKGBUILD | 11 | ||||
-rw-r--r-- | core/grep/grep-2.11-exclude-dir-crash.patch | 44 | ||||
-rw-r--r-- | core/libedit/PKGBUILD | 10 | ||||
-rw-r--r-- | core/mkinitcpio-busybox/PKGBUILD | 12 | ||||
-rw-r--r-- | core/mkinitcpio-busybox/config | 38 | ||||
-rw-r--r-- | core/mpfr/PKGBUILD | 6 | ||||
-rw-r--r-- | core/mpfr/mpfr-3.1.0.p7.patch | 1236 | ||||
-rw-r--r-- | core/openssl/PKGBUILD | 14 | ||||
-rw-r--r-- | core/udev/PKGBUILD | 19 | ||||
-rw-r--r-- | core/udev/udev.install | 100 | ||||
-rw-r--r-- | core/util-linux/PKGBUILD | 46 | ||||
-rw-r--r-- | core/util-linux/stable-fixes-2.21.patch | 1516 |
12 files changed, 2915 insertions, 137 deletions
diff --git a/core/grep/PKGBUILD b/core/grep/PKGBUILD index 34c43a1f8..2a2fda2cf 100644 --- a/core/grep/PKGBUILD +++ b/core/grep/PKGBUILD @@ -1,10 +1,10 @@ -# $Id: PKGBUILD 151831 2012-03-03 08:49:06Z allan $ +# $Id: PKGBUILD 153418 2012-03-13 08:24:31Z allan $ # Maintainer: Allan McRae <allan@archlinux.org> # Contributor: judd <jvinet@zeroflux.org> pkgname=grep pkgver=2.11 -pkgrel=1 +pkgrel=2 pkgdesc="A string search utility" arch=('i686' 'x86_64' 'mips64el') license=('GPL3') @@ -13,12 +13,15 @@ groups=('base') depends=('glibc' 'pcre' 'sh') makedepends=('texinfo') install=${pkgname}.install -source=(ftp://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver.tar.xz{,.sig}) +source=(ftp://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver.tar.xz{,.sig} + grep-2.11-exclude-dir-crash.patch) md5sums=('ad9c6dbdeab93e50d2bc380f10ed3643' - 'e4fea5e355973c951f93f48bc86f92fa') + 'e4fea5e355973c951f93f48bc86f92fa' + 'e882644cf8c1a4e37da7ba8c0867e70b') build() { cd ${srcdir}/${pkgname}-${pkgver} + patch -p1 -i $srcdir/grep-2.11-exclude-dir-crash.patch ./configure --prefix=/usr --without-included-regex make } diff --git a/core/grep/grep-2.11-exclude-dir-crash.patch b/core/grep/grep-2.11-exclude-dir-crash.patch new file mode 100644 index 000000000..6b1731768 --- /dev/null +++ b/core/grep/grep-2.11-exclude-dir-crash.patch @@ -0,0 +1,44 @@ +From 12c957f786b12a4dd116f9c40a715d671d17fa16 Mon Sep 17 00:00:00 2001 +From: Allan McRae <allan@archlinux.org> +Date: Mon, 12 Mar 2012 09:28:01 +0100 +Subject: [PATCH] grep: fix segfault with -r --exclude-dir and no file operand + +* src/main.c (grepdir): Don't invoke excluded_file_name on NULL. +* NEWS (Bug fixes): Mention it. +--- + NEWS | 5 +++++ + src/main.c | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +diff --git a/NEWS b/NEWS +index d0a63d5..d4d70f5 100644 +--- a/NEWS ++++ b/NEWS +@@ -2,6 +2,11 @@ GNU grep NEWS -*- outline -*- + + * Noteworthy changes in release ?.? (????-??-??) [?] + ++** Bug fixes ++ ++ grep no longer segfaults with -r --exclude-dir and no file operand. ++ I.e., ":|grep -r --exclude-dir=D PAT" would segfault. ++ + + * Noteworthy changes in release 2.11 (2012-03-02) [stable] + +diff --git a/src/main.c b/src/main.c +index 2f6c761..f4f1235 100644 +--- a/src/main.c ++++ b/src/main.c +@@ -1361,7 +1361,7 @@ grepdir (char const *dir, struct stats const *stats) + struct stats const *ancestor; + char *name_space; + int status = 1; +- if (excluded_directory_patterns ++ if (dir && excluded_directory_patterns + && excluded_file_name (excluded_directory_patterns, dir)) + return 1; + +-- +1.7.9.3 + diff --git a/core/libedit/PKGBUILD b/core/libedit/PKGBUILD index 59b8c9433..cfd7e4fbe 100644 --- a/core/libedit/PKGBUILD +++ b/core/libedit/PKGBUILD @@ -1,19 +1,19 @@ -# $Id: PKGBUILD 135574 2011-08-15 23:39:35Z bisson $ +# $Id: PKGBUILD 153493 2012-03-15 00:07:12Z bisson $ # Maintainer: Gaetan Bisson <bisson@archlinux.org> # Maintainer: Vesa Kaihlavirta <vesa@archlinux.org> # Contributor: Roman Cheplyaka <roma@ro-che.info> pkgname=libedit -pkgver=20110802_3.0 +pkgver=20120311_3.0 pkgrel=1 pkgdesc='Command line editor library providing generic line editing, history, and tokenization functions' -arch=('i686' 'x86_64' 'mips64el') url='http://www.thrysoee.dk/editline/' +arch=('i686' 'x86_64' 'mips64el') license=('BSD') depends=('ncurses') options=('!libtool') source=("http://www.thrysoee.dk/editline/libedit-${pkgver/_/-}.tar.gz") -sha1sums=('b06e3cf248a4235617c71454e15ca3a54a61d467') +sha1sums=('2a4be10c33af5e3b09c1d3c8829b02fe5b41796b') build() { cd "${srcdir}/${pkgname}-${pkgver/_/-}" @@ -26,5 +26,5 @@ package() { make prefix="${pkgdir}"/usr install cp "${pkgdir}"/usr/share/man/man3/editline.3 "${pkgdir}"/usr/share/man/man3/el.3 - install -D -m0644 COPYING "${pkgdir}"/usr/share/licenses/libedit/LICENSE + install -Dm644 COPYING "${pkgdir}"/usr/share/licenses/libedit/LICENSE } diff --git a/core/mkinitcpio-busybox/PKGBUILD b/core/mkinitcpio-busybox/PKGBUILD index 22980acea..ddc7eac08 100644 --- a/core/mkinitcpio-busybox/PKGBUILD +++ b/core/mkinitcpio-busybox/PKGBUILD @@ -1,10 +1,10 @@ -# $Id: PKGBUILD 141112 2011-10-24 09:59:21Z dreisner $ +# $Id: PKGBUILD 153485 2012-03-14 23:26:22Z tomegun $ # Maintainer: Dave Reisner <dreisner@archlinux.org> # Maintainer: Thomas Bächler <thomas@archlinux.org> pkgname=mkinitcpio-busybox -pkgver=1.19.2 -pkgrel=1.1 +pkgver=1.19.4 +pkgrel=2 pkgdesc="base initramfs tools" arch=('i686' 'x86_64' 'mips64el') url="http://www.busybox.net/" @@ -13,8 +13,8 @@ depends=('glibc') options=('!buildflags') source=("http://busybox.net/downloads/busybox-$pkgver.tar.bz2" 'config') -sha256sums=('ea7ec9b6df70b8c528f4a2b6300e9913431c7223308fb08dfafa7508d75a0cb9' - '21ae2cd21e33ba1ef9500a9b14273579fc554bf995cfd7907fb3fe94fc162cf8') +sha256sums=('9b853406da61ffb59eb488495fe99cbb7fb3dd29a31307fcfa9cf070543710ee' + '28dc775e12c40718b48e1dd6a63544ca9d8aa128f786577b27e4df73e1e8766a') build() { cd "$srcdir/busybox-$pkgver" @@ -33,7 +33,7 @@ build() { } package() { - install -Dm755 "$srcdir/busybox-$pkgver/busybox" "$pkgdir/lib/initcpio/busybox" + install -Dm755 "$srcdir/busybox-$pkgver/busybox" "$pkgdir/usr/lib/initcpio/busybox" } # vim:set ts=2 sw=2 et: diff --git a/core/mkinitcpio-busybox/config b/core/mkinitcpio-busybox/config index 86160a203..3cd776e03 100644 --- a/core/mkinitcpio-busybox/config +++ b/core/mkinitcpio-busybox/config @@ -486,14 +486,14 @@ CONFIG_LAST_SYSTEM_ID=0 # # Linux Module Utilities # -CONFIG_MODINFO=y +# CONFIG_MODINFO is not set # CONFIG_MODPROBE_SMALL is not set # CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE is not set # CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED is not set -CONFIG_INSMOD=y -CONFIG_RMMOD=y -CONFIG_LSMOD=y -CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT=y +# CONFIG_INSMOD is not set +# CONFIG_RMMOD is not set +# CONFIG_LSMOD is not set +# CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set # CONFIG_MODPROBE is not set # CONFIG_FEATURE_MODPROBE_BLACKLIST is not set # CONFIG_DEPMOD is not set @@ -508,11 +508,11 @@ CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT=y # CONFIG_FEATURE_INSMOD_LOADINKMEM is not set # CONFIG_FEATURE_INSMOD_LOAD_MAP is not set # CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set -CONFIG_FEATURE_CHECK_TAINTED_MODULE=y +# CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set # CONFIG_FEATURE_MODUTILS_ALIAS is not set # CONFIG_FEATURE_MODUTILS_SYMBOLS is not set -CONFIG_DEFAULT_MODULES_DIR="" -CONFIG_DEFAULT_DEPMOD_FILE="" +# CONFIG_DEFAULT_MODULES_DIR is not set +# CONFIG_DEFAULT_DEPMOD_FILE is not set # # Linux System Utilities @@ -570,15 +570,15 @@ CONFIG_LOSETUP=y # CONFIG_MKSWAP is not set # CONFIG_FEATURE_MKSWAP_UUID is not set # CONFIG_MORE is not set -CONFIG_MOUNT=y -CONFIG_FEATURE_MOUNT_FAKE=y -CONFIG_FEATURE_MOUNT_VERBOSE=y -CONFIG_FEATURE_MOUNT_HELPERS=y -CONFIG_FEATURE_MOUNT_LABEL=y -CONFIG_FEATURE_MOUNT_NFS=y -CONFIG_FEATURE_MOUNT_CIFS=y -CONFIG_FEATURE_MOUNT_FLAGS=y -CONFIG_FEATURE_MOUNT_FSTAB=y +# CONFIG_MOUNT is not set +# CONFIG_FEATURE_MOUNT_FAKE is not set +# CONFIG_FEATURE_MOUNT_VERBOSE is not set +# CONFIG_FEATURE_MOUNT_HELPERS is not set +# CONFIG_FEATURE_MOUNT_LABEL is not set +# CONFIG_FEATURE_MOUNT_NFS is not set +# CONFIG_FEATURE_MOUNT_CIFS is not set +# CONFIG_FEATURE_MOUNT_FLAGS is not set +# CONFIG_FEATURE_MOUNT_FSTAB is not set # CONFIG_PIVOT_ROOT is not set # CONFIG_RDATE is not set # CONFIG_RDEV is not set @@ -589,7 +589,7 @@ CONFIG_FEATURE_MOUNT_FSTAB=y # CONFIG_SETARCH is not set # CONFIG_SWAPONOFF is not set # CONFIG_FEATURE_SWAPON_PRI is not set -CONFIG_SWITCH_ROOT=y +# CONFIG_SWITCH_ROOT is not set CONFIG_UMOUNT=y CONFIG_FEATURE_UMOUNT_ALL=y @@ -599,7 +599,7 @@ CONFIG_FEATURE_UMOUNT_ALL=y CONFIG_FEATURE_MOUNT_LOOP=y CONFIG_FEATURE_MOUNT_LOOP_CREATE=y # CONFIG_FEATURE_MTAB_SUPPORT is not set -CONFIG_VOLUMEID=y +# CONFIG_VOLUMEID is not set # # Filesystem/Volume identification diff --git a/core/mpfr/PKGBUILD b/core/mpfr/PKGBUILD index 055e4aeb3..880bb2051 100644 --- a/core/mpfr/PKGBUILD +++ b/core/mpfr/PKGBUILD @@ -1,10 +1,10 @@ -# $Id: PKGBUILD 142421 2011-11-09 09:27:32Z allan $ +# $Id: PKGBUILD 153420 2012-03-13 08:24:35Z allan $ # Maintainer: Allan McRae <allan@archlinux.org> # Contributor: damir <damir@archlinux.org> pkgname=mpfr _pkgver=3.1.0 -_patchlevel=p3 +_patchlevel=p7 pkgver=${_pkgver}.${_patchlevel} pkgrel=1 pkgdesc="Multiple-precision floating-point library" @@ -18,7 +18,7 @@ source=(http://www.mpfr.org/mpfr-current/mpfr-${_pkgver}.tar.xz{,.asc} mpfr-${_pkgver}.${_patchlevel}.patch) md5sums=('6e495841bb026481567006cec0f821c3' '293374ee4b01527f8f7889fdfa9016f8' - 'd65858ccddbea968d6580124320fb6a0') + 'fb1bf603a2ad5e6ecc1903c3c53f5e13') build() { cd "${srcdir}/${pkgname}-${_pkgver}" diff --git a/core/mpfr/mpfr-3.1.0.p7.patch b/core/mpfr/mpfr-3.1.0.p7.patch new file mode 100644 index 000000000..f3de639bc --- /dev/null +++ b/core/mpfr/mpfr-3.1.0.p7.patch @@ -0,0 +1,1236 @@ +diff -Naurd mpfr-3.1.0-a/PATCHES mpfr-3.1.0-b/PATCHES +--- mpfr-3.1.0-a/PATCHES 2011-10-05 21:39:57.000000000 +0000 ++++ mpfr-3.1.0-b/PATCHES 2011-10-05 21:39:57.000000000 +0000 +@@ -0,0 +1 @@ ++mpfr_unlikely +diff -Naurd mpfr-3.1.0-a/VERSION mpfr-3.1.0-b/VERSION +--- mpfr-3.1.0-a/VERSION 2011-10-03 08:17:15.000000000 +0000 ++++ mpfr-3.1.0-b/VERSION 2011-10-05 21:39:57.000000000 +0000 +@@ -1 +1 @@ +-3.1.0 ++3.1.0-p1 +diff -Naurd mpfr-3.1.0-a/src/mpfr-impl.h mpfr-3.1.0-b/src/mpfr-impl.h +--- mpfr-3.1.0-a/src/mpfr-impl.h 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/mpfr-impl.h 2011-10-05 21:39:57.000000000 +0000 +@@ -988,10 +988,11 @@ + ******************************************************/ + + /* Theses macros help the compiler to determine if a test is +- * likely or unlikely. */ ++ likely or unlikely. The !! is necessary in case x is larger ++ than a long. */ + #if __MPFR_GNUC(3,0) || __MPFR_ICC(8,1,0) + # define MPFR_LIKELY(x) (__builtin_expect(!!(x),1)) +-# define MPFR_UNLIKELY(x) (__builtin_expect((x),0)) ++# define MPFR_UNLIKELY(x) (__builtin_expect(!!(x),0)) + #else + # define MPFR_LIKELY(x) (x) + # define MPFR_UNLIKELY(x) (x) +diff -Naurd mpfr-3.1.0-a/src/mpfr.h mpfr-3.1.0-b/src/mpfr.h +--- mpfr-3.1.0-a/src/mpfr.h 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/mpfr.h 2011-10-05 21:39:57.000000000 +0000 +@@ -27,7 +27,7 @@ + #define MPFR_VERSION_MAJOR 3 + #define MPFR_VERSION_MINOR 1 + #define MPFR_VERSION_PATCHLEVEL 0 +-#define MPFR_VERSION_STRING "3.1.0" ++#define MPFR_VERSION_STRING "3.1.0-p1" + + /* Macros dealing with MPFR VERSION */ + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) +diff -Naurd mpfr-3.1.0-a/src/version.c mpfr-3.1.0-b/src/version.c +--- mpfr-3.1.0-a/src/version.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/version.c 2011-10-05 21:39:57.000000000 +0000 +@@ -25,5 +25,5 @@ + const char * + mpfr_get_version (void) + { +- return "3.1.0"; ++ return "3.1.0-p1"; + } +diff -Naurd mpfr-3.1.0-a/PATCHES mpfr-3.1.0-b/PATCHES +--- mpfr-3.1.0-a/PATCHES 2011-10-14 10:43:32.000000000 +0000 ++++ mpfr-3.1.0-b/PATCHES 2011-10-14 10:43:32.000000000 +0000 +@@ -0,0 +1 @@ ++lib-search-path +diff -Naurd mpfr-3.1.0-a/VERSION mpfr-3.1.0-b/VERSION +--- mpfr-3.1.0-a/VERSION 2011-10-05 21:39:57.000000000 +0000 ++++ mpfr-3.1.0-b/VERSION 2011-10-14 10:43:32.000000000 +0000 +@@ -1 +1 @@ +-3.1.0-p1 ++3.1.0-p2 +diff -Naurd mpfr-3.1.0-a/src/mpfr.h mpfr-3.1.0-b/src/mpfr.h +--- mpfr-3.1.0-a/src/mpfr.h 2011-10-05 21:39:57.000000000 +0000 ++++ mpfr-3.1.0-b/src/mpfr.h 2011-10-14 10:43:32.000000000 +0000 +@@ -27,7 +27,7 @@ + #define MPFR_VERSION_MAJOR 3 + #define MPFR_VERSION_MINOR 1 + #define MPFR_VERSION_PATCHLEVEL 0 +-#define MPFR_VERSION_STRING "3.1.0-p1" ++#define MPFR_VERSION_STRING "3.1.0-p2" + + /* Macros dealing with MPFR VERSION */ + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) +diff -Naurd mpfr-3.1.0-a/src/version.c mpfr-3.1.0-b/src/version.c +--- mpfr-3.1.0-a/src/version.c 2011-10-05 21:39:57.000000000 +0000 ++++ mpfr-3.1.0-b/src/version.c 2011-10-14 10:43:32.000000000 +0000 +@@ -25,5 +25,5 @@ + const char * + mpfr_get_version (void) + { +- return "3.1.0-p1"; ++ return "3.1.0-p2"; + } +diff -Naurd mpfr-3.1.0-a/tests/Makefile.am mpfr-3.1.0-b/tests/Makefile.am +--- mpfr-3.1.0-a/tests/Makefile.am 2011-10-03 08:17:14.000000000 +0000 ++++ mpfr-3.1.0-b/tests/Makefile.am 2011-10-03 08:17:14.000000000 +0000 +@@ -65,8 +65,24 @@ + TESTS = $(check_PROGRAMS) + TESTS_ENVIRONMENT = MPFR_QUIET=1 $(VALGRIND) + +-# Option to prevent libtool from generating wrapper scripts for the tests. ++# The -no-install option prevents libtool from generating wrapper scripts ++# for the tests. + # This is useful to easily run the test scripts under valgrind or gdb. + # See discussion http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/28033 + # http://article.gmane.org/gmane.comp.lib.gnulib.bugs/28140 in particular. +-AM_LDFLAGS = -no-install ++# ++# The -L$(top_builddir)/src/.libs option is necessary for some platforms, ++# such as HP-UX, when --with-gmp or --with-gmp-lib is used and an old MPFR ++# library is already installed in the corresponding lib directory: its ++# purpose is to make sure that the local .libs comes first in the library ++# search path (otherwise the tests are linked against the old MPFR library ++# by the LINK command -- see the generated Makefile). See: ++# http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00042.html ++# http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00043.html ++# http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00044.html ++# http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00066.html ++# http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00065.html ++# and ++# http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9728 ++# ++AM_LDFLAGS = -no-install -L$(top_builddir)/src/.libs +diff -Naurd mpfr-3.1.0-a/tests/Makefile.in mpfr-3.1.0-b/tests/Makefile.in +--- mpfr-3.1.0-a/tests/Makefile.in 2011-10-03 08:17:35.000000000 +0000 ++++ mpfr-3.1.0-b/tests/Makefile.in 2011-10-03 08:17:35.000000000 +0000 +@@ -1124,11 +1124,27 @@ + TESTS = $(check_PROGRAMS) + TESTS_ENVIRONMENT = MPFR_QUIET=1 $(VALGRIND) + +-# Option to prevent libtool from generating wrapper scripts for the tests. ++# The -no-install option prevents libtool from generating wrapper scripts ++# for the tests. + # This is useful to easily run the test scripts under valgrind or gdb. + # See discussion http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/28033 + # http://article.gmane.org/gmane.comp.lib.gnulib.bugs/28140 in particular. +-AM_LDFLAGS = -no-install ++# ++# The -L$(top_builddir)/src/.libs option is necessary for some platforms, ++# such as HP-UX, when --with-gmp or --with-gmp-lib is used and an old MPFR ++# library is already installed in the corresponding lib directory: its ++# purpose is to make sure that the local .libs comes first in the library ++# search path (otherwise the tests are linked against the old MPFR library ++# by the LINK command -- see the generated Makefile). See: ++# http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00042.html ++# http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00043.html ++# http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00044.html ++# http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00066.html ++# http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00065.html ++# and ++# http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9728 ++# ++AM_LDFLAGS = -no-install -L$(top_builddir)/src/.libs + all: all-am + + .SUFFIXES: +diff -Naurd mpfr-3.1.0-a/PATCHES mpfr-3.1.0-b/PATCHES +--- mpfr-3.1.0-a/PATCHES 2011-11-03 15:15:11.000000000 +0000 ++++ mpfr-3.1.0-b/PATCHES 2011-11-03 15:15:11.000000000 +0000 +@@ -0,0 +1 @@ ++vasprintf +diff -Naurd mpfr-3.1.0-a/VERSION mpfr-3.1.0-b/VERSION +--- mpfr-3.1.0-a/VERSION 2011-10-14 10:43:32.000000000 +0000 ++++ mpfr-3.1.0-b/VERSION 2011-11-03 15:15:11.000000000 +0000 +@@ -1 +1 @@ +-3.1.0-p2 ++3.1.0-p3 +diff -Naurd mpfr-3.1.0-a/src/mpfr.h mpfr-3.1.0-b/src/mpfr.h +--- mpfr-3.1.0-a/src/mpfr.h 2011-10-14 10:43:32.000000000 +0000 ++++ mpfr-3.1.0-b/src/mpfr.h 2011-11-03 15:15:11.000000000 +0000 +@@ -27,7 +27,7 @@ + #define MPFR_VERSION_MAJOR 3 + #define MPFR_VERSION_MINOR 1 + #define MPFR_VERSION_PATCHLEVEL 0 +-#define MPFR_VERSION_STRING "3.1.0-p2" ++#define MPFR_VERSION_STRING "3.1.0-p3" + + /* Macros dealing with MPFR VERSION */ + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) +diff -Naurd mpfr-3.1.0-a/src/vasprintf.c mpfr-3.1.0-b/src/vasprintf.c +--- mpfr-3.1.0-a/src/vasprintf.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/vasprintf.c 2011-11-03 15:15:11.000000000 +0000 +@@ -1178,7 +1178,7 @@ + mpfr_exp_t exp; + char * str; + const int spec_g = (spec.spec == 'g' || spec.spec == 'G'); +- const int keep_trailing_zeros = spec_g && spec.alt; ++ const int keep_trailing_zeros = !spec_g || spec.alt; + + /* WARNING: an empty precision field is forbidden (it means precision = 6 + and it should have been changed to 6 before the function call) */ +@@ -1356,7 +1356,7 @@ + else + /* 1 <= |p| */ + { +- size_t nsd; /* Number of significant digits */ ++ size_t str_len; + + /* Determine the position of the most significant decimal digit. */ + exp = floor_log10 (p); +@@ -1365,12 +1365,10 @@ + /* P is too large to print all its integral part digits */ + return -1; + +- np->ip_size = exp + 1; +- +- nsd = spec.prec + np->ip_size; + if (dec_info == NULL) +- { +- str = mpfr_get_str (NULL, &exp, 10, nsd, p, spec.rnd_mode); ++ { /* this case occurs with mpfr_printf ("%.0RUf", x) with x=9.5 */ ++ str = ++ mpfr_get_str (NULL, &exp, 10, spec.prec+exp+1, p, spec.rnd_mode); + register_string (np->sl, str); + } + else +@@ -1379,81 +1377,60 @@ + str = dec_info->str; + } + np->ip_ptr = MPFR_IS_NEG (p) ? ++str : str; /* skip sign */ ++ str_len = strlen (str); ++ ++ /* integral part */ ++ if (exp > str_len) ++ /* mpfr_get_str gives no trailing zero when p is rounded up to the next ++ power of 10 (p integer, so no fractional part) */ ++ { ++ np->ip_trailing_zeros = exp - str_len; ++ np->ip_size = str_len; ++ } ++ else ++ np->ip_size = exp; + + if (spec.group) + /* thousands separator in integral part */ + np->thousands_sep = MPFR_THOUSANDS_SEPARATOR; + +- if (nsd == 0 || (spec_g && !spec.alt)) +- /* compute how much non-zero digits in integral and fractional +- parts */ ++ /* fractional part */ ++ str += np->ip_size; ++ str_len -= np->ip_size; ++ if (!keep_trailing_zeros) ++ /* remove trailing zeros, if any */ + { +- size_t str_len; +- str_len = strlen (str); /* note: the sign has been skipped */ +- +- if (exp > str_len) +- /* mpfr_get_str doesn't give the trailing zeros when p is a +- multiple of 10 (p integer, so no fractional part) */ +- { +- np->ip_trailing_zeros = exp - str_len; +- np->ip_size = str_len; +- if (spec.alt) +- np->point = MPFR_DECIMAL_POINT; +- } +- else +- /* str may contain some digits which are in fractional part */ ++ char *ptr = str + str_len - 1; /* pointer to the last digit of ++ str */ ++ while ((*ptr == '0') && (str_len != 0)) + { +- char *ptr; +- +- ptr = str + str_len - 1; /* points to the end of str */ +- str_len -= np->ip_size; /* number of digits in fractional +- part */ +- +- if (!keep_trailing_zeros) +- /* remove trailing zeros, if any */ +- { +- while ((*ptr == '0') && (str_len != 0)) +- { +- --ptr; +- --str_len; +- } +- } +- +- if (str_len > INT_MAX) +- /* too many digits in fractional part */ +- return -1; +- +- if (str_len != 0) +- /* some digits in fractional part */ +- { +- np->point = MPFR_DECIMAL_POINT; +- np->fp_ptr = str + np->ip_size; +- np->fp_size = str_len; +- } ++ --ptr; ++ --str_len; + } + } +- else +- /* spec.prec digits in fractional part */ ++ ++ if (str_len > 0) ++ /* some nonzero digits in fractional part */ + { +- if (np->ip_size == exp - 1) +- /* the absolute value of the number has been rounded up to a power +- of ten. +- Insert an additional zero in integral part and put the rest of +- them in fractional part. */ +- np->ip_trailing_zeros = 1; ++ if (str_len > INT_MAX) ++ /* too many digits in fractional part */ ++ return -1; + +- if (spec.prec != 0) +- { +- MPFR_ASSERTD (np->ip_size + np->ip_trailing_zeros == exp); +- MPFR_ASSERTD (np->ip_size + spec.prec == nsd); ++ np->point = MPFR_DECIMAL_POINT; ++ np->fp_ptr = str; ++ np->fp_size = str_len; ++ } + +- np->point = MPFR_DECIMAL_POINT; +- np->fp_ptr = str + np->ip_size; +- np->fp_size = spec.prec; +- } +- else if (spec.alt) +- np->point = MPFR_DECIMAL_POINT; ++ if (keep_trailing_zeros && str_len < spec.prec) ++ /* add missing trailing zeros */ ++ { ++ np->point = MPFR_DECIMAL_POINT; ++ np->fp_trailing_zeros = spec.prec - np->fp_size; + } ++ ++ if (spec.alt) ++ /* add decimal point even if no digits follow it */ ++ np->point = MPFR_DECIMAL_POINT; + } + + return 0; +diff -Naurd mpfr-3.1.0-a/src/version.c mpfr-3.1.0-b/src/version.c +--- mpfr-3.1.0-a/src/version.c 2011-10-14 10:43:32.000000000 +0000 ++++ mpfr-3.1.0-b/src/version.c 2011-11-03 15:15:11.000000000 +0000 +@@ -25,5 +25,5 @@ + const char * + mpfr_get_version (void) + { +- return "3.1.0-p2"; ++ return "3.1.0-p3"; + } +diff -Naurd mpfr-3.1.0-a/tests/tsprintf.c mpfr-3.1.0-b/tests/tsprintf.c +--- mpfr-3.1.0-a/tests/tsprintf.c 2011-10-03 08:17:14.000000000 +0000 ++++ mpfr-3.1.0-b/tests/tsprintf.c 2011-11-03 15:15:11.000000000 +0000 +@@ -475,6 +475,18 @@ + check_sprintf ("-1.", "%- #0.1RG", x); + + /* precision zero */ ++ mpfr_set_d (x, 9.5, MPFR_RNDN); ++ check_sprintf ("9", "%.0RDf", x); ++ check_sprintf ("10", "%.0RUf", x); ++ ++ mpfr_set_d (x, 19.5, MPFR_RNDN); ++ check_sprintf ("19", "%.0RDf", x); ++ check_sprintf ("20", "%.0RUf", x); ++ ++ mpfr_set_d (x, 99.5, MPFR_RNDN); ++ check_sprintf ("99", "%.0RDf", x); ++ check_sprintf ("100", "%.0RUf", x); ++ + mpfr_set_d (x, -9.5, MPFR_RNDN); + check_sprintf ("-10", "%.0RDf", x); + check_sprintf ("-10", "%.0RYf", x); +@@ -1078,6 +1090,23 @@ + mpfr_clear (x); + } + ++static void ++bug20111102 (void) ++{ ++ mpfr_t t; ++ char s[100]; ++ ++ mpfr_init2 (t, 84); ++ mpfr_set_str (t, "999.99999999999999999999", 10, MPFR_RNDN); ++ mpfr_sprintf (s, "%.20RNg", t); ++ if (strcmp (s, "1000") != 0) ++ { ++ printf ("Error in bug20111102, expected 1000, got %s\n", s); ++ exit (1); ++ } ++ mpfr_clear (t); ++} ++ + /* In particular, the following test makes sure that the rounding + * for %Ra and %Rb is not done on the MPFR number itself (as it + * would overflow). Note: it has been reported on comp.std.c that +@@ -1161,6 +1190,7 @@ + locale = setlocale (LC_ALL, "C"); + #endif + ++ bug20111102 (); + native_types (); + hexadecimal (); + binary (); +diff -Naurd mpfr-3.1.0-a/PATCHES mpfr-3.1.0-b/PATCHES +--- mpfr-3.1.0-a/PATCHES 2011-11-28 12:22:52.000000000 +0000 ++++ mpfr-3.1.0-b/PATCHES 2011-11-28 12:22:52.000000000 +0000 +@@ -0,0 +1 @@ ++gmp41compat +diff -Naurd mpfr-3.1.0-a/VERSION mpfr-3.1.0-b/VERSION +--- mpfr-3.1.0-a/VERSION 2011-11-03 15:15:11.000000000 +0000 ++++ mpfr-3.1.0-b/VERSION 2011-11-28 12:22:52.000000000 +0000 +@@ -1 +1 @@ +-3.1.0-p3 ++3.1.0-p4 +diff -Naurd mpfr-3.1.0-a/doc/mpfr.info mpfr-3.1.0-b/doc/mpfr.info +--- mpfr-3.1.0-a/doc/mpfr.info 2011-10-03 09:43:04.000000000 +0000 ++++ mpfr-3.1.0-b/doc/mpfr.info 2011-11-28 12:22:52.000000000 +0000 +@@ -2994,11 +2994,12 @@ + + * `mpfr_urandom' and `mpfr_urandomb' changed in MPFR 3.1. Their + behavior no longer depends on the platform (assuming this is also +- true for GMP's random generator). As a consequence, the returned +- values can be different between MPFR 3.1 and previous MPFR +- versions. Note: as the reproducibility of these functions was not +- specified before MPFR 3.1, the MPFR 3.1 behavior is _not_ regarded +- as backward incompatible with previous versions. ++ true for GMP's random generator, which is not the case between GMP ++ 4.1 and 4.2 if `gmp_randinit_default' is used). As a consequence, ++ the returned values can be different between MPFR 3.1 and previous ++ MPFR versions. Note: as the reproducibility of these functions ++ was not specified before MPFR 3.1, the MPFR 3.1 behavior is _not_ ++ regarded as backward incompatible with previous versions. + + + +@@ -4239,13 +4240,13 @@ + Node: Type and Macro Changes129308 + Node: Added Functions132029 + Node: Changed Functions134972 +-Node: Removed Functions139167 +-Node: Other Changes139579 +-Node: Contributors141108 +-Node: References143574 +-Node: GNU Free Documentation License145315 +-Node: Concept Index167758 +-Node: Function and Type Index173677 ++Node: Removed Functions139253 ++Node: Other Changes139665 ++Node: Contributors141194 ++Node: References143660 ++Node: GNU Free Documentation License145401 ++Node: Concept Index167844 ++Node: Function and Type Index173763 + + End Tag Table + +diff -Naurd mpfr-3.1.0-a/doc/mpfr.texi mpfr-3.1.0-b/doc/mpfr.texi +--- mpfr-3.1.0-a/doc/mpfr.texi 2011-10-03 08:17:14.000000000 +0000 ++++ mpfr-3.1.0-b/doc/mpfr.texi 2011-11-28 12:22:52.000000000 +0000 +@@ -3466,8 +3466,9 @@ + a lack of specification. + + @item @code{mpfr_urandom} and @code{mpfr_urandomb} changed in MPFR 3.1. +-Their behavior no longer depends on the platform (assuming this is also +-true for GMP's random generator). As a consequence, the returned values ++Their behavior no longer depends on the platform (assuming this is also true ++for GMP's random generator, which is not the case between GMP 4.1 and 4.2 if ++@code{gmp_randinit_default} is used). As a consequence, the returned values + can be different between MPFR 3.1 and previous MPFR versions. + Note: as the reproducibility of these functions was not specified + before MPFR 3.1, the MPFR 3.1 behavior is @emph{not} regarded as +diff -Naurd mpfr-3.1.0-a/src/mpfr.h mpfr-3.1.0-b/src/mpfr.h +--- mpfr-3.1.0-a/src/mpfr.h 2011-11-03 15:15:11.000000000 +0000 ++++ mpfr-3.1.0-b/src/mpfr.h 2011-11-28 12:22:52.000000000 +0000 +@@ -27,7 +27,7 @@ + #define MPFR_VERSION_MAJOR 3 + #define MPFR_VERSION_MINOR 1 + #define MPFR_VERSION_PATCHLEVEL 0 +-#define MPFR_VERSION_STRING "3.1.0-p3" ++#define MPFR_VERSION_STRING "3.1.0-p4" + + /* Macros dealing with MPFR VERSION */ + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) +diff -Naurd mpfr-3.1.0-a/src/version.c mpfr-3.1.0-b/src/version.c +--- mpfr-3.1.0-a/src/version.c 2011-11-03 15:15:11.000000000 +0000 ++++ mpfr-3.1.0-b/src/version.c 2011-11-28 12:22:52.000000000 +0000 +@@ -25,5 +25,5 @@ + const char * + mpfr_get_version (void) + { +- return "3.1.0-p3"; ++ return "3.1.0-p4"; + } +diff -Naurd mpfr-3.1.0-a/tests/trandom.c mpfr-3.1.0-b/tests/trandom.c +--- mpfr-3.1.0-a/tests/trandom.c 2011-10-03 08:17:14.000000000 +0000 ++++ mpfr-3.1.0-b/tests/trandom.c 2011-11-28 12:22:52.000000000 +0000 +@@ -114,21 +114,29 @@ + mpfr_t x; + gmp_randstate_t s; + ++#if __MPFR_GMP(4,2,0) ++# define C1 "0.895943" ++# define C2 "0.848824" ++#else ++# define C1 "0.479652" ++# define C2 "0.648529" ++#endif ++ + gmp_randinit_default (s); + gmp_randseed_ui (s, 42); + mpfr_init2 (x, 17); + mpfr_urandomb (x, s); +- if (mpfr_cmp_str1 (x, "0.895943") != 0) ++ if (mpfr_cmp_str1 (x, C1) != 0) + { +- printf ("Error in bug20100914, expected 0.895943, got "); ++ printf ("Error in bug20100914, expected " C1 ", got "); + mpfr_out_str (stdout, 10, 0, x, MPFR_RNDN); + printf ("\n"); + exit (1); + } + mpfr_urandomb (x, s); +- if (mpfr_cmp_str1 (x, "0.848824") != 0) ++ if (mpfr_cmp_str1 (x, C2) != 0) + { +- printf ("Error in bug20100914, expected 0.848824, got "); ++ printf ("Error in bug20100914, expected " C2 ", got "); + mpfr_out_str (stdout, 10, 0, x, MPFR_RNDN); + printf ("\n"); + exit (1); +diff -Naurd mpfr-3.1.0-a/tests/turandom.c mpfr-3.1.0-b/tests/turandom.c +--- mpfr-3.1.0-a/tests/turandom.c 2011-10-03 08:17:14.000000000 +0000 ++++ mpfr-3.1.0-b/tests/turandom.c 2011-11-28 12:22:52.000000000 +0000 +@@ -160,23 +160,29 @@ + mpfr_t x; + gmp_randstate_t s; + ++#if __MPFR_GMP(4,2,0) ++# define C1 "0.8488312" ++# define C2 "0.8156509" ++#else ++# define C1 "0.6485367" ++# define C2 "0.9362717" ++#endif ++ + gmp_randinit_default (s); + gmp_randseed_ui (s, 42); + mpfr_init2 (x, 17); + mpfr_urandom (x, s, MPFR_RNDN); +- /* the following values are obtained on a 32-bit computer, we should get +- the same values on a 64-bit computer */ +- if (mpfr_cmp_str1 (x, "0.8488312") != 0) ++ if (mpfr_cmp_str1 (x, C1) != 0) + { +- printf ("Error in bug20100914, expected 0.8488312, got "); ++ printf ("Error in bug20100914, expected " C1 ", got "); + mpfr_out_str (stdout, 10, 0, x, MPFR_RNDN); + printf ("\n"); + exit (1); + } + mpfr_urandom (x, s, MPFR_RNDN); +- if (mpfr_cmp_str1 (x, "0.8156509") != 0) ++ if (mpfr_cmp_str1 (x, C2) != 0) + { +- printf ("Error in bug20100914, expected 0.8156509, got "); ++ printf ("Error in bug20100914, expected " C2 ", got "); + mpfr_out_str (stdout, 10, 0, x, MPFR_RNDN); + printf ("\n"); + exit (1); +diff -Naurd mpfr-3.1.0-a/PATCHES mpfr-3.1.0-b/PATCHES +--- mpfr-3.1.0-a/PATCHES 2012-02-24 12:44:49.000000000 +0000 ++++ mpfr-3.1.0-b/PATCHES 2012-02-24 12:44:49.000000000 +0000 +@@ -0,0 +1 @@ ++logging-freeze +diff -Naurd mpfr-3.1.0-a/VERSION mpfr-3.1.0-b/VERSION +--- mpfr-3.1.0-a/VERSION 2011-11-28 12:22:52.000000000 +0000 ++++ mpfr-3.1.0-b/VERSION 2012-02-24 12:44:49.000000000 +0000 +@@ -1 +1 @@ +-3.1.0-p4 ++3.1.0-p5 +diff -Naurd mpfr-3.1.0-a/src/add_d.c mpfr-3.1.0-b/src/add_d.c +--- mpfr-3.1.0-a/src/add_d.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/add_d.c 2012-02-24 12:44:49.000000000 +0000 +@@ -34,7 +34,7 @@ + (("b[%Pu]=%.*Rg c=%.20g rnd=%d", + mpfr_get_prec(b), mpfr_log_prec, b, c, rnd_mode), + ("a[%Pu]=%.*Rg inexact=%d", +- mpfr_get_prec (a), mpfr_get_prec, a, inexact)); ++ mpfr_get_prec (a), mpfr_log_prec, a, inexact)); + + MPFR_SAVE_EXPO_MARK (expo); + +diff -Naurd mpfr-3.1.0-a/src/add_ui.c mpfr-3.1.0-b/src/add_ui.c +--- mpfr-3.1.0-a/src/add_ui.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/add_ui.c 2012-02-24 12:44:49.000000000 +0000 +@@ -29,7 +29,7 @@ + MPFR_LOG_FUNC + (("x[%Pu]=%.*Rg u=%d rnd=%d", + mpfr_get_prec(x), mpfr_log_prec, x, u, rnd_mode), +- ("y[%Pu]=%.*Rg", mpfr_get_prec (y), mpfr_get_prec, y)); ++ ("y[%Pu]=%.*Rg", mpfr_get_prec (y), mpfr_log_prec, y)); + + if (MPFR_LIKELY(u != 0) ) /* if u=0, do nothing */ + { +diff -Naurd mpfr-3.1.0-a/src/mpfr.h mpfr-3.1.0-b/src/mpfr.h +--- mpfr-3.1.0-a/src/mpfr.h 2011-11-28 12:22:52.000000000 +0000 ++++ mpfr-3.1.0-b/src/mpfr.h 2012-02-24 12:44:49.000000000 +0000 +@@ -27,7 +27,7 @@ + #define MPFR_VERSION_MAJOR 3 + #define MPFR_VERSION_MINOR 1 + #define MPFR_VERSION_PATCHLEVEL 0 +-#define MPFR_VERSION_STRING "3.1.0-p4" ++#define MPFR_VERSION_STRING "3.1.0-p5" + + /* Macros dealing with MPFR VERSION */ + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) +diff -Naurd mpfr-3.1.0-a/src/mul_d.c mpfr-3.1.0-b/src/mul_d.c +--- mpfr-3.1.0-a/src/mul_d.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/mul_d.c 2012-02-24 12:44:49.000000000 +0000 +@@ -34,7 +34,7 @@ + (("b[%Pu]=%.*Rg c=%.20g rnd=%d", + mpfr_get_prec(b), mpfr_log_prec, b, c, rnd_mode), + ("a[%Pu]=%.*Rg inexact=%d", +- mpfr_get_prec (a), mpfr_get_prec, a, inexact)); ++ mpfr_get_prec (a), mpfr_log_prec, a, inexact)); + + MPFR_SAVE_EXPO_MARK (expo); + +diff -Naurd mpfr-3.1.0-a/src/version.c mpfr-3.1.0-b/src/version.c +--- mpfr-3.1.0-a/src/version.c 2011-11-28 12:22:52.000000000 +0000 ++++ mpfr-3.1.0-b/src/version.c 2012-02-24 12:44:49.000000000 +0000 +@@ -25,5 +25,5 @@ + const char * + mpfr_get_version (void) + { +- return "3.1.0-p4"; ++ return "3.1.0-p5"; + } +diff -Naurd mpfr-3.1.0-a/PATCHES mpfr-3.1.0-b/PATCHES +--- mpfr-3.1.0-a/PATCHES 2012-02-24 13:50:05.000000000 +0000 ++++ mpfr-3.1.0-b/PATCHES 2012-02-24 13:50:05.000000000 +0000 +@@ -0,0 +1 @@ ++logging-varfmt +diff -Naurd mpfr-3.1.0-a/VERSION mpfr-3.1.0-b/VERSION +--- mpfr-3.1.0-a/VERSION 2012-02-24 12:44:49.000000000 +0000 ++++ mpfr-3.1.0-b/VERSION 2012-02-24 13:50:05.000000000 +0000 +@@ -1 +1 @@ +-3.1.0-p5 ++3.1.0-p6 +diff -Naurd mpfr-3.1.0-a/src/mpfr-impl.h mpfr-3.1.0-b/src/mpfr-impl.h +--- mpfr-3.1.0-a/src/mpfr-impl.h 2011-10-05 21:39:57.000000000 +0000 ++++ mpfr-3.1.0-b/src/mpfr-impl.h 2012-02-24 13:50:05.000000000 +0000 +@@ -1592,7 +1592,7 @@ + do \ + if ((MPFR_LOG_INTERNAL_F & mpfr_log_type) && \ + (mpfr_log_current <= mpfr_log_level)) \ +- LOG_PRINT ("%s.%d:%s[%#Pu]=%.*Rf\n", __func__, __LINE__, \ ++ LOG_PRINT ("%s.%d:%s[%#Pu]=%.*Rg\n", __func__, __LINE__, \ + #x, mpfr_get_prec (x), mpfr_log_prec, x); \ + while (0) + +diff -Naurd mpfr-3.1.0-a/src/mpfr.h mpfr-3.1.0-b/src/mpfr.h +--- mpfr-3.1.0-a/src/mpfr.h 2012-02-24 12:44:49.000000000 +0000 ++++ mpfr-3.1.0-b/src/mpfr.h 2012-02-24 13:50:05.000000000 +0000 +@@ -27,7 +27,7 @@ + #define MPFR_VERSION_MAJOR 3 + #define MPFR_VERSION_MINOR 1 + #define MPFR_VERSION_PATCHLEVEL 0 +-#define MPFR_VERSION_STRING "3.1.0-p5" ++#define MPFR_VERSION_STRING "3.1.0-p6" + + /* Macros dealing with MPFR VERSION */ + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) +diff -Naurd mpfr-3.1.0-a/src/version.c mpfr-3.1.0-b/src/version.c +--- mpfr-3.1.0-a/src/version.c 2012-02-24 12:44:49.000000000 +0000 ++++ mpfr-3.1.0-b/src/version.c 2012-02-24 13:50:05.000000000 +0000 +@@ -25,5 +25,5 @@ + const char * + mpfr_get_version (void) + { +- return "3.1.0-p5"; ++ return "3.1.0-p6"; + } +diff -Naurd mpfr-3.1.0-a/PATCHES mpfr-3.1.0-b/PATCHES +--- mpfr-3.1.0-a/PATCHES 2012-03-08 15:17:03.000000000 +0000 ++++ mpfr-3.1.0-b/PATCHES 2012-03-08 15:17:03.000000000 +0000 +@@ -0,0 +1 @@ ++large-prec +diff -Naurd mpfr-3.1.0-a/VERSION mpfr-3.1.0-b/VERSION +--- mpfr-3.1.0-a/VERSION 2012-02-24 13:50:05.000000000 +0000 ++++ mpfr-3.1.0-b/VERSION 2012-03-08 15:17:03.000000000 +0000 +@@ -1 +1 @@ +-3.1.0-p6 ++3.1.0-p7 +diff -Naurd mpfr-3.1.0-a/src/add1.c mpfr-3.1.0-b/src/add1.c +--- mpfr-3.1.0-a/src/add1.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/add1.c 2012-03-08 15:17:03.000000000 +0000 +@@ -44,12 +44,12 @@ + bq = MPFR_PREC(b); + cq = MPFR_PREC(c); + +- an = (aq-1)/GMP_NUMB_BITS+1; /* number of limbs of a */ ++ an = MPFR_PREC2LIMBS (aq); /* number of limbs of a */ + aq2 = (mpfr_prec_t) an * GMP_NUMB_BITS; + sh = aq2 - aq; /* non-significant bits in low limb */ + +- bn = (bq-1)/GMP_NUMB_BITS+1; /* number of limbs of b */ +- cn = (cq-1)/GMP_NUMB_BITS+1; /* number of limbs of c */ ++ bn = MPFR_PREC2LIMBS (bq); /* number of limbs of b */ ++ cn = MPFR_PREC2LIMBS (cq); /* number of limbs of c */ + + ap = MPFR_MANT(a); + bp = MPFR_MANT(b); +@@ -124,7 +124,7 @@ + dif = aq2 - diff_exp; + /* dif is the number of bits of c which overlap with a' */ + +- difn = (dif-1)/GMP_NUMB_BITS + 1; ++ difn = MPFR_PREC2LIMBS (dif); + /* only the highest difn limbs from c have to be considered */ + if (MPFR_UNLIKELY(difn > cn)) + { +diff -Naurd mpfr-3.1.0-a/src/add1sp.c mpfr-3.1.0-b/src/add1sp.c +--- mpfr-3.1.0-a/src/add1sp.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/add1sp.c 2012-03-08 15:17:03.000000000 +0000 +@@ -107,7 +107,7 @@ + + /* Read prec and num of limbs */ + p = MPFR_PREC(b); +- n = (p+GMP_NUMB_BITS-1)/GMP_NUMB_BITS; ++ n = MPFR_PREC2LIMBS (p); + MPFR_UNSIGNED_MINUS_MODULO(sh, p); + bx = MPFR_GET_EXP(b); + d = (mpfr_uexp_t) (bx - MPFR_GET_EXP(c)); +diff -Naurd mpfr-3.1.0-a/src/agm.c mpfr-3.1.0-b/src/agm.c +--- mpfr-3.1.0-a/src/agm.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/agm.c 2012-03-08 15:17:03.000000000 +0000 +@@ -91,7 +91,7 @@ + q = MPFR_PREC(r); + p = q + MPFR_INT_CEIL_LOG2(q) + 15; + MPFR_ASSERTD (p >= 7); /* see algorithms.tex */ +- s = (p - 1) / GMP_NUMB_BITS + 1; ++ s = MPFR_PREC2LIMBS (p); + + /* b (op2) and a (op1) are the 2 operands but we want b >= a */ + compare = mpfr_cmp (op1, op2); +@@ -285,7 +285,7 @@ + + /* Next iteration */ + MPFR_ZIV_NEXT (loop, p); +- s = (p - 1) / GMP_NUMB_BITS + 1; ++ s = MPFR_PREC2LIMBS (p); + } + MPFR_ZIV_FREE (loop); + +diff -Naurd mpfr-3.1.0-a/src/eq.c mpfr-3.1.0-b/src/eq.c +--- mpfr-3.1.0-a/src/eq.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/eq.c 2012-03-08 15:17:03.000000000 +0000 +@@ -56,8 +56,8 @@ + if (uexp != vexp) + return 0; /* no bit agree */ + +- usize = (MPFR_PREC(u) - 1) / GMP_NUMB_BITS + 1; +- vsize = (MPFR_PREC(v) - 1) / GMP_NUMB_BITS + 1; ++ usize = MPFR_LIMB_SIZE (u); ++ vsize = MPFR_LIMB_SIZE (v); + + if (vsize > usize) /* exchange u and v */ + { +diff -Naurd mpfr-3.1.0-a/src/exp.c mpfr-3.1.0-b/src/exp.c +--- mpfr-3.1.0-a/src/exp.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/exp.c 2012-03-08 15:17:03.000000000 +0000 +@@ -133,7 +133,7 @@ + mp_size_t yn; + int sh; + +- yn = 1 + (MPFR_PREC(y) - 1) / GMP_NUMB_BITS; ++ yn = MPFR_LIMB_SIZE (y); + sh = (mpfr_prec_t) yn * GMP_NUMB_BITS - MPFR_PREC(y); + MPFR_MANT(y)[0] += MPFR_LIMB_ONE << sh; + inexact = 1; +diff -Naurd mpfr-3.1.0-a/src/get_d.c mpfr-3.1.0-b/src/get_d.c +--- mpfr-3.1.0-a/src/get_d.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/get_d.c 2012-03-08 15:17:03.000000000 +0000 +@@ -100,7 +100,7 @@ + nbits += (1021 + e); + MPFR_ASSERTD (nbits >= 1); + } +- np = (nbits + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS; ++ np = MPFR_PREC2LIMBS (nbits); + MPFR_ASSERTD ( np <= MPFR_LIMBS_PER_DOUBLE ); + carry = mpfr_round_raw_4 (tp, MPFR_MANT(src), MPFR_PREC(src), negative, + nbits, rnd_mode); +diff -Naurd mpfr-3.1.0-a/src/get_flt.c mpfr-3.1.0-b/src/get_flt.c +--- mpfr-3.1.0-a/src/get_flt.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/get_flt.c 2012-03-08 15:17:03.000000000 +0000 +@@ -92,7 +92,7 @@ + nbits += (125 + e); + MPFR_ASSERTD (nbits >= 1); + } +- np = (nbits + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS; ++ np = MPFR_PREC2LIMBS (nbits); + MPFR_ASSERTD(np <= MPFR_LIMBS_PER_FLT); + carry = mpfr_round_raw_4 (tp, MPFR_MANT(src), MPFR_PREC(src), negative, + nbits, rnd_mode); +diff -Naurd mpfr-3.1.0-a/src/get_str.c mpfr-3.1.0-b/src/get_str.c +--- mpfr-3.1.0-a/src/get_str.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/get_str.c 2012-03-08 15:17:03.000000000 +0000 +@@ -2351,7 +2351,7 @@ + + /* the first digit will contain only r bits */ + prec = (m - 1) * pow2 + r; /* total number of bits */ +- n = (prec - 1) / GMP_NUMB_BITS + 1; ++ n = MPFR_PREC2LIMBS (prec); + + MPFR_TMP_MARK (marker); + x1 = MPFR_TMP_LIMBS_ALLOC (n + 1); +@@ -2417,12 +2417,12 @@ + exact = 1; + + /* number of limbs */ +- n = 1 + (prec - 1) / GMP_NUMB_BITS; ++ n = MPFR_PREC2LIMBS (prec); + + /* a will contain the approximation of the mantissa */ + a = MPFR_TMP_LIMBS_ALLOC (n); + +- nx = 1 + (MPFR_PREC(x) - 1) / GMP_NUMB_BITS; ++ nx = MPFR_LIMB_SIZE (x); + + if ((mpfr_exp_t) m == g) /* final exponent is 0, no multiplication or + division to perform */ +diff -Naurd mpfr-3.1.0-a/src/init2.c mpfr-3.1.0-b/src/init2.c +--- mpfr-3.1.0-a/src/init2.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/init2.c 2012-03-08 15:17:03.000000000 +0000 +@@ -51,7 +51,7 @@ + which both have an odd mantissa */ + MPFR_ASSERTN(p >= MPFR_PREC_MIN && p <= MPFR_PREC_MAX); + +- xsize = (mp_size_t) ((p - 1) / GMP_NUMB_BITS) + 1; ++ xsize = MPFR_PREC2LIMBS (p); + tmp = (mpfr_limb_ptr) (*__gmp_allocate_func)(MPFR_MALLOC_SIZE(xsize)); + + MPFR_PREC(x) = p; /* Set prec */ +diff -Naurd mpfr-3.1.0-a/src/lngamma.c mpfr-3.1.0-b/src/lngamma.c +--- mpfr-3.1.0-a/src/lngamma.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/lngamma.c 2012-03-08 15:17:03.000000000 +0000 +@@ -67,7 +67,7 @@ + + /* Now, the unit bit is represented. */ + +- prec = ((prec - 1) / GMP_NUMB_BITS + 1) * GMP_NUMB_BITS - expo; ++ prec = MPFR_PREC2LIMBS (prec) * GMP_NUMB_BITS - expo; + /* number of represented fractional bits (including the trailing 0's) */ + + x0 = *(MPFR_MANT (x) + prec / GMP_NUMB_BITS); +diff -Naurd mpfr-3.1.0-a/src/mpfr-impl.h mpfr-3.1.0-b/src/mpfr-impl.h +--- mpfr-3.1.0-a/src/mpfr-impl.h 2012-02-24 13:50:05.000000000 +0000 ++++ mpfr-3.1.0-b/src/mpfr-impl.h 2012-03-08 15:17:03.000000000 +0000 +@@ -646,10 +646,15 @@ + **************** mpfr_t properties ******************* + ******************************************************/ + ++/* In the following macro, p is usually a mpfr_prec_t, but this macro ++ works with other integer types (without integer overflow). */ ++#define MPFR_PREC2LIMBS(p) \ ++ (MPFR_ASSERTD (p >= 1), ((p) - 1) / GMP_NUMB_BITS + 1) ++ + #define MPFR_PREC(x) ((x)->_mpfr_prec) + #define MPFR_EXP(x) ((x)->_mpfr_exp) + #define MPFR_MANT(x) ((x)->_mpfr_d) +-#define MPFR_LIMB_SIZE(x) ((MPFR_PREC((x))-1)/GMP_NUMB_BITS+1) ++#define MPFR_LIMB_SIZE(x) (MPFR_PREC2LIMBS (MPFR_PREC ((x)))) + + + /****************************************************** +@@ -1213,8 +1218,8 @@ + _destp = MPFR_MANT (dest); \ + if (MPFR_UNLIKELY (_destprec >= _srcprec)) \ + { \ +- _srcs = (_srcprec + GMP_NUMB_BITS-1)/GMP_NUMB_BITS; \ +- _dests = (_destprec + GMP_NUMB_BITS-1)/GMP_NUMB_BITS - _srcs; \ ++ _srcs = MPFR_PREC2LIMBS (_srcprec); \ ++ _dests = MPFR_PREC2LIMBS (_destprec) - _srcs; \ + MPN_COPY (_destp + _dests, srcp, _srcs); \ + MPN_ZERO (_destp, _dests); \ + inexact = 0; \ +@@ -1227,8 +1232,8 @@ + mp_limb_t _rb, _sb, _ulp; \ + \ + /* Compute Position and shift */ \ +- _srcs = (_srcprec + GMP_NUMB_BITS-1)/GMP_NUMB_BITS; \ +- _dests = (_destprec + GMP_NUMB_BITS-1)/GMP_NUMB_BITS; \ ++ _srcs = MPFR_PREC2LIMBS (_srcprec); \ ++ _dests = MPFR_PREC2LIMBS (_destprec); \ + MPFR_UNSIGNED_MINUS_MODULO (_sh, _destprec); \ + _sp = (srcp) + _srcs - _dests; \ + \ +@@ -1372,7 +1377,7 @@ + if (MPFR_LIKELY (MPFR_PREC (dest) == MPFR_PREC (src))) \ + { \ + MPN_COPY (MPFR_MANT (dest), MPFR_MANT (src), \ +- (MPFR_PREC (src) + GMP_NUMB_BITS-1)/GMP_NUMB_BITS); \ ++ MPFR_LIMB_SIZE (src)); \ + inexact = 0; \ + } \ + else \ +@@ -1682,7 +1687,7 @@ + MPFR_ASSERTD (_prec >= MPFR_PREC_MIN); \ + if (MPFR_UNLIKELY (_prec > MPFR_PREC_MAX)) \ + mpfr_abort_prec_max (); \ +- _size = (mpfr_prec_t) (_prec + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS; \ ++ _size = MPFR_PREC2LIMBS (_prec); \ + if (MPFR_UNLIKELY (_size * (num) > MPFR_GROUP_STATIC_SIZE)) \ + { \ + (g).alloc = (num) * _size * sizeof (mp_limb_t); \ +@@ -1733,7 +1738,7 @@ + MPFR_ASSERTD (_prec >= MPFR_PREC_MIN); \ + if (MPFR_UNLIKELY (_prec > MPFR_PREC_MAX)) \ + mpfr_abort_prec_max (); \ +- _size = (mpfr_prec_t) (_prec + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS; \ ++ _size = MPFR_PREC2LIMBS (_prec); \ + (g).alloc = (num) * _size * sizeof (mp_limb_t); \ + if (MPFR_LIKELY (_oalloc == 0)) \ + (g).mant = (mp_limb_t *) (*__gmp_allocate_func) ((g).alloc); \ +@@ -1886,7 +1891,7 @@ + MPFR_NORETURN_ATTR; + + __MPFR_DECLSPEC void mpfr_rand_raw _MPFR_PROTO((mpfr_limb_ptr, gmp_randstate_t, +- unsigned long)); ++ mpfr_prec_t)); + + __MPFR_DECLSPEC mpz_t* mpfr_bernoulli_internal _MPFR_PROTO((mpz_t*, + unsigned long)); +diff -Naurd mpfr-3.1.0-a/src/mpfr.h mpfr-3.1.0-b/src/mpfr.h +--- mpfr-3.1.0-a/src/mpfr.h 2012-02-24 13:50:05.000000000 +0000 ++++ mpfr-3.1.0-b/src/mpfr.h 2012-03-08 15:17:03.000000000 +0000 +@@ -27,7 +27,7 @@ + #define MPFR_VERSION_MAJOR 3 + #define MPFR_VERSION_MINOR 1 + #define MPFR_VERSION_PATCHLEVEL 0 +-#define MPFR_VERSION_STRING "3.1.0-p6" ++#define MPFR_VERSION_STRING "3.1.0-p7" + + /* Macros dealing with MPFR VERSION */ + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) +diff -Naurd mpfr-3.1.0-a/src/mul.c mpfr-3.1.0-b/src/mul.c +--- mpfr-3.1.0-a/src/mul.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/mul.c 2012-03-08 15:17:03.000000000 +0000 +@@ -93,15 +93,15 @@ + + ax = MPFR_GET_EXP (b) + MPFR_GET_EXP (c); + +- bq = MPFR_PREC(b); +- cq = MPFR_PREC(c); ++ bq = MPFR_PREC (b); ++ cq = MPFR_PREC (c); + +- MPFR_ASSERTD(bq+cq > bq); /* PREC_MAX is /2 so no integer overflow */ ++ MPFR_ASSERTN ((mpfr_uprec_t) bq + cq <= MPFR_PREC_MAX); + +- bn = (bq+GMP_NUMB_BITS-1)/GMP_NUMB_BITS; /* number of limbs of b */ +- cn = (cq+GMP_NUMB_BITS-1)/GMP_NUMB_BITS; /* number of limbs of c */ ++ bn = MPFR_PREC2LIMBS (bq); /* number of limbs of b */ ++ cn = MPFR_PREC2LIMBS (cq); /* number of limbs of c */ + k = bn + cn; /* effective nb of limbs used by b*c (= tn or tn+1) below */ +- tn = (bq + cq + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS; ++ tn = MPFR_PREC2LIMBS (bq + cq); + /* <= k, thus no int overflow */ + MPFR_ASSERTD(tn <= k); + +@@ -292,12 +292,12 @@ + bq = MPFR_PREC (b); + cq = MPFR_PREC (c); + +- MPFR_ASSERTD (bq+cq > bq); /* PREC_MAX is /2 so no integer overflow */ ++ MPFR_ASSERTN ((mpfr_uprec_t) bq + cq <= MPFR_PREC_MAX); + +- bn = (bq+GMP_NUMB_BITS-1)/GMP_NUMB_BITS; /* number of limbs of b */ +- cn = (cq+GMP_NUMB_BITS-1)/GMP_NUMB_BITS; /* number of limbs of c */ ++ bn = MPFR_PREC2LIMBS (bq); /* number of limbs of b */ ++ cn = MPFR_PREC2LIMBS (cq); /* number of limbs of c */ + k = bn + cn; /* effective nb of limbs used by b*c (= tn or tn+1) below */ +- tn = (bq + cq + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS; ++ tn = MPFR_PREC2LIMBS (bq + cq); + MPFR_ASSERTD (tn <= k); /* tn <= k, thus no int overflow */ + + /* Check for no size_t overflow*/ +diff -Naurd mpfr-3.1.0-a/src/pow.c mpfr-3.1.0-b/src/pow.c +--- mpfr-3.1.0-a/src/pow.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/pow.c 2012-03-08 15:17:03.000000000 +0000 +@@ -136,7 +136,7 @@ + (b) all the 'z' bits are zero + */ + +- prec = ((prec - 1) / GMP_NUMB_BITS + 1) * GMP_NUMB_BITS - expo; ++ prec = MPFR_PREC2LIMBS (prec) * GMP_NUMB_BITS - expo; + /* number of z+0 bits */ + + yn = prec / GMP_NUMB_BITS; +diff -Naurd mpfr-3.1.0-a/src/print_raw.c mpfr-3.1.0-b/src/print_raw.c +--- mpfr-3.1.0-a/src/print_raw.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/print_raw.c 2012-03-08 15:17:03.000000000 +0000 +@@ -84,7 +84,7 @@ + int i; + mpfr_prec_t count = 0; + char c; +- mp_size_t n = (r - 1) / GMP_NUMB_BITS + 1; ++ mp_size_t n = MPFR_PREC2LIMBS (r); + + printf("%s ", str); + for(n-- ; n>=0 ; n--) +@@ -109,7 +109,7 @@ + int i; + mpfr_prec_t count = 0; + char c; +- mp_size_t n = (r - 1) / GMP_NUMB_BITS + 1; ++ mp_size_t n = MPFR_PREC2LIMBS (r); + + for(n-- ; n>=0 ; n--) + { +diff -Naurd mpfr-3.1.0-a/src/round_prec.c mpfr-3.1.0-b/src/round_prec.c +--- mpfr-3.1.0-a/src/round_prec.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/round_prec.c 2012-03-08 15:17:03.000000000 +0000 +@@ -55,12 +55,12 @@ + + MPFR_ASSERTN(prec >= MPFR_PREC_MIN && prec <= MPFR_PREC_MAX); + +- nw = 1 + (prec - 1) / GMP_NUMB_BITS; /* needed allocated limbs */ ++ nw = MPFR_PREC2LIMBS (prec); /* needed allocated limbs */ + + /* check if x has enough allocated space for the significand */ + /* Get the number of limbs from the precision. + (Compatible with all allocation methods) */ +- ow = (MPFR_PREC (x) + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS; ++ ow = MPFR_LIMB_SIZE (x); + if (nw > ow) + { + /* FIXME: Variable can't be created using custom allocation, +diff -Naurd mpfr-3.1.0-a/src/round_raw_generic.c mpfr-3.1.0-b/src/round_raw_generic.c +--- mpfr-3.1.0-a/src/round_raw_generic.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/round_raw_generic.c 2012-03-08 15:17:03.000000000 +0000 +@@ -80,7 +80,7 @@ + (xprec <= yprec || MPFR_IS_LIKE_RNDZ (rnd_mode, neg))) + return 0; + +- xsize = (xprec-1)/GMP_NUMB_BITS + 1; ++ xsize = MPFR_PREC2LIMBS (xprec); + nw = yprec / GMP_NUMB_BITS; + rw = yprec & (GMP_NUMB_BITS - 1); + +diff -Naurd mpfr-3.1.0-a/src/set.c mpfr-3.1.0-b/src/set.c +--- mpfr-3.1.0-a/src/set.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/set.c 2012-03-08 15:17:03.000000000 +0000 +@@ -48,8 +48,7 @@ + /* Same precision and b is not singular: + * just copy the mantissa, and set the exponent and the sign + * The result is exact. */ +- MPN_COPY (MPFR_MANT (a), MPFR_MANT (b), +- (MPFR_PREC (b) + GMP_NUMB_BITS-1)/GMP_NUMB_BITS); ++ MPN_COPY (MPFR_MANT (a), MPFR_MANT (b), MPFR_LIMB_SIZE (b)); + MPFR_RET (0); + } + else +diff -Naurd mpfr-3.1.0-a/src/set_f.c mpfr-3.1.0-b/src/set_f.c +--- mpfr-3.1.0-a/src/set_f.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/set_f.c 2012-03-08 15:17:03.000000000 +0000 +@@ -43,7 +43,7 @@ + if (SIZ(x) * MPFR_FROM_SIGN_TO_INT(MPFR_SIGN(y)) < 0) + MPFR_CHANGE_SIGN (y); + +- sy = 1 + (MPFR_PREC(y) - 1) / GMP_NUMB_BITS; ++ sy = MPFR_LIMB_SIZE (y); + my = MPFR_MANT(y); + mx = PTR(x); + +diff -Naurd mpfr-3.1.0-a/src/set_prec.c mpfr-3.1.0-b/src/set_prec.c +--- mpfr-3.1.0-a/src/set_prec.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/set_prec.c 2012-03-08 15:17:03.000000000 +0000 +@@ -32,7 +32,7 @@ + MPFR_ASSERTN (p >= MPFR_PREC_MIN && p <= MPFR_PREC_MAX); + + /* Calculate the new number of limbs */ +- xsize = (p - 1) / GMP_NUMB_BITS + 1; ++ xsize = MPFR_PREC2LIMBS (p); + + /* Realloc only if the new size is greater than the old */ + xoldsize = MPFR_GET_ALLOC_SIZE (x); +diff -Naurd mpfr-3.1.0-a/src/setmax.c mpfr-3.1.0-b/src/setmax.c +--- mpfr-3.1.0-a/src/setmax.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/setmax.c 2012-03-08 15:17:03.000000000 +0000 +@@ -32,7 +32,7 @@ + mp_limb_t *xp; + + MPFR_SET_EXP (x, e); +- xn = 1 + (MPFR_PREC(x) - 1) / GMP_NUMB_BITS; ++ xn = MPFR_LIMB_SIZE (x); + sh = (mpfr_prec_t) xn * GMP_NUMB_BITS - MPFR_PREC(x); + xp = MPFR_MANT(x); + xp[0] = MP_LIMB_T_MAX << sh; +diff -Naurd mpfr-3.1.0-a/src/sqr.c mpfr-3.1.0-b/src/sqr.c +--- mpfr-3.1.0-a/src/sqr.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/sqr.c 2012-03-08 15:17:03.000000000 +0000 +@@ -56,11 +56,11 @@ + ax = 2 * MPFR_GET_EXP (b); + bq = MPFR_PREC(b); + +- MPFR_ASSERTD (2 * bq > bq); /* PREC_MAX is /2 so no integer overflow */ ++ MPFR_ASSERTN (2 * (mpfr_uprec_t) bq <= MPFR_PREC_MAX); + +- bn = MPFR_LIMB_SIZE(b); /* number of limbs of b */ +- tn = 1 + (2 * bq - 1) / GMP_NUMB_BITS; /* number of limbs of square, +- 2*bn or 2*bn-1 */ ++ bn = MPFR_LIMB_SIZE (b); /* number of limbs of b */ ++ tn = MPFR_PREC2LIMBS (2 * bq); /* number of limbs of square, ++ 2*bn or 2*bn-1 */ + + if (MPFR_UNLIKELY(bn > MPFR_SQR_THRESHOLD)) + return mpfr_mul (a, b, b, rnd_mode); +diff -Naurd mpfr-3.1.0-a/src/stack_interface.c mpfr-3.1.0-b/src/stack_interface.c +--- mpfr-3.1.0-a/src/stack_interface.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/stack_interface.c 2012-03-08 15:17:03.000000000 +0000 +@@ -26,7 +26,7 @@ + size_t + mpfr_custom_get_size (mpfr_prec_t prec) + { +- return (prec + GMP_NUMB_BITS -1) / GMP_NUMB_BITS * BYTES_PER_MP_LIMB; ++ return MPFR_PREC2LIMBS (prec) * BYTES_PER_MP_LIMB; + } + + #undef mpfr_custom_init +diff -Naurd mpfr-3.1.0-a/src/strtofr.c mpfr-3.1.0-b/src/strtofr.c +--- mpfr-3.1.0-a/src/strtofr.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/strtofr.c 2012-03-08 15:17:03.000000000 +0000 +@@ -467,7 +467,7 @@ + /* Set y to the value of the ~prec most significant bits of pstr->mant + (as long as we guarantee correct rounding, we don't need to get + exactly prec bits). */ +- ysize = (prec - 1) / GMP_NUMB_BITS + 1; ++ ysize = MPFR_PREC2LIMBS (prec); + /* prec bits corresponds to ysize limbs */ + ysize_bits = ysize * GMP_NUMB_BITS; + /* and to ysize_bits >= prec > MPFR_PREC (x) bits */ +diff -Naurd mpfr-3.1.0-a/src/sub1sp.c mpfr-3.1.0-b/src/sub1sp.c +--- mpfr-3.1.0-a/src/sub1sp.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/sub1sp.c 2012-03-08 15:17:03.000000000 +0000 +@@ -155,8 +155,8 @@ + MPFR_ASSERTD(MPFR_IS_PURE_FP(c)); + + /* Read prec and num of limbs */ +- p = MPFR_PREC(b); +- n = (p-1)/GMP_NUMB_BITS+1; ++ p = MPFR_PREC (b); ++ n = MPFR_PREC2LIMBS (p); + + /* Fast cmp of |b| and |c|*/ + bx = MPFR_GET_EXP (b); +diff -Naurd mpfr-3.1.0-a/src/urandomb.c mpfr-3.1.0-b/src/urandomb.c +--- mpfr-3.1.0-a/src/urandomb.c 2011-10-03 08:17:09.000000000 +0000 ++++ mpfr-3.1.0-b/src/urandomb.c 2012-03-08 15:17:03.000000000 +0000 +@@ -31,13 +31,20 @@ + a sufficient number of limbs */ + void + mpfr_rand_raw (mpfr_limb_ptr mp, gmp_randstate_t rstate, +- unsigned long int nbits) ++ mpfr_prec_t nbits) + { + mpz_t z; + ++ MPFR_ASSERTN (nbits >= 1); + /* To be sure to avoid the potential allocation of mpz_urandomb */ +- ALLOC(z) = SIZ(z) = ((nbits - 1) / GMP_NUMB_BITS) + 1; ++ ALLOC(z) = SIZ(z) = MPFR_PREC2LIMBS (nbits); + PTR(z) = mp; ++#if __MPFR_GMP(5,0,0) ++ /* Check for integer overflow (unless mp_bitcnt_t is signed, ++ but according to the GMP manual, this shouldn't happen). ++ Note: mp_bitcnt_t has been introduced in GMP 5.0.0. */ ++ MPFR_ASSERTN ((mp_bitcnt_t) -1 < 0 || nbits <= (mp_bitcnt_t) -1); ++#endif + mpz_urandomb (z, rstate, nbits); + } + +diff -Naurd mpfr-3.1.0-a/src/version.c mpfr-3.1.0-b/src/version.c +--- mpfr-3.1.0-a/src/version.c 2012-02-24 13:50:05.000000000 +0000 ++++ mpfr-3.1.0-b/src/version.c 2012-03-08 15:17:03.000000000 +0000 +@@ -25,5 +25,5 @@ + const char * + mpfr_get_version (void) + { +- return "3.1.0-p6"; ++ return "3.1.0-p7"; + } +diff -Naurd mpfr-3.1.0-a/tests/tinits.c mpfr-3.1.0-b/tests/tinits.c +--- mpfr-3.1.0-a/tests/tinits.c 2011-10-03 08:17:14.000000000 +0000 ++++ mpfr-3.1.0-b/tests/tinits.c 2012-03-08 15:17:03.000000000 +0000 +@@ -1,4 +1,4 @@ +-/* Test file for mpfr_inits, mpfr_inits2 and mpfr_clears. ++/* Test file for mpfr_init2, mpfr_inits, mpfr_inits2 and mpfr_clears. + + Copyright 2003, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. + Contributed by the Arenaire and Caramel projects, INRIA. +@@ -20,18 +20,43 @@ + http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ + ++#include <stdlib.h> ++ + #include "mpfr-test.h" + + int + main (void) + { + mpfr_t a, b, c; ++ long large_prec; + + tests_start_mpfr (); ++ + mpfr_inits (a, b, c, (mpfr_ptr) 0); + mpfr_clears (a, b, c, (mpfr_ptr) 0); + mpfr_inits2 (200, a, b, c, (mpfr_ptr) 0); + mpfr_clears (a, b, c, (mpfr_ptr) 0); ++ ++ /* test for precision 2^31-1, see ++ https://gforge.inria.fr/tracker/index.php?func=detail&aid=13918 */ ++ large_prec = 2147483647; ++ if (getenv ("MPFR_CHECK_LARGEMEM") != NULL) ++ { ++ /* We assume that the precision won't be increased internally. */ ++ if (large_prec > MPFR_PREC_MAX) ++ large_prec = MPFR_PREC_MAX; ++ mpfr_inits2 (large_prec, a, b, (mpfr_ptr) 0); ++ mpfr_set_ui (a, 17, MPFR_RNDN); ++ mpfr_set (b, a, MPFR_RNDN); ++ if (mpfr_get_ui (a, MPFR_RNDN) != 17) ++ { ++ printf ("Error in mpfr_init2 with precision 2^31-1\n"); ++ exit (1); ++ } ++ mpfr_clears (a, b, (mpfr_ptr) 0); ++ } ++ + tests_end_mpfr (); ++ + return 0; + } diff --git a/core/openssl/PKGBUILD b/core/openssl/PKGBUILD index e5c5da68a..5ca2cbcb8 100644 --- a/core/openssl/PKGBUILD +++ b/core/openssl/PKGBUILD @@ -1,8 +1,8 @@ -# $Id: PKGBUILD 137334 2011-09-07 08:58:53Z pierre $ +# $Id: PKGBUILD 153454 2012-03-14 16:44:04Z pierre $ # Maintainer: Pierre Schmitz <pierre@archlinux.de> pkgname=openssl -_ver=1.0.0e +_ver=1.0.0h # use a pacman compatible version scheme pkgver=${_ver/[a-z]/.${_ver//[0-9.]/}} pkgrel=1 @@ -19,18 +19,12 @@ source=("https://www.openssl.org/source/${pkgname}-${_ver}.tar.gz" 'no-rpath.patch' 'gnu-linux-mips64el-gcc.patch' 'ca-dir.patch') -md5sums=('7040b89c4c58c7a1016c0dfa6e821c86' +md5sums=('a5bc483c570f2ac3758ce5c19b667fab' '5bbc0655bda2af95bc8eb568963ce8ba' 'dc78d3d06baffc16217519242ce92478' 'd7115f0cc44df346d7b68c681819f94b' '3bf51be3a1bbd262be46dc619f92aa90') -[ "$CARCH" = "mips64el" ] && \ -makedepends=('imake') - -# keep an upgrade path for older installations -PKGEXT='.pkg.tar.gz' - build() { cd $srcdir/$pkgname-$_ver @@ -59,7 +53,7 @@ build() { if [ "$CARCH" = "mips64el" ]; then ./Configure --prefix=/usr --openssldir=/etc/ssl --libdir=lib \ shared zlib enable-md2 \ - "${openssltarget}" -Wa,--noexecstack "${CFLAGS}" + "${openssltarget}" -Wa,--noexecstack "${CFLAGS}" "${LDFLAGS}" else ./Configure --prefix=/usr --openssldir=/etc/ssl --libdir=lib \ shared zlib enable-md2 \ diff --git a/core/udev/PKGBUILD b/core/udev/PKGBUILD index 80bd4b804..7fcfcf217 100644 --- a/core/udev/PKGBUILD +++ b/core/udev/PKGBUILD @@ -1,4 +1,4 @@ -# $Id: PKGBUILD 150105 2012-02-12 15:37:11Z dreisner $ +# $Id: PKGBUILD 153480 2012-03-14 23:26:14Z tomegun $ # Maintainer: Tom Gundersen <teg@jklm.no> # Contributor: Aaron Griffin <aaron@archlinux.org> # Contributor: Tobias Powalowski <tpowa@archlinux.org> @@ -6,9 +6,9 @@ pkgname=udev pkgver=181 -pkgrel=2 +pkgrel=4 pkgdesc="The userspace dev tools (udev)" -depends=('util-linux' 'libusb-compat' 'glib2' 'kmod' 'pciutils' 'usbutils' 'pciutils') +depends=('util-linux' 'libusb-compat' 'glib2' 'kmod' 'pciutils' 'usbutils' 'pciutils' 'acl') install=udev.install arch=(i686 x86_64 mips64el) license=('GPL') @@ -39,15 +39,12 @@ package() { cd $srcdir/$pkgname-$pkgver make DESTDIR=${pkgdir} install - # /dev/loop0 is created for convenience, to autoload the module if necessary - # this is no longer needed when util-linux-2.21 is released as /dev/loop-control - # will be used instead. Support for this will go away in a future version of udev - install -d -m755 ${pkgdir}/lib/udev/devices/ - mknod ${pkgdir}/lib/udev/devices/loop0 b 7 0 - chgrp disk ${pkgdir}/lib/udev/devices/loop0 - # udevd moved, symlink to make life easy for restarting udevd manually - ln -s /lib/udev/udevd ${pkgdir}/usr/bin/udevd + ln -s ../../lib/udev/udevd ${pkgdir}/usr/bin/udevd + + # the path to udevadm is hardcoded in some places + install -d ${pkgdir}/sbin + ln -s ../usr/bin/udevadm ${pkgdir}/sbin/udevadm # Replace dialout/tape/cdrom group in rules with uucp/storage/optical group for i in $pkgdir/lib/udev/rules.d/*.rules; do diff --git a/core/udev/udev.install b/core/udev/udev.install index 7c866c2a3..557efe9e1 100644 --- a/core/udev/udev.install +++ b/core/udev/udev.install @@ -2,72 +2,58 @@ # arg 2: the old package version post_upgrade() { - if [ "$(vercmp $2 181)" -lt 0 ]; then - echo "ATTENTION UDEV:" - echo "----------" + if [ "$(vercmp $2 181-3)" -lt 0 ]; then + echo "udev changes:" if [ "$(vercmp $2 168)" -lt 0 ]; then - echo "Kernel 2.6.32 or newer is now required." - echo " --" - echo "OSS emulation modules are not loaded by default, add to rc.conf if needed." - echo " --" - echo "Arch specific cd symlinks are now no longer created." - echo " --" - echo "cd and net persistent rules will no longer be autogenerated," - echo "see <https://wiki.archlinux.org/index.php/Udev> for details." - echo " --" - echo "Errors are now logged (possibly to the console) by default." - echo " --" + echo " * Kernel 2.6.32 or newer is now required." + echo " * OSS emulation modules are not loaded by default, add to rc.conf if needed." + echo " * Arch specific cd symlinks are now no longer created." + echo " * cd and net persistent rules will no longer be autogenerated," + echo " see <https://wiki.archlinux.org/index.php/Udev> for details." + echo " * Errors are now logged (possibly to the console) by default." fi if [ "$(vercmp $2 171)" -lt 0 ]; then - echo "Arch's custom blacklisting logic has been removed. MOD_AUTOLOAD and" - echo "blacklisting in MODULES no longer works." - echo "See 'man modprobe.conf' for a replacement to blacklisting." - echo "To disable a module mod1 on the kernel command line, use" - echo "mod1.disable=1" - echo "or" - echo "modprobe.blacklist=mod1" - echo " --" - echo "The following modules are no longer unconditionally loaded:" - echo " pcspkr irtty-sir analog lp ppdev ide-generic" - echo "Add them to MODULES in rc.conf if you need them." - echo " --" + echo " * Arch's custom blacklisting logic has been removed. MOD_AUTOLOAD and" + echo " blacklisting in MODULES no longer works." + echo " See 'man modprobe.conf' for a replacement to blacklisting." + echo " To disable a module mod1 on the kernel command line, use" + echo " mod1.disable=1" + echo " or" + echo " modprobe.blacklist=mod1" + echo " * The following modules are no longer unconditionally loaded:" + echo " pcspkr irtty-sir analog lp ppdev ide-generic" + echo " Add them to MODULES in rc.conf if you need them." fi if [ "$(vercmp $2 172)" -lt 0 ]; then - echo "Blacklisting of framebuffer devices has moved from /etc/modprobe.d to" - echo "/lib/modprobe.d. Any customizations shoud be done to the file in /etc, as it" - echo "takes precedence." - echo " --" - echo "kbd and rtc devices are no longer world readable." - echo " --" - echo "rtc is no longer in the audio group and fb devices are no longer in" - echo "the video group, as permissions and ownership of fb devices are controlled" - echo "by X." - echo " --" + echo " * Blacklisting of framebuffer devices has moved from /etc/modprobe.d to" + echo " /lib/modprobe.d. Any customizations shoud be done to the file in /etc, as it" + echo " takes precedence." + echo " * kbd and rtc devices are no longer world readable." + echo " * rtc is no longer in the audio group and fb devices are no longer in" + echo " the video group, as permissions and ownership of fb devices are controlled" + echo " by X." fi if [ "$(vercmp $2 174)" -lt 0 ]; then - echo "We now use upstream rules for assigning devices to the 'disk', 'optical'," - echo "'scanner' and 'video' groups. Beware of any changes." - echo " --" - echo "We no longer create symlinks from /dev/<dev> to /dev/<dev>0." - echo " --" - echo "For security reasons, we no longer add devices to the 'storage' group. Use" - echo "udisks and friends, or add custom rules to /etc/udev.d/rules/, if you want" - echo "this functionality back." - echo " --" - echo "We no longer create the static nodes on install needed for an initrd-less boot" - echo "where devtmpfs is not mounted by the kernel, this only affects fresh installs." - echo " --" + echo " * We now use upstream rules for assigning devices to the 'disk', 'optical'," + echo " 'scanner' and 'video' groups. Beware of any changes." + echo " * We no longer create symlinks from /dev/<dev> to /dev/<dev>0." + echo " * For security reasons, we no longer add devices to the 'storage' group. Use" + echo " udisks and friends, or add custom rules to /etc/udev.d/rules/, if you want" + echo " this functionality back." + echo " * We no longer create the static nodes on install needed for an initrd-less" + echo " boot where devtmpfs is not mounted by the kernel, this only affects fresh" + echo " installs." fi if [ "$(vercmp $2 175)" -lt 0 ]; then - echo "devtmpfs support is now a hard requirement. Users of the official Arch kernels" - echo "have this enabled." - echo " --" + echo " * devtmpfs support is now a hard requirement. Users of the official Arch" + echo " kernels have this enabled." fi - echo "udev-compat has been removed, and should be uninstalled." - echo " --" - echo "Framebuffers are no longer blacklisted by default." - echo " --" - echo "binaries moved from /sbin to /usr/bin" - echo "---------------" + if [ "$(vercmp $2 181)" -lt 0 ]; then + echo " * udev-compat has been removed, and should be uninstalled." + echo " * Framebuffers are no longer blacklisted by default." + echo " * binaries moved from /sbin to /usr/bin" + fi + echo " * if your kernel does not provide /dev/loop-control, you need to manually" + echo " load the 'loop' module before using losetup" fi } diff --git a/core/util-linux/PKGBUILD b/core/util-linux/PKGBUILD index b5f7dada8..3bf4d08a7 100644 --- a/core/util-linux/PKGBUILD +++ b/core/util-linux/PKGBUILD @@ -1,22 +1,21 @@ -# $Id: PKGBUILD 146393 2012-01-10 11:39:59Z tomegun $ +# $Id: PKGBUILD 153482 2012-03-14 23:26:17Z tomegun $ # Maintainer: Tom Gundersen <teg@jklm.no> # Contributor: judd <jvinet@zeroflux.org> pkgname=util-linux -pkgver=2.20.1 -pkgrel=2 +pkgver=2.21 +pkgrel=5 pkgdesc="Miscellaneous system utilities for Linux" -url="http://userweb.kernel.org/~kzak/util-linux-ng/" +url="http://www.kernel.org/pub/linux/utils/util-linux/" arch=('i686' 'x86_64' 'mips64el') groups=('base') -depends=('filesystem') -replaces=('linux32' 'util-linux-ng') -conflicts=('linux32' 'util-linux-ng' 'e2fsprogs<1.41.8-2') -provides=('linux32' "util-linux-ng=${pkgver}") +depends=('udev') +conflicts=('util-linux-ng') +provides=("util-linux-ng=${pkgver}") license=('GPL2') options=('!libtool') -source=(ftp://ftp.kernel.org/pub/linux/utils/${pkgname}/v2.20/${pkgname}-${pkgver}.tar.bz2 - 0001-findmnt-support-alternative-location-of-fstab.patch) +source=(ftp://ftp.kernel.org/pub/linux/utils/${pkgname}/v${pkgver}/${pkgname}-${pkgver}.tar.xz + stable-fixes-2.21.patch) optdepends=('perl: for chkdupexe support') build() { @@ -25,15 +24,13 @@ build() { # hardware clock sed -e 's%etc/adjtime%var/lib/hwclock/adjtime%' -i include/pathnames.h - # backport patch needed for usr support in initramfs - patch -p1 -i ../0001-findmnt-support-alternative-location-of-fstab.patch + patch -p1 -i ../stable-fixes-2.21.patch - ./configure --enable-arch\ - --enable-write\ - --enable-raw\ - --disable-wall\ - --enable-partx\ - --enable-libmount-mount + ./configure --prefix=/usr \ + --libdir=/usr/lib \ + --enable-write \ + --enable-raw \ + --disable-wall make } @@ -41,9 +38,14 @@ build() { package() { cd "${srcdir}/${pkgname}-${pkgver}" - install -dm755 "${pkgdir}/var/lib/hwclock" - make DESTDIR="${pkgdir}" install + + cd "${pkgdir}" + + install -dm755 var/lib/hwclock + + # delete stray empty dir, fixed upstream + rm -r usr/share/man/ru } -md5sums=('079b37517fd4e002a2e6e992e8b4e361' - '823e2d87885b81f245b8c368e28f8cab') +md5sums=('208aa058f4117759d2939d1be7d662fc' + '415b850a4efa9174cd9c34022949f177') diff --git a/core/util-linux/stable-fixes-2.21.patch b/core/util-linux/stable-fixes-2.21.patch new file mode 100644 index 000000000..3c6c32483 --- /dev/null +++ b/core/util-linux/stable-fixes-2.21.patch @@ -0,0 +1,1516 @@ +diff --git a/configure.ac b/configure.ac +index d3b298c..9da5b24 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -387,6 +387,8 @@ AC_CACHE_VAL([scanf_cv_alloc_modifier], + [scanf_cv_alloc_modifier=as], + [scanf_cv_alloc_modifier=no] + ) ++ , ++ [scanf_cv_alloc_modifier=no] + ) + ) + +@@ -833,6 +835,8 @@ AC_ARG_ENABLE([ddate], + ) + UL_BUILD_INIT([ddate]) + AM_CONDITIONAL(BUILD_DDATE, test "x$build_ddate" = xyes) ++ruman1dir='${mandir}/ru/man1' ++AC_SUBST([ruman1dir]) + + + AC_ARG_ENABLE([agetty], +diff --git a/fdisk/fdiskbsdlabel.h b/fdisk/fdiskbsdlabel.h +index 9f9e091..e58e2ff 100644 +--- a/fdisk/fdiskbsdlabel.h ++++ b/fdisk/fdiskbsdlabel.h +@@ -46,7 +46,7 @@ + + #define BSD_LINUX_BOOTDIR "/usr/ucb/mdec" + +-#if defined (i386) || defined (__sparc__) || defined (__arm__) || \ ++#if defined (__i386__) || defined (__sparc__) || defined (__arm__) || \ + defined (__mips__) || defined (__s390__) || defined (__sh__) || \ + defined(__x86_64__) || defined (__avr32__) || defined(__cris__) + #define BSD_LABELSECTOR 1 +diff --git a/include/list.h b/include/list.h +index 3ce46ca..d8c3bf0 100644 +--- a/include/list.h ++++ b/include/list.h +@@ -166,6 +166,10 @@ _INLINE_ void list_splice(struct list_head *list, struct list_head *head) + #define list_entry(ptr, type, member) \ + ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member))) + ++ ++#define list_first_entry(head, type, member) \ ++ ((head) && (head)->next != (head) ? list_entry((head)->next, type, member) : NULL) ++ + /** + * list_for_each - iterate over elements in a list + * @pos: the &struct list_head to use as a loop counter. +diff --git a/lib/canonicalize.c b/lib/canonicalize.c +index ab32c10..fd18af4 100644 +--- a/lib/canonicalize.c ++++ b/lib/canonicalize.c +@@ -174,9 +174,16 @@ canonicalize_path(const char *path) + if (path == NULL) + return NULL; + +- if (!myrealpath(path, canonical, PATH_MAX+1)) +- return strdup(path); +- ++ if (!myrealpath(path, canonical, PATH_MAX+1)) { ++ char *res = strdup(path); ++ if (res) { ++ p = strrchr(res, '/'); ++ /* delete trailing slash */ ++ if (p && p > res && *(p + 1) == '\0') ++ *p = '\0'; ++ } ++ return res; ++ } + + p = strrchr(canonical, '/'); + if (p && strncmp(p, "/dm-", 4) == 0 && isdigit(*(p + 4))) { +diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c +index 763f75c..6bd69d3 100644 +--- a/libblkid/src/probe.c ++++ b/libblkid/src/probe.c +@@ -388,6 +388,7 @@ void blkid_reset_probe(blkid_probe pr) + return; + + blkid_probe_reset_vals(pr); ++ blkid_probe_set_wiper(pr, 0, 0); + + pr->cur_chain = NULL; + +@@ -989,7 +990,7 @@ int blkid_do_wipe(blkid_probe pr, int dryrun) + len = sizeof(buf); + + DBG(DEBUG_LOWPROBE, printf( +- "wiping [offset=0x%jx, len=%zd, chain=%s, idx=%d, dryrun=%s]\n", ++ "do_wipe [offset=0x%jx, len=%zd, chain=%s, idx=%d, dryrun=%s]\n", + offset, len, chn->driver->name, chn->idx, dryrun ? "yes" : "not")); + + l = lseek(fd, offset, SEEK_SET); +@@ -1008,10 +1009,23 @@ int blkid_do_wipe(blkid_probe pr, int dryrun) + if (chn->idx >= 0) { + chn->idx--; + DBG(DEBUG_LOWPROBE, +- printf("wipe: moving %s chain index to %d\n", ++ printf("do_wipe: moving %s chain index to %d\n", + chn->driver->name, + chn->idx)); + } ++ if (chn->idx == -1) { ++ /* blkid_do_probe() goes to the next chain if the index ++ * of the current chain is -1, so we have to set the ++ * chain pointer to the previos chain. ++ */ ++ size_t idx = chn->driver->id > 0 ? ++ chn->driver->id - 1 : 0; ++ ++ if (idx > 0) ++ pr->cur_chain = &pr->chains[idx]; ++ else if (idx == 0) ++ pr->cur_chain = NULL; ++ } + } + return 0; + } +@@ -1579,8 +1593,9 @@ size_t blkid_rtrim_whitespace(unsigned char *str) + * for later resolution to conflicts between superblocks. + * + * For example we found valid LVM superblock, LVM wipes 8KiB at the begin of +- * the device. If we found another signature (for example MBR) this wiped area +- * then the signature has been added later and LVM superblock should be ignore. ++ * the device. If we found another signature (for example MBR) within the ++ * wiped area then the signature has been added later and LVM superblock ++ * should be ignore. + * + * Note that this heuristic is not 100% reliable, for example "pvcreate --zero + * n" allows to keep the begin of the device unmodified. It's probably better +@@ -1588,6 +1603,16 @@ size_t blkid_rtrim_whitespace(unsigned char *str) + * than for conflicts between filesystem superblocks -- existence of unwanted + * partition table is very unusual, because PT is pretty visible (parsed and + * interpreted by kernel). ++ * ++ * Note that we usually expect only one signature on the device, it means that ++ * we have to remember only one wiped area from previously successfully ++ * detected signature. ++ * ++ * blkid_probe_set_wiper() -- defines wiped area (e.g. LVM) ++ * blkid_probe_use_wiper() -- try to use area (e.g. MBR) ++ * ++ * Note that there is not relation between _wiper and blkid_to_wipe(). ++ * + */ + void blkid_probe_set_wiper(blkid_probe pr, blkid_loff_t off, blkid_loff_t size) + { +@@ -1638,12 +1663,17 @@ int blkid_probe_is_wiped(blkid_probe pr, struct blkid_chain **chn, + return 0; + } + ++/* ++ * Try to use any area -- if the area has been previously wiped then the ++ * previous probing result should be ignored (reseted). ++ */ + void blkid_probe_use_wiper(blkid_probe pr, blkid_loff_t off, blkid_loff_t size) + { + struct blkid_chain *chn = NULL; + + if (blkid_probe_is_wiped(pr, &chn, off, size) && chn) { +- DBG(DEBUG_LOWPROBE, printf("wiped area detected -- ignore previous results\n")); ++ DBG(DEBUG_LOWPROBE, printf("previously wiped area modified " ++ " -- ignore previous results\n")); + blkid_probe_set_wiper(pr, 0, 0); + blkid_probe_chain_reset_vals(pr, chn); + } +diff --git a/libmount/src/context.c b/libmount/src/context.c +index 1f30292..f97dd36 100644 +--- a/libmount/src/context.c ++++ b/libmount/src/context.c +@@ -1165,6 +1165,10 @@ int mnt_context_prepare_srcpath(struct libmnt_context *cxt) + + src = mnt_fs_get_source(cxt->fs); + ++ if (!src && (cxt->mountflags & MS_PROPAGATION)) ++ /* mount --make-{shared,private,...} */ ++ return mnt_fs_set_source(cxt->fs, "none"); ++ + /* ignore filesystems without source or filesystems + * where the source is quasi-path (//foo/bar) + */ +@@ -1203,7 +1207,7 @@ int mnt_context_prepare_srcpath(struct libmnt_context *cxt) + + if ((cxt->mountflags & (MS_BIND | MS_MOVE | MS_PROPAGATION)) || + mnt_fs_is_pseudofs(cxt->fs)) { +- DBG(CXT, mnt_debug_h(cxt, "PROPAGATION/pseudo FS source: %s", path)); ++ DBG(CXT, mnt_debug_h(cxt, "BIND/MOVE/pseudo FS source: %s", path)); + return rc; + } + +diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c +index 8cbc25b..c56ffd4 100644 +--- a/libmount/src/context_mount.c ++++ b/libmount/src/context_mount.c +@@ -369,7 +369,12 @@ static int exec_helper(struct libmnt_context *cxt) + args[i++] = mnt_fs_get_srcpath(cxt->fs);/* 2 */ + args[i++] = mnt_fs_get_target(cxt->fs); /* 3 */ + +- if (mnt_context_is_sloppy(cxt)) ++ /* ++ * TODO: remove the exception for "nfs", -s is documented ++ * for years should be usable everywhere. ++ */ ++ if (mnt_context_is_sloppy(cxt) && ++ type && startswith(type, "nfs")) + args[i++] = "-s"; /* 4 */ + if (mnt_context_is_fake(cxt)) + args[i++] = "-f"; /* 5 */ +@@ -446,9 +451,14 @@ static int do_mount(struct libmnt_context *cxt, const char *try_type) + src = mnt_fs_get_srcpath(cxt->fs); + target = mnt_fs_get_target(cxt->fs); + +- if (!src || !target) ++ if (!target) + return -EINVAL; +- ++ if (!src) { ++ /* unnecessary, should be already resolved in ++ * mnt_context_prepare_srcpath(), but for sure... */ ++ DBG(CXT, mnt_debug_h(cxt, "WARNING: source is NULL -- using \"none\"!")); ++ src = "none"; ++ } + type = try_type ? : mnt_fs_get_fstype(cxt->fs); + + if (!(flags & MS_MGC_MSK)) +diff --git a/libmount/src/fs.c b/libmount/src/fs.c +index a28e66c..19650cb 100644 +--- a/libmount/src/fs.c ++++ b/libmount/src/fs.c +@@ -304,11 +304,7 @@ int __mnt_fs_set_source_ptr(struct libmnt_fs *fs, char *source) + + assert(fs); + +- if (source && !strcmp(source, "none")) { +- free(source); +- source = NULL; +- +- } else if (source && strchr(source, '=')) { ++ if (source && strchr(source, '=')) { + if (blkid_parse_tag_string(source, &t, &v) != 0) + return -1; + } +@@ -341,6 +337,7 @@ int mnt_fs_set_source(struct libmnt_fs *fs, const char *source) + + if (!fs) + return -EINVAL; ++ + if (source) { + p = strdup(source); + if (!p) +@@ -353,6 +350,41 @@ int mnt_fs_set_source(struct libmnt_fs *fs, const char *source) + return rc; + } + ++/* ++ * Compares @fs source path with @path. The tailing slash is ignored. ++ * See also mnt_fs_match_source(). ++ * ++ * Returns: 1 if @fs source path equal to @path, otherwise 0. ++ */ ++int mnt_fs_streq_srcpath(struct libmnt_fs *fs, const char *path) ++{ ++ const char *p; ++ ++ if (!fs) ++ return 0; ++ ++ p = mnt_fs_get_srcpath(fs); ++ ++ if (!mnt_fs_is_pseudofs(fs)) ++ return streq_except_trailing_slash(p, path); ++ ++ if (!p && !path) ++ return 1; ++ ++ return p && path && strcmp(p, path) == 0; ++} ++ ++/* ++ * Compares @fs target path with @path. The tailing slash is ignored. ++ * See also mnt_fs_match_target(). ++ * ++ * Returns: 1 if @fs target path equal to @path, otherwise 0. ++ */ ++int mnt_fs_streq_target(struct libmnt_fs *fs, const char *path) ++{ ++ return fs && streq_except_trailing_slash(mnt_fs_get_target(fs), path); ++} ++ + /** + * mnt_fs_get_tag: + * @fs: fs +@@ -1114,7 +1146,7 @@ int mnt_fs_match_target(struct libmnt_fs *fs, const char *target, + return 0; + + /* 1) native paths */ +- rc = !strcmp(target, fs->target); ++ rc = mnt_fs_streq_target(fs, target); + + if (!rc && cache) { + /* 2) - canonicalized and non-canonicalized */ +@@ -1146,10 +1178,6 @@ int mnt_fs_match_target(struct libmnt_fs *fs, const char *target, + * The 2nd, 3rd and 4th attempts are not performed when @cache is NULL. The + * 2nd and 3rd attempts are not performed if @fs->source is tag. + * +- * Note that valid source path is NULL; the libmount uses NULL instead of +- * "none". The "none" is used in /proc/{mounts,self/mountninfo} for pseudo +- * filesystems. +- * + * Returns: 1 if @fs source is equal to @source else 0. + */ + int mnt_fs_match_source(struct libmnt_fs *fs, const char *source, +@@ -1161,15 +1189,15 @@ int mnt_fs_match_source(struct libmnt_fs *fs, const char *source, + if (!fs) + return 0; + +- /* undefined source -- "none" in /proc */ +- if (source == NULL && fs->source == NULL) ++ /* 1) native paths... */ ++ if (mnt_fs_streq_srcpath(fs, source) == 1) + return 1; + +- if (source == NULL || fs->source == NULL) ++ if (!source || !fs->source) + return 0; + +- /* 1) native paths/tags */ +- if (streq_except_trailing_slash(source, fs->source)) ++ /* ... and tags */ ++ if (fs->tagname && strcmp(source, fs->source) == 0) + return 1; + + if (!cache) +@@ -1183,7 +1211,7 @@ int mnt_fs_match_source(struct libmnt_fs *fs, const char *source, + + /* 2) canonicalized and native */ + src = mnt_fs_get_srcpath(fs); +- if (src && streq_except_trailing_slash(cn, src)) ++ if (src && mnt_fs_streq_srcpath(fs, cn)) + return 1; + + /* 3) canonicalized and canonicalized */ +diff --git a/libmount/src/mountP.h b/libmount/src/mountP.h +index fa0edf5..a7b5c0d 100644 +--- a/libmount/src/mountP.h ++++ b/libmount/src/mountP.h +@@ -367,6 +367,11 @@ extern struct libmnt_fs *mnt_copy_mtab_fs(const struct libmnt_fs *fs); + extern int __mnt_fs_set_source_ptr(struct libmnt_fs *fs, char *source); + extern int __mnt_fs_set_fstype_ptr(struct libmnt_fs *fs, char *fstype); + ++/* exported in v2.22 */ ++extern int mnt_fs_streq_srcpath(struct libmnt_fs *fs, const char *path); ++extern int mnt_fs_streq_target(struct libmnt_fs *fs, const char *path); ++ ++ + /* context.c */ + extern int mnt_context_prepare_srcpath(struct libmnt_context *cxt); + extern int mnt_context_prepare_target(struct libmnt_context *cxt); +diff --git a/libmount/src/tab.c b/libmount/src/tab.c +index 37f47bd..f3ec573 100644 +--- a/libmount/src/tab.c ++++ b/libmount/src/tab.c +@@ -286,6 +286,11 @@ int mnt_table_next_child_fs(struct libmnt_table *tb, struct libmnt_iter *itr, + + id = mnt_fs_get_id(fs); + ++ /* avoid infinite loop. This only happens in rare cases ++ * such as in early userspace when the rootfs is its own parent */ ++ if (id == parent_id) ++ continue; ++ + if ((!lastchld_id || id > lastchld_id) && + (!*chld || id < chld_id)) { + *chld = fs; +@@ -438,7 +443,7 @@ struct libmnt_fs *mnt_table_find_target(struct libmnt_table *tb, const char *pat + /* native @target */ + mnt_reset_iter(&itr, direction); + while(mnt_table_next_fs(tb, &itr, &fs) == 0) { +- if (fs->target && strcmp(fs->target, path) == 0) ++ if (mnt_fs_streq_target(fs, path)) + return fs; + } + if (!tb->cache || !(cn = mnt_resolve_path(path, tb->cache))) +@@ -447,7 +452,7 @@ struct libmnt_fs *mnt_table_find_target(struct libmnt_table *tb, const char *pat + /* canonicalized paths in struct libmnt_table */ + mnt_reset_iter(&itr, direction); + while(mnt_table_next_fs(tb, &itr, &fs) == 0) { +- if (fs->target && strcmp(fs->target, cn) == 0) ++ if (mnt_fs_streq_target(fs, cn)) + return fs; + } + +@@ -456,12 +461,13 @@ struct libmnt_fs *mnt_table_find_target(struct libmnt_table *tb, const char *pat + while(mnt_table_next_fs(tb, &itr, &fs) == 0) { + char *p; + +- if (!fs->target || !mnt_fs_is_swaparea(fs) || ++ if (!fs->target || mnt_fs_is_swaparea(fs) || + (*fs->target == '/' && *(fs->target + 1) == '\0')) + continue; + + p = mnt_resolve_path(fs->target, tb->cache); +- if (strcmp(cn, p) == 0) ++ /* both canonicalized, strcmp() is fine here */ ++ if (p && strcmp(cn, p) == 0) + return fs; + } + return NULL; +@@ -480,9 +486,8 @@ struct libmnt_fs *mnt_table_find_target(struct libmnt_table *tb, const char *pat + * The 2nd, 3rd and 4th iterations are not performed when @tb cache is not + * set (see mnt_table_set_cache()). + * +- * Note that valid source path is NULL; the libmount uses NULL instead of +- * "none". The "none" is used in /proc/{mounts,self/mountninfo} for pseudo +- * filesystems. ++ * Note that NULL is a valid source path; it will be replaced with "none". The ++ * "none" is used in /proc/{mounts,self/mountinfo} for pseudo filesystems. + * + * Returns: a tab entry or NULL. + */ +@@ -501,16 +506,10 @@ struct libmnt_fs *mnt_table_find_srcpath(struct libmnt_table *tb, const char *pa + /* native paths */ + mnt_reset_iter(&itr, direction); + while(mnt_table_next_fs(tb, &itr, &fs) == 0) { +- const char *src = mnt_fs_get_source(fs); +- +- p = mnt_fs_get_srcpath(fs); +- +- if (path == NULL && src == NULL) +- return fs; /* source is "none" */ +- if (path && p && streq_except_trailing_slash(p, path)) ++ if (mnt_fs_streq_srcpath(fs, path)) + return fs; +- if (!p && src) +- ntags++; /* mnt_fs_get_srcpath() returs nothing, it's TAG */ ++ if (mnt_fs_get_tag(fs, NULL, NULL) == 0) ++ ntags++; + } + + if (!path || !tb->cache || !(cn = mnt_resolve_path(path, tb->cache))) +@@ -520,8 +519,7 @@ struct libmnt_fs *mnt_table_find_srcpath(struct libmnt_table *tb, const char *pa + if (ntags < mnt_table_get_nents(tb)) { + mnt_reset_iter(&itr, direction); + while(mnt_table_next_fs(tb, &itr, &fs) == 0) { +- p = mnt_fs_get_srcpath(fs); +- if (p && streq_except_trailing_slash(p, cn)) ++ if (mnt_fs_streq_srcpath(fs, cn)) + return fs; + } + } +@@ -552,7 +550,9 @@ struct libmnt_fs *mnt_table_find_srcpath(struct libmnt_table *tb, const char *pa + if (mnt_fs_get_tag(fs, &t, &v)) + continue; + x = mnt_resolve_tag(t, v, tb->cache); +- if (x && streq_except_trailing_slash(x, cn)) ++ ++ /* both canonicalized, strcmp() is fine here */ ++ if (x && strcmp(x, cn) == 0) + return fs; + } + } +@@ -567,7 +567,9 @@ struct libmnt_fs *mnt_table_find_srcpath(struct libmnt_table *tb, const char *pa + p = mnt_fs_get_srcpath(fs); + if (p) + p = mnt_resolve_path(p, tb->cache); +- if (p && streq_except_trailing_slash(cn, p)) ++ ++ /* both canonicalized, strcmp() is fine here */ ++ if (p && strcmp(p, cn) == 0) + return fs; + } + } +@@ -702,16 +704,18 @@ struct libmnt_fs *mnt_table_find_pair(struct libmnt_table *tb, const char *sourc + } + + /* +- * @tb: /proc/self/mountinfo +- * @fs: filesystem +- * @mountflags: MS_BIND or 0 +- * @fsroot: fs-root that will be probably used in the mountinfo file ++ * tb: /proc/self/mountinfo ++ * fs: filesystem ++ * mountflags: MS_BIND or 0 ++ * fsroot: fs-root that will be probably used in the mountinfo file + * for @fs after mount(2) + * + * For btrfs subvolumes this function returns NULL, but @fsroot properly set. + * + * Returns: entry from @tb that will be used as a source for @fs if the @fs is + * bindmount. ++ * ++ * Don't export to library API! + */ + struct libmnt_fs *mnt_table_get_fs_root(struct libmnt_table *tb, + struct libmnt_fs *fs, +@@ -814,6 +818,20 @@ err: + return NULL; + } + ++static int is_mountinfo(struct libmnt_table *tb) ++{ ++ struct libmnt_fs *fs; ++ ++ if (!tb) ++ return 0; ++ ++ fs = list_first_entry(&tb->ents, struct libmnt_fs, ents); ++ if (fs && mnt_fs_is_kernel(fs) && mnt_fs_get_root(fs)) ++ return 1; ++ ++ return 0; ++} ++ + /** + * mnt_table_is_mounted: + * @tb: /proc/self/mountinfo file +@@ -829,10 +847,9 @@ err: + int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs) + { + char *root = NULL; +- struct libmnt_fs *src_fs; +- const char *src, *tgt; +- char *xsrc = NULL; +- int flags = 0, rc = 0; ++ const char *src = NULL; ++ char *xsrc = NULL, *tgt; ++ int rc = 0; + + assert(tb); + assert(fstab_fs); +@@ -840,39 +857,49 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs) + if (mnt_fs_is_swaparea(fstab_fs)) + return 0; + +- if (mnt_fs_get_option(fstab_fs, "bind", NULL, NULL) == 0) +- flags = MS_BIND; ++ if (is_mountinfo(tb)) { ++ /* @tb is mountinfo, so we can try to use fs-roots */ ++ struct libmnt_fs *fs; ++ int flags = 0; ++ ++ if (mnt_fs_get_option(fstab_fs, "bind", NULL, NULL) == 0) ++ flags = MS_BIND; + +- src_fs = mnt_table_get_fs_root(tb, fstab_fs, flags, &root); +- if (src_fs) +- src = mnt_fs_get_srcpath(src_fs); ++ fs = mnt_table_get_fs_root(tb, fstab_fs, flags, &root); ++ if (fs) ++ src = mnt_fs_get_srcpath(fs); ++ } ++ ++ if (src) ++ src = xsrc = mnt_resolve_spec(src, tb->cache); + else if (mnt_fs_is_pseudofs(fstab_fs)) + src = mnt_fs_get_source(fstab_fs); + else + src = xsrc = mnt_resolve_spec(mnt_fs_get_source(fstab_fs), + tb->cache); + +- tgt = mnt_fs_get_target(fstab_fs); ++ tgt = mnt_resolve_path(mnt_fs_get_target(fstab_fs), tb->cache); + +- if (tgt && src && root) { ++ if (tgt && src) { + struct libmnt_iter itr; + struct libmnt_fs *fs; + + mnt_reset_iter(&itr, MNT_ITER_FORWARD); + + while(mnt_table_next_fs(tb, &itr, &fs) == 0) { +- const char *s = mnt_fs_get_srcpath(fs), +- *t = mnt_fs_get_target(fs), +- *r = mnt_fs_get_root(fs); +- +- /* +- * Note that kernel can add tailing slash to the +- * network filesystem source paths. +- */ +- if (t && s && r && +- strcmp(t, tgt) == 0 && +- streq_except_trailing_slash(s, src) && +- strcmp(r, root) == 0) ++ ++ if (root) { ++ /* mountinfo: compare root, source and target */ ++ const char *r = mnt_fs_get_root(fs); ++ ++ if (r && strcmp(r, root) == 0 && ++ mnt_fs_streq_srcpath(fs, src) && ++ mnt_fs_streq_target(fs, tgt)) ++ break; ++ } ++ /* mtab: compare source and target */ ++ else if (mnt_fs_streq_srcpath(fs, src) && ++ mnt_fs_streq_target(fs, tgt)) + break; + } + if (fs) +@@ -881,6 +908,8 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs) + + if (xsrc && !tb->cache) + free(xsrc); ++ if (!tb->cache) ++ free(tgt); + + free(root); + return rc; +diff --git a/libmount/src/tab_parse.c b/libmount/src/tab_parse.c +index 0f618bb..28c8536 100644 +--- a/libmount/src/tab_parse.c ++++ b/libmount/src/tab_parse.c +@@ -180,12 +180,7 @@ static int mnt_parse_mountinfo_line(struct libmnt_fs *fs, char *s) + unmangle_string(fs->vfs_optstr); + unmangle_string(fstype); + unmangle_string(src); +- +- if (!strcmp(fs->fs_optstr, "none")) { +- free(fs->fs_optstr); +- fs->fs_optstr = NULL; +- } else +- unmangle_string(fs->fs_optstr); ++ unmangle_string(fs->fs_optstr); + + rc = __mnt_fs_set_fstype_ptr(fs, fstype); + if (!rc) { +@@ -733,21 +728,14 @@ static struct libmnt_fs *mnt_table_merge_user_fs(struct libmnt_table *tb, struct + mnt_reset_iter(&itr, MNT_ITER_BACKWARD); + + while(mnt_table_next_fs(tb, &itr, &fs) == 0) { +- const char *s = mnt_fs_get_srcpath(fs), +- *t = mnt_fs_get_target(fs), +- *r = mnt_fs_get_root(fs); ++ const char *r = mnt_fs_get_root(fs); + + if (fs->flags & MNT_FS_MERGED) + continue; + +- /* +- * Note that kernel can add tailing slash to the network +- * filesystem source path +- */ +- if (s && t && r && +- strcmp(t, target) == 0 && +- streq_except_trailing_slash(s, src) && +- strcmp(r, root) == 0) ++ if (r && strcmp(r, root) == 0 ++ && mnt_fs_streq_target(fs, target) ++ && mnt_fs_streq_srcpath(fs, src)) + break; + } + +diff --git a/libmount/src/utils.c b/libmount/src/utils.c +index c7a1fd1..4d316d1 100644 +--- a/libmount/src/utils.c ++++ b/libmount/src/utils.c +@@ -235,6 +235,7 @@ int mnt_fstype_is_pseudofs(const char *type) + strcmp(type, "binfmt_misc") == 0 || + strcmp(type, "fuse.gvfs-fuse-daemon") == 0 || + strcmp(type, "debugfs") == 0 || ++ strcmp(type, "nfsd") == 0 || + strcmp(type, "spufs") == 0) + return 1; + return 0; +diff --git a/login-utils/login.c b/login-utils/login.c +index 84d8b1b..4f448f8 100644 +--- a/login-utils/login.c ++++ b/login-utils/login.c +@@ -128,6 +128,22 @@ static int timeout = LOGIN_TIMEOUT; + static int child_pid = 0; + static volatile int got_sig = 0; + ++#ifdef LOGIN_CHOWN_VCS ++/* true if the filedescriptor fd is a console tty, very Linux specific */ ++static int is_consoletty(int fd) ++{ ++ struct stat stb; ++ ++ if ((fstat(fd, &stb) >= 0) ++ && (major(stb.st_rdev) == TTY_MAJOR) ++ && (minor(stb.st_rdev) < 64)) { ++ return 1; ++ } ++ return 0; ++} ++#endif ++ ++ + /* + * Robert Ambrose writes: + * A couple of my users have a problem with login processes hanging around +@@ -316,15 +332,15 @@ static void chown_tty(struct login_context *cxt) + + #ifdef LOGIN_CHOWN_VCS + if (is_consoletty(0)) { +- if (chown(cxt->vcs, uid, gid)) /* vcs */ +- chown_err(cxt->vcs, uid, gid); +- if (chmod(cxt->vcs, cxt->tty_mode)) +- chmod_err(cxt->vcs, cxt->tty_mode); +- +- if (chown(cxt->vcsa, uid, gid)) /* vcsa */ +- chown_err(cxt->vcsa, uid, gid); +- if (chmod(cxt->vcsa, cxt->tty_mode)) +- chmod_err(cxt->vcsa, cxt->tty_mode); ++ if (chown(cxt->vcsn, uid, gid)) /* vcs */ ++ chown_err(cxt->vcsn, uid, gid); ++ if (chmod(cxt->vcsn, cxt->tty_mode)) ++ chmod_err(cxt->vcsn, cxt->tty_mode); ++ ++ if (chown(cxt->vcsan, uid, gid)) /* vcsa */ ++ chown_err(cxt->vcsan, uid, gid); ++ if (chmod(cxt->vcsan, cxt->tty_mode)) ++ chmod_err(cxt->vcsan, cxt->tty_mode); + } + #endif + } +@@ -403,21 +419,6 @@ static void init_tty(struct login_context *cxt) + } + + +-#ifdef LOGIN_CHOWN_VCS +-/* true if the filedescriptor fd is a console tty, very Linux specific */ +-static int is_consoletty(int fd) +-{ +- struct stat stb; +- +- if ((fstat(fd, &stb) >= 0) +- && (major(stb.st_rdev) == TTY_MAJOR) +- && (minor(stb.st_rdev) < 64)) { +- return 1; +- } +- return 0; +-} +-#endif +- + /* + * Log failed login attempts in _PATH_BTMP if that exists. + * Must be called only with username the name of an actual user. +@@ -1145,13 +1146,10 @@ static void init_environ(struct login_context *cxt) + setenv("TERM", termenv, 1); + + if (pwd->pw_uid) +- setenv("PATH", getlogindefs_str("ENV_PATH", _PATH_DEFPATH), 1); +- else { +- const char *x = getlogindefs_str("ENV_ROOTPATH", NULL); +- if (!x) +- x = getlogindefs_str("ENV_SUPATH", _PATH_DEFPATH_ROOT); +- setenv("PATH", x, 1); +- } ++ logindefs_setenv("PATH", "ENV_PATH", _PATH_DEFPATH); ++ ++ else if (logindefs_setenv("PATH", "ENV_ROOTPATH", NULL) != 0) ++ logindefs_setenv("PATH", "ENV_SUPATH", _PATH_DEFPATH_ROOT); + + /* mailx will give a funny error msg if you forget this one */ + len = snprintf(tmp, sizeof(tmp), "%s/%s", _PATH_MAILDIR, pwd->pw_name); +diff --git a/login-utils/logindefs.c b/login-utils/logindefs.c +index fe590e9..e9517ac 100644 +--- a/login-utils/logindefs.c ++++ b/login-utils/logindefs.c +@@ -211,6 +211,43 @@ const char *getlogindefs_str(const char *name, const char *dflt) + return ptr->value; + } + ++/* ++ * For compatibililty with shadow-utils we have tu support additional ++ * syntax for environment variables in login.defs(5) file. The standard ++ * syntax is: ++ * ++ * ENV_FOO data ++ * ++ * but shadow-utils supports also ++ * ++ * ENV_FOO FOO=data ++ * ++ * the FOO= prefix has to be remove before we call setenv(). ++ */ ++int logindefs_setenv(const char *name, const char *conf, const char *dflt) ++{ ++ const char *val = getlogindefs_str(conf, dflt); ++ const char *p; ++ ++ if (!val) ++ return -1; ++ ++ p = strchr(val, '='); ++ if (p) { ++ size_t sz = strlen(name); ++ ++ if (strncmp(val, name, sz) == 0 && *(p + 1)) { ++ val = p + 1; ++ if (*val == '"') ++ val++; ++ if (!*val) ++ val = dflt; ++ } ++ } ++ ++ return val ? setenv(name, val, 1) : -1; ++} ++ + #ifdef TEST_PROGRAM + int main(int argc, char *argv[]) + { +diff --git a/login-utils/logindefs.h b/login-utils/logindefs.h +index 37d19e1..163869d 100644 +--- a/login-utils/logindefs.h ++++ b/login-utils/logindefs.h +@@ -5,5 +5,6 @@ extern int getlogindefs_bool(const char *name, int dflt); + extern long getlogindefs_num(const char *name, long dflt); + extern const char *getlogindefs_str(const char *name, const char *dflt); + extern void free_getlogindefs_data(void); ++extern int logindefs_setenv(const char *name, const char *conf, const char *dflt); + + #endif /* UTIL_LINUX_LOGINDEFS_H */ +diff --git a/man/ru/Makefile.am b/man/ru/Makefile.am +index 799feca..281ec23 100644 +--- a/man/ru/Makefile.am ++++ b/man/ru/Makefile.am +@@ -1,9 +1,6 @@ + include $(top_srcdir)/config/include-Makefile.am + +-mandir = @mandir@/ru +- +-dist_man_MANS = +- + if BUILD_DDATE +-dist_man_MANS += ddate.1 ++ruman1_DATA = ddate.1 ++EXTRA_DIST = $(ruman1_DATA) + endif +diff --git a/misc-utils/lsblk.8 b/misc-utils/lsblk.8 +index 028b19f..286d54b 100644 +--- a/misc-utils/lsblk.8 ++++ b/misc-utils/lsblk.8 +@@ -59,7 +59,7 @@ Use key="value" output format. + Use the raw output format. + .IP "\fB\-t, \-\-topology\fP" + Output info about block device topology. +-This option is equivalent to "-o NAME,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,SCHED". ++This option is equivalent to "-o NAME,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,SCHED,RQ-SIZE". + .SH NOTES + For the partitions are some information (e.g. queue attributes) inherited from + parental device. +diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c +index 8468b3f..54bf360 100644 +--- a/misc-utils/lsblk.c ++++ b/misc-utils/lsblk.c +@@ -478,9 +478,14 @@ static void set_tt_data(struct blkdev_cxt *cxt, int col, int id, struct tt_line + switch(id) { + case COL_NAME: + if (cxt->dm_name) { +- snprintf(buf, sizeof(buf), "%s (%s)", ++ if ((lsblk->tt->flags & TT_FL_RAW) || ++ (lsblk->tt->flags & TT_FL_EXPORT)) ++ tt_line_set_data(ln, col, xstrdup(cxt->dm_name)); ++ else { ++ snprintf(buf, sizeof(buf), "%s (%s)", + cxt->dm_name, cxt->name); +- tt_line_set_data(ln, col, xstrdup(buf)); ++ tt_line_set_data(ln, col, xstrdup(buf)); ++ } + break; + } + case COL_KNAME: +diff --git a/mount/fstab.5 b/mount/fstab.5 +index b0cd763..c618947 100644 +--- a/mount/fstab.5 ++++ b/mount/fstab.5 +@@ -167,7 +167,7 @@ support filesystem + The subtype is defined by '.subtype' suffix. For + example 'fuse.sshfs'. It's recommended to use subtype notation rather than add + any prefix to the first fstab field (for example 'sshfs#example.com' is +-depreacated). ++deprecated). + .RE + + .B The fourth field +diff --git a/sys-utils/losetup.8 b/sys-utils/losetup.8 +index a68836e..f50b072 100644 +--- a/sys-utils/losetup.8 ++++ b/sys-utils/losetup.8 +@@ -80,6 +80,8 @@ for non-root users. + force loop driver to reread size of the file associated with the specified loop device + .IP "\fB\-d, \-\-detach\fP \fIloopdev\fP..." + detach the file or device associated with the specified loop device(s) ++.IP "\fB\-D, \-\-detach-all\fP" ++detach all associated loop devices + .IP "\fB\-e, \-E, \-\-encryption \fIencryption_type\fP" + enable data encryption with specified name or number + .IP "\fB\-f, \-\-find\fP" +diff --git a/sys-utils/losetup.c b/sys-utils/losetup.c +index 16ace6f..9f03151 100644 +--- a/sys-utils/losetup.c ++++ b/sys-utils/losetup.c +@@ -362,7 +362,7 @@ int main(int argc, char **argv) + if (flags & LOOPDEV_FL_OFFSET) + loopcxt_set_offset(&lc, offset); + if (flags & LOOPDEV_FL_SIZELIMIT) +- loopcxt_set_offset(&lc, sizelimit); ++ loopcxt_set_sizelimit(&lc, sizelimit); + if (lo_flags) + loopcxt_set_flags(&lc, lo_flags); + if ((res = loopcxt_set_backing_file(&lc, file))) { +diff --git a/sys-utils/mount.8 b/sys-utils/mount.8 +index 78e7a41..44d4402 100644 +--- a/sys-utils/mount.8 ++++ b/sys-utils/mount.8 +@@ -2760,6 +2760,10 @@ mount failure + .TP + .BR 64 + some mount succeeded ++.RE ++ ++The command mount -a returns 0 (all success), 32 (all failed) or 64 (some ++failed, some success). + + .SH NOTES + The syntax of external mount helpers is: +diff --git a/sys-utils/mount.c b/sys-utils/mount.c +index 15510e0..12ec372 100644 +--- a/sys-utils/mount.c ++++ b/sys-utils/mount.c +@@ -182,6 +182,8 @@ static int mount_all(struct libmnt_context *cxt) + struct libmnt_fs *fs; + int mntrc, ignored, rc = MOUNT_EX_SUCCESS; + ++ int nsucc = 0, nerrs = 0; ++ + itr = mnt_new_iter(MNT_ITER_FORWARD); + if (!itr) { + warn(_("failed to initialize libmount iterator")); +@@ -197,31 +199,40 @@ static int mount_all(struct libmnt_context *cxt) + printf(ignored == 1 ? _("%-25s: ignored\n") : + _("%-25s: already mounted\n"), + tgt); +- + } else if (mnt_context_is_fork(cxt)) { + if (mnt_context_is_verbose(cxt)) + printf("%-25s: mount successfully forked\n", tgt); + } else { +- rc |= mk_exit_code(cxt, mntrc); ++ mk_exit_code(cxt, mntrc); /* to print warnings */ + + if (mnt_context_get_status(cxt)) { +- rc |= MOUNT_EX_SOMEOK; ++ nsucc++; + + if (mnt_context_is_verbose(cxt)) + printf("%-25s: successfully mounted\n", tgt); +- } ++ } else ++ nerrs++; + } + } + + if (mnt_context_is_parent(cxt)) { + /* wait for mount --fork children */ +- int nerrs = 0, nchildren = 0; ++ int nchildren = 0; ++ ++ nerrs = 0, nsucc = 0; + + rc = mnt_context_wait_for_children(cxt, &nchildren, &nerrs); + if (!rc && nchildren) +- rc = nchildren == nerrs ? MOUNT_EX_FAIL : MOUNT_EX_SOMEOK; ++ nsucc = nchildren - nerrs; + } + ++ if (nerrs == 0) ++ rc = MOUNT_EX_SUCCESS; /* all success */ ++ else if (nsucc == 0) ++ rc = MOUNT_EX_FAIL; /* all failed */ ++ else ++ rc = MOUNT_EX_SOMEOK; /* some success, some failed */ ++ + mnt_free_iter(itr); + return rc; + } +@@ -290,6 +301,25 @@ static void selinux_warning(struct libmnt_context *cxt, const char *tgt) + # define selinux_warning(_x, _y) + #endif + ++/* temporary in mount(8) for v2.21.x releases, in v2.22 will be in libmount ++ */ ++static int mnt_fs_streq_srcpath(struct libmnt_fs *fs, const char *path) ++{ ++ const char *p; ++ ++ if (!fs) ++ return 0; ++ ++ p = mnt_fs_get_srcpath(fs); ++ ++ if (!mnt_fs_is_pseudofs(fs)) ++ return streq_except_trailing_slash(p, path); ++ ++ if (!p && !path) ++ return 1; ++ ++ return p && path && strcmp(p, path) == 0; ++} + + /* + * rc = 0 success +@@ -336,7 +366,11 @@ try_readonly: + return MOUNT_EX_USAGE; + } + +- if (src == NULL || tgt == NULL) { ++ /* ++ * TODO: add mnt_context_fstab_applied() to check if we found ++ * target/source in the file. ++ */ ++ if (!tgt) { + if (mflags & MS_REMOUNT) + warnx(_("%s not mounted"), src ? src : tgt); + else +@@ -408,7 +442,7 @@ try_readonly: + const char *s = mnt_fs_get_srcpath(fs), + *t = mnt_fs_get_target(fs); + +- if (t && s && streq_except_trailing_slash(s, src)) ++ if (t && s && mnt_fs_streq_srcpath(fs, src)) + fprintf(stderr, _( + " %s is already mounted on %s\n"), s, t); + } +@@ -697,7 +731,7 @@ int main(int argc, char **argv) + longopts, NULL)) != -1) { + + /* only few options are allowed for non-root users */ +- if (mnt_context_is_restricted(cxt) && !strchr("hlLUVvpr", c)) ++ if (mnt_context_is_restricted(cxt) && !strchr("hlLUVvpri", c)) + exit_non_root(option_to_longopt(c, longopts)); + + switch(c) { +diff --git a/sys-utils/mountpoint.c b/sys-utils/mountpoint.c +index 5cc833d..d0a0069 100644 +--- a/sys-utils/mountpoint.c ++++ b/sys-utils/mountpoint.c +@@ -40,12 +40,12 @@ + + static int quiet; + +-static dev_t dir_to_device(const char *spec) ++static int dir_to_device(const char *spec, dev_t *dev) + { + struct libmnt_table *tb = mnt_new_table_from_file("/proc/self/mountinfo"); + struct libmnt_fs *fs; + struct libmnt_cache *cache; +- dev_t res = 0; ++ int rc = -1; + + if (!tb) { + /* +@@ -57,7 +57,7 @@ static dev_t dir_to_device(const char *spec) + int len; + + if (stat(spec, &st) != 0) +- return 0; ++ return -1; + + cn = mnt_resolve_path(spec, NULL); /* canonicalize */ + +@@ -65,15 +65,17 @@ static dev_t dir_to_device(const char *spec) + free(cn); + + if (len < 0 || (size_t) len + 1 > sizeof(buf)) +- return 0; ++ return -1; + if (stat(buf, &pst) !=0) +- return 0; ++ return -1; + + if ((st.st_dev != pst.st_dev) || +- (st.st_dev == pst.st_dev && st.st_ino == pst.st_ino)) +- return st.st_dev; ++ (st.st_dev == pst.st_dev && st.st_ino == pst.st_ino)) { ++ *dev = st.st_dev; ++ return 0; ++ } + +- return 0; ++ return -1; + } + + /* to canonicalize all necessary paths */ +@@ -81,12 +83,14 @@ static dev_t dir_to_device(const char *spec) + mnt_table_set_cache(tb, cache); + + fs = mnt_table_find_target(tb, spec, MNT_ITER_BACKWARD); +- if (fs && mnt_fs_get_target(fs)) +- res = mnt_fs_get_devno(fs); ++ if (fs && mnt_fs_get_target(fs)) { ++ *dev = mnt_fs_get_devno(fs); ++ rc = 0; ++ } + + mnt_free_table(tb); + mnt_free_cache(cache); +- return res; ++ return rc; + } + + static int print_devno(const char *devname, struct stat *st) +@@ -185,8 +189,8 @@ int main(int argc, char **argv) + errx(EXIT_FAILURE, _("%s: not a directory"), spec); + return EXIT_FAILURE; + } +- src = dir_to_device(spec); +- if (!src) { ++ ++ if ( dir_to_device(spec, &src)) { + if (!quiet) + printf(_("%s is not a mountpoint\n"), spec); + return EXIT_FAILURE; +diff --git a/term-utils/script.c b/term-utils/script.c +index 58f9790..0d891b8 100644 +--- a/term-utils/script.c ++++ b/term-utils/script.c +@@ -437,6 +437,16 @@ doshell(void) { + else + shname = shell; + ++ /* ++ * When invoked from within /etc/csh.login, script spawns a csh shell ++ * that spawns programs that cannot be killed with a SIGTERM. This is ++ * because csh has a documented behaviour wherein it disables all ++ * signals when processing the /etc/csh.* files. ++ * ++ * Let's restore the default behavior. ++ */ ++ signal(SIGTERM, SIG_DFL); ++ + if (cflg) + execl(shell, shname, "-c", cflg, NULL); + else +diff --git a/tests/Makefile.am b/tests/Makefile.am +index fd62519..2c72318 100644 +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -7,5 +7,5 @@ EXTRA_DIST = expected \ + functions.sh \ + run.sh + +-distclean-local: ++clean-local: + rm -rf output diff +diff --git a/tests/expected/libmount/tabfiles-find-target2 b/tests/expected/libmount/tabfiles-find-target2 +new file mode 100644 +index 0000000..8a6c57b +--- /dev/null ++++ b/tests/expected/libmount/tabfiles-find-target2 +@@ -0,0 +1,5 @@ ++------ fs: ++source: /dev/foo ++target: /any/foo/ ++fstype: auto ++optstr: defaults +diff --git a/tests/expected/libmount/tabfiles-find-target3 b/tests/expected/libmount/tabfiles-find-target3 +new file mode 100644 +index 0000000..8a6c57b +--- /dev/null ++++ b/tests/expected/libmount/tabfiles-find-target3 +@@ -0,0 +1,5 @@ ++------ fs: ++source: /dev/foo ++target: /any/foo/ ++fstype: auto ++optstr: defaults +diff --git a/tests/expected/libmount/tabfiles-parse-fstab b/tests/expected/libmount/tabfiles-parse-fstab +index 14bdfb4..d661526 100644 +--- a/tests/expected/libmount/tabfiles-parse-fstab ++++ b/tests/expected/libmount/tabfiles-parse-fstab +@@ -58,3 +58,8 @@ target: /mnt/gogogo + fstype: cifs + optstr: user=SRGROUP/baby,noauto + user-optstr: user=SRGROUP/baby,noauto ++------ fs: ++source: /dev/foo ++target: /any/foo/ ++fstype: auto ++optstr: defaults +diff --git a/tests/expected/libmount/tabfiles-parse-mountinfo b/tests/expected/libmount/tabfiles-parse-mountinfo +index 95182dd..4470801 100644 +--- a/tests/expected/libmount/tabfiles-parse-mountinfo ++++ b/tests/expected/libmount/tabfiles-parse-mountinfo +@@ -296,7 +296,7 @@ id: 41 + parent: 20 + devno: 253:0 + ------ fs: +-source: (null) ++source: none + target: /proc/sys/fs/binfmt_misc + fstype: binfmt_misc + optstr: rw,relatime +diff --git a/tests/expected/libmount/tabfiles-parse-mtab b/tests/expected/libmount/tabfiles-parse-mtab +index d7171ea..ffd0c13 100644 +--- a/tests/expected/libmount/tabfiles-parse-mtab ++++ b/tests/expected/libmount/tabfiles-parse-mtab +@@ -42,7 +42,7 @@ fstype: ext4 + optstr: rw,noatime + VFS-optstr: rw,noatime + ------ fs: +-source: (null) ++source: none + target: /proc/sys/fs/binfmt_misc + fstype: binfmt_misc + optstr: rw +diff --git a/tests/expected/libmount/update-utab-mount b/tests/expected/libmount/update-utab-mount +index 1784e00..58a0179 100644 +--- a/tests/expected/libmount/update-utab-mount ++++ b/tests/expected/libmount/update-utab-mount +@@ -1,3 +1,3 @@ + SRC=/dev/sdb1 TARGET=/mnt/bar ROOT=/ OPTS=user + SRC=/dev/sda2 TARGET=/mnt/xyz ROOT=/ OPTS=loop=/dev/loop0,uhelper=hal +-TARGET=/proc ROOT=/ OPTS=user ++SRC=none TARGET=/proc ROOT=/ OPTS=user +diff --git a/tests/expected/libmount/update-utab-move b/tests/expected/libmount/update-utab-move +index 12917cc..6008140 100644 +--- a/tests/expected/libmount/update-utab-move ++++ b/tests/expected/libmount/update-utab-move +@@ -1,3 +1,3 @@ + SRC=/dev/sdb1 TARGET=/mnt/newbar ROOT=/ OPTS=user + SRC=/dev/sda2 TARGET=/mnt/newxyz ROOT=/ OPTS=loop=/dev/loop0,uhelper=hal +-TARGET=/proc ROOT=/ OPTS=user ++SRC=none TARGET=/proc ROOT=/ OPTS=user +diff --git a/tests/expected/libmount/update-utab-remount b/tests/expected/libmount/update-utab-remount +index 737e2a3..8e344b3 100644 +--- a/tests/expected/libmount/update-utab-remount ++++ b/tests/expected/libmount/update-utab-remount +@@ -1,3 +1,3 @@ + SRC=/dev/sdb1 TARGET=/mnt/newbar ROOT=/ OPTS=user + SRC=/dev/sda2 TARGET=/mnt/newxyz ROOT=/ OPTS=user +-TARGET=/proc ROOT=/ OPTS=user ++SRC=none TARGET=/proc ROOT=/ OPTS=user +diff --git a/tests/expected/mount/fstab-none b/tests/expected/mount/fstab-none +new file mode 100644 +index 0000000..3582111 +--- /dev/null ++++ b/tests/expected/mount/fstab-none +@@ -0,0 +1 @@ ++Success +diff --git a/tests/expected/mount/shared-subtree b/tests/expected/mount/shared-subtree +new file mode 100644 +index 0000000..3582111 +--- /dev/null ++++ b/tests/expected/mount/shared-subtree +@@ -0,0 +1 @@ ++Success +diff --git a/tests/expected/mount/shared-subtree-make-private b/tests/expected/mount/shared-subtree-make-private +new file mode 100644 +index 0000000..39cdd0d +--- /dev/null ++++ b/tests/expected/mount/shared-subtree-make-private +@@ -0,0 +1 @@ ++- +diff --git a/tests/expected/mount/shared-subtree-make-shared b/tests/expected/mount/shared-subtree-make-shared +new file mode 100644 +index 0000000..8a205e8 +--- /dev/null ++++ b/tests/expected/mount/shared-subtree-make-shared +@@ -0,0 +1 @@ ++shared +diff --git a/tests/expected/mount/shared-subtree-make-unbindable b/tests/expected/mount/shared-subtree-make-unbindable +new file mode 100644 +index 0000000..376cfac +--- /dev/null ++++ b/tests/expected/mount/shared-subtree-make-unbindable +@@ -0,0 +1 @@ ++unbindable +diff --git a/tests/functions.sh b/tests/functions.sh +index 85b1621..6556e4e 100644 +--- a/tests/functions.sh ++++ b/tests/functions.sh +@@ -93,6 +93,8 @@ function ts_init_core_subtest_env { + TS_MOUNTPOINT="$TS_OUTDIR/${TS_TESTNAME}-${TS_SUBNAME}-mnt" + + rm -f $TS_OUTPUT $TS_VGDUMP ++ [ -d "$TS_OUTDIR" ] || mkdir -p "$TS_OUTDIR" ++ + touch $TS_OUTPUT + [ -n "$TS_VALGRIND_CMD" ] && touch $TS_VGDUMP + } +@@ -127,8 +129,6 @@ function ts_init_env { + + BLKID_FILE="$TS_OUTDIR/${TS_TESTNAME}.blkidtab" + +- [ -d "$TS_OUTDIR" ] || mkdir -p "$TS_OUTDIR" +- [ -d "$TS_DIFFDIR" ] || mkdir -p "$TS_DIFFDIR" + + declare -a TS_SUID_PROGS + declare -a TS_SUID_USER +@@ -141,6 +141,8 @@ function ts_init_env { + export BLKID_FILE + + rm -f $TS_OUTPUT $TS_VGDUMP ++ [ -d "$TS_OUTDIR" ] || mkdir -p "$TS_OUTDIR" ++ + touch $TS_OUTPUT + [ -n "$TS_VALGRIND_CMD" ] && touch $TS_VGDUMP + +@@ -219,8 +221,15 @@ function ts_gen_diff { + local res=0 + + if [ -s "$TS_OUTPUT" ]; then ++ ++ [ -d "$TS_DIFFDIR" ] || mkdir -p "$TS_DIFFDIR" + diff -u $TS_EXPECTED $TS_OUTPUT > $TS_DIFF +- [ -s $TS_DIFF ] && res=1 ++ ++ if [ -s $TS_DIFF ]; then ++ res=1 ++ else ++ rm -f $TS_DIFF; ++ fi + else + res=1 + fi +diff --git a/tests/ts/build-sys/config b/tests/ts/build-sys/config +index 7ede38c..e2c2b00 100755 +--- a/tests/ts/build-sys/config ++++ b/tests/ts/build-sys/config +@@ -52,9 +52,18 @@ for conf in $config_gen_dir/config-gen.d/*.conf; do + esac + fi + done ++ ++ # clean the tree, but exclude tests/{diff,output} dirs ++ # ++ [ -d tests/diff ] && mv tests/diff tests/diff.save ++ [ -d tests/output ] && mv tests/output tests/output.save ++ + make -j clean &> /dev/null +- cd $olddir + ++ [ -d tests/diff.save ] && mv tests/diff.save tests/diff ++ [ -d tests/output.save ] && mv tests/output.save tests/output ++ ++ cd $olddir + ts_finalize_subtest + done + +diff --git a/tests/ts/libmount/context-utab b/tests/ts/libmount/context-utab +index aa49806..4c1d117 100755 +--- a/tests/ts/libmount/context-utab ++++ b/tests/ts/libmount/context-utab +@@ -67,6 +67,8 @@ grep -q $DEVICE /proc/mounts || \ + echo "(by device) cannot find $DEVICE in /proc/mounts" >> $TS_OUTPUT 2>&1 + ts_finalize_subtest + ++sleep 1 ++ + ts_init_subtest "umount-by-devname" + ts_valgrind $TESTPROG --umount $DEVICE >> $TS_OUTPUT 2>&1 + grep -q $DEVICE /proc/mounts && +@@ -81,6 +83,8 @@ grep -q $DEVICE $LIBMOUNT_UTAB || \ + echo "(by label) cannot find $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1 + ts_finalize_subtest + ++sleep 1 ++ + ts_init_subtest "umount" + ts_valgrind $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>&1 + grep -q $DEVICE $LIBMOUNT_UTAB && \ +@@ -94,6 +98,8 @@ if [ -x "/sbin/mkfs.btrfs" ]; then + /sbin/btrfsctl -S sub $MOUNTPOINT &> /dev/null + umount $MOUNTPOINT &> /dev/null + ++ sleep 1 ++ + ts_init_subtest "mount-uhelper-subvol" + mkdir -p $MOUNTPOINT &> /dev/null + ts_valgrind $TESTPROG --mount -o uhelper=foo,rw,subvol=sub $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>&1 +@@ -105,6 +111,8 @@ if [ -x "/sbin/mkfs.btrfs" ]; then + $TS_CMD_FINDMNT --mtab $MOUNTPOINT -o OPTIONS -n >> $TS_OUTPUT 2>&1 + ts_log "---" + ++ sleep 1 ++ + ts_init_subtest "umount-subvol" + ts_valgrind $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>&1 + grep -q $DEVICE $LIBMOUNT_UTAB && \ +diff --git a/tests/ts/libmount/files/fstab b/tests/ts/libmount/files/fstab +index 2503065..a8f73bc 100644 +--- a/tests/ts/libmount/files/fstab ++++ b/tests/ts/libmount/files/fstab +@@ -10,3 +10,5 @@ proc /proc proc defaults 0 0 + + foo.com:/mnt/share /mnt/remote nfs noauto + //bar.com/gogogo /mnt/gogogo cifs user=SRGROUP/baby,noauto ++ ++/dev/foo /any/foo/ auto defaults 0 0 +diff --git a/tests/ts/libmount/tabfiles b/tests/ts/libmount/tabfiles +index 7f4913e..671c649 100755 +--- a/tests/ts/libmount/tabfiles ++++ b/tests/ts/libmount/tabfiles +@@ -47,6 +47,16 @@ ts_valgrind $TESTPROG --find-forward "$TS_SELF/files/fstab" target /home/foo &> + sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT + ts_finalize_subtest + ++ts_init_subtest "find-target2" ++ts_valgrind $TESTPROG --find-forward "$TS_SELF/files/fstab" target /any/foo &> $TS_OUTPUT ++sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT ++ts_finalize_subtest ++ ++ts_init_subtest "find-target3" ++ts_valgrind $TESTPROG --find-forward "$TS_SELF/files/fstab" target /any/foo/ &> $TS_OUTPUT ++sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT ++ts_finalize_subtest ++ + ts_init_subtest "find-pair" + ts_valgrind $TESTPROG --find-pair "$TS_SELF/files/mtab" /dev/mapper/kzak-home /home/kzak &> $TS_OUTPUT + sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT +diff --git a/tests/ts/mount/fstab-none b/tests/ts/mount/fstab-none +new file mode 100755 +index 0000000..62a89ca +--- /dev/null ++++ b/tests/ts/mount/fstab-none +@@ -0,0 +1,30 @@ ++#!/bin/bash ++ ++TS_TOPDIR="$(dirname $0)/../.." ++TS_DESC="none" ++ ++. $TS_TOPDIR/functions.sh ++ts_init "$*" ++ts_skip_nonroot ++ ++set -o pipefail ++ ++ts_fstab_add "none" "$TS_MOUNTPOINT" "tmpfs" "rw,nosuid,nodev,relatime" ++ ++mkdir -p $TS_MOUNTPOINT ++ ++$TS_CMD_MOUNT $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT ++ ++$TS_CMD_FINDMNT --target "$TS_MOUNTPOINT" &> /dev/null ++[ $? -eq 0 ] || ts_die "Not found target (mount failed?)" ++ ++$TS_CMD_FINDMNT --source "none" --target "$TS_MOUNTPOINT" &> /dev/null ++[ $? -eq 0 ] || ts_die "Not found source and target" ++ ++$TS_CMD_UMOUNT $TS_MOUNTPOINT || ts_die "Cannot umount $TS_MOUNTPOINT" ++ ++ts_fstab_clean ++ ++ts_log "Success" ++ts_finalize ++ +diff --git a/tests/ts/mount/shared-subtree b/tests/ts/mount/shared-subtree +new file mode 100755 +index 0000000..a0a76c5 +--- /dev/null ++++ b/tests/ts/mount/shared-subtree +@@ -0,0 +1,58 @@ ++#!/bin/bash ++ ++TS_TOPDIR="$(dirname $0)/../.." ++TS_DESC="shared-subtree" ++ ++. $TS_TOPDIR/functions.sh ++ts_init "$*" ++ts_skip_nonroot ++ ++function get_attr() ++{ ++ # It's usually stupid idea to use 'grep | awk', ++ # but use paths in awk /regex/ is too tricky... ++ # ++ # TODO; improve libmount and findmnt to return the ++ # shared-subtree flags ++ # ++ echo $(grep "$1" /proc/self/mountinfo | \ ++ awk '{print $7}' | \ ++ awk -F ':' '{ print $1 }') ++} ++ ++[ -d $TS_MOUNTPOINT ] || mkdir -p $TS_MOUNTPOINT ++ ++# bind ++$TS_CMD_MOUNT --bind $TS_MOUNTPOINT $TS_MOUNTPOINT ++ ++# check the bind ++$TS_CMD_FINDMNT --kernel --target $TS_MOUNTPOINT &> /dev/null ++[ "$?" == "0" ] || ts_die "Cannot find binded $TS_MOUNTPOINT in /proc/self/mountinfo" ++ ++# use the same mounpoint for all sub-tests ++MOUNTPOINT="$TS_MOUNTPOINT" ++ ++ ++ts_init_subtest "make-shared" ++$TS_CMD_MOUNT --make-shared $MOUNTPOINT >> $TS_OUTPUT 2>&1 ++echo "$(get_attr $MOUNTPOINT)" >> $TS_OUTPUT ++ts_finalize_subtest ++ ++ts_init_subtest "make-private" ++$TS_CMD_MOUNT --make-private $MOUNTPOINT >> $TS_OUTPUT 2>&1 ++echo "$(get_attr $MOUNTPOINT)" >> $TS_OUTPUT ++ts_finalize_subtest ++ ++ts_init_subtest "make-unbindable" ++$TS_CMD_MOUNT --make-unbindable $MOUNTPOINT >> $TS_OUTPUT 2>&1 ++echo "$(get_attr $MOUNTPOINT)" >> $TS_OUTPUT ++ts_finalize_subtest ++ ++ ++# clean up ++$TS_CMD_UMOUNT $TS_MOUNTPOINT ++rmdir $TS_MOUNTPOINT ++ ++ts_log "Success" ++ts_finalize ++ |