Documentation
¶
Overview ¶
Package disk provides utilities for working directly with a disk
Most of the provided functions are intelligent wrappers around implementations of github.com/diskfs/go-diskfs/partition and github.com/diskfs/go-diskfs/filesystem
Index ¶
- type Disk
- func (d *Disk) CreateFilesystem(partition int, fstype filesystem.Type) (filesystem.FileSystem, error)
- func (d *Disk) GetFilesystem(partition int) (filesystem.FileSystem, error)
- func (d *Disk) GetPartitionTable() (partition.Table, error)
- func (d *Disk) Partition(table partition.Table) error
- func (d *Disk) ReadPartitionContents(partition int, writer io.Writer) (int64, error)
- func (d *Disk) WritePartitionContents(partition int, reader io.Reader) (int64, error)
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Disk ¶
type Disk struct {
File *os.File
Info os.FileInfo
Type Type
Size int64
LogicalBlocksize int64
PhysicalBlocksize int64
Table partition.Table
}
Disk is a reference to a single disk block device or image that has been Create() or Open()
func (*Disk) CreateFilesystem ¶
func (d *Disk) CreateFilesystem(partition int, fstype filesystem.Type) (filesystem.FileSystem, error)
CreateFilesystem creates a filesystem on a disk image, the equivalent of mkfs.
pass the desired partition number, or 0 to create the filesystem on the entire block device / disk image, as well as the filesystem type from github.com/diskfs/go-diskfs/filesystem
if successful, returns a filesystem-implementing structure for the given filesystem type
returns error if there was an error creating the filesystem, or the partition table is invalid and did not request the entire disk.
func (*Disk) GetFilesystem ¶
func (d *Disk) GetFilesystem(partition int) (filesystem.FileSystem, error)
GetFilesystem gets the filesystem that already exists on a disk image
pass the desired partition number, or 0 to create the filesystem on the entire block device / disk image,
if successful, returns a filesystem-implementing structure for the given filesystem type
returns error if there was an error reading the filesystem, or the partition table is invalid and did not request the entire disk.
func (*Disk) GetPartitionTable ¶
GetPartitionTable retrieves a PartitionTable for a Disk
returns an error if the Disk is invalid or does not exist, or the partition table is unknown
func (*Disk) Partition ¶
Partition applies a partition.Table implementation to a Disk
The Table can have zero, one or more Partitions, each of which is unique to its implementation. E.g. MBR partitions in mbr.Table look different from GPT partitions in gpt.Table
Actual writing of the table is delegated to the individual implementation
func (*Disk) ReadPartitionContents ¶
ReadPartitionContents reads the contents of a partition to an io.Writer
if successful, returns the number of bytes read
returns an error if there was an error reading from the disk, writing to the writer, the table is invalid, or the partition is invalid
func (*Disk) WritePartitionContents ¶
WritePartitionContents writes the contents of an io.Reader to a given partition
if successful, returns the number of bytes written
returns an error if there was an error writing to the disk, reading from the reader, the table is invalid, or the partition is invalid