Skip to content

Commit

Permalink
Merge pull request #44 from rhatdan/version
Browse files Browse the repository at this point in the history
Fix definitions for cross compilers
  • Loading branch information
vrothberg authored Jan 17, 2020
2 parents bbd8862 + e109656 commit 4bd64b9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
17 changes: 0 additions & 17 deletions pkg/config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"path/filepath"
"regexp"
"strconv"
"syscall"

"github.com/containers/common/pkg/unshare"
"github.com/containers/storage"
Expand Down Expand Up @@ -113,22 +112,6 @@ const (
SeccompDefaultPath = _installPrefix + "/share/containers/seccomp.json"
)

const (
cgroupRoot = "/sys/fs/cgroup"
_cgroup2SuperMagic = 0x63677270
)

// isCgroup2UnifiedMode returns whether we are running in cgroup 2 cgroup2 mode.
func isCgroup2UnifiedMode() (isUnified bool, isUnifiedErr error) {
var st syscall.Statfs_t
if err := syscall.Statfs(cgroupRoot, &st); err != nil {
isUnified, isUnifiedErr = false, err
} else {
isUnified, isUnifiedErr = st.Type == _cgroup2SuperMagic, nil
}
return
}

// DefaultConfig defines the default values from containers.conf
func DefaultConfig() (*Config, error) {

Expand Down
19 changes: 19 additions & 0 deletions pkg/config/default_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package config

import (
"syscall"
)

// isCgroup2UnifiedMode returns whether we are running in cgroup2 mode.
func isCgroup2UnifiedMode() (isUnified bool, isUnifiedErr error) {
_cgroup2SuperMagic := int64(0x63677270)
cgroupRoot := "/sys/fs/cgroup"

var st syscall.Statfs_t
if err := syscall.Statfs(cgroupRoot, &st); err != nil {
isUnified, isUnifiedErr = false, err
} else {
isUnified, isUnifiedErr = st.Type == _cgroup2SuperMagic, nil
}
return
}
8 changes: 8 additions & 0 deletions pkg/config/default_unsupported.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// +build !linux

package config

// isCgroup2UnifiedMode returns whether we are running in cgroup2 mode.
func isCgroup2UnifiedMode() (isUnified bool, isUnifiedErr error) {
return false, nil
}

0 comments on commit 4bd64b9

Please sign in to comment.