filesystem

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnsupportedFilesystem is an error for unsupported filesystems.
	ErrUnsupportedFilesystem = errors.New("unsupported filesystem")

	// ErrNonBlockDevice is an error returned when the file is not a block device.
	ErrNonBlockDevice = errors.New("not a block device")

	// ErrFilesystemExists is an error returned when the device has a filesystem.
	ErrFilesystemExists = errors.New("filesystem exists")
)

Functions

func DetectFilesystem

func DetectFilesystem(device string) (string, error)

DetectFilesystem returns filesystem type if device has a filesystem. This returns an empty string if no filesystem exists.

func List

func List() []string

List returns a list of supported filesystem types.

func Mount

func Mount(device, target, fsType, opts string, readonly bool) error

Mount mounts a block device onto target with filesystem-specific opts. target directory must exist.

func Unmount

func Unmount(device, target string) error

Unmount unmounts the device if it is mounted.

Types

type Filesystem

type Filesystem interface {
	// Exists returns true if the filesystem exists in the underlying block device.
	Exists() bool

	// Mkfs creates the filesystem on the underlying block device if the filesystem is not yet created.
	// This returns ErrFilesystemExists if device has some filesystem.
	Mkfs() error

	// Mount mounts the filesystem onto the target directory.
	// target directory must exist.
	// If device is mounted on target, this returns nil.
	// If readonly is true, the filesystem will be mounted as read-only.
	Mount(target string, readonly bool) error

	// Unmount unmounts if device is mounted.
	// target directory must exist.
	// If not mounted, this does nothing.
	Unmount(target string) error

	// Resize resizes the filesystem to match the size of the underlying block device.
	// It should be called while the filesystem is mounted.
	Resize(target string) error
}

Filesystem represents the operations of a filesystem in a block device.

func New

func New(fsType, device string) (Filesystem, error)

New returns a Filesystem if fsType is supported. device must be an existing block device file.

Jump to

Keyboard shortcuts

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