diskfile

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package diskfile makes, grows, copies and measures disk files: the sparse files that hold a guest's disks on the host.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllocatedBytes

func AllocatedBytes(path string) int64

AllocatedBytes returns the space the file at path takes up on the host, which for a sparse file is less than its size, or 0 if there is no file.

func AllocatedBytesUnder

func AllocatedBytesUnder(dir string) (int64, error)

AllocatedBytesUnder returns the space the files in the directory tree at dir take up on the host, by AllocatedBytes. It returns what it counted with the first error met walking the tree.

func Copy

func Copy(src, dst string) (err error)

Copy copies the disk file at src to dst, sharing its blocks by reflink where the filesystem supports it and otherwise keeping its holes. The copy is written beside dst and renamed into place, so dst never holds a disk half copied.

func CreateExt4

func CreateExt4(ctx context.Context, path string, sizeBytes int64) error

CreateExt4 creates a sparse disk file of sizeBytes at path, holding an empty ext4 filesystem. It is formatted beside path and renamed into place, so path never holds a disk half made. Formatting needs mke2fs, from e2fsprogs.

func CreateExt4From

func CreateExt4From(ctx context.Context, path string, sizeBytes int64, dir string) error

CreateExt4From is CreateExt4 with the filesystem holding a copy of the files in dir. It needs e2fsprogs 1.43 or later.

func GrowExt4

func GrowExt4(ctx context.Context, path string, sizeBytes int64) error

GrowExt4 grows the ext4 disk file at path, and its filesystem, to sizeBytes. A disk that is already that large is left as it is. The filesystem must not be mounted. Growing needs e2fsck and resize2fs, from e2fsprogs. If the filesystem cannot be grown, the file keeps its size.

Types

This section is empty.

Jump to

Keyboard shortcuts

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