0

I'm trying to use 'unix.setns' to switch the mount namespace from container to host machine like what 'nsenter' command did. My code is below

const (
   CLONE_NEWNS   = 0x20000      /* New mount namespace */
)
nsMNTFD, err := unix.Open("/proc/1/ns/mnt", unix.O_RDONLY|unix.O_CLOEXEC, 0) 
err = unix.Setns(nsMNTFD, CLONE_NEWNS)

but it always reported 'invalid argument'. Other namespace like net/ipd works fine. Any idea for how to resolve this error or debug further? thanks in advance!

shuanglu
  • 65
  • 1
  • 1
  • 6

0 Answers0