projects
/
openwrt
/
staging
/
blogic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
571d2f0
)
um: Use race-free temporary file creation
author
Mickaël Salaün
<
[email protected]
>
Tue, 22 Dec 2015 21:15:10 +0000
(22:15 +0100)
committer
Richard Weinberger
<
[email protected]
>
Sun, 10 Jan 2016 20:49:50 +0000
(21:49 +0100)
Open the memory mapped file with the O_TMPFILE flag when available.
Signed-off-by: Mickaël Salaün <
[email protected]
>
Cc: Jeff Dike <
[email protected]
>
Cc: Richard Weinberger <
[email protected]
>
Acked-by: Tristan Schmelcher <
[email protected]
>
Signed-off-by: Richard Weinberger <
[email protected]
>
arch/um/os-Linux/mem.c
patch
|
blob
|
history
diff --git
a/arch/um/os-Linux/mem.c
b/arch/um/os-Linux/mem.c
index 840d573f7e388036d3aae20d8e5bed886b6201b6..8b1767668515f642f3f18ee0fd780d4dbbc4812b 100644
(file)
--- a/
arch/um/os-Linux/mem.c
+++ b/
arch/um/os-Linux/mem.c
@@
-106,6
+106,17
@@
static int __init make_tempfile(const char *template)
}
}
+#ifdef O_TMPFILE
+ fd = open(tempdir, O_CLOEXEC | O_RDWR | O_EXCL | O_TMPFILE, 0700);
+ /*
+ * If the running system does not support O_TMPFILE flag then retry
+ * without it.
+ */
+ if (fd != -1 || (errno != EINVAL && errno != EISDIR &&
+ errno != EOPNOTSUPP))
+ return fd;
+#endif
+
tempname = malloc(strlen(tempdir) + strlen(template) + 1);
if (tempname == NULL)
return -1;