topolvm: github.com/cybozu-go/topolvm/filesystem Index | Files

package filesystem

import "github.com/cybozu-go/topolvm/filesystem"

Index

Package Files

btrfs.go ext4.go interface.go list.go util.go xfs.go

Variables

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")
)

func DetectFilesystem Uses

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 Uses

func List() []string

List returns a list of supported filesystem types.

func Mount Uses

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 Uses

func Unmount(device, target string) error

Unmount unmounts the device if it is mounted.

type Filesystem Uses

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 Uses

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

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

Package filesystem imports 11 packages (graph) and is imported by 1 packages. Updated 2019-10-24. Refresh now. Tools for package owners.