Skip to content

Commit 2dfbdb8

Browse files
committed
Mount special filesystems in chroot runners
This can be used to mount special filesystems like '/proc' and '/sys' in the input root of actions if 'chroot' is enabled. The filesystems are required for many tools to work. Solves: #115
1 parent 89ca85f commit 2dfbdb8

File tree

6 files changed

+381
-29
lines changed

6 files changed

+381
-29
lines changed

cmd/bb_runner/main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ func main() {
7575
buildDirectoryPath,
7676
commandCreator,
7777
configuration.SetTmpdirEnvironmentVariable)
78+
for _, mountinfo := range configuration.InputRootMounts {
79+
r = runner.NewMountingRunner(
80+
r,
81+
buildDirectory,
82+
mountinfo,
83+
)
84+
}
7885

7986
// Let bb_runner replace temporary directories with symbolic
8087
// links pointing to the temporary directory set up by

pkg/proto/configuration/bb_runner/bb_runner.pb.go

Lines changed: 128 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/proto/configuration/bb_runner/bb_runner.proto

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,37 @@ message ApplicationConfiguration {
131131
// https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/exec/local/XcodeLocalEnvProvider.java
132132
// https://www.smileykeith.com/2021/03/08/locking-xcode-in-bazel/
133133
map<string, string> apple_xcode_developer_directories = 14;
134+
135+
// Mount special filesystems in the input root. This is useful when
136+
// running with `chroot_into_input_root`. Some tools require access to
137+
// special filesystems that are created when the operating system
138+
// boots. An input root with a full userland implementation may need
139+
// these.
140+
//
141+
// The mount point directories must exist in the input root.
142+
//
143+
// Typical choices are:
144+
//
145+
// inputRootMounts: [
146+
// {
147+
// mountpoint: 'proc',
148+
// source: '/proc',
149+
// filesystemType: 'proc',
150+
// },
151+
// {
152+
// mountpoint: 'sys',
153+
// source: '/sys',
154+
// filesystemType: 'sysfs',
155+
// },
156+
// ],
157+
repeated InputMountOptions input_root_mounts = 15;
158+
}
159+
160+
message InputMountOptions {
161+
// Mount a filesystem in the input root, a relative path.
162+
string mountpoint = 1;
163+
// Source filesystem from the runner's operating system.
164+
string source = 2;
165+
// Type of filesystem, see the mount(8) man page.
166+
string filesystem_type = 3;
134167
}

pkg/runner/BUILD.bazel

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ go_library(
1111
"local_runner_rss_kibibytes.go",
1212
"local_runner_unix.go",
1313
"local_runner_windows.go",
14+
"mounting_runner.go",
1415
"path_existence_checking_runner.go",
1516
"temporary_directory_installing_runner.go",
1617
"temporary_directory_symlinking_runner.go",
@@ -19,6 +20,7 @@ go_library(
1920
visibility = ["//visibility:public"],
2021
deps = [
2122
"//pkg/cleaner",
23+
"//pkg/proto/configuration/bb_runner",
2224
"//pkg/proto/runner",
2325
"//pkg/proto/tmp_installer",
2426
"@com_github_buildbarn_bb_storage//pkg/filesystem",
@@ -70,13 +72,15 @@ go_test(
7072
"apple_xcode_resolving_runner_test.go",
7173
"clean_runner_test.go",
7274
"local_runner_test.go",
75+
"mounting_runner_test.go",
7376
"path_existence_checking_runner_test.go",
7477
"temporary_directory_symlinking_runner_test.go",
7578
],
7679
deps = [
7780
":runner",
7881
"//internal/mock",
7982
"//pkg/cleaner",
83+
"//pkg/proto/configuration/bb_runner",
8084
"//pkg/proto/resourceusage",
8185
"//pkg/proto/runner",
8286
"@com_github_buildbarn_bb_storage//pkg/filesystem",

0 commit comments

Comments
 (0)