Add sandbox-dev-shm-size option

Fixes #1069.
This commit is contained in:
Eelco Dolstra 2016-09-21 16:53:41 +02:00
parent 4546be1b3e
commit 818ab58cc6
2 changed files with 15 additions and 1 deletions

View file

@ -602,6 +602,19 @@ flag, e.g. <literal>--option gc-keep-outputs false</literal>.</para>
</varlistentry>
<varlistentry xml:id="conf-sandbox-dev-shm-size"><term><literal>sandbox-dev-shm-size</literal></term>
<listitem><para>This option determines the maximum size of the
<literal>tmpfs</literal> filesystem mounted on
<filename>/dev/shm</filename> in Linux sandboxes. For the format,
see the description of the <option>size</option> option of
<literal>tmpfs</literal> in
<citerefentry><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry>. The
default is <literal>50%</literal>.</para></listitem>
</varlistentry>
</variablelist>
</para>

View file

@ -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