overlay

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2021 License: MPL-2.0-no-copyleft-exception Imports: 5 Imported by: 0

Documentation

Overview

Package overlay implements union filesystems via overlayfs for the purposes of keep your source tree clean.

To use, simply create three paths -- ioutil.TempDir()s work great -- and have the path to your source code. Assign then to the various properties in the Mount parameter, assign the path to your source code to the Lower property.

Then, call the methods:

func main() {
	m := &Mount{}
	m.Lower = os.Args[0]

	var err error
	m.Upper, err = ioutil.TempDir("", "")
	if err != nil {
		panic(err)
	}

	m.Target, err = ioutil.TempDir("", "")
	if err != nil {
		panic(err)
	}

	m.Work, err = ioutil.TempDir("", "")
	if err != nil {
		panic(err)
	}

	if err := m.Mount(); err != nil {
		panic(err)
	}

	fmt.Println(m.Target)
	fmt.Println("do some damage, and press enter to unmount")
	os.Stdin.Read([]byte{})

	if err := m.Unmount(); err != nil {
		panic(err)
	}

	if err := m.Cleanup(); err != nil {
		panic(err)
	}
}

Your program must have the *CAP_SYS_ADMIN* linux capability (see capabilities(7)) or be root to use this library without permissions issues.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mount

type Mount struct {
	Lower  string
	Work   string
	Upper  string
	Target string
}

Mount is the struct containing the mount information required to establish the union.

func (*Mount) Cleanup

func (m *Mount) Cleanup() error

Cleanup cleans up the work directories.

func (*Mount) Mount

func (m *Mount) Mount() error

Mount mounts the overlayfs, creating any dirs necessary

func (*Mount) Unmount

func (m *Mount) Unmount() error

Unmount unmounts the overlayfs.

Jump to

Keyboard shortcuts

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