fs

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: Apache-2.0 Imports: 14 Imported by: 32

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenIsoImage

func GenIsoImage(isoPath string, volumeID string, srcDir string) error

GenIsoImage generates an ISO 9660 filesystem image containing files from srcDir. It uses specified volumeID as the volume id.

func GetFsStatsForPath

func GetFsStatsForPath(path string) (uint64, uint64, error)

GetFsStatsForPath returns the info about inode usage and space usage (in bytes) for the filesystem that contains the provided path.

func WriteFiles

func WriteFiles(targetDir string, content map[string][]byte) error

WriteFiles writes the files specified as a map under `targetDir`. The keys of the map are subpaths and values are file contents. WriteFiles automatically creates any non-existing directories mentioned in subpaths.

Types

type DelimitedReader

type DelimitedReader interface {
	// ReadString returns next part of data up to (and including it)
	// the delimeter byte.
	ReadString(delim byte) (string, error)
	// Close closes the reader.
	Close() error
}

DelimitedReader is an interface for reading a delimeter-separated data from files. It can be used for reading /sys and /proc information, for example.

type FileSystem

type FileSystem interface {
	// Mount mounts the specified source under the target path.
	// For bind mounts, bind must be true. The bind mounts will
	// happen in the host mount namespace (that of PID 1).
	Mount(source string, target string, fstype string, bind bool) error
	// Unmount unmounts the specified target directory. If detach
	// is true, MNT_DETACH option is used (disconnect the
	// filesystem for the new accesses even if it's busy).
	Unmount(target string, detach bool) error
	// IsPathAnNs verifies if the path is a mountpoint with nsfs filesystem type.
	IsPathAnNs(string) bool
	// ChownForEmulator makes a file or directory owned by the emulator user.
	ChownForEmulator(filePath string, recursive bool) error
	// GetDelimitedReader returns a DelimitedReader for the specified path.
	GetDelimitedReader(path string) (DelimitedReader, error)
	// WriteFile creates a new file with the specified path or truncates
	// the existing one, setting the specified permissions and writing
	// the data to it. Returns an error if any occured
	// during the operation.
	WriteFile(path string, data []byte, perm os.FileMode) error
}

FileSystem defines a filesystem interface interface

var NullFileSystem FileSystem = nullFileSystem{}

NullFileSystem is a fs that's used for testing and does nothing instead of mounting/unmounting.

var RealFileSystem FileSystem = &realFileSystem{}

RealFileSystem provides access to the real filesystem.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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