// Package privatefile handles bounded private files. Runtime support is Linux // only; other platforms refuse operations until their privacy guarantees exist. package privatefile import "errors" var ErrUnavailable = errors.New("private file unavailable") var ErrUnsupported = errors.New("private files unsupported on this platform") // Read returns exact bytes from an owned, single-link, regular 0600 file. // Paths must be absolute and already clean. It rejects symlinks in every path component. The caller validates payload // syntax and completeness: Read cannot distinguish an interrupted write from // intentionally short content. max must be positive. func Read(path string, max int) ([]byte, error) { return read(path, max) } // CreateExclusiveDurable creates a new 0600 file and checks file and parent // synchronization before returning success. The parent must already exist and // be owned and private. The path must be absolute and already clean. Failures preserve any created file, which prevents // retry from overwriting it. The caller must retain its recovery material and // must not treat a later Read as proof that this operation completed. A future // resume caller needs its own checked durability barrier after validating the // saved payload; reopening a file does not repair a failed synchronization. func CreateExclusiveDurable(path string, data []byte, max int) error { return create(path, data, max) }