[libvirt PATCH v2 26/56] src: conditionalize use of O_DIRECT

Daniel P. Berrangé berrange at redhat.com
Tue Jan 28 13:11:07 UTC 2020


The O_DIRECT flag is not available on all platforms, so we
must introduce a compat define the same way gnulib does.

Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
---
 src/util/iohelper.c | 4 ++++
 src/util/virfile.c  | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/src/util/iohelper.c b/src/util/iohelper.c
index d864bbeaed..618bfb1d3d 100644
--- a/src/util/iohelper.c
+++ b/src/util/iohelper.c
@@ -39,6 +39,10 @@
 
 #define VIR_FROM_THIS VIR_FROM_STORAGE
 
+#ifndef O_DIRECT
+# define O_DIRECT 0
+#endif
+
 static int
 runIO(const char *path, int fd, int oflags)
 {
diff --git a/src/util/virfile.c b/src/util/virfile.c
index d0e0062aa7..efa59f2b13 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -95,6 +95,10 @@
 
 VIR_LOG_INIT("util.file");
 
+#ifndef O_DIRECT
+# define O_DIRECT 0
+#endif
+
 int virFileClose(int *fdptr, virFileCloseFlags flags)
 {
     int saved_errno = 0;
-- 
2.24.1




More information about the libvir-list mailing list