From c2ba4d879956436c1349acb0aeafd6f885276c67 Mon Sep 17 00:00:00 2001
From: Colin Walters <walters@verbum.org>
Date: Wed, 3 Aug 2016 11:07:59 -0400
Subject: [PATCH] Add --disable-otmpfile

Some systems have bugs with it, so let's allow downstreams to easily
disable it.

https://bugzilla.gnome.org/show_bug.cgi?id=769453
https://github.com/ostreedev/ostree/issues/421
---
 glnx-fdio.c | 2 +-
 libglnx.m4  | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/glnx-fdio.c b/glnx-fdio.c
index f4648ed8d..82006604e 100644
--- a/glnx-fdio.c
+++ b/glnx-fdio.c
@@ -122,7 +122,7 @@ glnx_open_tmpfile_linkable_at (int dfd,
    * tempoary path name used is returned in "ret_path". Use
    * link_tmpfile() below to rename the result after writing the file
    * in full. */
-#ifdef O_TMPFILE
+#if defined(O_TMPFILE) && !defined(DISABLE_OTMPFILE)
   fd = openat (dfd, subpath, O_TMPFILE|flags, 0600);
   if (fd == -1 && !(errno == ENOSYS || errno == EISDIR || errno == EOPNOTSUPP))
     {
diff --git a/libglnx.m4 b/libglnx.m4
index 6603c0922..43dff9755 100644
--- a/libglnx.m4
+++ b/libglnx.m4
@@ -12,4 +12,13 @@ AC_CHECK_DECLS([
 #include <linux/loop.h>
 #include <linux/random.h>
 ]])
+
+AC_ARG_ENABLE(otmpfile,
+              [AS_HELP_STRING([--disable-otmpfile],
+                              [Disable use of O_TMPFILE [default=no]])],,
+              [enable_otmpfile=yes])
+AS_IF([test $enable_otmpfile = yes], [], [
+  AC_DEFINE([DISABLE_OTMPFILE], 1, [Define if we should avoid using O_TMPFILE])])
+
 ])
+
-- 
GitLab