integration-cli/requirements_unix_test.go
930a9869
 // +build !windows
 
 package main
 
 import (
 	"bytes"
 	"io/ioutil"
 	"os/exec"
 	"strings"
 
 	"github.com/docker/docker/pkg/parsers/kernel"
 	"github.com/docker/docker/pkg/sysinfo"
 )
 
 var (
 	// SysInfo stores information about which features a kernel supports.
 	SysInfo *sysinfo.SysInfo
 )
 
 func cpuCfsPeriod() bool {
b1fb4198
 	return testEnv.DaemonInfo.CPUCfsPeriod
930a9869
 }
 
 func cpuCfsQuota() bool {
b1fb4198
 	return testEnv.DaemonInfo.CPUCfsQuota
930a9869
 }
 
 func cpuShare() bool {
b1fb4198
 	return testEnv.DaemonInfo.CPUShares
930a9869
 }
 
 func oomControl() bool {
b1fb4198
 	return testEnv.DaemonInfo.OomKillDisable
930a9869
 }
 
 func pidsLimit() bool {
 	return SysInfo.PidsLimit
 }
 
 func kernelMemorySupport() bool {
b1fb4198
 	return testEnv.DaemonInfo.KernelMemory
930a9869
 }
 
 func memoryLimitSupport() bool {
b1fb4198
 	return testEnv.DaemonInfo.MemoryLimit
930a9869
 }
 
 func memoryReservationSupport() bool {
 	return SysInfo.MemoryReservation
 }
 
 func swapMemorySupport() bool {
b1fb4198
 	return testEnv.DaemonInfo.SwapLimit
930a9869
 }
 
 func memorySwappinessSupport() bool {
b1fb4198
 	return SameHostDaemon() && SysInfo.MemorySwappiness
930a9869
 }
 
 func blkioWeight() bool {
b1fb4198
 	return SameHostDaemon() && SysInfo.BlkioWeight
930a9869
 }
 
 func cgroupCpuset() bool {
b1fb4198
 	return testEnv.DaemonInfo.CPUSet
930a9869
 }
 
 func seccompEnabled() bool {
 	return supportsSeccomp && SysInfo.Seccomp
 }
 
 func bridgeNfIptables() bool {
 	return !SysInfo.BridgeNFCallIPTablesDisabled
 }
 
 func bridgeNfIP6tables() bool {
 	return !SysInfo.BridgeNFCallIP6TablesDisabled
 }
 
 func unprivilegedUsernsClone() bool {
 	content, err := ioutil.ReadFile("/proc/sys/kernel/unprivileged_userns_clone")
 	return err != nil || !strings.Contains(string(content), "0")
 }
 
 func ambientCapabilities() bool {
 	content, err := ioutil.ReadFile("/proc/self/status")
 	return err != nil || strings.Contains(string(content), "CapAmb:")
 }
 
 func overlayFSSupported() bool {
 	cmd := exec.Command(dockerBinary, "run", "--rm", "busybox", "/bin/sh", "-c", "cat /proc/filesystems")
 	out, err := cmd.CombinedOutput()
 	if err != nil {
 		return false
 	}
 	return bytes.Contains(out, []byte("overlay\n"))
 }
 
 func overlay2Supported() bool {
 	if !overlayFSSupported() {
 		return false
 	}
 
f85ef42e
 	daemonV, err := kernel.ParseRelease(testEnv.DaemonInfo.KernelVersion)
930a9869
 	if err != nil {
 		return false
 	}
 	requiredV := kernel.VersionInfo{Kernel: 4}
 	return kernel.CompareKernelVersion(*daemonV, requiredV) > -1
 
 }
 
 func init() {
b1fb4198
 	if SameHostDaemon() {
 		SysInfo = sysinfo.New(true)
 	}
930a9869
 }