chroot

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChrootedCallback

func ChrootedCallback(s *sys.System, path string, bindMounts map[string]string, callback func() error, opts ...Opts) error

ChrootedCallback runs the given callback in a chroot environment

Types

type Chroot

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

Chroot represents the struct that will allow us to run commands inside a given chroot

func NewChroot

func NewChroot(s *sys.System, path string, opts ...Opts) *Chroot

func (*Chroot) Close

func (c *Chroot) Close() (err error)

Close will unmount all active mounts created in Prepare on reverse order

func (*Chroot) Prepare

func (c *Chroot) Prepare() (err error)

Prepare will mount the defaultMounts as bind mounts, to be ready when we run chroot

func (*Chroot) Run

func (c *Chroot) Run(command string, args ...string) (out []byte, err error)

Run executes a command inside a chroot

func (*Chroot) RunCallback

func (c *Chroot) RunCallback(callback func() error) (err error)

RunCallback runs the given callback in a chroot environment

func (*Chroot) SetExtraMounts

func (c *Chroot) SetExtraMounts(extraMounts map[string]string)

Sets additional bind mounts for the chroot environment. They are represented in a map where the key is the path outside the chroot and the value is the path inside the chroot.

type Opts

type Opts func(c *Chroot)

func WithoutDefaultBinds

func WithoutDefaultBinds() Opts

Jump to

Keyboard shortcuts

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