Documentation
¶
Overview ¶
Package filesystem owns root-confined production filesystem access.
Index ¶
- Variables
- func Backup(source string, readWithMode func(string) ([]byte, fs.FileMode, error), ...) (string, error)
- func CanonicalRoot(root string) (string, error)
- func CommittedPublication(err error) (destination, residue string, committed bool)
- func SupportedTreeEntry(entry fs.DirEntry) (bool, error)
- type ExpectedIdentity
- func (e *ExpectedIdentity) IsDir() bool
- func (e *ExpectedIdentity) ModTime() time.Time
- func (e *ExpectedIdentity) Mode() fs.FileMode
- func (e *ExpectedIdentity) Name() string
- func (e *ExpectedIdentity) Release() error
- func (e *ExpectedIdentity) SameFile(info fs.FileInfo) bool
- func (e *ExpectedIdentity) Size() int64
- func (e *ExpectedIdentity) Sys() any
- type Handle
- func (h *Handle) Backup(source string) (string, error)
- func (h *Handle) Chmod(path string, mode fs.FileMode) error
- func (h *Handle) Close() error
- func (h *Handle) CreateDirectory(destination string, mode fs.FileMode) (created *ExpectedIdentity, returnErr error)
- func (h *Handle) ExpectedIdentity(name string) (*ExpectedIdentity, error)
- func (h *Handle) Info(path string) (fs.FileInfo, error)
- func (h *Handle) LinkInfo(path string) (fs.FileInfo, error)
- func (h *Handle) MkdirAll(path string, mode fs.FileMode) error
- func (h *Handle) Publish(path string, contents []byte, mode fs.FileMode) error
- func (h *Handle) Read(path string) ([]byte, error)
- func (h *Handle) ReadDir(path string) ([]fs.DirEntry, error)
- func (h *Handle) ReadWithMode(path string) ([]byte, fs.FileMode, error)
- func (h *Handle) Remove(path string) error
- func (h *Handle) RemoveAll(path string) error
- func (h *Handle) RemoveExpected(destination string, expected *ExpectedIdentity) (returnErr error)
- func (h *Handle) Rename(oldPath, newPath string) error
- func (h *Handle) Replace(destination string, contents []byte, mode fs.FileMode) error
- func (h *Handle) ReplaceExpected(destination string, expected *ExpectedIdentity, contents []byte, ...) (returnErr error)
- func (h *Handle) RetireExpected(destination string, expected *ExpectedIdentity) (returnErr error)
- func (h *Handle) RootMatches(root string) (bool, error)
- func (h *Handle) Walk(subtree string, visit func(path string, info fs.FileInfo) (bool, error)) error
- type Lease
- type LeaseError
- type LeaseErrorKind
Constants ¶
This section is empty.
Variables ¶
var ErrDirectoryNotEmpty = errors.New("filesystem: directory not empty")
ErrDirectoryNotEmpty reports that expected removal safely preserved a directory containing another entry.
var ErrIdentityChanged = errors.New("filesystem: observed identity changed")
ErrIdentityChanged reports that a path no longer names the entry observed by the caller. It is stable under wrapping.
Functions ¶
func CanonicalRoot ¶ added in v0.41.0
CanonicalRoot returns the symlink-resolved absolute identity used to serialize one existing physical root.
func CommittedPublication ¶ added in v0.41.0
CommittedPublication reports the confined destination and cleanup residue carried by a committed exclusive-publication error.
Types ¶
type ExpectedIdentity ¶ added in v0.41.0
type ExpectedIdentity struct {
// contains filtered or unexported fields
}
ExpectedIdentity is an opaque, releasable identity capability for one observed directory entry. It is acquired only for an expected mutation. On platforms that need it to resist inode reuse it retains a native handle.
func (*ExpectedIdentity) IsDir ¶ added in v0.41.0
func (e *ExpectedIdentity) IsDir() bool
func (*ExpectedIdentity) ModTime ¶ added in v0.41.0
func (e *ExpectedIdentity) ModTime() time.Time
func (*ExpectedIdentity) Mode ¶ added in v0.41.0
func (e *ExpectedIdentity) Mode() fs.FileMode
func (*ExpectedIdentity) Name ¶ added in v0.41.0
func (e *ExpectedIdentity) Name() string
func (*ExpectedIdentity) Release ¶ added in v0.41.0
func (e *ExpectedIdentity) Release() error
Release releases resources retained by this identity. It is idempotent.
func (*ExpectedIdentity) SameFile ¶ added in v0.41.0
func (e *ExpectedIdentity) SameFile(info fs.FileInfo) bool
SameFile reports whether info names the entry retained by this identity.
func (*ExpectedIdentity) Size ¶ added in v0.41.0
func (e *ExpectedIdentity) Size() int64
func (*ExpectedIdentity) Sys ¶ added in v0.41.0
func (e *ExpectedIdentity) Sys() any
type Handle ¶
type Handle struct {
// contains filtered or unexported fields
}
Handle provides root-confined filesystem operations.
func (*Handle) Backup ¶ added in v0.36.0
Backup reads source once, preserving its permission mode, then exclusively publishes a complete sibling backup at source.awf-bak or its first available numbered suffix. The supplied confined callbacks keep source access and publication policy with the caller while this package owns the shared naming and collision protocol. Backup copies a source beneath this handle to its first free sibling backup.
func (*Handle) Chmod ¶ added in v0.35.1
Chmod changes path's permission mode beneath the selected root.
func (*Handle) CreateDirectory ¶ added in v0.41.0
func (h *Handle) CreateDirectory(destination string, mode fs.FileMode) (created *ExpectedIdentity, returnErr error)
CreateDirectory atomically publishes one new directory and returns the identity of the directory it created. It refuses an existing destination.
func (*Handle) ExpectedIdentity ¶ added in v0.41.0
func (h *Handle) ExpectedIdentity(name string) (*ExpectedIdentity, error)
ExpectedIdentity pins one leaf for an expected mutation. The caller must Release an identity it abandons; expected-mutation methods consume it.
func (*Handle) LinkInfo ¶
LinkInfo returns metadata for path without following a final symbolic link.
func (*Handle) MkdirAll ¶ added in v0.34.0
MkdirAll creates path and missing parents beneath the selected root.
func (*Handle) Publish ¶ added in v0.34.0
Publish atomically publishes one complete file without replacement beneath the selected root.
func (*Handle) ReadWithMode ¶ added in v0.35.1
ReadWithMode reads path and returns its permission mode from one confined open.
func (*Handle) RemoveAll ¶ added in v0.40.0
RemoveAll removes path and its descendants beneath the selected root.
func (*Handle) RemoveExpected ¶ added in v0.41.0
func (h *Handle) RemoveExpected(destination string, expected *ExpectedIdentity) (returnErr error)
RemoveExpected removes path only while it still has expected's identity.
func (*Handle) Replace ¶ added in v0.34.0
Replace atomically replaces path with one complete file beneath the selected root, preserving the requested final mode. Callers that previously observed the destination should use ReplaceExpected.
func (*Handle) ReplaceExpected ¶ added in v0.41.0
func (h *Handle) ReplaceExpected(destination string, expected *ExpectedIdentity, contents []byte, mode fs.FileMode) (returnErr error)
ReplaceExpected publishes only while destination still has expected's entry identity. A nil expected identity creates exclusively rather than clobbering.
func (*Handle) RetireExpected ¶ added in v0.41.0
func (h *Handle) RetireExpected(destination string, expected *ExpectedIdentity) (returnErr error)
RetireExpected atomically detaches the expected directory before deleting its contents. A same-name successor installed after the exchange is never traversed or removed.
func (*Handle) RootMatches ¶ added in v0.41.0
RootMatches reports whether this handle remains anchored at root's current directory identity. It lets operation owners reject a handle supplied for a different selected checkout before it can observe or publish anything.
type Lease ¶ added in v0.41.0
type Lease struct {
// contains filtered or unexported fields
}
Lease is an acquired, ordered set of advisory identities. Keeping this value explicit lets an operation prove that authority loading and publication share the same transaction without making the mechanism own operation policy.
func AcquireProjectLease ¶ added in v0.41.0
AcquireProjectLease returns the transaction identity for an operation that changes both checkout-local and primary-resident state. acquire canonicalizes and orders both identities before taking either lock.
func AcquireResidentLease ¶ added in v0.41.0
AcquireResidentLease obtains the primary-resident transaction capability. Resident-only operations use it so independent selected checkouts contend on their shared lifecycle state without unnecessarily serializing tracked work.
func AcquireTrackedLease ¶ added in v0.41.0
AcquireTrackedLease obtains the checkout-local mutation lease. Operations that do not reach primary-resident state must use this instead of a combined project lease so independent linked worktrees can proceed concurrently.
func (*Lease) CoversProject ¶ added in v0.41.0
CoversProject reports whether this live lease contains the complete tracked and resident identity set for roots.
func (*Lease) CoversTracked ¶ added in v0.41.0
CoversTracked reports whether this live lease contains the selected checkout's tracked-tree identity.
type LeaseError ¶ added in v0.41.0
type LeaseError struct {
Kind LeaseErrorKind
Cause error
}
LeaseError preserves the failed lease stage and underlying error identity.
func (*LeaseError) Error ¶ added in v0.41.0
func (e *LeaseError) Error() string
func (*LeaseError) Unwrap ¶ added in v0.41.0
func (e *LeaseError) Unwrap() error
type LeaseErrorKind ¶ added in v0.41.0
type LeaseErrorKind string
LeaseErrorKind identifies the lease stage that failed so focused callers can preserve their own diagnostics without branching on filesystem error text.
const ( LeaseCanonicalRoot LeaseErrorKind = "canonical-root" LeaseCacheLocation LeaseErrorKind = "cache-location" LeaseCacheCreation LeaseErrorKind = "cache-creation" LeaseCacheMode LeaseErrorKind = "cache-mode" LeaseAcquisition LeaseErrorKind = "acquisition" LeaseFileMode LeaseErrorKind = "file-mode" )