From 818ab58cc67a2b80f47d2cfcc1de2d07fe83a11f Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 21 Sep 2016 16:53:41 +0200 Subject: [PATCH] Add sandbox-dev-shm-size option Fixes #1069. --- doc/manual/command-ref/conf-file.xml | 13 +++++++++++++ src/libstore/build.cc | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/doc/manual/command-ref/conf-file.xml b/doc/manual/command-ref/conf-file.xml index 8b7640e58..69295fafc 100644 --- a/doc/manual/command-ref/conf-file.xml +++ b/doc/manual/command-ref/conf-file.xml @@ -602,6 +602,19 @@ flag, e.g. --option gc-keep-outputs false. + sandbox-dev-shm-size + + This option determines the maximum size of the + tmpfs filesystem mounted on + /dev/shm in Linux sandboxes. For the format, + see the description of the option of + tmpfs in + mount8. The + default is 50%. + + + + diff --git a/src/libstore/build.cc b/src/libstore/build.cc index 476453412..e7054a05a 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -2346,7 +2346,8 @@ void DerivationGoal::runChild() /* Mount a new tmpfs on /dev/shm to ensure that whatever the builder puts in /dev/shm is cleaned up automatically. */ - if (pathExists("/dev/shm") && mount("none", (chrootRootDir + "/dev/shm").c_str(), "tmpfs", 0, 0) == -1) + if (pathExists("/dev/shm") && mount("none", (chrootRootDir + "/dev/shm").c_str(), "tmpfs", 0, + fmt("size=%s", settings.get("sandbox-dev-shm-size", std::string("50%"))).c_str()) == -1) throw SysError("mounting /dev/shm"); /* Mount a new devpts on /dev/pts. Note that this