blockdevice

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2020 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package blockdevice provides a library for working with block devices.

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingPartitionTable = errors.New("missing partition table")

ErrMissingPartitionTable indicates that the the block device does not have a partition table.

Functions

This section is empty.

Types

type BlockDevice

type BlockDevice struct {
	// contains filtered or unexported fields
}

BlockDevice represents a block device.

func Open

func Open(devname string, setters ...Option) (bd *BlockDevice, err error)

Open initializes and returns a block device. TODO(andrewrynhard): Use BLKGETSIZE ioctl to get the size.

func (*BlockDevice) Close

func (bd *BlockDevice) Close() error

Close closes the block devices's open file.

func (*BlockDevice) Device

func (bd *BlockDevice) Device() *os.File

Device returns the backing file for the block device.

func (*BlockDevice) PartitionTable

func (bd *BlockDevice) PartitionTable() (table.PartitionTable, error)

PartitionTable returns the block device partition table.

func (*BlockDevice) RereadPartitionTable

func (bd *BlockDevice) RereadPartitionTable() error

RereadPartitionTable invokes the BLKRRPART ioctl to have the kernel read the partition table.

NB: Rereading the partition table requires that all partitions be unmounted or it will fail with EBUSY.

func (*BlockDevice) Reset added in v0.5.0

func (bd *BlockDevice) Reset() (err error)

Reset will reset a block device given a device name. Simply deletes partition table on device.

func (*BlockDevice) Size

func (bd *BlockDevice) Size() (uint64, error)

Size returns the size of the block device in bytes.

type Option

type Option func(*Options)

Option is the functional option func.

func WithNewGPT

func WithNewGPT(o bool) Option

WithNewGPT opens the blockdevice with a new GPT.

type Options

type Options struct {
	CreateGPT bool
}

Options is the functional options struct.

func NewDefaultOptions

func NewDefaultOptions(setters ...Option) *Options

NewDefaultOptions initializes a Options struct with default values.

Directories

Path Synopsis
xfs
Package xfs provides an interface to xfsprogs.
Package xfs provides an interface to xfsprogs.
Package lba provides a library for working with Logical Block Addresses.
Package lba provides a library for working with Logical Block Addresses.
Package table provides a library for working with block device partition tables.
Package table provides a library for working with block device partition tables.
gpt
Package gpt provides a library for working with GPT partitions.
Package gpt provides a library for working with GPT partitions.
gpt/header
Package header provides a library for working with GPT headers.
Package header provides a library for working with GPT headers.
gpt/partition
Package partition provides a library for working with GPT partitions.
Package partition provides a library for working with GPT partitions.

Jump to

Keyboard shortcuts

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