rootfstar

package
v0.6.13 Latest Latest
Warning

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

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

Documentation

Overview

Package rootfstar turns a VM's root filesystem into the tar stream of a one-layer container image, and checks such a stream on its way into the image store.

A Firecracker snapshot is built in two halves. Inside a helper VM, the guest kernel mounts a copy of the sandbox's disk and the agent walks it with Write: the host kernel never parses a filesystem the tenant could have crafted. On the host, Filter reads the helper's stream as untrusted input (a guest that broke out of its kernel's ext4 code could send anything) before the image store sees it.

Index

Constants

This section is empty.

Variables

View Source
var ErrTooLarge = errors.New("rootfs stream exceeds its size limit")

ErrTooLarge: the stream carried more than Filter's byte limit.

Functions

func Filter

func Filter(dst io.Writer, src io.Reader, excluded func(guestPath string) bool, maxBytes int64) error

Filter copies the tar stream src to dst, dropping every entry excluded names (an excluded directory takes everything under it, and a hard link to an excluded file goes with it), and refusing a stream that is not a well-formed, complete tar of relative paths: an entry name or link target that is absolute or climbs out with "..", a stream cut short (no end-of-archive), or more than maxBytes of it in all. Names are matched as guest paths: "/" + the cleaned entry name.

The output is re-encoded entry by entry, so nothing in it is a byte the source chose outside a header field or file body Filter checked.

func Write

func Write(w io.Writer, root string) error

Write writes the tree under root as a tar stream that keeps what a container image layer needs: numeric owners, modes, symlinks, hard links, device and fifo nodes, and extended attributes (file capabilities such as ping's live in security.capability). Sockets are left out: one is only a name for a listener that died with the VM, tar cannot hold it, and docker export leaves them out too. Symlinks are stored, never followed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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