linkresolve

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: AGPL-3.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

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSymlinkLoop    = errors.New("linkresolve: symbolic link loop")
	ErrNotDirectory   = errors.New("linkresolve: target is not a directory")
	ErrTargetMismatch = errors.New("linkresolve: resolved target does not match kernel object")
)

Functions

func IsSymlinkLoop

func IsSymlinkLoop(err error) bool

IsSymlinkLoop reports whether err indicates a symbolic link cycle from either the kernel (ELOOP) or Go's filepath.EvalSymlinks ("too many links").

func ResolvePOSIXDirectory

func ResolvePOSIXDirectory(path string, ops POSIXOps) (string, fs.FileInfo, error)

ResolvePOSIXDirectory resolves a caller-supplied directory path through symbolic links under the same kernel-agreement guarantees as ResolvePOSIXTarget, rejecting non-directory targets with ErrNotDirectory.

func ResolvePOSIXTarget

func ResolvePOSIXTarget(path string, ops POSIXOps) (string, fs.FileInfo, error)

ResolvePOSIXTarget resolves a caller-supplied path through symbolic links only when kernel stat(path) (honoring Linux fs.protected_symlinks without opening FIFOs), filepath.EvalSymlinks(path), and no-follow lstat(resolved) all agree on the exact same non-symlink object.

Types

type POSIXOps

type POSIXOps struct {
	Follow       func(string) (fs.FileInfo, error)
	EvalSymlinks func(string) (string, error)
	Lstat        func(string) (fs.FileInfo, error)
}

POSIXOps injects filesystem lookup seams for deterministic unit testing. Zero fields fall back to standard os / filepath operations.

Jump to

Keyboard shortcuts

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