Merge pull request #15316 from dfr/freebsd-build

Add non-linux build stubs for pkg/domain and pkg/specgen
This commit is contained in:
OpenShift Merge Robot
2022-08-15 14:15:17 +00:00
committed by GitHub
5 changed files with 80 additions and 14 deletions

View File

@ -0,0 +1,25 @@
//go:build !linux
// +build !linux
package terminal
import (
"context"
"errors"
"os"
"github.com/containers/podman/v4/libpod"
"github.com/containers/podman/v4/libpod/define"
)
// ExecAttachCtr execs and attaches to a container
func ExecAttachCtr(ctx context.Context, ctr *libpod.Container, execConfig *libpod.ExecConfig, streams *define.AttachStreams) (int, error) {
return -1, errors.New("not implemented ExecAttachCtr")
}
// StartAttachCtr starts and (if required) attaches to a container
// if you change the signature of this function from os.File to io.Writer, it will trigger a downstream
// error. we may need to just lint disable this one.
func StartAttachCtr(ctx context.Context, ctr *libpod.Container, stdout, stderr, stdin *os.File, detachKeys string, sigProxy bool, startContainer bool) error { //nolint: interfacer
return errors.New("not implemented StartAttachCtr")
}

View File

@ -0,0 +1,29 @@
//go:build !linux
// +build !linux
package generate
import (
"errors"
"github.com/containers/common/libimage"
"github.com/containers/podman/v4/pkg/specgen"
spec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-tools/generate"
)
// DevicesFromPath computes a list of devices
func DevicesFromPath(g *generate.Generator, devicePath string) error {
return errors.New("unsupported DevicesFromPath")
}
func BlockAccessToKernelFilesystems(privileged, pidModeIsHost bool, mask, unmask []string, g *generate.Generator) {
}
func supportAmbientCapabilities() bool {
return false
}
func getSeccompConfig(s *specgen.SpecGenerator, configSpec *spec.Spec, img *libimage.Image) (*spec.LinuxSeccomp, error) {
return nil, errors.New("not implemented getSeccompConfig")
}

View File

@ -58,38 +58,38 @@ func addRlimits(s *specgen.SpecGenerator, g *generate.Generator) {
// files and number of processes to the maximum they can be set to
// (without overriding a sysctl)
if !nofileSet {
max := define.RLimitDefaultValue
current := define.RLimitDefaultValue
max := rlimT(define.RLimitDefaultValue)
current := rlimT(define.RLimitDefaultValue)
if isRootless {
var rlimit unix.Rlimit
if err := unix.Getrlimit(unix.RLIMIT_NOFILE, &rlimit); err != nil {
logrus.Warnf("Failed to return RLIMIT_NOFILE ulimit %q", err)
}
if rlimit.Cur < current {
current = rlimit.Cur
if rlimT(rlimit.Cur) < current {
current = rlimT(rlimit.Cur)
}
if rlimit.Max < max {
max = rlimit.Max
if rlimT(rlimit.Max) < max {
max = rlimT(rlimit.Max)
}
}
g.AddProcessRlimits("RLIMIT_NOFILE", max, current)
g.AddProcessRlimits("RLIMIT_NOFILE", uint64(max), uint64(current))
}
if !nprocSet {
max := define.RLimitDefaultValue
current := define.RLimitDefaultValue
max := rlimT(define.RLimitDefaultValue)
current := rlimT(define.RLimitDefaultValue)
if isRootless {
var rlimit unix.Rlimit
if err := unix.Getrlimit(unix.RLIMIT_NPROC, &rlimit); err != nil {
logrus.Warnf("Failed to return RLIMIT_NPROC ulimit %q", err)
}
if rlimit.Cur < current {
current = rlimit.Cur
if rlimT(rlimit.Cur) < current {
current = rlimT(rlimit.Cur)
}
if rlimit.Max < max {
max = rlimit.Max
if rlimT(rlimit.Max) < max {
max = rlimT(rlimit.Max)
}
}
g.AddProcessRlimits("RLIMIT_NPROC", max, current)
g.AddProcessRlimits("RLIMIT_NPROC", uint64(max), uint64(current))
}
}

View File

@ -0,0 +1,6 @@
//go:build freebsd
// +build freebsd
package generate
type rlimT int64

View File

@ -0,0 +1,6 @@
//go:build linux || darwin
// +build linux darwin
package generate
type rlimT uint64