Documentation
¶
Overview ¶
Package safefs provides narrow filesystem primitives for cache publication and repository-contained regular-file rewrites.
Index ¶
- Variables
- func AtomicWriteFile(path string, data []byte, perm fs.FileMode) error
- func ReadRepositoryRegularFile(repoRoot, path string) (string, []byte, error)
- func ReadRepositoryRegularFileLimit(repoRoot, path string, maxBytes int64) (string, []byte, error)
- func RepositoryRegularFile(repoRoot, path string) (string, fs.FileMode, error)
- func RewriteRepositoryRegularFile(repoRoot, path string, data []byte) error
Constants ¶
This section is empty.
Variables ¶
var ErrRepositoryFileTooLarge = errors.New("repository file exceeds read limit")
ErrRepositoryFileTooLarge reports a repository file that exceeds a caller's bounded-read limit.
var ErrUnsafeRepositoryFile = errors.New("unsafe repository file")
ErrUnsafeRepositoryFile reports a path that cannot safely be read or rewritten as a regular file contained by a repository root.
Functions ¶
func AtomicWriteFile ¶
AtomicWriteFile publishes data via a unique temporary file and rename. Unique names keep concurrent writers from publishing each other's partial data. Sync bounds torn writes across crashes.
func ReadRepositoryRegularFile ¶
ReadRepositoryRegularFile reads a regular file contained by repoRoot. It rejects absolute and escaping paths, directories, and symlinks.
func ReadRepositoryRegularFileLimit ¶
ReadRepositoryRegularFileLimit reads at most maxBytes from a regular file contained by repoRoot. It reads one extra byte to detect overflow without allocating the full file.
func RepositoryRegularFile ¶
RepositoryRegularFile validates and locates a regular file contained by repoRoot without following symlinks in any path component.
func RewriteRepositoryRegularFile ¶
RewriteRepositoryRegularFile atomically rewrites a regular repository file while preserving its existing permission bits. It validates the target again immediately before publishing the replacement.
Types ¶
This section is empty.