Version: v0.0.0-...-ed07a65 Latest Latest

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

Go to latest
Published: Sep 19, 2019 License: BSD-3-Clause Imports: 11 Imported by: 0



Package util contains various u-root utility functions.



View Source
const (
	// Not all these paths may be populated or even exist but OTOH they might.
	PATHHEAD = "/ubin"
	PATHMID  = "/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin:/usr/local/sbin"
	PATHTAIL = "/buildbin:/bbin"


View Source
var (
	Env = map[string]string{
		"LD_LIBRARY_PATH": "/usr/local/lib",
		"GOROOT":          "/go",
		"GOPATH":          "/",
		"GOBIN":           "/ubin",
		"CGO_ENABLED":     "0",


func AbsSymlink(originalFile, target string) string

AbsSymlink returns an absolute path for the link from a file to a target.

func FindFileSystem

func FindFileSystem(fs string) error

FindFileSystem returns nil if a file system is installed. It rereads /proc/filesystems each time as the supported file systems can change as modules are added and removed.

func GoBin

func GoBin() string
func IsTargetSymlink(originalFile, target string) bool

IsTargetSymlink returns true if a target of a symlink is also a symlink.

func ResolveUntilLastSymlink(p string) string

ResolveUntilLastSymlink resolves until the last symlink. This is needed when we have a chain of symlinks and want the last symlink, not the file pointed to (which is why we don't use filepath.EvalSymlinks)

func Rootfs

func Rootfs()

build the root file system.

func UrootPath

func UrootPath(n ...string) string

UrootPath returns the full path for a uroot file with the UROOT_ROOT environment variable taken into account. It returns a proper value if UROOT_ROOT is not set. u-root was built to assume everything is rooted at /, and in most cases that is still true. But in hosted mode, e.g. on developer mode chromebooks, it's far better if u-root can be rooted in /usr/local, so successive kernel/root file system upgrades do not wipe it out.

func Usage

func Usage(cmd string)


type Creator

type Creator interface {
	Create() error

type Dev

type Dev struct {
	Name string
	Mode uint32
	Dev  int

func (Dev) Create

func (d Dev) Create() error

func (Dev) String

func (d Dev) String() string

type Dir

type Dir struct {
	Name string
	Mode os.FileMode

func (Dir) Create

func (d Dir) Create() error

func (Dir) String

func (d Dir) String() string

type File

type File struct {
	Name     string
	Contents string
	Mode     os.FileMode

func (File) Create

func (f File) Create() error

func (File) String

func (f File) String() string
type Link struct {
	OldPath string
	NewPath string

func (Link) Create

func (s Link) Create() error

func (Link) String

func (s Link) String() string

type Mount

type Mount struct {
	Source string
	Target string
	FSType string
	Flags  uintptr
	Opts   string

func (Mount) Create

func (m Mount) Create() error

func (Mount) String

func (m Mount) String() string
type Symlink struct {
	Target  string
	NewPath string

func (Symlink) Create

func (s Symlink) Create() error

func (Symlink) String

func (s Symlink) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL