01e807f0d8
Toolchains using glibc-2.18 or older do not define O_TMPFILE, which
causes build failures on some archs.
systemd has a definition for O_TMPFILE if it is missing, but only
defines it for i386 or x86_64. Furthermore, the header defining it is
not included everywhere O_TMPFILE is used.
Fix that with three patches backported from upstream:
- include the needed header where it is needed (he!),
- define O_TMPFILE for all archs, according to linux-4.8rc3,
- no longer guard against undefined O_TMPFILE in fileio.
Upstream merge commit:
4a13100c6a
Fixes:
http://autobuild.buildroot.net/results/b0067e72ffcbbe1db9ef49ab297cece951345aeb/
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
66 lines
2.2 KiB
Diff
66 lines
2.2 KiB
Diff
From 1d9ed171788821c21ca900a921833a8e41bf22f3 Mon Sep 17 00:00:00 2001
|
|
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
|
|
Date: Mon, 29 Aug 2016 12:34:50 +0200
|
|
Subject: [PATCH] basic/fileio: we always have O_TMPFILE now
|
|
|
|
fileio makes use of O_TMPFILE when it is available.
|
|
|
|
We now always have O_TMPFILE, defined in missing.h if missing
|
|
from the toolchain headers.
|
|
|
|
Have fileio include missing.h and drop the guards around the
|
|
use of O_TMPFILE.
|
|
|
|
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
|
|
---
|
|
Backported from upstream:
|
|
https://github.com/systemd/systemd/commit/1d9ed171788821c21ca900a921833a8e41bf22f3
|
|
---
|
|
src/basic/fileio.c | 5 +----
|
|
1 file changed, 1 insertion(+), 4 deletions(-)
|
|
|
|
diff --git a/src/basic/fileio.c b/src/basic/fileio.c
|
|
index d642f3d..a5920e7 100644
|
|
--- a/src/basic/fileio.c
|
|
+++ b/src/basic/fileio.c
|
|
@@ -37,6 +37,7 @@
|
|
#include "hexdecoct.h"
|
|
#include "log.h"
|
|
#include "macro.h"
|
|
+#include "missing.h"
|
|
#include "parse-util.h"
|
|
#include "path-util.h"
|
|
#include "random-util.h"
|
|
@@ -1280,12 +1281,10 @@ int open_tmpfile_unlinkable(const char *directory, int flags) {
|
|
|
|
/* Returns an unlinked temporary file that cannot be linked into the file system anymore */
|
|
|
|
-#ifdef O_TMPFILE
|
|
/* Try O_TMPFILE first, if it is supported */
|
|
fd = open(directory, flags|O_TMPFILE|O_EXCL, S_IRUSR|S_IWUSR);
|
|
if (fd >= 0)
|
|
return fd;
|
|
-#endif
|
|
|
|
/* Fall back to unguessable name + unlinking */
|
|
p = strjoina(directory, "/systemd-tmp-XXXXXX");
|
|
@@ -1313,7 +1312,6 @@ int open_tmpfile_linkable(const char *target, int flags, char **ret_path) {
|
|
* which case "ret_path" will be returned as NULL. If not possible a the 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
|
|
{
|
|
_cleanup_free_ char *dn = NULL;
|
|
|
|
@@ -1329,7 +1327,6 @@ int open_tmpfile_linkable(const char *target, int flags, char **ret_path) {
|
|
|
|
log_debug_errno(errno, "Failed to use O_TMPFILE on %s: %m", dn);
|
|
}
|
|
-#endif
|
|
|
|
r = tempfn_random(target, NULL, &tmp);
|
|
if (r < 0)
|
|
--
|
|
2.7.4
|
|
|