[PATCH] shell: Add support for disabling memfd_create(3)
Herbert Xu <[email protected]> Tue, 3 Feb 2026 13:04:21 +0800
| Newsgroups | org.kernel.vger.dash |
|---|---|
| Message-ID | <[email protected]> |
In order to test the fallback path for systems without memfd_create(3), add a --disable-memfd-create argument to the configure script. Signed-off-by: Herbert Xu <[email protected]> diff --git a/configure.ac b/configure.ac index 5efd9e2..bdcb339 100644 --- a/configure.ac +++ b/configure.ac @@ -40,6 +40,8 @@ fi AC_ARG_ENABLE(fnmatch, AS_HELP_STRING(--enable-fnmatch, \ [Use fnmatch(3) from libc])) AC_ARG_ENABLE(glob, AS_HELP_STRING(--enable-glob, [Use glob(3) from libc])) +AC_ARG_ENABLE(memfd_create, AS_HELP_STRING(--disable-memfd-create, + [Do not use memfd_create(3)])) dnl Checks for libraries. @@ -131,6 +133,14 @@ if test "$use_fnmatch" = yes && test "$enable_glob" = yes; then AC_CHECK_FUNCS(glob) fi +if test "$enable_memfd_create" != no; then + AC_DEFINE([USE_MEMFD_CREATE], [1], + [Non-zero if memfd_create(3) should be used]) +else + AC_DEFINE([USE_MEMFD_CREATE], [0], + [Non-zero if memfd_create(3) should be used]) +fi + dnl Check for klibc signal. AC_CHECK_FUNC(signal) if test "$ac_cv_func_signal" != yes; then diff --git a/src/redir.c b/src/redir.c index 8d1c8f6..e61d3da 100644 --- a/src/redir.c +++ b/src/redir.c @@ -331,7 +331,7 @@ static void dupredirect(union node *redir, int f) int sh_pipe(int pip[2], int memfd) { if (memfd) { - pip[0] = memfd_create("dash", 0); + pip[0] = USE_MEMFD_CREATE ? memfd_create("dash", 0) : -1; if (pip[0] >= 0) { pip[1] = sh_dup2(pip[0], -1, pip[0]); return 1; -- Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt