Skip to content

Commit 8be05eb

Browse files
committed
Fix freebsd build
This brings freebsd in line with Darwin, ie it builds, but some parts may not yet be fully functional. There is now a WIP `runc` port for FreeBSD at https://github.com/clovertrail/runc/tree/1501-SupportOnFreeBSD so should be able to test further. Signed-off-by: Justin Cormack <justin@specialbusservice.com>
1 parent c7e31f1 commit 8be05eb

File tree

4 files changed

+75
-3
lines changed

4 files changed

+75
-3
lines changed
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// +build !linux,!windows,!darwin
1+
// +build freebsd
22

33
/*
44
Copyright The containerd Authors.
@@ -39,5 +39,8 @@ func setupSignals() (chan os.Signal, error) {
3939
}
4040

4141
func newServer() (*ttrpc.Server, error) {
42-
return ttrpc.NewServer(ttrpc.WithServerHandshaker(ttrpc.UnixSocketRequireSameUser()))
42+
// for freebsd, we omit the socket credentials because these syscalls are
43+
// slightly different. since we don't have freebsd support yet, this can be
44+
// implemented later and the build can continue without issue.
45+
return ttrpc.NewServer()
4346
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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 main
20+
21+
import (
22+
"syscall"
23+
)
24+
25+
func setRlimit() error {
26+
rlimit := int64(100000)
27+
if rlimit > 0 {
28+
var limit syscall.Rlimit
29+
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
30+
return err
31+
}
32+
if limit.Cur < rlimit {
33+
limit.Cur = rlimit
34+
if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
35+
return err
36+
}
37+
}
38+
}
39+
return nil
40+
}

cmd/containerd-stress/rlimit_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// +build !windows
1+
// +build !windows,!freebsd
22

33
/*
44
Copyright The containerd Authors.

runtime/v2/shim/shim_freebsd.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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 shim
20+
21+
import "github.com/containerd/ttrpc"
22+
23+
func newServer() (*ttrpc.Server, error) {
24+
return ttrpc.NewServer()
25+
}
26+
27+
func subreaper() error {
28+
return nil
29+
}

0 commit comments

Comments
 (0)