-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from vrothberg/cgroupsv2-support
Cgroupsv2 support
- Loading branch information
Showing
42 changed files
with
10,764 additions
and
4,147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2019 psgo authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package cgroups | ||
|
||
import ( | ||
"sync" | ||
"syscall" | ||
) | ||
|
||
const ( | ||
CgroupRoot = "/sys/fs/cgroup" | ||
cgroup2SuperMagic = 0x63677270 | ||
) | ||
|
||
var ( | ||
isUnifiedOnce sync.Once | ||
isUnified bool | ||
isUnifiedErr error | ||
) | ||
|
||
// IsCgroup2UnifiedMode returns whether we are running in cgroup or cgroupv2 mode. | ||
func IsCgroup2UnifiedMode() (bool, error) { | ||
isUnifiedOnce.Do(func() { | ||
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 isUnified, isUnifiedErr | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
82 changes: 82 additions & 0 deletions
82
vendor/github.com/stretchr/testify/assert/assertion_format.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.