sparsefile

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sparsefile copies files while preserving holes, and measures the disk space a file's data takes.

The biggest thing atelet copies is a guest memory image, which is mostly unallocated: a plain io.Copy reads holes as zeroes and writes them as data, inflating a snapshot to its full logical size. That costs disk on every copy, and it destroys the sparseness later stages rely on to tell which parts of guest RAM actually hold anything.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllocatedBytes

func AllocatedBytes(info fs.FileInfo) int64

AllocatedBytes returns the disk space allocated to info (st_blocks * 512) rather than its apparent size, which for a sparse guest memory image is the guest RAM ceiling, often orders of magnitude more than the data it holds. ext4, XFS, and btrfs count delayed allocations before writeback.

func Copy

func Copy(src, dst *os.File) (int64, error)

Copy copies the open handle src into the open handle dst, preserving holes where it can, and returns the number of logical bytes copied. Neither handle is closed, and both handles' offsets are clobbered. It exists for callers that must control how the endpoints are opened — e.g. a source opened before its directory entry could vanish, or a destination created with O_EXCL.

dst must be empty (freshly created): holes are never written, so any pre-existing destination bytes would show through them, silently corrupting the copy. A non-empty destination is rejected up front.

func CopyFile

func CopyFile(src, dst string) (int64, error)

CopyFile copies src to dst, preserving holes where it can, and returns the number of logical bytes copied. dst is created (truncated if it exists), like os.Create.

Types

This section is empty.

Jump to

Keyboard shortcuts

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