zfs: implement ZFSSend

This commit is contained in:
Christian Schwarz
2017-05-07 12:18:54 +02:00
parent 1a92717894
commit 030bd7affe
3 changed files with 109 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package zfs
import (
"bytes"
"errors"
"fmt"
"sort"
@ -15,6 +16,18 @@ const (
Snapshot = "snapshot"
)
func (t VersionType) DelimiterChar() string {
switch t {
case Bookmark:
return "#"
case Snapshot:
return "@"
default:
panic(fmt.Sprintf("unexpected VersionType %#v", t))
}
return ""
}
type FilesystemVersion struct {
Type VersionType
@ -29,6 +42,14 @@ type FilesystemVersion struct {
CreateTXG uint64
}
func (v FilesystemVersion) ToAbsPath(p DatasetPath) string {
var b bytes.Buffer
b.WriteString(p.ToString())
b.WriteString(v.Type.DelimiterChar())
b.WriteString(v.Name)
return b.String()
}
type fsbyCreateTXG []FilesystemVersion
func (l fsbyCreateTXG) Len() int { return len(l) }