Skip to content

Commit

Permalink
Merge pull request opencontainers#131 from LK4D4/name_cgroup
Browse files Browse the repository at this point in the history
Fix handling name= cgroups
  • Loading branch information
Mrunal Patel committed Jul 15, 2015
2 parents 42aa891 + e289cf7 commit 48ac222
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions libcontainer/cgroups/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
"github.com/docker/docker/pkg/units"
)

const cgroupNamePrefix = "name="

// https://www.kernel.org/doc/Documentation/cgroups/cgroups.txt
func FindCgroupMountpoint(subsystem string) (string, error) {
f, err := os.Open("/proc/self/mountinfo")
Expand Down Expand Up @@ -90,8 +92,8 @@ func GetCgroupMounts() ([]Mount, error) {
m := Mount{Mountpoint: mount.Mountpoint}

for _, opt := range strings.Split(mount.VfsOpts, ",") {
if strings.HasPrefix(opt, "name=") {
m.Subsystems = append(m.Subsystems, opt)
if strings.HasPrefix(opt, cgroupNamePrefix) {
m.Subsystems = append(m.Subsystems, opt[len(cgroupNamePrefix):])
}
if allMap[opt] {
m.Subsystems = append(m.Subsystems, opt)
Expand Down Expand Up @@ -186,7 +188,7 @@ func ParseCgroupFile(subsystem string, r io.Reader) (string, error) {
parts := strings.Split(text, ":")

for _, subs := range strings.Split(parts[1], ",") {
if subs == subsystem {
if subs == subsystem || subs == cgroupNamePrefix+subsystem {
return parts[2], nil
}
}
Expand Down

0 comments on commit 48ac222

Please sign in to comment.