fsview

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 7 Imported by: 0

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 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
)

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
	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 (*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.

Jump to

Keyboard shortcuts

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