You've already forked runc
mirror of
https://github.com/opencontainers/runc.git
synced 2025-07-30 17:43:06 +03:00
libct/cgroups: separate getCgroupMountsV1
This function should not really be used for cgroupv2 code. Currently it is used in kubernetes code, so we can't remove the v2 case yet. Add a TODO item to remove v2 code once kubernetes is converted to not use it, and separate out v1 code. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@ -219,8 +219,11 @@ func getCgroupMountsHelper(ss map[string]bool, mi io.Reader, all bool) ([]Mount,
|
|||||||
|
|
||||||
// GetCgroupMounts returns the mounts for the cgroup subsystems.
|
// GetCgroupMounts returns the mounts for the cgroup subsystems.
|
||||||
// all indicates whether to return just the first instance or all the mounts.
|
// all indicates whether to return just the first instance or all the mounts.
|
||||||
|
// This function should not be used from cgroupv2 code, as in this case
|
||||||
|
// all the controllers are available under the constant unifiedMountpoint.
|
||||||
func GetCgroupMounts(all bool) ([]Mount, error) {
|
func GetCgroupMounts(all bool) ([]Mount, error) {
|
||||||
if IsCgroup2UnifiedMode() {
|
if IsCgroup2UnifiedMode() {
|
||||||
|
// TODO: remove cgroupv2 case once all external users are converted
|
||||||
availableControllers, err := GetAllSubsystems()
|
availableControllers, err := GetAllSubsystems()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -233,6 +236,10 @@ func GetCgroupMounts(all bool) ([]Mount, error) {
|
|||||||
return []Mount{m}, nil
|
return []Mount{m}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return getCgroupMountsV1(all)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getCgroupMountsV1(all bool) ([]Mount, error) {
|
||||||
f, err := os.Open("/proc/self/mountinfo")
|
f, err := os.Open("/proc/self/mountinfo")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Reference in New Issue
Block a user