Skip to content

Commit

Permalink
Merge pull request opencontainers#259 from hqhq/hq_fix_cgroup
Browse files Browse the repository at this point in the history
Fix bug in find cgroup mount point dir
  • Loading branch information
Mrunal Patel committed Sep 10, 2015
2 parents 5731a04 + b94fe5b commit cd01b01
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions libcontainer/cgroups/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,15 @@ func FindCgroupMountpointDir() (string, error) {

scanner := bufio.NewScanner(f)
for scanner.Scan() {
txt := scanner.Text()
fields := strings.Split(txt, " ")
if fields[7] == "cgroup" {
text := scanner.Text()
fields := strings.Split(text, " ")
// Safe as mountinfo encodes mountpoints with spaces as \040.
index := strings.Index(text, " - ")
postSeparatorFields := strings.Fields(text[index+3:])
if len(postSeparatorFields) < 3 {
return "", fmt.Errorf("Error found less than 3 fields post '-' in %q", text)
}
if postSeparatorFields[0] == "cgroup" {
return filepath.Dir(fields[4]), nil
}
}
Expand Down

0 comments on commit cd01b01

Please sign in to comment.