From 1b5e234135b063cc583eab2cef47f13075c6381f Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Sun, 7 Jun 2020 23:13:58 -0500 Subject: [PATCH] uwac: don't try to use O_TMPFILE on FreeBSD Currently, this sets an invalid open flag and attempts to open(), which will fail. Instead of doing that, don't try to define O_TMPFILE where such a definition can't exist and force the fallback rather than making an always-fail open() call. --- uwac/libuwac/uwac-os.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/uwac/libuwac/uwac-os.c b/uwac/libuwac/uwac-os.c index 4f8c8f5161ef..7e36721104ee 100644 --- a/uwac/libuwac/uwac-os.c +++ b/uwac/libuwac/uwac-os.c @@ -34,7 +34,7 @@ #endif /* uClibc and uClibc-ng don't provide O_TMPFILE */ -#ifndef O_TMPFILE +#if !defined(O_TMPFILE) && !defined(__FreeBSD__) #define O_TMPFILE (020000000 | O_DIRECTORY) #endif @@ -230,7 +230,16 @@ int uwac_create_anonymous_file(off_t size) return -1; } +#ifdef O_TMPFILE fd = open(path, O_TMPFILE | O_RDWR | O_EXCL, 0600); +#else + /* + * Some platforms (e.g. FreeBSD) won't support O_TMPFILE and can't + * reasonably emulate it at first blush. Opt to make them rely on + * the create_tmpfile_cloexec() path instead. + */ + fd = -1; +#endif if (fd < 0) {