nsenter

package
v0.0.0-...-205da4a Latest Latest
Warning

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

Go to latest
Published: May 26, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

Variables

This section is empty.

Functions

func CGroupNsId

func CGroupNsId(options ...Option) (uint32, error)

CGroupNsId reads cgroup namespace inode for specified process id and host procfs

func Execute

func Execute(ctx context.Context, runnable Runnable, options ...Option) error

Execute executes runnable object in specified namespaces

func HTTP

func HTTP(options ...Option) (*http.Client, error)

func MountNsId

func MountNsId(options ...Option) (uint32, error)

MountNsId reads mount namespace inode for specified process id and host procfs

func NetNsId

func NetNsId(options ...Option) (uint32, error)

NetNsId reads net namespace inode for specified process id and host procfs

func NewReader

func NewReader(filename string, options ...Option) (io.ReadCloser, error)

NewReader creates a namespace file reader, which reads file from mount namespace bind with process id(host pid namespace) and host procfs

func NewWriter

func NewWriter(filename string, flag int, perm os.FileMode, options ...Option) (io.WriteCloser, error)

NewWriter creates a namespace file writer, which write file to mount namespace bind with process id(host pid namespace) and host procfs

func PidNsId

func PidNsId(options ...Option) (uint32, error)

PidNsId reads pid namespace inode for specified process id and host procfs

func ReadFile

func ReadFile(name string, options ...Option) ([]byte, error)

ReadFile reads file in specified mount namespace bind to pid and procfs

func Stat

func Stat(name string, options ...Option) (os.FileInfo, error)

Stat reads file stat information in specified mount namespace bind to pid and procfs

func UserNsId

func UserNsId(options ...Option) (uint32, error)

UserNsId reads user namespace inode for specified process id and host procfs

func UtsNsId

func UtsNsId(options ...Option) (uint32, error)

UtsNsId reads uts namespace inode for specified process id and host procfs

func WriteFile

func WriteFile(name string, data []byte, perm os.FileMode, options ...Option) error

WriteFile writes file in specified mount namespace bind to pid and procfs

Types

type Command

type Command []string

func (Command) Run

func (cmdline Command) Run(ctx context.Context) error

type Lambda

type Lambda func(context.Context) error

func (Lambda) Run

func (fn Lambda) Run(ctx context.Context) error

type NsType

type NsType int

func (NsType) String

func (nst NsType) String() string

type Option

type Option interface {
	// contains filtered or unexported methods
}

func Envs

func Envs(envs ...string) Option

func GID

func GID(gid int) Option

func Output

func Output(output io.Writer) Option

Output specify output writer for execution results, only works for Command

func Pid

func Pid(pid int) Option

Pid specify which process attached to for namespaces

func Procfs

func Procfs(procfs string) Option

Procfs specify host procfs, which is useful for using package in container that has bind host /proc into container or starts with host pid namespace

func Types

func Types(types ...NsType) Option

Types specify namespace types while creating Namespace instance, supports NET, UTS, IPC, USER, and PID.

func UID

func UID(uid int) Option

type Runnable

type Runnable interface {
	Run(context.Context) error
}

type Scanner

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

Scanner represents a namespace file scanner which return a line for each Next() call

func NewScanner

func NewScanner(filename string, options ...Option) (*Scanner, error)

NewScanner creates a namespace file scanner, which reads lines of specified file from mount namespace bind with process id(host pid namespace) and host procfs

func (*Scanner) Close

func (s *Scanner) Close() error

func (*Scanner) Next

func (s *Scanner) Next() ([]byte, error)

Next returns line of opened file, if returned data is nil, indicates EOF or failed with specified error

Jump to

Keyboard shortcuts

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