Skip to content

Commit

Permalink
fix: proper option search
Browse files Browse the repository at this point in the history
Avoid trigger on larger strings having the target as substring
  • Loading branch information
andreas-kupries committed Apr 29, 2021
1 parent 1800af1 commit 34f6fb9
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions sigar_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -656,13 +656,25 @@ func determineControllerMounts(sysd1, sysd2 *string) {
*sysd2 = mpath
return true
}
if mtype == "cgroup" && strings.Contains(moptions, "memory") {
if *sysd1 != "" {
panic("Multiple cgroup v1 mount points")
if mtype == "cgroup" {
options := strings.Split(moptions, ",")
if stringSliceContains(options, "memory") {
if *sysd1 != "" {
panic("Multiple cgroup v1 mount points")
}
*sysd1 = mpath
return true
}
*sysd1 = mpath
return true
}
return true
})
}

func stringSliceContains(a []string, x string) bool {
for _, n := range a {
if x == n {
return true
}
}
return false
}

0 comments on commit 34f6fb9

Please sign in to comment.