fsview

package
v0.7.8 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 7 Imported by: ? 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 fsview builds an in-memory merged view of an image's layered filesystem. Layers are overlaid in manifest order with whiteout and opaque-directory semantics, so the resulting tree describes the final rootfs without writing anything to disk.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanEntryName

func CleanEntryName(name string) (string, error)

CleanEntryName turns a raw tar entry name into a clean slash-separated path relative to the tree root, rejecting names that escape the root.

func IsDeviceKind added in v0.6.0

func IsDeviceKind(k Kind) bool

IsDeviceKind reports whether a kind is a device node or FIFO. These carry no content and cannot be recreated without privileges, so extraction paths skip them while listings still show them.

func NormalizePath

func NormalizePath(p string) (string, error)

NormalizePath converts a user-provided in-image path into a clean relative path: "" denotes the tree root itself.

Types

type Kind

type Kind uint8

Kind describes how a node is materialized on disk.

const (
	KindDir Kind = iota
	KindFile
	KindSymlink
	KindHardlink
	KindCharDev
	KindBlockDev
	KindFifo
)

type Node

type Node struct {
	Name      string // base name inside the tree
	Path      string // slash-separated path relative to the tree root; empty for the root itself
	EntryName string // original entry name in the layer tar that defined this node
	Kind      Kind
	Size      int64
	Mode      int64 // raw tar mode, permission bits plus special bits
	ModTime   time.Time
	UID       int
	GID       int
	Uname     string
	Gname     string
	Linkname  string // symlink target, or hardlink source path inside the tree
	Layer     string // archive entry name of the layer that last defined this node
	Devmajor  int64  // device major number, only meaningful for KindCharDev/KindBlockDev
	Devminor  int64  // device minor number, only meaningful for KindCharDev/KindBlockDev
	Children  []*Node
}

Node is a single entry in the merged filesystem view of an image.

func Build

func Build(layerOrder []string, open func(name string) (io.Reader, func(), error)) (*Node, error)

Build merges every layer in order into a single in-memory tree, applying whiteout and opaque-directory semantics the same way on-disk extraction does.

func BuildParsed added in v0.6.2

func BuildParsed(layerOrder []string, layers map[string]*ParsedLayer) (*Node, error)

BuildParsed merges pre-parsed layers in the given order. Semantics match Build: whiteouts, opaque directories and later-layer overrides apply the same way.

func (*Node) Resolve

func (n *Node) Resolve(target string) *Node

Resolve walks the tree following the given clean relative path and returns the matching node, or nil when any component does not exist. An empty or root path returns the tree root itself.

func (*Node) SortedChildren

func (n *Node) SortedChildren() []*Node

SortedChildren returns the children in byte-wise name order, like ls.

type ParsedLayer added in v0.6.2

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

ParsedLayer holds one layer's tar headers in memory so the layer can be merged later. It exists for archives whose members cannot be re-read in manifest order: a single sequential pass parses every layer (a compressed archive is decompressed once), then the merge applies them in order.

func NewParsedLayer added in v0.7.0

func NewParsedLayer(headers []*tar.Header) *ParsedLayer

NewParsedLayer wraps headers that were parsed elsewhere — for instance from the header bytes a gzip index build captured while scanning — so they can be merged the same way a layer read from the archive would be.

func ParseLayer added in v0.6.2

func ParseLayer(r io.Reader) (*ParsedLayer, error)

ParseLayer reads all tar headers from r, discarding file data.

func (*ParsedLayer) HeaderCount added in v0.6.2

func (l *ParsedLayer) HeaderCount() int

HeaderCount reports how many tar entries the parsed layer holds; callers use it to bound how much is buffered.

Jump to

Keyboard shortcuts

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