From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= Date: Tue, 22 Dec 2015 22:15:10 +0100 Message-Id: <1450818910-23355-3-git-send-email-mic@digikod.net> In-Reply-To: <1450818910-23355-1-git-send-email-mic@digikod.net> References: <1450818910-23355-1-git-send-email-mic@digikod.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Sender: linux-kernel-owner@vger.kernel.org Subject: [PATCH v5 2/2] um: Use race-free temporary file creation To: linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Jeff Dike , Richard Weinberger , Tristan Schmelcher , Greg Kroah-Hartman , user-mode-linux-devel@lists.sourceforge.net, user-mode-linux-user@lists.sourceforge.net List-ID: Open the memory mapped file with the O_TMPFILE flag when available. Signed-off-by: Micka=C3=ABl Sala=C3=BCn Cc: Jeff Dike Cc: Richard Weinberger Acked-by: Tristan Schmelcher --- arch/um/os-Linux/mem.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c index 840d573f7e38..8b1767668515 100644 --- 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 *templa= te) } } =20 +#ifdef O_TMPFILE + fd =3D 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 !=3D -1 || (errno !=3D EINVAL && errno !=3D EISDIR && + errno !=3D EOPNOTSUPP)) + return fd; +#endif + tempname =3D malloc(strlen(tempdir) + strlen(template) + 1); if (tempname =3D=3D NULL) return -1; --=20 2.6.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel"= in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/