cgroups/fs2/CreateCgroupPath: nit

This slightly improves code readability.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin 2020-04-07 12:50:17 -07:00
parent b5c1949f2a
commit de1134156b
1 changed files with 4 additions and 3 deletions

View File

@ -25,9 +25,10 @@ func CreateCgroupPath(path string) (Err error) {
ctrs := bytes.Fields(content)
res := append([]byte("+"), bytes.Join(ctrs, []byte(" +"))...)
current := "/sys/fs"
elements := strings.Split(path, "/")
for i, e := range elements[3:] {
elements = elements[3:]
current := "/sys/fs"
for i, e := range elements {
current = filepath.Join(current, e)
if i > 0 {
if err := os.Mkdir(current, 0755); err != nil {
@ -44,7 +45,7 @@ func CreateCgroupPath(path string) (Err error) {
}()
}
}
if i < len(elements[3:])-1 {
if i < len(elements)-1 {
if err := ioutil.WriteFile(filepath.Join(current, "cgroup.subtree_control"), res, 0755); err != nil {
return err
}