[Libguestfs] [PATCH nbdkit 11/13] filters, plugins: Port to Windows or disable various filters and plugins.

Richard W.M. Jones rjones at redhat.com
Thu Aug 20 11:37:44 UTC 2020


Miscellaneous ports of filters and plugins to Windows.  Ones which
could not be ported easily are disabled in the Makefile.am with a
comment outlining why.
---
 configure.ac                        |  2 ++
 filters/cache/Makefile.am           |  5 +++++
 filters/cow/Makefile.am             |  2 ++
 filters/ddrescue/Makefile.am        |  2 ++
 filters/extentlist/Makefile.am      |  2 ++
 filters/gzip/Makefile.am            |  2 ++
 filters/log/Makefile.am             |  4 ++++
 filters/pause/Makefile.am           |  4 ++++
 filters/rate/Makefile.am            |  2 ++
 filters/tar/Makefile.am             |  6 ++++++
 plugins/cc/Makefile.am              |  5 +++++
 plugins/cdi/Makefile.am             |  4 ++++
 plugins/eval/Makefile.am            |  4 ++++
 plugins/example2/Makefile.am        |  6 ++++++
 plugins/example3/Makefile.am        |  6 ++++++
 plugins/iso/Makefile.am             |  7 +++++--
 plugins/linuxdisk/Makefile.am       |  5 +++--
 plugins/ocaml/Makefile.am           |  6 ++++--
 plugins/ondemand/Makefile.am        |  5 +++++
 plugins/sh/Makefile.am              |  4 ++++
 plugins/split/Makefile.am           |  2 ++
 plugins/streaming/Makefile.am       |  5 +++++
 plugins/tar/Makefile.am             |  3 +++
 plugins/tmpdisk/Makefile.am         |  4 ++++
 plugins/vddk/Makefile.am            |  3 +++
 plugins/info/info.c                 |  9 +++++++++
 plugins/ondemand/ondemand.c         |  3 +++
 plugins/partitioning/partitioning.c |  2 ++
 plugins/split/split.c               |  3 +++
 filters/cache/blk.c                 |  3 +++
 filters/cache/cache.c               |  5 ++++-
 filters/cow/blk.c                   | 10 ++++++----
 filters/ddrescue/ddrescue.c         |  1 +
 filters/error/error.c               |  1 +
 filters/extentlist/extentlist.c     |  1 +
 filters/gzip/gzip.c                 |  1 +
 filters/ip/ip.c                     |  9 +++++++++
 filters/log/log.c                   |  1 +
 filters/nozero/nozero.c             |  5 +++++
 filters/rate/rate.c                 |  2 ++
 filters/retry/retry.c               |  1 +
 filters/stats/stats.c               |  1 +
 filters/tar/tar.c                   |  2 +-
 43 files changed, 148 insertions(+), 12 deletions(-)

