nsinit

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2014 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNamespaceFlags

func GetNamespaceFlags(namespaces libcontainer.Namespaces) (flag int)

GetNamespaceFlags parses the container's Namespaces options to set the correct flags on clone, unshare, and setns

Types

type CommandFactory

type CommandFactory interface {
	Create(container *libcontainer.Container, console string, syncFd *os.File, args []string) *exec.Cmd
}

CommandFactory takes the container's configuration and options passed by the parent processes and creates an *exec.Cmd that will be used to fork/exec the namespaced init process

type DefaultCommandFactory

type DefaultCommandFactory struct {
	Root string
}

func (*DefaultCommandFactory) Create

func (c *DefaultCommandFactory) Create(container *libcontainer.Container, console string, pipe *os.File, args []string) *exec.Cmd

Create will return an exec.Cmd with the Cloneflags set to the proper namespaces defined on the container's configuration and use the current binary as the init with the args provided

type DefaultStateWriter

type DefaultStateWriter struct {
	Root string
}

func (*DefaultStateWriter) DeletePid

func (d *DefaultStateWriter) DeletePid() error

func (*DefaultStateWriter) WritePid

func (d *DefaultStateWriter) WritePid(pid int) error

writePidFile writes the namespaced processes pid to pid in the rootfs for the container

type NsInit

type NsInit interface {
	Exec(container *libcontainer.Container, term Terminal, args []string) (int, error)
	ExecIn(container *libcontainer.Container, nspid int, args []string) (int, error)
	Init(container *libcontainer.Container, uncleanRootfs, console string, syncPipe *SyncPipe, args []string) error
}

NsInit is an interface with the public facing methods to provide high level exec operations on a container

func NewNsInit

func NewNsInit(command CommandFactory, state StateWriter) NsInit

type StateWriter

type StateWriter interface {
	WritePid(pid int) error
	DeletePid() error
}

StateWriter handles writing and deleting the pid file on disk

type StdTerminal

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

func (*StdTerminal) Attach

func (s *StdTerminal) Attach(command *exec.Cmd) error

func (*StdTerminal) Close

func (s *StdTerminal) Close() error

func (*StdTerminal) Resize

func (s *StdTerminal) Resize(h, w int) error

func (*StdTerminal) SetMaster

func (s *StdTerminal) SetMaster(*os.File)

type SyncPipe

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

SyncPipe allows communication to and from the child processes to it's parent and allows the two independent processes to syncronize their state.

func NewSyncPipe

func NewSyncPipe() (s *SyncPipe, err error)

func NewSyncPipeFromFd

func NewSyncPipeFromFd(parendFd, childFd uintptr) (*SyncPipe, error)

func (*SyncPipe) Close

func (s *SyncPipe) Close() error

func (*SyncPipe) ReadFromParent

func (s *SyncPipe) ReadFromParent() (libcontainer.Context, error)

func (*SyncPipe) SendToChild

func (s *SyncPipe) SendToChild(context libcontainer.Context) error

type Terminal

type Terminal interface {
	io.Closer
	SetMaster(*os.File)
	Attach(*exec.Cmd) error
	Resize(h, w int) error
}

func NewTerminal

func NewTerminal(stdin io.Reader, stdout, stderr io.Writer, tty bool) Terminal

type TtyTerminal

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

func (*TtyTerminal) Attach

func (t *TtyTerminal) Attach(command *exec.Cmd) error

func (*TtyTerminal) Close

func (t *TtyTerminal) Close() error

func (*TtyTerminal) Resize

func (t *TtyTerminal) Resize(h, w int) error

func (*TtyTerminal) SetMaster

func (t *TtyTerminal) SetMaster(master *os.File)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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