namespace

package
v0.0.0-test Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 5 Imported by: 4

Documentation

Index

Constants

View Source
const (
	NSMNT    = "mnt"
	NSUTS    = "uts"
	NSIPC    = "ipc"
	NSUSER   = "user"
	NSPID    = "pid"
	NSNET    = "net"
	NSCGROUP = "cgroup"
)

Variables

View Source
var (
	ErrNotImplemented = errors.New("not implemented")
)
View Source
var SYS_SETNS = map[string]uintptr{
	"386":     346,
	"amd64":   308,
	"arm64":   268,
	"arm":     375,
	"ppc64":   350,
	"ppc64le": 350,
	"s390x":   339,
}[runtime.GOARCH]

SYS_SETNS syscall allows changing the namespace of the current process.

Functions

func GetPathFromPid

func GetPathFromPid(nstype string, proc string, pid int) string

func Set

func Set(ns *NsHandle) (err error)

Set sets the current network namespace to the namespace represented by NsHandle.

Types

type NsHandle

type NsHandle struct {
	// contains filtered or unexported fields
}

NsHandle is a handle to a network namespace. It can be cast directly to an int and used as a file descriptor.

func CurNsHandle

func CurNsHandle(nstype string) (*NsHandle, error)

func NewNsHandle

func NewNsHandle(nstype string, proc string, pid int) (*NsHandle, error)

func (*NsHandle) Close

func (ns *NsHandle) Close() error

Close closes the NsHandle and resets its file descriptor to -1. It is not safe to use an NsHandle after Close() is called.

func (*NsHandle) IsOpen

func (ns *NsHandle) IsOpen() bool

IsOpen returns true if Close() has not been called.

func (*NsHandle) String

func (ns *NsHandle) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL