rootfs: don't change directory
There's no point in changing directory here. Syscalls are resolved local to the linkpath, not to the current directory that the process was in when creating the symlink. Changing directories just confuses people who are trying to debug things. Signed-off-by: Aleksa Sarai <asarai@suse.de>
This commit is contained in:
parent
0f1d6772c6
commit
c29695ad0a
|
@ -238,29 +238,16 @@ func mountToRootfs(m *configs.Mount, rootfs, mountLabel string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// create symlinks for merged cgroups
|
|
||||||
cwd, err := os.Getwd()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := os.Chdir(filepath.Join(rootfs, m.Destination)); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
for _, mc := range merged {
|
for _, mc := range merged {
|
||||||
for _, ss := range strings.Split(mc, ",") {
|
for _, ss := range strings.Split(mc, ",") {
|
||||||
if err := os.Symlink(mc, ss); err != nil {
|
// symlink(2) is very dumb, it will just shove the path into
|
||||||
// if cgroup already exists, then okay(it could have been created before)
|
// the link and doesn't do any checks or relative path
|
||||||
if os.IsExist(err) {
|
// conversion. Also, don't error out if the cgroup already exists.
|
||||||
continue
|
if err := os.Symlink(mc, filepath.Join(rootfs, m.Destination, ss)); err != nil && !os.IsExist(err) {
|
||||||
}
|
|
||||||
os.Chdir(cwd)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := os.Chdir(cwd); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if m.Flags&syscall.MS_RDONLY != 0 {
|
if m.Flags&syscall.MS_RDONLY != 0 {
|
||||||
// remount cgroup root as readonly
|
// remount cgroup root as readonly
|
||||||
mcgrouproot := &configs.Mount{
|
mcgrouproot := &configs.Mount{
|
||||||
|
|
Loading…
Reference in New Issue