Documentation
¶
Overview ¶
Package volume provides bounded snapshot and restore mechanics for a caller-selected local volume or directory. Identity, authorization, retention, and transport policy belong to the caller.
Index ¶
Constants ¶
const ( // DefaultMaxEntries bounds the files and directories removal may traverse. DefaultMaxEntries = 10_000 // MaxEntries is the library ceiling for MaxEntries. MaxEntries = 1_000_000 // DefaultMaxBytes bounds the content bytes removal may traverse. DefaultMaxBytes int64 = 1 << 30 // MaxBytes is the library ceiling for MaxBytes. MaxBytes int64 = 1 << 40 // DefaultMaxDepth bounds the number of directory components a path may add. DefaultMaxDepth = 32 // MaxDepth is the library ceiling for MaxDepth. MaxDepth = 128 )
Variables ¶
var ( // ErrUnsafePath reports a link, reparse point, non-directory, or broad // target the caller did not intend to create or delete. ErrUnsafePath = errors.New("unsafe private volume path") // ErrStale reports a volume whose native identity no longer matches the // inspected directory. ErrStale = errors.New("private volume identity changed") // ErrLimit reports content beyond a caller-selected creation or removal // bound. ErrLimit = errors.New("private volume limit exceeded") // ErrInvalid reports a malformed path or volume value. ErrInvalid = errors.New("invalid private volume") )
Functions ¶
func RemovePrivate ¶
func RemovePrivate(ctx context.Context, volume PrivateVolume, limits PrivateLimits) error
RemovePrivate removes exactly the inspected directory after revalidating its native identity and bounded contents. It refuses links, reparse points, broad targets, and a directory replaced since inspection. The caller supplies the traversal bounds and authorizes deletion; the library does neither.
Types ¶
type PrivateLimits ¶
PrivateLimits bound creation and removal. Zero values select the defaults.
type PrivateVolume ¶
type PrivateVolume struct {
Path string
Identity string
Created bool
Entries int
Bytes int64
// contains filtered or unexported fields
}
PrivateVolume is an inspected, caller-selected private directory. Identity is an opaque digest for reporting; native same-file checks pin the handle. A PrivateVolume is only usable for removal when produced by InspectPrivate or CreatePrivate.
func CreatePrivate ¶
func CreatePrivate(ctx context.Context, path string, limits PrivateLimits) (PrivateVolume, error)
CreatePrivate creates a caller-selected private directory with 0700 permissions and missing parents. The library never selects the path and never authorizes deletion; the caller does both.
func InspectPrivate ¶
func InspectPrivate(ctx context.Context, path string, limits PrivateLimits) (PrivateVolume, error)
InspectPrivate validates and counts an existing private directory without following links. It refuses a directory readable or writable by another user.