New upstream version 1.3.9.

New tool: nbdinfo.
This commit is contained in:
Richard W.M. Jones 2020-07-21 11:15:24 +01:00
parent d62b63765d
commit 4f792d0a40
3 changed files with 12 additions and 103 deletions

View File

@ -1,96 +0,0 @@
From 814e597c4ed49ca59b8f24a5f16a487409a4804e Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 17 Jul 2020 12:35:59 +0100
Subject: [PATCH] lib/utils.c: Use strerrordesc_np as alternative in async-safe
perror.
See:
https://lists.fedoraproject.org/archives/list/glibc@lists.fedoraproject.org/thread/WJHGG2OO7ABNAYICGA5WQZ2Q34Q2FEHU/
Thanks: Florian Weimer
---
configure.ac | 5 +++++
lib/utils.c | 31 +++++++++++++++++++------------
2 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/configure.ac b/configure.ac
index e5c29cd..a44e3b1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -79,6 +79,11 @@ AC_CHECK_HEADERS([\
AC_CHECK_HEADERS([linux/vm_sockets.h], [], [], [#include <sys/socket.h>])
+dnl Check for strerrordesc_np (optional, glibc only).
+dnl Prefer this over sys_errlist.
+dnl https://lists.fedoraproject.org/archives/list/glibc@lists.fedoraproject.org/thread/WJHGG2OO7ABNAYICGA5WQZ2Q34Q2FEHU/
+AC_CHECK_FUNCS([strerrordesc_np])
+
dnl Check for sys_errlist (optional).
AC_MSG_CHECKING([for sys_errlist])
AC_TRY_LINK([], [extern int sys_errlist; char *p = &sys_errlist;], [
diff --git a/lib/utils.c b/lib/utils.c
index bc62f93..86e9849 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -136,6 +136,11 @@ nbd_internal_fork_safe_itoa (long v, char *buf, size_t bufsize)
return &buf[i];
}
+#if defined(__GNUC__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+#endif
+
/* Fork-safe version of perror. ONLY use this after fork and before
* exec, the rest of the time use set_error().
*/
@@ -143,24 +148,22 @@ void
nbd_internal_fork_safe_perror (const char *s)
{
const int err = errno;
+ const char *m = NULL;
+ char buf[32];
-#if defined(__GNUC__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-result"
-#endif
write (2, s, strlen (s));
write (2, ": ", 2);
-#if HAVE_SYS_ERRLIST
- write (2, sys_errlist[errno], strlen (sys_errlist[errno]));
+#ifdef HAVE_STRERRORDESC_NP
+ m = strerrordesc_np (errno);
#else
- char buf[32];
- const char *v = nbd_internal_fork_safe_itoa ((long) errno, buf, sizeof buf);
- write (2, v, strlen (v));
+#ifdef HAVE_SYS_ERRLIST
+ m = errno >= 0 && errno < sys_nerr ? sys_errlist[errno] : NULL;
#endif
+#endif
+ if (!m)
+ m = nbd_internal_fork_safe_itoa ((long) errno, buf, sizeof buf);
+ write (2, m, strlen (m));
write (2, "\n", 1);
-#if defined(__GNUC__)
-#pragma GCC diagnostic pop
-#endif
/* Restore original errno in case it was disturbed by the system
* calls above.
@@ -168,6 +171,10 @@ nbd_internal_fork_safe_perror (const char *s)
errno = err;
}
+#if defined(__GNUC__)
+#pragma GCC diagnostic pop
+#endif
+
/* nbd_internal_printable_* functions are used by the API code to
* print debug messages when we trace calls in and out of libnbd. The
* calls should attempt to convert the parameter into something
--
2.27.0

View File

@ -2,14 +2,14 @@
%global verify_tarball_signature 1
# If there are patches which touch autotools files, set this to 1.
%global patches_touch_autotools 1
%global patches_touch_autotools %{nil}
# The source directory.
%global source_directory 1.3-development
Name: libnbd
Version: 1.3.8
Release: 2%{?dist}
Version: 1.3.9
Release: 1%{?dist}
Summary: NBD client library in userspace
License: LGPLv2+
@ -22,8 +22,6 @@ Source1: http://libguestfs.org/download/libnbd/%{source_directory}/%{name
# https://pgp.key-server.io/pks/lookup?search=rjones%40redhat.com&fingerprint=on&op=vindex
Source2: libguestfs.keyring
Patch1: 0001-lib-utils.c-Use-strerrordesc_np-as-alternative-in-as.patch
%if 0%{patches_touch_autotools}
BuildRequires: autoconf, automake, libtool
%endif
@ -226,8 +224,10 @@ make %{?_smp_mflags} check || {
%doc README
%license COPYING.LIB
%{_bindir}/nbdcopy
%{_bindir}/nbdinfo
%{_libdir}/libnbd.so.*
%{_mandir}/man1/nbdcopy.1*
%{_mandir}/man1/nbdinfo.1*
%files devel
@ -280,10 +280,15 @@ make %{?_smp_mflags} check || {
%dir %{_datadir}/bash-completion/completions
%{_datadir}/bash-completion/completions/nbdcopy
%{_datadir}/bash-completion/completions/nbdfuse
%{_datadir}/bash-completion/completions/nbdinfo
%{_datadir}/bash-completion/completions/nbdsh
%changelog
* Tue Jul 21 2020 Richard W.M. Jones <rjones@redhat.com> - 1.3.9-1
- New upstream version 1.3.9.
- New tool: nbdinfo.
* Fri Jul 17 2020 Richard W.M. Jones <rjones@redhat.com> - 1.3.8-2
- New upstream version 1.3.8.
- New tool: nbdcopy

View File

@ -1,2 +1,2 @@
SHA512 (libnbd-1.3.8.tar.gz) = 01fb1c2a47e7db695e39de0331ca4db5e2a25a556d113e83ab5d393d6cbdfc4a1824e6add9f58a59807e92842c748c92ce37c3ea1b54468528d131139ce3d5c9
SHA512 (libnbd-1.3.8.tar.gz.sig) = 488633083633c3e9c9ebdb91c0f69005f1ad508c9d175502bedfc3277d3f672477e62c4ed9058d5767083839739f7e6269628cb427d2ba8d6b1f551ceb559a1a
SHA512 (libnbd-1.3.9.tar.gz) = 4af441f7d1ca0b2b5f1afdbf06af7f2c68378e3168bb2b75901ebe09dfde009ca81c314cc7fbb03516f4ddc92309aa68cb5bc4d21fd8719c155c094e80a39ff2
SHA512 (libnbd-1.3.9.tar.gz.sig) = cf453012ee2098a6eeb5844845f4d385cebc55d3d51a4f301f7be710f8eb1babd6a45cf2e5a17cb0eb02f39a911a44faee02f5a247d1e8cc8b6652798e930e28