Richard W.M. Jones
2018-Aug-12 08:51 UTC
[Libguestfs] [PATCH nbdkit 00/10] FreeBSD support.
With these patches, a majority of tests pass. The notable things which are still broken: - Because FreeBSD links /home -> /usr/home, $(pwd) gives a different result from realpath(2). Therefore some tests which implicitly rely on (eg) a plugin which calls nbdkit_realpath internally and then checking that path against $(pwd) fail. - Shebangs (#!) don't seem to work the same way under FreeBSD as they do under the Linux kernel. In any case ‘#!/usr/sbin/nbdkit perl’ runs the script under the shell. I didn't investigate why so far. - You have to use GNU make (gmake). BSD make gets very confused by automake Makefiles. I don't know if it's something we're doing wrong or if it's just not supposed to work. Rich.
Richard W.M. Jones
2018-Aug-12 08:51 UTC
[Libguestfs] [PATCH nbdkit 01/10] common: Allow common/ functions to be used by core server.
Originally the common/ directory was only for common code shared by plugins and filters but that we didn't want to include in the core server. However we might as well make the code under common/ available everywhere. (This now works the same way as the libguestfs common/ directory.) --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 09dbdb9..2170b1f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -50,11 +50,11 @@ SUBDIRS = \ bash \ docs \ include \ + common/include \ src if HAVE_PLUGINS SUBDIRS += \ - common/include \ plugins \ filters endif -- 2.18.0
Richard W.M. Jones
2018-Aug-12 08:51 UTC
[Libguestfs] [PATCH nbdkit 02/10] freebsd: Implement --exit-with-parent on FreeBSD ≥ 11.2.
See also: https://www.freebsd.org/cgi/man.cgi?query=procctl&sektion=2 --- common/include/Makefile.am | 5 +- common/include/exit-with-parent.h | 80 +++++++++++++++++++++++++++++++ configure.ac | 2 +- docs/nbdkit-captive.pod | 12 +++-- src/Makefile.am | 3 +- src/main.c | 13 ++--- tests/Makefile.am | 9 +++- tests/test-exit-with-parent.c | 7 +-- tests/test-layers.c | 7 +-- 9 files changed, 109 insertions(+), 29 deletions(-) diff --git a/common/include/Makefile.am b/common/include/Makefile.am index 4ce1723..a882ff9 100644 --- a/common/include/Makefile.am +++ b/common/include/Makefile.am @@ -32,8 +32,9 @@ include $(top_srcdir)/common-rules.mk -# These headers contain only common code shared by plugins and -# filters. They are not installed. +# These headers contain only common code shared by the core server, +# plugins and/or filters. They are not installed. EXTRA_DIST = \ + exit-with-parent.h \ ispowerof2.h \ iszero.h diff --git a/common/include/exit-with-parent.h b/common/include/exit-with-parent.h new file mode 100644 index 0000000..cb4bc9b --- /dev/null +++ b/common/include/exit-with-parent.h @@ -0,0 +1,80 @@ +/* nbdkit + * Copyright (C) 2013-2018 Red Hat Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of Red Hat nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* Implement the --exit-with-parent feature on operating systems which + * support it. + */ + +#ifndef NBDKIT_EXIT_WITH_PARENT_H +#define NBDKIT_EXIT_WITH_PARENT_H + +#include <config.h> + +#include <signal.h> + +#ifdef HAVE_SYS_PRCTL_H +#include <sys/prctl.h> +#endif + +#ifdef HAVE_SYS_PROCCTL_H +#include <sys/procctl.h> +#endif + +#if defined(HAVE_SYS_PRCTL_H) && defined(PR_SET_PDEATHSIG) + +/* For Linux >= 2.1.57. */ + +static inline int +set_exit_with_parent (void) +{ + return prctl (PR_SET_PDEATHSIG, SIGTERM); +} + +#define HAVE_EXIT_WITH_PARENT 1 + +#elif defined(HAVE_SYS_PROCCTL_H) && defined(PROC_PDEATHSIG_CTL) + +/* For FreeBSD >= 11.2 */ + +static inline int +set_exit_with_parent (void) +{ + const int sig = SIGTERM; + return procctl (P_PID, 0, PROC_PDEATHSIG_CTL, (void*) &sig); +} + +#define HAVE_EXIT_WITH_PARENT 1 + +#endif + +#endif /* NBDKIT_INTERNAL_H */ diff --git a/configure.ac b/configure.ac index 91473e8..b9bb220 100644 --- a/configure.ac +++ b/configure.ac @@ -129,7 +129,7 @@ dnl restore CFLAGS CFLAGS="${acx_nbdkit_save_CFLAGS}" dnl Check for other headers, all optional. -AC_CHECK_HEADERS([selinux/selinux.h sys/prctl.h]) +AC_CHECK_HEADERS([selinux/selinux.h sys/prctl.h sys/procctl.h]) dnl Check support for setsockcreatecon_raw (part of SELinux). AC_CHECK_LIB([selinux], [setsockcreatecon_raw], [], [:]) diff --git a/docs/nbdkit-captive.pod b/docs/nbdkit-captive.pod index 5b7eff0..6db9520 100644 --- a/docs/nbdkit-captive.pod +++ b/docs/nbdkit-captive.pod @@ -103,20 +103,22 @@ I<--exit-with-parent> is incompatible with forking into the background (because when we fork into the background we lose track of the parent process). Therefore I<-f> / I<--foreground> is implied. -This is currently implemented using a feature of the Linux kernel, so -it requires a Linux build of nbdkit and won't work on other operating -systems (patches welcome to make it work). +This is currently implemented using a non-POSIX feature available in +S<Linux ≥ 2.1.57> and S<FreeBSD ≥ 11.2>, so it won't work on other +operating systems (patches welcome to make it work). If the parent application is multithreaded, then (in the Linux implementation) if the parent I<thread> exits, that will cause nbdkit to exit. Thus in multithreaded applications you usually want to run C<nbdkit --exit-with-parent> only from the main thread (unless you actually want nbdkit to exit with the thread, but that may not work -reliably if we extend the implementation to other operating systems). +reliably on all operating systems). =head1 SEE ALSO -L<nbdkit(1)>. +L<nbdkit(1)>, +L<prctl(2)> (on Linux), +L<procctl(2)> (on FreeBSD). =head1 AUTHORS diff --git a/src/Makefile.am b/src/Makefile.am index 84ef477..ae7dcc3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -62,7 +62,8 @@ nbdkit_CPPFLAGS = \ -Dfilterdir=\"$(filterdir)\" \ -Dsbindir=\"$(sbindir)\" \ -Dsysconfdir=\"$(sysconfdir)\" \ - -I$(top_srcdir)/include + -I$(top_srcdir)/include \ + -I$(top_srcdir)/common/include nbdkit_CFLAGS = \ -pthread \ $(WARNINGS_CFLAGS) \ diff --git a/src/main.c b/src/main.c index 4d8a92b..c6f0878 100644 --- a/src/main.c +++ b/src/main.c @@ -50,15 +50,12 @@ #include <assert.h> #include <syslog.h> -#ifdef HAVE_SYS_PRCTL_H -#include <sys/prctl.h> -#endif - #include <pthread.h> #include <dlfcn.h> #include "internal.h" +#include "exit-with-parent.h" #define FIRST_SOCKET_ACTIVATION_FD 3 /* defined by systemd ABI */ @@ -266,7 +263,7 @@ main (int argc, char *argv[]) break; case EXIT_WITH_PARENT_OPTION: -#ifdef PR_SET_PDEATHSIG +#ifdef HAVE_EXIT_WITH_PARENT exit_with_parent = 1; foreground = 1; break; @@ -539,10 +536,10 @@ main (int argc, char *argv[]) /* Implement --exit-with-parent early in case plugin initialization * takes a long time and the parent exits during that time. */ -#ifdef PR_SET_PDEATHSIG +#ifdef HAVE_EXIT_WITH_PARENT if (exit_with_parent) { - if (prctl (PR_SET_PDEATHSIG, SIGTERM) == -1) { - perror ("prctl: PR_SET_PDEATHSIG"); + if (set_exit_with_parent () == -1) { + perror ("nbdkit: --exit-with-parent"); exit (EXIT_FAILURE); } } diff --git a/tests/Makefile.am b/tests/Makefile.am index 86bef71..e4a28d5 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -175,8 +175,12 @@ endif HAVE_CXX check_PROGRAMS += test-exit-with-parent TESTS += test-exit-with-parent -test_exit_with_parent_SOURCES = test-exit-with-parent.c test.h -test_exit_with_parent_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS) +test_exit_with_parent_SOURCES = \ + test-exit-with-parent.c test.h +test_exit_with_parent_CPPFLAGS = \ + -I$(top_srcdir)/common/include +test_exit_with_parent_CFLAGS = \ + $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS) # PKI files for the TLS tests. check_DATA += pki/.stamp @@ -530,6 +534,7 @@ test_layers_SOURCES = \ test-layers.c \ $(top_srcdir)/src/protocol.h test_layers_CPPFLAGS = \ + -I$(top_srcdir)/common/include \ -I$(top_srcdir)/src test_layers_CFLAGS = \ $(WARNINGS_CFLAGS) \ diff --git a/tests/test-exit-with-parent.c b/tests/test-exit-with-parent.c index 358d64f..d364884 100644 --- a/tests/test-exit-with-parent.c +++ b/tests/test-exit-with-parent.c @@ -43,10 +43,7 @@ #include <sys/wait.h> #include <errno.h> -#ifdef HAVE_SYS_PRCTL_H -#include <sys/prctl.h> -#endif - +#include "exit-with-parent.h" #include "test.h" static char pidpath[] = "/tmp/nbdkitpidXXXXXX"; @@ -56,7 +53,7 @@ static void run_test (void); int main (int argc, char *argv[]) { -#ifndef PR_SET_PDEATHSIG +#ifndef HAVE_EXIT_WITH_PARENT printf ("--exit-with-parent is not implemented on this platform, skipping\n"); exit (77); #else diff --git a/tests/test-layers.c b/tests/test-layers.c index b83fad6..ee425ea 100644 --- a/tests/test-layers.c +++ b/tests/test-layers.c @@ -57,12 +57,9 @@ #include <sys/socket.h> #include <sys/wait.h> -#ifdef HAVE_SYS_PRCTL_H -#include <sys/prctl.h> -#endif - #include <pthread.h> +#include "exit-with-parent.h" #include "protocol.h" /* From nbdkit core. */ /* Declare program_name. */ @@ -97,7 +94,7 @@ main (int argc, char *argv[]) struct reply reply; char data[512]; -#ifndef PR_SET_PDEATHSIG +#ifndef HAVE_EXIT_WITH_PARENT printf ("%s: this test requires --exit-with-parent functionality\n", program_name); exit (77); -- 2.18.0
Richard W.M. Jones
2018-Aug-12 08:51 UTC
[Libguestfs] [PATCH nbdkit 03/10] freebsd: Make endian functions work on FreeBSD.
Introduce a new "byte-swapping.h" header which encapsulates the differences between platforms. --- common/include/Makefile.am | 1 + common/include/byte-swapping.h | 84 ++++++++++++++++++++++++++++++++++ configure.ac | 8 +++- filters/partition/Makefile.am | 3 +- filters/partition/partition.c | 3 +- plugins/nbd/Makefile.am | 1 + plugins/nbd/nbd.c | 1 + plugins/pattern/Makefile.am | 3 +- plugins/pattern/pattern.c | 2 + src/connections.c | 2 +- src/internal.h | 36 --------------- tests/test-layers.c | 1 + 12 files changed, 104 insertions(+), 41 deletions(-) diff --git a/common/include/Makefile.am b/common/include/Makefile.am index a882ff9..07f28b3 100644 --- a/common/include/Makefile.am +++ b/common/include/Makefile.am @@ -35,6 +35,7 @@ include $(top_srcdir)/common-rules.mk # These headers contain only common code shared by the core server, # plugins and/or filters. They are not installed. EXTRA_DIST = \ + byte-swapping.h \ exit-with-parent.h \ ispowerof2.h \ iszero.h diff --git a/common/include/byte-swapping.h b/common/include/byte-swapping.h new file mode 100644 index 0000000..3f35aa5 --- /dev/null +++ b/common/include/byte-swapping.h @@ -0,0 +1,84 @@ +/* nbdkit + * Copyright (C) 2013-2018 Red Hat Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of Red Hat nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef NBDKIT_BYTE_SWAPPING_H +#define NBDKIT_BYTE_SWAPPING_H + +#ifdef HAVE_BYTESWAP_H +#include <byteswap.h> +#endif + +#ifdef HAVE_ENDIAN_H +#include <endian.h> +#endif + +#ifdef HAVE_SYS_ENDIAN_H +#include <sys/endian.h> +#endif + +#ifndef htobe32 +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define htobe16(x) __bswap_16 (x) +# define htole16(x) (x) +# define be16toh(x) __bswap_16 (x) +# define le16toh(x) (x) + +# define htobe32(x) __bswap_32 (x) +# define htole32(x) (x) +# define be32toh(x) __bswap_32 (x) +# define le32toh(x) (x) + +# define htobe64(x) __bswap_64 (x) +# define htole64(x) (x) +# define be64toh(x) __bswap_64 (x) +# define le64toh(x) (x) + +# else +# define htobe16(x) (x) +# define htole16(x) __bswap_16 (x) +# define be16toh(x) (x) +# define le16toh(x) __bswap_16 (x) + +# define htobe32(x) (x) +# define htole32(x) __bswap_32 (x) +# define be32toh(x) (x) +# define le32toh(x) __bswap_32 (x) + +# define htobe64(x) (x) +# define htole64(x) __bswap_64 (x) +# define be64toh(x) (x) +# define le64toh(x) __bswap_64 (x) +# endif +#endif + +#endif /* NBDKIT_BYTE_SWAPPING_H */ diff --git a/configure.ac b/configure.ac index b9bb220..87f14d6 100644 --- a/configure.ac +++ b/configure.ac @@ -129,7 +129,13 @@ dnl restore CFLAGS CFLAGS="${acx_nbdkit_save_CFLAGS}" dnl Check for other headers, all optional. -AC_CHECK_HEADERS([selinux/selinux.h sys/prctl.h sys/procctl.h]) +AC_CHECK_HEADERS([\ + byteswap.h \ + endian.h \ + selinux/selinux.h \ + sys/endian.h \ + sys/prctl.h \ + sys/procctl.h]) dnl Check support for setsockcreatecon_raw (part of SELinux). AC_CHECK_LIB([selinux], [setsockcreatecon_raw], [], [:]) diff --git a/filters/partition/Makefile.am b/filters/partition/Makefile.am index 9ab8730..eebe9e1 100644 --- a/filters/partition/Makefile.am +++ b/filters/partition/Makefile.am @@ -41,7 +41,8 @@ nbdkit_partition_filter_la_SOURCES = \ $(top_srcdir)/include/nbdkit-filter.h nbdkit_partition_filter_la_CPPFLAGS = \ - -I$(top_srcdir)/include + -I$(top_srcdir)/include \ + -I$(top_srcdir)/common/include nbdkit_partition_filter_la_CFLAGS = \ $(WARNINGS_CFLAGS) nbdkit_partition_filter_la_LDFLAGS = \ diff --git a/filters/partition/partition.c b/filters/partition/partition.c index 1fe0bc7..f6d2c5c 100644 --- a/filters/partition/partition.c +++ b/filters/partition/partition.c @@ -38,10 +38,11 @@ #include <stdint.h> #include <string.h> #include <inttypes.h> -#include <endian.h> #include <nbdkit-filter.h> +#include "byte-swapping.h" + #define THREAD_MODEL NBDKIT_THREAD_MODEL_PARALLEL static int partnum = -1; diff --git a/plugins/nbd/Makefile.am b/plugins/nbd/Makefile.am index f930b26..e998a28 100644 --- a/plugins/nbd/Makefile.am +++ b/plugins/nbd/Makefile.am @@ -42,6 +42,7 @@ nbdkit_nbd_plugin_la_SOURCES = \ nbdkit_nbd_plugin_la_CPPFLAGS = \ -I$(top_srcdir)/include \ + -I$(top_srcdir)/common/include \ -I$(top_srcdir)/src nbdkit_nbd_plugin_la_CFLAGS = \ $(WARNINGS_CFLAGS) diff --git a/plugins/nbd/nbd.c b/plugins/nbd/nbd.c index 2b5569b..b9a4523 100644 --- a/plugins/nbd/nbd.c +++ b/plugins/nbd/nbd.c @@ -50,6 +50,7 @@ #include <nbdkit-plugin.h> #include "protocol.h" +#include "byte-swapping.h" static char *sockname = NULL; static char *export = NULL; diff --git a/plugins/pattern/Makefile.am b/plugins/pattern/Makefile.am index f5b99a2..d6df76c 100644 --- a/plugins/pattern/Makefile.am +++ b/plugins/pattern/Makefile.am @@ -41,7 +41,8 @@ nbdkit_pattern_plugin_la_SOURCES = \ $(top_srcdir)/include/nbdkit-plugin.h nbdkit_pattern_plugin_la_CPPFLAGS = \ - -I$(top_srcdir)/include + -I$(top_srcdir)/include \ + -I$(top_srcdir)/common/include nbdkit_pattern_plugin_la_CFLAGS = \ $(WARNINGS_CFLAGS) nbdkit_pattern_plugin_la_LDFLAGS = \ diff --git a/plugins/pattern/pattern.c b/plugins/pattern/pattern.c index 11b258d..46b5abd 100644 --- a/plugins/pattern/pattern.c +++ b/plugins/pattern/pattern.c @@ -44,6 +44,8 @@ #define NBDKIT_API_VERSION 2 #include <nbdkit-plugin.h> +#include "byte-swapping.h" + /* The size of disk in bytes (initialized by size=<SIZE> parameter). */ static int64_t size = 0; diff --git a/src/connections.c b/src/connections.c index 398f89d..4f4a17f 100644 --- a/src/connections.c +++ b/src/connections.c @@ -40,7 +40,6 @@ #include <string.h> #include <unistd.h> #include <errno.h> -#include <endian.h> #include <sys/types.h> #include <stddef.h> #include <assert.h> @@ -48,6 +47,7 @@ #include <pthread.h> #include "internal.h" +#include "byte-swapping.h" #include "protocol.h" /* Maximum read or write request that we will handle. */ diff --git a/src/internal.h b/src/internal.h index f263c8a..55bb1eb 100644 --- a/src/internal.h +++ b/src/internal.h @@ -58,42 +58,6 @@ #define SOCK_CLOEXEC 0 #endif -#ifndef htobe32 -#include <byteswap.h> -# if __BYTE_ORDER == __LITTLE_ENDIAN -# define htobe16(x) __bswap_16 (x) -# define htole16(x) (x) -# define be16toh(x) __bswap_16 (x) -# define le16toh(x) (x) - -# define htobe32(x) __bswap_32 (x) -# define htole32(x) (x) -# define be32toh(x) __bswap_32 (x) -# define le32toh(x) (x) - -# define htobe64(x) __bswap_64 (x) -# define htole64(x) (x) -# define be64toh(x) __bswap_64 (x) -# define le64toh(x) (x) - -# else -# define htobe16(x) (x) -# define htole16(x) __bswap_16 (x) -# define be16toh(x) (x) -# define le16toh(x) __bswap_16 (x) - -# define htobe32(x) (x) -# define htole32(x) __bswap_32 (x) -# define be32toh(x) (x) -# define le32toh(x) __bswap_32 (x) - -# define htobe64(x) (x) -# define htole64(x) __bswap_64 (x) -# define be64toh(x) (x) -# define le64toh(x) __bswap_64 (x) -# endif -#endif - #if HAVE_VALGRIND # include <valgrind.h> /* http://valgrind.org/docs/manual/faq.html#faq.unhelpful */ diff --git a/tests/test-layers.c b/tests/test-layers.c index ee425ea..baf046a 100644 --- a/tests/test-layers.c +++ b/tests/test-layers.c @@ -59,6 +59,7 @@ #include <pthread.h> +#include "byte-swapping.h" #include "exit-with-parent.h" #include "protocol.h" /* From nbdkit core. */ -- 2.18.0
Richard W.M. Jones
2018-Aug-12 08:51 UTC
[Libguestfs] [PATCH nbdkit 04/10] freebsd: Make <alloca.h> conditional.
On FreeBSD the definition exists in <stdlib.h> --- configure.ac | 1 + filters/cache/cache.c | 5 ++++- filters/cow/cow.c | 5 ++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 87f14d6..3381955 100644 --- a/configure.ac +++ b/configure.ac @@ -130,6 +130,7 @@ CFLAGS="${acx_nbdkit_save_CFLAGS}" dnl Check for other headers, all optional. AC_CHECK_HEADERS([\ + alloca.h \ byteswap.h \ endian.h \ selinux/selinux.h \ diff --git a/filters/cache/cache.c b/filters/cache/cache.c index 76a0438..90a0444 100644 --- a/filters/cache/cache.c +++ b/filters/cache/cache.c @@ -39,7 +39,6 @@ #include <stdbool.h> #include <string.h> #include <inttypes.h> -#include <alloca.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> @@ -47,6 +46,10 @@ #include <sys/ioctl.h> #include <assert.h> +#ifdef HAVE_ALLOCA_H +#include <alloca.h> +#endif + #include <nbdkit-filter.h> #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) diff --git a/filters/cow/cow.c b/filters/cow/cow.c index 2f86f6c..5df1db2 100644 --- a/filters/cow/cow.c +++ b/filters/cow/cow.c @@ -77,13 +77,16 @@ #include <stdbool.h> #include <string.h> #include <inttypes.h> -#include <alloca.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <sys/types.h> #include <sys/ioctl.h> +#ifdef HAVE_ALLOCA_H +#include <alloca.h> +#endif + #include <nbdkit-filter.h> #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) -- 2.18.0
Richard W.M. Jones
2018-Aug-12 08:51 UTC
[Libguestfs] [PATCH nbdkit 05/10] freebsd: Provide alternative for glibc get_current_dir_name function.
--- configure.ac | 4 ++++ src/utils.c | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/configure.ac b/configure.ac index 3381955..0b0f233 100644 --- a/configure.ac +++ b/configure.ac @@ -138,6 +138,10 @@ AC_CHECK_HEADERS([\ sys/prctl.h \ sys/procctl.h]) +dnl Check for functions in libc, all optional. +AC_CHECK_FUNCS([\ + get_current_dir_name]) + dnl Check support for setsockcreatecon_raw (part of SELinux). AC_CHECK_LIB([selinux], [setsockcreatecon_raw], [], [:]) diff --git a/src/utils.c b/src/utils.c index 636e483..0e48d52 100644 --- a/src/utils.c +++ b/src/utils.c @@ -40,11 +40,24 @@ #include <inttypes.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <termios.h> #include <errno.h> #include "internal.h" +#ifndef HAVE_GET_CURRENT_DIR_NAME +static char * +get_current_dir_name (void) +{ + char *ret = malloc (PATH_MAX); + + ret = getcwd (ret, PATH_MAX); + ret = realloc (ret, strlen (ret) + 1); + return ret; +} +#endif + char * nbdkit_absolute_path (const char *path) { -- 2.18.0
Richard W.M. Jones
2018-Aug-12 08:51 UTC
[Libguestfs] [PATCH nbdkit 06/10] freebsd: filters/error: Use ordinary random() instead of *_r function.
The reentrant (*_r) functions don't exist on FreeBSD. Unfortunately the replacement is probably not thread-safe, but there's not much we can do about that. --- filters/error/error.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/filters/error/error.c b/filters/error/error.c index c365a43..3ba3803 100644 --- a/filters/error/error.c +++ b/filters/error/error.c @@ -216,8 +216,10 @@ error_config (nbdkit_next_config *next, void *nxdata, " Apply settings only to read/write/trim/zero" struct handle { +#ifdef __GNU_LIBRARY__ struct random_data rd; char rd_state[32]; +#endif }; static void * @@ -234,9 +236,11 @@ error_open (nbdkit_next_open *next, void *nxdata, int readonly) nbdkit_error ("malloc: %m"); return NULL; } +#ifdef __GNU_LIBRARY__ memset (&h->rd, 0, sizeof h->rd); time (&t); initstate_r (t, (char *) &h->rd_state, sizeof h->rd_state, &h->rd); +#endif return h; } @@ -268,7 +272,11 @@ random_error (struct handle *h, if (error_settings->rate >= 1) /* 100% = always inject */ goto inject; +#ifdef __GNU_LIBRARY__ random_r (&h->rd, &rand); +#else + rand = random (); +#endif if (rand >= error_settings->rate * RAND_MAX) return false; -- 2.18.0
Richard W.M. Jones
2018-Aug-12 08:51 UTC
[Libguestfs] [PATCH nbdkit 07/10] freebsd: filters/truncate: Rename variable.
Avoids a conflict with the truncate(2) symbol which FreeBSD includes from a standard header file. --- filters/truncate/truncate.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/filters/truncate/truncate.c b/filters/truncate/truncate.c index a44301f..185f6cc 100644 --- a/filters/truncate/truncate.c +++ b/filters/truncate/truncate.c @@ -50,7 +50,7 @@ #define THREAD_MODEL NBDKIT_THREAD_MODEL_PARALLEL /* These are the parameters. */ -static int64_t truncate = -1; +static int64_t truncate_size = -1; static unsigned round_up = 0, round_down = 0; /* The real size of the underlying plugin. */ @@ -100,8 +100,8 @@ truncate_config (nbdkit_next_config *next, void *nxdata, const char *key, const char *value) { if (strcmp (key, "truncate") == 0) { - truncate = nbdkit_parse_size (value); - if (truncate == -1) + truncate_size = nbdkit_parse_size (value); + if (truncate_size == -1) return -1; return 0; } @@ -154,8 +154,8 @@ truncate_get_size (struct nbdkit_next_ops *next_ops, void *nxdata, * separate operations. It's possible to specify more than one, * although perhaps not very useful. */ - if (truncate >= 0) - size = truncate; + if (truncate_size >= 0) + size = truncate_size; if (round_up > 0) size = (size + round_up - 1) & ~(round_up - 1); if (round_down > 0) -- 2.18.0
Richard W.M. Jones
2018-Aug-12 08:51 UTC
[Libguestfs] [PATCH nbdkit 08/10] freebsd: In scripts use 'env bash' instead of '/bin/bash'.
The path to bash on FreeBSD is /usr/local/bin/bash. --- docs/make-links.sh | 2 +- nbdkit.in | 2 +- tests/make-pki.sh | 2 +- tests/make-psk.sh | 2 +- tests/test-blocksize.sh | 2 +- tests/test-cache.sh | 2 +- tests/test-captive.sh | 2 +- tests/test-cow.sh | 2 +- tests/test-cxx.sh | 2 +- tests/test-dump-config.sh | 2 +- tests/test-dump-plugin-example4.sh | 2 +- tests/test-dump-plugin.sh | 2 +- tests/test-foreground.sh | 2 +- tests/test-fua.sh | 2 +- tests/test-help-plugin.sh | 2 +- tests/test-help.sh | 2 +- tests/test-ip.sh | 2 +- tests/test-layers.sh | 2 +- tests/test-log.sh | 2 +- tests/test-nozero.sh | 2 +- tests/test-offset2.sh | 2 +- tests/test-parallel-file.sh | 2 +- tests/test-parallel-nbd.sh | 2 +- tests/test-pattern-largest.sh | 2 +- tests/test-pattern.sh | 2 +- tests/test-python-exception.sh | 2 +- tests/test-random-sock.sh | 2 +- tests/test-shebang-perl.sh | 2 +- tests/test-shebang-python.sh | 2 +- tests/test-shebang-ruby.sh | 2 +- tests/test-single.sh | 2 +- tests/test-start.sh | 2 +- tests/test-tls-psk.sh | 2 +- tests/test-tls.sh | 2 +- tests/test-truncate1.sh | 2 +- tests/test-truncate2.sh | 2 +- tests/test-vddk.sh | 2 +- tests/test-version-filter.sh | 2 +- tests/test-version-plugin.sh | 2 +- tests/test-version.sh | 2 +- tests/test-zero.sh | 2 +- 41 files changed, 41 insertions(+), 41 deletions(-) diff --git a/docs/make-links.sh b/docs/make-links.sh index ccf4554..048bb6c 100755 --- a/docs/make-links.sh +++ b/docs/make-links.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2018 Red Hat Inc. # All rights reserved. diff --git a/nbdkit.in b/nbdkit.in index fc269d1..0469f1a 100644 --- a/nbdkit.in +++ b/nbdkit.in @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # @configure_input@ # Copyright (C) 2017-2018 Red Hat Inc. diff --git a/tests/make-pki.sh b/tests/make-pki.sh index 413d898..bba92f7 100755 --- a/tests/make-pki.sh +++ b/tests/make-pki.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2017 Red Hat Inc. # All rights reserved. diff --git a/tests/make-psk.sh b/tests/make-psk.sh index 5e27ea5..4c4a648 100755 --- a/tests/make-psk.sh +++ b/tests/make-psk.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2018 Red Hat Inc. # All rights reserved. diff --git a/tests/test-blocksize.sh b/tests/test-blocksize.sh index e008f5e..de407c5 100755 --- a/tests/test-blocksize.sh +++ b/tests/test-blocksize.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2018 Red Hat Inc. # All rights reserved. diff --git a/tests/test-cache.sh b/tests/test-cache.sh index da1f6d3..6f058b8 100755 --- a/tests/test-cache.sh +++ b/tests/test-cache.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2018 Red Hat Inc. # All rights reserved. diff --git a/tests/test-captive.sh b/tests/test-captive.sh index aca735b..d993ad5 100755 --- a/tests/test-captive.sh +++ b/tests/test-captive.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2014 Red Hat Inc. # All rights reserved. diff --git a/tests/test-cow.sh b/tests/test-cow.sh index 7211958..5bde829 100755 --- a/tests/test-cow.sh +++ b/tests/test-cow.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2018 Red Hat Inc. # All rights reserved. diff --git a/tests/test-cxx.sh b/tests/test-cxx.sh index 8f3e79b..1852565 100755 --- a/tests/test-cxx.sh +++ b/tests/test-cxx.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2017-2018 Red Hat Inc. # All rights reserved. diff --git a/tests/test-dump-config.sh b/tests/test-dump-config.sh index fcbff48..8ba393d 100755 --- a/tests/test-dump-config.sh +++ b/tests/test-dump-config.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2014 Red Hat Inc. # All rights reserved. diff --git a/tests/test-dump-plugin-example4.sh b/tests/test-dump-plugin-example4.sh index 55cb5a0..bff3b76 100755 --- a/tests/test-dump-plugin-example4.sh +++ b/tests/test-dump-plugin-example4.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2017 Red Hat Inc. # All rights reserved. diff --git a/tests/test-dump-plugin.sh b/tests/test-dump-plugin.sh index 9add962..e08db84 100755 --- a/tests/test-dump-plugin.sh +++ b/tests/test-dump-plugin.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2014 Red Hat Inc. # All rights reserved. diff --git a/tests/test-foreground.sh b/tests/test-foreground.sh index a889226..2d4ea72 100755 --- a/tests/test-foreground.sh +++ b/tests/test-foreground.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2014 Red Hat Inc. # All rights reserved. diff --git a/tests/test-fua.sh b/tests/test-fua.sh index 22e0fa6..22a03ef 100755 --- a/tests/test-fua.sh +++ b/tests/test-fua.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2018 Red Hat Inc. # All rights reserved. diff --git a/tests/test-help-plugin.sh b/tests/test-help-plugin.sh index c083a09..5054115 100755 --- a/tests/test-help-plugin.sh +++ b/tests/test-help-plugin.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2014 Red Hat Inc. # All rights reserved. diff --git a/tests/test-help.sh b/tests/test-help.sh index 0a4602b..c4d4454 100755 --- a/tests/test-help.sh +++ b/tests/test-help.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2014 Red Hat Inc. # All rights reserved. diff --git a/tests/test-ip.sh b/tests/test-ip.sh index 4bd841e..12448c4 100755 --- a/tests/test-ip.sh +++ b/tests/test-ip.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2016-2018 Red Hat Inc. # All rights reserved. diff --git a/tests/test-layers.sh b/tests/test-layers.sh index 3a4490f..f89eda3 100755 --- a/tests/test-layers.sh +++ b/tests/test-layers.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2018 Red Hat Inc. # All rights reserved. diff --git a/tests/test-log.sh b/tests/test-log.sh index 8948c2c..7b2c7be 100755 --- a/tests/test-log.sh +++ b/tests/test-log.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2018 Red Hat Inc. # All rights reserved. diff --git a/tests/test-nozero.sh b/tests/test-nozero.sh index 77fda0b..781b196 100755 --- a/tests/test-nozero.sh +++ b/tests/test-nozero.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2018 Red Hat Inc. # All rights reserved. diff --git a/tests/test-offset2.sh b/tests/test-offset2.sh index 78bb690..c37e060 100755 --- a/tests/test-offset2.sh +++ b/tests/test-offset2.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2018 Red Hat Inc. # All rights reserved. diff --git a/tests/test-parallel-file.sh b/tests/test-parallel-file.sh index d032bf7..fdc8a1b 100755 --- a/tests/test-parallel-file.sh +++ b/tests/test-parallel-file.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2017-2018 Red Hat Inc. # All rights reserved. diff --git a/tests/test-parallel-nbd.sh b/tests/test-parallel-nbd.sh index cfb9391..e793c11 100755 --- a/tests/test-parallel-nbd.sh +++ b/tests/test-parallel-nbd.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2017-2018 Red Hat Inc. # All rights reserved. diff --git a/tests/test-pattern-largest.sh b/tests/test-pattern-largest.sh index 9789675..2a903bf 100755 --- a/tests/test-pattern-largest.sh +++ b/tests/test-pattern-largest.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2018 Red Hat Inc. # All rights reserved. diff --git a/tests/test-pattern.sh b/tests/test-pattern.sh index c6e605d..68022c9 100755 --- a/tests/test-pattern.sh +++ b/tests/test-pattern.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2018 Red Hat Inc. # All rights reserved. diff --git a/tests/test-python-exception.sh b/tests/test-python-exception.sh index fd94827..567853a 100755 --- a/tests/test-python-exception.sh +++ b/tests/test-python-exception.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2018 Red Hat Inc. # All rights reserved. diff --git a/tests/test-random-sock.sh b/tests/test-random-sock.sh index 35ff637..0a313f5 100755 --- a/tests/test-random-sock.sh +++ b/tests/test-random-sock.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2014 Red Hat Inc. # All rights reserved. diff --git a/tests/test-shebang-perl.sh b/tests/test-shebang-perl.sh index 8d4426d..4456741 100755 --- a/tests/test-shebang-perl.sh +++ b/tests/test-shebang-perl.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2017 Red Hat Inc. # All rights reserved. diff --git a/tests/test-shebang-python.sh b/tests/test-shebang-python.sh index 191d663..5f1d024 100755 --- a/tests/test-shebang-python.sh +++ b/tests/test-shebang-python.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2017 Red Hat Inc. # All rights reserved. diff --git a/tests/test-shebang-ruby.sh b/tests/test-shebang-ruby.sh index e8d9c89..ad14b94 100755 --- a/tests/test-shebang-ruby.sh +++ b/tests/test-shebang-ruby.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2017 Red Hat Inc. # All rights reserved. diff --git a/tests/test-single.sh b/tests/test-single.sh index b4aefcc..dc6ce34 100755 --- a/tests/test-single.sh +++ b/tests/test-single.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2014 Red Hat Inc. # All rights reserved. diff --git a/tests/test-start.sh b/tests/test-start.sh index 46baa79..dc578e7 100755 --- a/tests/test-start.sh +++ b/tests/test-start.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2014 Red Hat Inc. # All rights reserved. diff --git a/tests/test-tls-psk.sh b/tests/test-tls-psk.sh index e7954bb..3d485ba 100755 --- a/tests/test-tls-psk.sh +++ b/tests/test-tls-psk.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2018 Red Hat Inc. # All rights reserved. diff --git a/tests/test-tls.sh b/tests/test-tls.sh index dcf34a2..71bd8a4 100755 --- a/tests/test-tls.sh +++ b/tests/test-tls.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2017 Red Hat Inc. # All rights reserved. diff --git a/tests/test-truncate1.sh b/tests/test-truncate1.sh index d522d70..719f63b 100755 --- a/tests/test-truncate1.sh +++ b/tests/test-truncate1.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2018 Red Hat Inc. # All rights reserved. diff --git a/tests/test-truncate2.sh b/tests/test-truncate2.sh index 8b57184..0295b96 100755 --- a/tests/test-truncate2.sh +++ b/tests/test-truncate2.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2018 Red Hat Inc. # All rights reserved. diff --git a/tests/test-vddk.sh b/tests/test-vddk.sh index 5ccfff1..d3d6c21 100755 --- a/tests/test-vddk.sh +++ b/tests/test-vddk.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2018 Red Hat Inc. # All rights reserved. diff --git a/tests/test-version-filter.sh b/tests/test-version-filter.sh index 4fca70b..f7dc985 100755 --- a/tests/test-version-filter.sh +++ b/tests/test-version-filter.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2016-2018 Red Hat Inc. # All rights reserved. diff --git a/tests/test-version-plugin.sh b/tests/test-version-plugin.sh index 6086807..379e53f 100755 --- a/tests/test-version-plugin.sh +++ b/tests/test-version-plugin.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2016 Red Hat Inc. # All rights reserved. diff --git a/tests/test-version.sh b/tests/test-version.sh index 52af147..9bfcc9b 100755 --- a/tests/test-version.sh +++ b/tests/test-version.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2016 Red Hat Inc. # All rights reserved. diff --git a/tests/test-zero.sh b/tests/test-zero.sh index 1f4549c..2c5cece 100755 --- a/tests/test-zero.sh +++ b/tests/test-zero.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash # nbdkit # Copyright (C) 2017-2018 Red Hat Inc. # All rights reserved. -- 2.18.0
Richard W.M. Jones
2018-Aug-12 08:51 UTC
[Libguestfs] [PATCH nbdkit 09/10] freebsd: Use truncate -s option instead of --size.
FreeBSD truncate(1) utility does not support the long option variant. --- tests/test-blocksize.sh | 4 ++-- tests/test-fua.sh | 2 +- tests/test-log.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test-blocksize.sh b/tests/test-blocksize.sh index de407c5..d239c9b 100755 --- a/tests/test-blocksize.sh +++ b/tests/test-blocksize.sh @@ -40,14 +40,14 @@ rm -f $files # Prep images, and check that qemu-io understands the actions we plan on doing. # TODO: Until we implement NBD_OPT_GO, qemu-io does its own read-modify-write # at 512-byte alignment, while we'd like to ultimately test 1-byte accesses -truncate --size 10M blocksize1.img +truncate -s 10M blocksize1.img if ! qemu-io -f raw -c 'r 0 1' -c 'w -z 1000 2000' \ -c 'w -P 0 1M 2M' -c 'discard 3M 4M' blocksize1.img; then echo "$0: missing or broken qemu-io" rm blocksize1.img exit 77 fi -truncate --size 10M blocksize2.img +truncate -s 10M blocksize2.img pid1= pid2 diff --git a/tests/test-fua.sh b/tests/test-fua.sh index 22a03ef..98b1e84 100755 --- a/tests/test-fua.sh +++ b/tests/test-fua.sh @@ -43,7 +43,7 @@ rm -f $files # Prep images, and check that qemu-io understands the actions we plan on # doing. We can't test trim+FUA, since qemu-io won't expose that. -truncate --size 1M fua.img +truncate -s 1M fua.img if ! qemu-io -f raw -t none -c flush -c 'w -f -z 0 64k' fua.img; then echo "$0: missing or broken qemu-io" rm fua.img diff --git a/tests/test-log.sh b/tests/test-log.sh index 7b2c7be..877f9cc 100755 --- a/tests/test-log.sh +++ b/tests/test-log.sh @@ -37,7 +37,7 @@ files="log.img log.log log.sock log.pid" rm -f $files # Test that qemu-io works -truncate --size 10M log.img +truncate -s 10M log.img if ! qemu-io -f raw -c 'w 1M 2M' log.img; then echo "$0: missing or broken qemu-io" exit 77 -- 2.18.0
Richard W.M. Jones
2018-Aug-12 08:51 UTC
[Libguestfs] [PATCH nbdkit 10/10] README: Advertise FreeBSD support.
--- README | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README b/README index e4eda79..eb2e997 100644 --- a/README +++ b/README @@ -37,7 +37,13 @@ Requirements ------------ To build the basic server and some plugins nbdkit needs nothing except -Linux and reasonably recent gcc or clang. +Linux or FreeBSD, and: + + - gcc or clang + + - bash + + - GNU make Although it is possible to build without it, it’s recommended to enable TLS support for which you will need: @@ -112,10 +118,6 @@ For bash tab completion: - bash-completion >= 1.99 -To run the test suite: - - - bash - To test for memory leaks (‘make check-valgrind’): - valgrind program and development headers -- 2.18.0
Eric Blake
2018-Aug-13 21:11 UTC
Re: [Libguestfs] [PATCH nbdkit 05/10] freebsd: Provide alternative for glibc get_current_dir_name function.
On 08/12/2018 03:51 AM, Richard W.M. Jones wrote:> --- > configure.ac | 4 ++++ > src/utils.c | 13 +++++++++++++ > 2 files changed, 17 insertions(+)> +#ifndef HAVE_GET_CURRENT_DIR_NAME > +static char * > +get_current_dir_name (void) > +{ > + char *ret = malloc (PATH_MAX); > + > + ret = getcwd (ret, PATH_MAX); > + ret = realloc (ret, strlen (ret) + 1); > + return ret;PATH_MAX need not be defined (think GNU Hurd, for example), or may be insanely large where you are wasting time overallocating then shrinking in the common case. A more robust implementation starts with a smaller size, then repeatedly grows the buffer as long as getcwd() fails with ERANGE. Or, you could use realpath(".", NULL), to get an equivalent (but not necessarily identical) name, with the malloc() taken care of on your behalf. But I don't think we need to worry about that for BSD, and that your implementation works fine for now. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Eric Blake
2018-Aug-13 21:14 UTC
Re: [Libguestfs] [PATCH nbdkit 08/10] freebsd: In scripts use 'env bash' instead of '/bin/bash'.
On 08/12/2018 03:51 AM, Richard W.M. Jones wrote:> The path to bash on FreeBSD is /usr/local/bin/bash. > ---> +++ b/docs/make-links.sh > @@ -1,4 +1,4 @@ > -#!/bin/bash - > +#!/usr/bin/env bashThis loses the '-' argument that used to be passed by the kernel (but you can't add it back to the #! linew without using BSD's or GNU coreutils' recent addition of 'env -S'). Is it worth adding a 'set -' line later in the script to compensate, if you were previously passing the '-' as a way to reset the shell from inheriting environmental differences? -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Eric Blake
2018-Aug-13 21:16 UTC
Re: [Libguestfs] [PATCH nbdkit 10/10] README: Advertise FreeBSD support.
On 08/12/2018 03:51 AM, Richard W.M. Jones wrote:> --- > README | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/README b/README > index e4eda79..eb2e997 100644 > --- a/README > +++ b/README > @@ -37,7 +37,13 @@ Requirements > ------------ > > To build the basic server and some plugins nbdkit needs nothing except > -Linux and reasonably recent gcc or clang. > +Linux or FreeBSD, and: > + > + - gcc or clang > + > + - bash > + > + - GNU makeTheoretically, automake should produce makefiles compatible with BSD make as long as you didn't introduce any GNU make'isms in your Makefile.am files. I don't know if the problem was an actual GNU make'ism, or a bug in BSD make, but I'm also not too worried about this (after all, both libvirt and qemu require GNU make as a conscious choice, so people on BSD systems are already used to using gmake rather than figuring out whether BSD make can do the job). -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Reasonably Related Threads
- [PATCH nbdkit 00/10] FreeBSD support.
- [PATCH nbdkit 2/4] valgrind: Add --show-leak-kinds=all and comprehensive list of suppressions.
- [PATCH nbdkit 3/4] valgrind: Enable valgrinding of Python plugin.
- [PATCH nbdkit] valgrind: Don't call dlclose when running under valgrind.
- [PATCH nbdkit v3 4/4] tests: Valgrind is only enabled when NBDKIT_VALGRIND = 1, not any other values.