Documentation
¶
Overview ¶
Package remote implements fsops.Backend over SFTP, on the pooled SSH connection the instance's stored credentials open. Reflinks have no sftp operation and answer fsops.ErrUnsupported, and hardlinks need the server to advertise hardlink@openssh.com. File identity needs the exec tier, where GNU stat and find run as remote commands. Remote paths are slash-delimited, so this package uses path and never path/filepath: the separator belongs to the remote host, not to ours.
Index ¶
- type Backend
- func (b *Backend) HardlinkTree(ctx context.Context, plan *hardlinktree.TreePlan) (*fsops.TreeCreateResult, error)
- func (b *Backend) Lstat(ctx context.Context, p string) (*fsops.LstatInfo, error)
- func (b *Backend) LstatBatch(ctx context.Context, paths []string) ([]*fsops.LstatInfo, []error)
- func (b *Backend) Mkdir(ctx context.Context, p string, _ fs.FileMode) error
- func (b *Backend) MkdirAll(ctx context.Context, p string, _ fs.FileMode) error
- func (b *Backend) Paths() fsops.PathDialect
- func (b *Backend) ReadDir(ctx context.Context, p string) ([]fsops.DirEntry, error)
- func (b *Backend) ReflinkTree(ctx context.Context, _ *hardlinktree.TreePlan) (*fsops.TreeCreateResult, error)
- func (b *Backend) Remove(ctx context.Context, p string, opts fsops.RemoveOptions) error
- func (b *Backend) RemoveTree(ctx context.Context, created *fsops.TreeCreateResult) error
- func (b *Backend) SameFilesystem(ctx context.Context, p1, p2 string) (bool, error)
- func (b *Backend) Stat(ctx context.Context, p string) (*fsops.LstatInfo, error)
- func (b *Backend) StatBatch(ctx context.Context, paths []string) ([]*fsops.LstatInfo, []error)
- func (b *Backend) Statfs(ctx context.Context, p string) (*fsops.StatfsResult, error)
- func (b *Backend) SupportsReflink(ctx context.Context, _ string) (bool, string, error)
- func (b *Backend) WalkDir(ctx context.Context, root string, opts fsops.WalkOptions) (<-chan fsops.WalkEntry, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend implements fsops.Backend for one instance over SFTP. It holds no connection of its own: the pool owns those, so a backend is cheap to build per resolution and safe to discard.
func (*Backend) HardlinkTree ¶
func (b *Backend) HardlinkTree(ctx context.Context, plan *hardlinktree.TreePlan) (*fsops.TreeCreateResult, error)
HardlinkTree mirrors hardlinktree.Create. A target that already exists is skipped when targetIsSource can prove it is a link to the source, which needs the exec tier; the sftp tier refuses it, since its attrs carry no inode to tell that link from a stranger's file (fsops.Backend states the contract).
func (*Backend) LstatBatch ¶ added in v1.33.0
LstatBatch answers fsops.BatchStater. On the exec tier, one find lstats a batch of paths, with identity, in two round trips. Lstat answers each path that find did not print, such as a missing one, so the error is the one Lstat gives. On the sftp tier, Lstat answers every path. The single Lstat calls run batchWidth at a time.
The paths must be absolute: find reads an argument that starts with "-", "!" or "(" as an expression.
func (*Backend) Mkdir ¶ added in v1.34.0
Mkdir ignores perm, as MkdirAll does. The server answers SSH_FX_FAILURE for an existing path, so an lstat names that cause as fs.ErrExist.
func (*Backend) MkdirAll ¶
MkdirAll ignores perm: pkg/sftp sends SSH_FXP_MKDIR with empty attrs, so the server's umask decides, the way it does for every file sftp creates.
func (*Backend) Paths ¶
func (b *Backend) Paths() fsops.PathDialect
func (*Backend) ReflinkTree ¶
func (b *Backend) ReflinkTree(ctx context.Context, _ *hardlinktree.TreePlan) (*fsops.TreeCreateResult, error)
func (*Backend) RemoveTree ¶
RemoveTree is hardlinktree.Created.Rollback over sftp: each recorded file is unlinked, each recorded directory removed deepest first and only when empty, so a directory that gained a sibling torrent's files stays. The algorithm is repeated rather than shared because the local one is bound to os.Remove and an errno; a second copy is smaller than the seam.
func (*Backend) SameFilesystem ¶
func (*Backend) StatBatch ¶ added in v1.33.0
StatBatch answers fsops.BatchStater. It is LstatBatch, but it follows symlinks, as Stat does.