Skip to content

Commit ba4fa32

Browse files
authored
Merge pull request #5472 from gizahNL/freebsd_mounts
Fix mounts for FreeBSD
2 parents 0a92694 + a4f97d4 commit ba4fa32

3 files changed

Lines changed: 109 additions & 44 deletions

File tree

oci/mounts.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// +build !freebsd
2+
3+
/*
4+
Copyright The containerd Authors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package oci
20+
21+
import (
22+
specs "github.com/opencontainers/runtime-spec/specs-go"
23+
)
24+
25+
func defaultMounts() []specs.Mount {
26+
return []specs.Mount{
27+
{
28+
Destination: "/proc",
29+
Type: "proc",
30+
Source: "proc",
31+
Options: []string{"nosuid", "noexec", "nodev"},
32+
},
33+
{
34+
Destination: "/dev",
35+
Type: "tmpfs",
36+
Source: "tmpfs",
37+
Options: []string{"nosuid", "strictatime", "mode=755", "size=65536k"},
38+
},
39+
{
40+
Destination: "/dev/pts",
41+
Type: "devpts",
42+
Source: "devpts",
43+
Options: []string{"nosuid", "noexec", "newinstance", "ptmxmode=0666", "mode=0620", "gid=5"},
44+
},
45+
{
46+
Destination: "/dev/shm",
47+
Type: "tmpfs",
48+
Source: "shm",
49+
Options: []string{"nosuid", "noexec", "nodev", "mode=1777", "size=65536k"},
50+
},
51+
{
52+
Destination: "/dev/mqueue",
53+
Type: "mqueue",
54+
Source: "mqueue",
55+
Options: []string{"nosuid", "noexec", "nodev"},
56+
},
57+
{
58+
Destination: "/sys",
59+
Type: "sysfs",
60+
Source: "sysfs",
61+
Options: []string{"nosuid", "noexec", "nodev", "ro"},
62+
},
63+
{
64+
Destination: "/run",
65+
Type: "tmpfs",
66+
Source: "tmpfs",
67+
Options: []string{"nosuid", "strictatime", "mode=755", "size=65536k"},
68+
},
69+
}
70+
}

oci/mounts_freebsd.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
Copyright The containerd Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package oci
18+
19+
import (
20+
specs "github.com/opencontainers/runtime-spec/specs-go"
21+
)
22+
23+
func defaultMounts() []specs.Mount {
24+
return []specs.Mount{
25+
{
26+
Destination: "/dev",
27+
Type: "devfs",
28+
Source: "devfs",
29+
Options: []string{"ruleset=4"},
30+
},
31+
{
32+
Destination: "/dev/fd",
33+
Type: "fdescfs",
34+
Source: "fdescfs",
35+
Options: []string{},
36+
},
37+
}
38+
}

oci/spec.go

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -161,50 +161,6 @@ func populateDefaultUnixSpec(ctx context.Context, s *Spec, id string) error {
161161
},
162162
},
163163
},
164-
Mounts: []specs.Mount{
165-
{
166-
Destination: "/proc",
167-
Type: "proc",
168-
Source: "proc",
169-
Options: []string{"nosuid", "noexec", "nodev"},
170-
},
171-
{
172-
Destination: "/dev",
173-
Type: "tmpfs",
174-
Source: "tmpfs",
175-
Options: []string{"nosuid", "strictatime", "mode=755", "size=65536k"},
176-
},
177-
{
178-
Destination: "/dev/pts",
179-
Type: "devpts",
180-
Source: "devpts",
181-
Options: []string{"nosuid", "noexec", "newinstance", "ptmxmode=0666", "mode=0620", "gid=5"},
182-
},
183-
{
184-
Destination: "/dev/shm",
185-
Type: "tmpfs",
186-
Source: "shm",
187-
Options: []string{"nosuid", "noexec", "nodev", "mode=1777", "size=65536k"},
188-
},
189-
{
190-
Destination: "/dev/mqueue",
191-
Type: "mqueue",
192-
Source: "mqueue",
193-
Options: []string{"nosuid", "noexec", "nodev"},
194-
},
195-
{
196-
Destination: "/sys",
197-
Type: "sysfs",
198-
Source: "sysfs",
199-
Options: []string{"nosuid", "noexec", "nodev", "ro"},
200-
},
201-
{
202-
Destination: "/run",
203-
Type: "tmpfs",
204-
Source: "tmpfs",
205-
Options: []string{"nosuid", "strictatime", "mode=755", "size=65536k"},
206-
},
207-
},
208164
Linux: &specs.Linux{
209165
MaskedPaths: []string{
210166
"/proc/acpi",
@@ -237,6 +193,7 @@ func populateDefaultUnixSpec(ctx context.Context, s *Spec, id string) error {
237193
Namespaces: defaultUnixNamespaces(),
238194
},
239195
}
196+
s.Mounts = defaultMounts()
240197
return nil
241198
}
242199

0 commit comments

Comments
 (0)