experiment: zync: an rsync-like tool for ZFS datasets (re-uses zrepl abstractions)

Local sync and sync over SSH seems to work.
The sshdirect transport might be interesting / re-usable for zrepl as well, although we'd still need some kind of locking in that case.
This commit is contained in:
Christian Schwarz
2021-01-14 01:31:08 +01:00
parent 96d5288667
commit bd30afaaf9
8 changed files with 939 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
package sshdirect
import (
"fmt"
"net"
"os"
"syscall"
)
type timeouter interface {
Timeout() bool
}
var _ timeouter = &os.PathError{}
type IOError struct {
Cause error
}
var _ net.Error = &IOError{}
func (e IOError) GoString() string {
return fmt.Sprintf("ServeConnIOError:%#v", e.Cause)
}
func (e IOError) Error() string {
// following case found by experiment
if pathErr, ok := e.Cause.(*os.PathError); ok {
if pathErr.Err == syscall.EPIPE {
return fmt.Sprintf("netssh %s: %s (likely: connection reset by peer)",
pathErr.Op, pathErr.Err,
)
}
return fmt.Sprintf("netssh: %s: %s", pathErr.Op, pathErr.Err)
}
return fmt.Sprintf("netssh: %s", e.Cause.Error())
}
func (e IOError) Timeout() bool {
if to, ok := e.Cause.(timeouter); ok {
return to.Timeout()
}
return false
}
func (e IOError) Temporary() bool {
return false
}