This is an automated email from the ASF dual-hosted git repository. josephwu pushed a commit to branch 1.7.x in repository https://gitbox.apache.org/repos/asf/mesos.git
commit f6ec8e565e8a84cd54cd2bd27a76c493d89420a5 Author: Andrei Budnik <abud...@mesosphere.com> AuthorDate: Fri Feb 22 16:37:38 2019 -0800 Exposed `memfd_create` syscall via `memfd::create` function. This patch exposes a wrapper function for `memfd_create` system call. This function can be used to create an anonymous in-memory files on Linux. Review: https://reviews.apache.org/r/70009/ --- src/linux/memfd.cpp | 12 +++--------- src/linux/memfd.hpp | 12 ++++++++++++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/linux/memfd.cpp b/src/linux/memfd.cpp index 348d0ce..2cd6195 100644 --- a/src/linux/memfd.cpp +++ b/src/linux/memfd.cpp @@ -26,15 +26,9 @@ #include <stout/os/open.hpp> #include <stout/os/stat.hpp> -using std::string; - -#if !defined(MFD_CLOEXEC) -#define MFD_CLOEXEC 0x0001U -#endif +#include "linux/memfd.hpp" -#if !defined(MFD_ALLOW_SEALING) -#define MFD_ALLOW_SEALING 0x0002U -#endif +using std::string; #if !defined(F_ADD_SEALS) #define F_ADD_SEALS 1033 @@ -64,7 +58,7 @@ namespace mesos { namespace internal { namespace memfd { -static Try<int_fd> create(const string& name, unsigned int flags) +Try<int_fd> create(const string& name, unsigned int flags) { #ifdef __NR_memfd_create int_fd fd = ::syscall(__NR_memfd_create, name.c_str(), flags); diff --git a/src/linux/memfd.hpp b/src/linux/memfd.hpp index 4cf9906..b2630d2 100644 --- a/src/linux/memfd.hpp +++ b/src/linux/memfd.hpp @@ -23,10 +23,22 @@ #include <stout/os/int_fd.hpp> +#if !defined(MFD_CLOEXEC) +#define MFD_CLOEXEC 0x0001U +#endif + +#if !defined(MFD_ALLOW_SEALING) +#define MFD_ALLOW_SEALING 0x0002U +#endif + namespace mesos { namespace internal { namespace memfd { +// Creates an anonymous in-memory file via `memfd_create`. +Try<int_fd> create(const std::string& name, unsigned int flags); + + // Clone a file into a sealed private copy such that any attempt to // modify it will not modify the original binary. Returns the memfd of // the sealed copy.