diff --git a/configure.ac b/configure.ac
index 7060f445..0b17ef95 100644
--- a/configure.ac
+++ b/configure.ac
@@ -311,6 +311,7 @@ test (void)
 dnl Check for other headers, all optional.
 AC_CHECK_HEADERS([\
 	alloca.h \
+	arpa/inet.h \
 	byteswap.h \
 	endian.h \
 	grp.h \
@@ -327,6 +328,7 @@ AC_CHECK_HEADERS([\
 	sys/prctl.h \
 	sys/procctl.h \
 	sys/socket.h \
+	sys/statvfs.h \
 	sys/un.h \
 	sys/wait.h])
 
diff --git a/filters/cache/Makefile.am b/filters/cache/Makefile.am
index e8879807..2d4e96f4 100644
--- a/filters/cache/Makefile.am
+++ b/filters/cache/Makefile.am
@@ -33,6 +33,10 @@ include $(top_srcdir)/common-rules.mk
 
 EXTRA_DIST = nbdkit-cache-filter.pod
 
+# Requires hole-punching and other OS specific features which make
+# this an effort to port to Windows.
+if !IS_WINDOWS
+
 filter_LTLIBRARIES = nbdkit-cache-filter.la
 
 nbdkit_cache_filter_la_SOURCES = \
@@ -75,3 +79,4 @@ nbdkit-cache-filter.1: nbdkit-cache-filter.pod
 	    $<
 
 endif HAVE_POD
+endif !IS_WINDOWS
diff --git a/filters/cow/Makefile.am b/filters/cow/Makefile.am
index 93ecf76b..a80ccd8f 100644
--- a/filters/cow/Makefile.am
+++ b/filters/cow/Makefile.am
@@ -46,6 +46,7 @@ nbdkit_cow_filter_la_CPPFLAGS = \
 	-I$(top_srcdir)/include \
 	-I$(top_srcdir)/common/bitmap \
 	-I$(top_srcdir)/common/include \
+	-I$(top_srcdir)/common/replacements \
 	-I$(top_srcdir)/common/utils \
 	$(NULL)
 nbdkit_cow_filter_la_CFLAGS = $(WARNINGS_CFLAGS)
@@ -56,6 +57,7 @@ nbdkit_cow_filter_la_LDFLAGS = \
 nbdkit_cow_filter_la_LIBADD = \
 	$(top_builddir)/common/bitmap/libbitmap.la \
 	$(top_builddir)/common/utils/libutils.la \
+	$(top_builddir)/common/replacements/libcompat.la \
 	$(IMPORT_LIBRARY_ON_WINDOWS) \
 	$(NULL)
 
diff --git a/filters/ddrescue/Makefile.am b/filters/ddrescue/Makefile.am
index e19c022f..68f1937a 100644
--- a/filters/ddrescue/Makefile.am
+++ b/filters/ddrescue/Makefile.am
@@ -45,6 +45,7 @@ nbdkit_ddrescue_filter_la_SOURCES = \
 nbdkit_ddrescue_filter_la_CPPFLAGS = \
 	-I$(top_srcdir)/include \
 	-I$(top_srcdir)/common/include \
+	-I$(top_srcdir)/common/replacements \
 	-I$(top_srcdir)/common/utils \
 	$(NULL)
 nbdkit_ddrescue_filter_la_CFLAGS = \
@@ -57,6 +58,7 @@ nbdkit_ddrescue_filter_la_LDFLAGS = \
 	$(NULL)
 nbdkit_ddrescue_filter_la_LIBADD = \
 	$(top_builddir)/common/utils/libutils.la \
+	$(top_builddir)/common/replacements/libcompat.la \
 	$(IMPORT_LIBRARY_ON_WINDOWS) \
 	$(GNUTLS_LIBS) \
 	$(NULL)
diff --git a/filters/extentlist/Makefile.am b/filters/extentlist/Makefile.am
index 66d3b306..3965aa76 100644
--- a/filters/extentlist/Makefile.am
+++ b/filters/extentlist/Makefile.am
@@ -43,6 +43,7 @@ nbdkit_extentlist_filter_la_SOURCES = \
 nbdkit_extentlist_filter_la_CPPFLAGS = \
 	-I$(top_srcdir)/include \
 	-I$(top_srcdir)/common/include \
+	-I$(top_srcdir)/common/replacements \
 	-I$(top_srcdir)/common/utils \
 	$(NULL)
 nbdkit_extentlist_filter_la_CFLAGS = $(WARNINGS_CFLAGS)
@@ -52,6 +53,7 @@ nbdkit_extentlist_filter_la_LDFLAGS = \
 	$(NULL)
 nbdkit_extentlist_filter_la_LIBADD = \
 	$(top_builddir)/common/utils/libutils.la \
+	$(top_builddir)/common/replacements/libcompat.la \
 	$(IMPORT_LIBRARY_ON_WINDOWS) \
 	$(NULL)
 
diff --git a/filters/gzip/Makefile.am b/filters/gzip/Makefile.am
index d571b820..428bf036 100644
--- a/filters/gzip/Makefile.am
+++ b/filters/gzip/Makefile.am
@@ -45,6 +45,7 @@ nbdkit_gzip_filter_la_SOURCES = \
 nbdkit_gzip_filter_la_CPPFLAGS = \
 	-I$(top_srcdir)/include \
 	-I$(top_srcdir)/common/include \
+	-I$(top_srcdir)/common/replacements \
 	-I$(top_srcdir)/common/utils \
 	$(NULL)
 nbdkit_gzip_filter_la_CFLAGS = \
@@ -53,6 +54,7 @@ nbdkit_gzip_filter_la_CFLAGS = \
 	$(NULL)
 nbdkit_gzip_filter_la_LIBADD = \
 	$(top_builddir)/common/utils/libutils.la \
+	$(top_builddir)/common/replacements/libcompat.la \
 	$(IMPORT_LIBRARY_ON_WINDOWS) \
 	$(ZLIB_LIBS) \
 	$(NULL)
diff --git a/filters/log/Makefile.am b/filters/log/Makefile.am
index a31d2a67..a5552664 100644
--- a/filters/log/Makefile.am
+++ b/filters/log/Makefile.am
@@ -33,6 +33,9 @@ include $(top_srcdir)/common-rules.mk
 
 EXTRA_DIST = nbdkit-log-filter.pod
 
+# Requires open_memstream.
+if !IS_WINDOWS
+
 filter_LTLIBRARIES = nbdkit-log-filter.la
 
 nbdkit_log_filter_la_SOURCES = \
@@ -65,3 +68,4 @@ nbdkit-log-filter.1: nbdkit-log-filter.pod
 	    $<
 
 endif HAVE_POD
+endif !IS_WINDOWS
diff --git a/filters/pause/Makefile.am b/filters/pause/Makefile.am
index 12600033..108de544 100644
--- a/filters/pause/Makefile.am
+++ b/filters/pause/Makefile.am
@@ -33,6 +33,9 @@ include $(top_srcdir)/common-rules.mk
 
 EXTRA_DIST = nbdkit-pause-filter.pod
 
+# Relies on a Unix domain socket.
+if !IS_WINDOWS
+
 filter_LTLIBRARIES = nbdkit-pause-filter.la
 
 nbdkit_pause_filter_la_SOURCES = \
@@ -66,3 +69,4 @@ nbdkit-pause-filter.1: nbdkit-pause-filter.pod
 	    $<
 
 endif HAVE_POD
+endif !IS_WINDOWS
diff --git a/filters/rate/Makefile.am b/filters/rate/Makefile.am
index f4cf414a..ab35dc4a 100644
--- a/filters/rate/Makefile.am
+++ b/filters/rate/Makefile.am
@@ -45,11 +45,13 @@ nbdkit_rate_filter_la_SOURCES = \
 nbdkit_rate_filter_la_CPPFLAGS = \
 	-I$(top_srcdir)/include \
 	-I$(top_srcdir)/common/include \
+	-I$(top_srcdir)/common/replacements \
 	-I$(top_srcdir)/common/utils \
 	$(NULL)
 nbdkit_rate_filter_la_CFLAGS = $(WARNINGS_CFLAGS)
 nbdkit_rate_filter_la_LIBADD = \
 	$(top_builddir)/common/utils/libutils.la \
+	$(top_builddir)/common/replacements/libcompat.la \
 	$(IMPORT_LIBRARY_ON_WINDOWS) \
 	$(NULL)
 nbdkit_rate_filter_la_LDFLAGS = \
diff --git a/filters/tar/Makefile.am b/filters/tar/Makefile.am
index 897a5c3b..c6b1f750 100644
--- a/filters/tar/Makefile.am
+++ b/filters/tar/Makefile.am
@@ -33,6 +33,9 @@ include $(top_srcdir)/common-rules.mk
 
 EXTRA_DIST = nbdkit-tar-filter.pod
 
+# Requires open_memstream.
+if !IS_WINDOWS
+
 filter_LTLIBRARIES = nbdkit-tar-filter.la
 
 nbdkit_tar_filter_la_SOURCES = \
@@ -43,6 +46,7 @@ nbdkit_tar_filter_la_SOURCES = \
 nbdkit_tar_filter_la_CPPFLAGS = \
 	-I$(top_srcdir)/include \
 	-I$(top_srcdir)/common/include \
+	-I$(top_srcdir)/common/replacements \
 	-I$(top_srcdir)/common/utils \
 	$(NULL)
 nbdkit_tar_filter_la_CFLAGS = $(WARNINGS_CFLAGS)
@@ -52,6 +56,7 @@ nbdkit_tar_filter_la_LDFLAGS = \
 	$(NULL)
 nbdkit_tar_filter_la_LIBADD = \
 	$(top_builddir)/common/utils/libutils.la \
+	$(top_builddir)/common/replacements/libcompat.la \
 	$(IMPORT_LIBRARY_ON_WINDOWS) \
 	$(NULL)
 
@@ -66,3 +71,4 @@ nbdkit-tar-filter.1: nbdkit-tar-filter.pod
 	    $<
 
 endif HAVE_POD
+endif !IS_WINDOWS
diff --git a/plugins/cc/Makefile.am b/plugins/cc/Makefile.am
index a624903d..ffee90c5 100644
--- a/plugins/cc/Makefile.am
+++ b/plugins/cc/Makefile.am
@@ -33,6 +33,10 @@ include $(top_srcdir)/common-rules.mk
 
 EXTRA_DIST = nbdkit-cc-plugin.pod
 
+# Disabled on Windows because we lack mkstemps, and possibly cannot
+# run shell commands.
+if !IS_WINDOWS
+
 plugin_LTLIBRARIES = nbdkit-cc-plugin.la
 
 nbdkit_cc_plugin_la_SOURCES = \
@@ -69,3 +73,4 @@ nbdkit-cc-plugin.3: nbdkit-cc-plugin.pod
 	    $<
 
 endif HAVE_POD
+endif !IS_WINDOWS
diff --git a/plugins/cdi/Makefile.am b/plugins/cdi/Makefile.am
index 79c669bb..be042ba1 100644
--- a/plugins/cdi/Makefile.am
+++ b/plugins/cdi/Makefile.am
@@ -33,6 +33,9 @@ include $(top_srcdir)/common-rules.mk
 
 EXTRA_DIST = nbdkit-cdi-plugin.pod
 
+# Disabled on Windows because this needs to run a bash script.
+if !IS_WINDOWS
+
 plugin_LTLIBRARIES = nbdkit-cdi-plugin.la
 
 nbdkit_cdi_plugin_la_SOURCES = \
@@ -70,3 +73,4 @@ nbdkit-cdi-plugin.1: nbdkit-cdi-plugin.pod
 	    $<
 
 endif HAVE_POD
+endif !IS_WINDOWS
diff --git a/plugins/eval/Makefile.am b/plugins/eval/Makefile.am
index 762c0b24..947974e4 100644
--- a/plugins/eval/Makefile.am
+++ b/plugins/eval/Makefile.am
@@ -33,6 +33,9 @@ include $(top_srcdir)/common-rules.mk
 
 EXTRA_DIST = nbdkit-eval-plugin.pod
 
+# Disabled on Windows because no bash scripting.
+if !IS_WINDOWS
+
 plugin_LTLIBRARIES = nbdkit-eval-plugin.la
 
 # This plugin shares most of the same sources as nbdkit-sh-plugin.  In
@@ -83,3 +86,4 @@ nbdkit-eval-plugin.1: nbdkit-eval-plugin.pod
 	    $<
 
 endif HAVE_POD
+endif !IS_WINDOWS
diff --git a/plugins/example2/Makefile.am b/plugins/example2/Makefile.am
index 7a392567..8b0a5412 100644
--- a/plugins/example2/Makefile.am
+++ b/plugins/example2/Makefile.am
@@ -33,6 +33,11 @@ include $(top_srcdir)/common-rules.mk
 
 EXTRA_DIST = nbdkit-example2-plugin.pod
 
+# A Windows port would be quite invasive and detract from the
+# educational value of the example.  It would be better to have a
+# Windows-specific example plugin.
+if !IS_WINDOWS
+
 plugin_LTLIBRARIES = nbdkit-example2-plugin.la
 
 nbdkit_example2_plugin_la_SOURCES = \
@@ -63,3 +68,4 @@ nbdkit-example2-plugin.1: nbdkit-example2-plugin.pod
 	    $<
 
 endif HAVE_POD
+endif !IS_WINDOWS
diff --git a/plugins/example3/Makefile.am b/plugins/example3/Makefile.am
index 092787eb..98b47a27 100644
--- a/plugins/example3/Makefile.am
+++ b/plugins/example3/Makefile.am
@@ -33,6 +33,11 @@ include $(top_srcdir)/common-rules.mk
 
 EXTRA_DIST = nbdkit-example3-plugin.pod
 
+# A Windows port would be quite invasive and detract from the
+# educational value of the example.  It would be better to have a
+# Windows-specific example plugin.
+if !IS_WINDOWS
+
 plugin_LTLIBRARIES = nbdkit-example3-plugin.la
 
 nbdkit_example3_plugin_la_SOURCES = \
@@ -63,3 +68,4 @@ nbdkit-example3-plugin.1: nbdkit-example3-plugin.pod
 	    $<
 
 endif HAVE_POD
+endif !IS_WINDOWS
diff --git a/plugins/iso/Makefile.am b/plugins/iso/Makefile.am
index 7c05548e..f419feb2 100644
--- a/plugins/iso/Makefile.am
+++ b/plugins/iso/Makefile.am
@@ -34,6 +34,9 @@ include $(top_srcdir)/common-rules.mk
 EXTRA_DIST = nbdkit-iso-plugin.pod
 
 if HAVE_ISO
+# Disabled on Windows because it uses open_memstream to construct the
+# command.
+if !IS_WINDOWS
 
 plugin_LTLIBRARIES = nbdkit-iso-plugin.la
 
@@ -68,5 +71,5 @@ nbdkit-iso-plugin.1: nbdkit-iso-plugin.pod
 	    $<
 
 endif HAVE_POD
-
-endif
+endif !IS_WINDOWS
+endif HAVE_ISO
diff --git a/plugins/linuxdisk/Makefile.am b/plugins/linuxdisk/Makefile.am
index 20579bb5..d26ee7e9 100644
--- a/plugins/linuxdisk/Makefile.am
+++ b/plugins/linuxdisk/Makefile.am
@@ -34,6 +34,7 @@ include $(top_srcdir)/common-rules.mk
 EXTRA_DIST = nbdkit-linuxdisk-plugin.pod
 
 if HAVE_MKE2FS_WITH_D
+if !IS_WINDOWS
 
 plugin_LTLIBRARIES = nbdkit-linuxdisk-plugin.la
 
@@ -76,5 +77,5 @@ nbdkit-linuxdisk-plugin.1: nbdkit-linuxdisk-plugin.pod
 	    $<
 
 endif HAVE_POD
-
-endif
+endif !IS_WINDOWS
+endif HAVE_MKE2FS_WITH_D
diff --git a/plugins/ocaml/Makefile.am b/plugins/ocaml/Makefile.am
index b9c70bd9..61551d31 100644
--- a/plugins/ocaml/Makefile.am
+++ b/plugins/ocaml/Makefile.am
@@ -39,6 +39,8 @@ EXTRA_DIST = \
 	$(NULL)
 
 if HAVE_OCAML
+# Requires some work to port to Windows.  Disable it for now.
+if !IS_WINDOWS
 
 ocamllibdir = $(OCAMLLIB)
 ocamllib_DATA = NBDKit.mli NBDKit.cmi NBDKit.cmx NBDKit.o
@@ -92,5 +94,5 @@ nbdkit-ocaml-plugin.3: nbdkit-ocaml-plugin.pod
 	    $<
 
 endif HAVE_POD
-
-endif
+endif !IS_WINDOWS
+endif HAVE_OCAML
diff --git a/plugins/ondemand/Makefile.am b/plugins/ondemand/Makefile.am
index 6312f4b1..7c2f41b9 100644
--- a/plugins/ondemand/Makefile.am
+++ b/plugins/ondemand/Makefile.am
@@ -36,6 +36,10 @@ EXTRA_DIST = \
 	nbdkit-ondemand-plugin.pod \
 	$(NULL)
 
+# Disabled on Windows because it requires open_memstream and other
+# porting work.
+if !IS_WINDOWS
+
 # The default command we use (if we don't use command=) comes from a
 # shell script which is turned into a C source file.
 BUILT_SOURCES = default-command.c
@@ -80,3 +84,4 @@ nbdkit-ondemand-plugin.1: nbdkit-ondemand-plugin.pod
 	    $<
 
 endif HAVE_POD
+endif !IS_WINDOWS
diff --git a/plugins/sh/Makefile.am b/plugins/sh/Makefile.am
index 90cf2617..91bb91cb 100644
--- a/plugins/sh/Makefile.am
+++ b/plugins/sh/Makefile.am
@@ -37,6 +37,9 @@ EXTRA_DIST = \
 	example.sh \
 	$(NULL)
 
+# Disabled on Windows because no bash scripting.
+if !IS_WINDOWS
+
 plugin_LTLIBRARIES = nbdkit-sh-plugin.la
 
 nbdkit_sh_plugin_la_SOURCES = \
@@ -74,3 +77,4 @@ nbdkit-sh-plugin.3: nbdkit-sh-plugin.pod
 	    $<
 
 endif HAVE_POD
+endif !IS_WINDOWS
diff --git a/plugins/split/Makefile.am b/plugins/split/Makefile.am
index 7c09d036..1ac0fefe 100644
--- a/plugins/split/Makefile.am
+++ b/plugins/split/Makefile.am
@@ -42,6 +42,7 @@ nbdkit_split_plugin_la_SOURCES = \
 
 nbdkit_split_plugin_la_CPPFLAGS = \
 	-I$(top_srcdir)/include \
+	-I$(top_srcdir)/common/replacements \
 	-I$(top_srcdir)/common/utils \
 	$(NULL)
 nbdkit_split_plugin_la_CFLAGS = $(WARNINGS_CFLAGS)
@@ -51,6 +52,7 @@ nbdkit_split_plugin_la_LDFLAGS = \
 	$(NULL)
 nbdkit_split_plugin_la_LIBADD = \
 	$(top_builddir)/common/utils/libutils.la \
+	$(top_builddir)/common/replacements/libcompat.la \
 	$(IMPORT_LIBRARY_ON_WINDOWS) \
 	$(NULL)
 
diff --git a/plugins/streaming/Makefile.am b/plugins/streaming/Makefile.am
index d18d77c7..5cd92e8e 100644
--- a/plugins/streaming/Makefile.am
+++ b/plugins/streaming/Makefile.am
@@ -33,6 +33,10 @@ include $(top_srcdir)/common-rules.mk
 
 EXTRA_DIST = nbdkit-streaming-plugin.pod
 
+# This will require a special effort to port to Windows because named
+# pipes work quite differently.
+if !IS_WINDOWS
+
 plugin_LTLIBRARIES = nbdkit-streaming-plugin.la
 
 nbdkit_streaming_plugin_la_SOURCES = \
@@ -63,3 +67,4 @@ nbdkit-streaming-plugin.1: nbdkit-streaming-plugin.pod
 	    $<
 
 endif HAVE_POD
+endif !IS_WINDOWS
diff --git a/plugins/tar/Makefile.am b/plugins/tar/Makefile.am
index 7ca941c9..dbace303 100644
--- a/plugins/tar/Makefile.am
+++ b/plugins/tar/Makefile.am
@@ -33,6 +33,8 @@ include $(top_srcdir)/common-rules.mk
 
 EXTRA_DIST = nbdkit-tar-plugin.pod
 
+if !IS_WINDOWS
+
 plugin_LTLIBRARIES = nbdkit-tar-plugin.la
 
 nbdkit_tar_plugin_la_SOURCES = \
@@ -66,3 +68,4 @@ nbdkit-tar-plugin.1: nbdkit-tar-plugin.pod
 	    $<
 
 endif HAVE_POD
+endif !IS_WINDOWS
diff --git a/plugins/tmpdisk/Makefile.am b/plugins/tmpdisk/Makefile.am
index b1e045b1..ae263e1f 100644
--- a/plugins/tmpdisk/Makefile.am
+++ b/plugins/tmpdisk/Makefile.am
@@ -36,6 +36,9 @@ EXTRA_DIST = \
 	nbdkit-tmpdisk-plugin.pod \
 	$(NULL)
 
+# Requires running a bash script.
+if !IS_WINDOWS
+
 # The default command we use (if we don't use command=) comes from a
 # shell script which is turned into a C source file.
 BUILT_SOURCES = default-command.c
@@ -80,3 +83,4 @@ nbdkit-tmpdisk-plugin.1: nbdkit-tmpdisk-plugin.pod
 	    $<
 
 endif HAVE_POD
+endif !IS_WINDOWS
diff --git a/plugins/vddk/Makefile.am b/plugins/vddk/Makefile.am
index e334d46d..232aaedd 100644
--- a/plugins/vddk/Makefile.am
+++ b/plugins/vddk/Makefile.am
@@ -37,6 +37,8 @@ EXTRA_DIST = \
 	$(NULL)
 
 if HAVE_VDDK
+# Windows VDDK likely works in a completely different way.
+if !IS_WINDOWS
 
 plugin_LTLIBRARIES = nbdkit-vddk-plugin.la
 
@@ -78,4 +80,5 @@ nbdkit-vddk-plugin.1: nbdkit-vddk-plugin.pod
 
 endif HAVE_POD
 
+endif !IS_WINDOWS
 endif HAVE_VDDK
diff --git a/plugins/info/info.c b/plugins/info/info.c
index 33c4facd..0486d60f 100644
--- a/plugins/info/info.c
+++ b/plugins/info/info.c
@@ -36,9 +36,18 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/time.h>
+
+#ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#endif
+
+#ifdef HAVE_NETINET_IN_H
 #include <netinet/in.h>
+#endif
+
+#ifdef HAVE_ARPA_INET_H
 #include <arpa/inet.h>
+#endif
 
 #if defined(HAVE_GNUTLS) && defined(HAVE_GNUTLS_BASE64_DECODE2)
 #include <gnutls/gnutls.h>
diff --git a/plugins/ondemand/ondemand.c b/plugins/ondemand/ondemand.c
index 6bdf5c32..2386e1a6 100644
--- a/plugins/ondemand/ondemand.c
+++ b/plugins/ondemand/ondemand.c
@@ -45,7 +45,10 @@
 #include <assert.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+
+#ifdef HAVE_SYS_WAIT_H
 #include <sys/wait.h>
+#endif
 
 #include <pthread.h>
 
diff --git a/plugins/partitioning/partitioning.c b/plugins/partitioning/partitioning.c
index 79b56dd6..fe34c758 100644
--- a/plugins/partitioning/partitioning.c
+++ b/plugins/partitioning/partitioning.c
@@ -53,6 +53,8 @@
 #include "fdatasync.h"
 #include "isaligned.h"
 #include "iszero.h"
+#include "pread.h"
+#include "pwrite.h"
 #include "rounding.h"
 #include "vector.h"
 
diff --git a/plugins/split/split.c b/plugins/split/split.c
index a12b1037..3380a6e0 100644
--- a/plugins/split/split.c
+++ b/plugins/split/split.c
@@ -47,6 +47,9 @@
 #include <nbdkit-plugin.h>
 
 #include "cleanup.h"
+#include "pread.h"
+#include "pwrite.h"
+#include "windows-compat.h"
 #include "vector.h"
 
 /* The files. */
diff --git a/filters/cache/blk.c b/filters/cache/blk.c
index 60c12caf..dc1bcc57 100644
--- a/filters/cache/blk.c
+++ b/filters/cache/blk.c
@@ -45,7 +45,10 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <errno.h>
+
+#ifdef HAVE_SYS_STATVFS_H
 #include <sys/statvfs.h>
+#endif
 
 #include <nbdkit-filter.h>
 
diff --git a/filters/cache/cache.c b/filters/cache/cache.c
index db32619d..91dcc43d 100644
--- a/filters/cache/cache.c
+++ b/filters/cache/cache.c
@@ -41,9 +41,12 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <errno.h>
+#include <assert.h>
 #include <sys/types.h>
+
+#ifdef HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
-#include <assert.h>
+#endif
 
 #include <pthread.h>
 
diff --git a/filters/cow/blk.c b/filters/cow/blk.c
index 7fd7bc37..10af4a84 100644
--- a/filters/cow/blk.c
+++ b/filters/cow/blk.c
@@ -71,7 +71,10 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <sys/types.h>
+
+#ifdef HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
+#endif
 
 #ifdef HAVE_ALLOCA_H
 #include <alloca.h>
@@ -80,14 +83,13 @@
 #include <nbdkit-filter.h>
 
 #include "bitmap.h"
+#include "fdatasync.h"
+#include "pread.h"
+#include "pwrite.h"
 #include "utils.h"
 
 #include "blk.h"
 
-#ifndef HAVE_FDATASYNC
-#define fdatasync fsync
-#endif
-
 /* The temporary overlay. */
 static int fd = -1;
 
diff --git a/filters/ddrescue/ddrescue.c b/filters/ddrescue/ddrescue.c
index a60f07e6..53a03f8d 100644
--- a/filters/ddrescue/ddrescue.c
+++ b/filters/ddrescue/ddrescue.c
@@ -43,6 +43,7 @@
 #include <nbdkit-filter.h>
 
 #include "cleanup.h"
+#include "getline.h"
 #include "vector.h"
 
 struct range {
diff --git a/filters/error/error.c b/filters/error/error.c
index 45e434d4..a7ed3f3b 100644
--- a/filters/error/error.c
+++ b/filters/error/error.c
@@ -47,6 +47,7 @@
 
 #include "cleanup.h"
 #include "random.h"
+#include "windows-compat.h"
 
 struct error_settings {
   int error;                   /* errno, eg. EIO */
diff --git a/filters/extentlist/extentlist.c b/filters/extentlist/extentlist.c
index dfb5e808..98b65f9e 100644
--- a/filters/extentlist/extentlist.c
+++ b/filters/extentlist/extentlist.c
@@ -43,6 +43,7 @@
 #include <nbdkit-filter.h>
 
 #include "cleanup.h"
+#include "getline.h"
 #include "minmax.h"
 #include "vector.h"
 
diff --git a/filters/gzip/gzip.c b/filters/gzip/gzip.c
index d92e00d9..929260bf 100644
--- a/filters/gzip/gzip.c
+++ b/filters/gzip/gzip.c
@@ -46,6 +46,7 @@
 #include <nbdkit-filter.h>
 
 #include "cleanup.h"
+#include "pread.h"
 #include "minmax.h"
 
 /* The first thread to call gzip_prepare has to uncompress the whole
diff --git a/filters/ip/ip.c b/filters/ip/ip.c
index 26a34d6e..6e64042d 100644
--- a/filters/ip/ip.c
+++ b/filters/ip/ip.c
@@ -39,9 +39,18 @@
 #include <inttypes.h>
 #include <string.h>
 #include <assert.h>
+
+#ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#endif
+
+#ifdef HAVE_ARPA_INET_H
 #include <arpa/inet.h>
+#endif
+
+#ifdef HAVE_NETINET_IN_H
 #include <netinet/in.h>
+#endif
 
 #include <nbdkit-filter.h>
 
diff --git a/filters/log/log.c b/filters/log/log.c
index 71c21211..1ba6486f 100644
--- a/filters/log/log.c
+++ b/filters/log/log.c
@@ -49,6 +49,7 @@
 
 #include "cleanup.h"
 #include "utils.h"
+#include "windows-compat.h"
 
 static uint64_t connections;
 static char *logfilename;
diff --git a/filters/nozero/nozero.c b/filters/nozero/nozero.c
index d14b248c..22d5914c 100644
--- a/filters/nozero/nozero.c
+++ b/filters/nozero/nozero.c
@@ -44,6 +44,11 @@
 
 #include "minmax.h"
 
+/* IGNORE is defined as a macro in Windows headers files ... */
+#ifdef IGNORE
+#undef IGNORE
+#endif
+
 #define MAX_WRITE (64 * 1024 * 1024)
 
 static enum ZeroMode {
diff --git a/filters/rate/rate.c b/filters/rate/rate.c
index 325f5657..103eae0b 100644
--- a/filters/rate/rate.c
+++ b/filters/rate/rate.c
@@ -49,6 +49,8 @@
 #include <nbdkit-filter.h>
 
 #include "cleanup.h"
+#include "getline.h"
+#include "windows-compat.h"
 
 #include "bucket.h"
 
diff --git a/filters/retry/retry.c b/filters/retry/retry.c
index a2e57d77..472cf96b 100644
--- a/filters/retry/retry.c
+++ b/filters/retry/retry.c
@@ -43,6 +43,7 @@
 #include <nbdkit-filter.h>
 
 #include "cleanup.h"
+#include "windows-compat.h"
 
 static unsigned retries = 5;    /* 0 = filter is disabled */
 static unsigned initial_delay = 2;
diff --git a/filters/stats/stats.c b/filters/stats/stats.c
index 687dd05b..639ceacf 100644
--- a/filters/stats/stats.c
+++ b/filters/stats/stats.c
@@ -48,6 +48,7 @@
 
 #include "cleanup.h"
 #include "tvdiff.h"
+#include "windows-compat.h"
 
 static char *filename;
 static bool append;
diff --git a/filters/tar/tar.c b/filters/tar/tar.c
index ab041153..cb42b918 100644
--- a/filters/tar/tar.c
+++ b/filters/tar/tar.c
@@ -39,7 +39,6 @@
 #include <inttypes.h>
 #include <string.h>
 #include <unistd.h>
-#include <poll.h>
 #include <assert.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -49,6 +48,7 @@
 #include <nbdkit-filter.h>
 
 #include "cleanup.h"
+#include "poll.h"
 #include "minmax.h"
 #include "utils.h"
 
-- 
2.27.0




More information about the Libguestfs mailing list