...

Source file src/github.com/opencontainers/runc/libcontainer/configs/namespaces_syscall.go

Documentation: github.com/opencontainers/runc/libcontainer/configs

     1  //go:build linux
     2  // +build linux
     3  
     4  package configs
     5  
     6  import "golang.org/x/sys/unix"
     7  
     8  func (n *Namespace) Syscall() int {
     9  	return namespaceInfo[n.Type]
    10  }
    11  
    12  var namespaceInfo = map[NamespaceType]int{
    13  	NEWNET:    unix.CLONE_NEWNET,
    14  	NEWNS:     unix.CLONE_NEWNS,
    15  	NEWUSER:   unix.CLONE_NEWUSER,
    16  	NEWIPC:    unix.CLONE_NEWIPC,
    17  	NEWUTS:    unix.CLONE_NEWUTS,
    18  	NEWPID:    unix.CLONE_NEWPID,
    19  	NEWCGROUP: unix.CLONE_NEWCGROUP,
    20  }
    21  
    22  // CloneFlags parses the container's Namespaces options to set the correct
    23  // flags on clone, unshare. This function returns flags only for new namespaces.
    24  func (n *Namespaces) CloneFlags() uintptr {
    25  	var flag int
    26  	for _, v := range *n {
    27  		if v.Path != "" {
    28  			continue
    29  		}
    30  		flag |= namespaceInfo[v.Type]
    31  	}
    32  	return uintptr(flag)
    33  }
    34  

View as plain text