Documentation
¶
Overview ¶
Package imagefs reads the filesystem of an OCI/Docker image as the merged view that a running container would see, and extracts it to disk with path-traversal and absolute-symlink-rewrite protection.
Whiteouts (.wh.* markers and .wh..wh..opq opaque markers) are honored: files explicitly deleted in an upper layer are invisible in the result.
NOT a Go fs.FS implementation - the API surface is purpose-built for the `d8 cr fs` subcommands (MergedFS / ReadFile / ExtractMerged).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrFileTooLarge = errors.New("file too large")
ErrFileTooLarge signals that a file's size exceeds the in-memory cap imposed by ReadFile to bound peak RSS when serving `fs cat`.
var ErrNotFound = errors.New("not found")
ErrNotFound signals an unknown layer reference or a missing file.
var ErrNotRegularFile = errors.New("not a regular file")
ErrNotRegularFile signals that a path exists but is not a regular file.
var ErrStopWalk = errors.New("stop walk")
ErrStopWalk stops a WalkTar iteration without surfacing as an error.
Functions ¶
func NormalizeScopePath ¶
NormalizeScopePath canonicalizes a user-supplied PATH argument used to scope `fs ls`/`fs tree` output. Leading "./" or "/" is stripped, the path is Clean'd, trailing whitespace is trimmed, and an empty result is normalized to ".".
func ReadFile ¶
ReadFile returns the content of filePath in the merged FS. Layers are scanned top-down; a whiteout found before a matching entry causes ErrNotFound.
Types ¶
type Entry ¶
type Entry struct {
Path string `json:"path"`
Type EntryType `json:"type"`
Size int64 `json:"size"`
Mode fs.FileMode `json:"-"`
ModeStr string `json:"mode"`
Linkname string `json:"linkname,omitempty"`
}
func FilterBySubpath ¶
FilterBySubpath returns entries whose tar-relative path is at or under subpath. An empty or "."-equivalent subpath returns the entries unchanged.
type ExtractStats ¶
ExtractStats summarizes how many entries were materialized.
func ExtractMerged ¶
ExtractMerged writes the merged filesystem of img into destDir, honoring whiteouts top-down. Paths attempting to escape destDir are rejected.
Cancellation is checked between layers and at every tar entry, so a Ctrl-C from the cobra command interrupts a multi-GB extraction within the next entry boundary instead of running to completion.