diff options
author | Xin Gao <xingao@google.com> | 2016-12-20 12:20:36 +0000 |
---|---|---|
committer | Klaus Aehlig <aehlig@google.com> | 2016-12-20 13:35:16 +0000 |
commit | 18e6b410a7f4e24b67740978d101cd665edea6cc (patch) | |
tree | 2d59b53517cfb9946bffb48172982fa252b4a6e9 /src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxRunner.java | |
parent | 4fb378c0fa08131394dc5e815f6fe5597d007a66 (diff) |
Add customized path mounting in Bazel sandbox.
RELNOTES: New flag --sandbox_add_mount_pair to specify customized source:target path pairs to bind mount inside the sandbox.
--
Change-Id: Ifbacfc0e16bbaedcf5b6d3937799710f2cfa3d58
Reviewed-on: https://cr.bazel.build/7150
PiperOrigin-RevId: 142542381
MOS_MIGRATED_REVID=142542381
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxRunner.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxRunner.java | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxRunner.java b/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxRunner.java index da50cda15a..97151e24ce 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxRunner.java +++ b/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxRunner.java @@ -45,7 +45,8 @@ final class LinuxSandboxRunner extends SandboxRunner { private final Set<Path> writableDirs; private final Set<Path> inaccessiblePaths; private final Set<Path> tmpfsPaths; - private final Set<Path> bindMounts; + // a <target, source> mapping of paths to bind mount + private final Map<Path, Path> bindMounts; private final boolean sandboxDebug; LinuxSandboxRunner( @@ -56,7 +57,7 @@ final class LinuxSandboxRunner extends SandboxRunner { Set<Path> writableDirs, Set<Path> inaccessiblePaths, Set<Path> tmpfsPaths, - Set<Path> bindMounts, + Map<Path, Path> bindMounts, boolean verboseFailures, boolean sandboxDebug) { super(sandboxExecRoot, verboseFailures); @@ -155,9 +156,15 @@ final class LinuxSandboxRunner extends SandboxRunner { fileArgs.add(tmpfsPath.getPathString()); } - for (Path bindMount : bindMounts) { - fileArgs.add("-b"); - fileArgs.add(bindMount.getPathString()); + for (ImmutableMap.Entry<Path, Path> bindMount : bindMounts.entrySet()) { + fileArgs.add("-M"); + fileArgs.add(bindMount.getValue().getPathString()); + + // The file is mounted in a custom location inside the sandbox. + if (!bindMount.getKey().equals(bindMount.getValue())) { + fileArgs.add("-m"); + fileArgs.add(bindMount.getKey().getPathString()); + } } if (!allowNetwork) { |