split into packages
This commit is contained in:
31
internal/zfs/zfs.go
Normal file
31
internal/zfs/zfs.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package zfs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Snapshot struct {
|
||||
SnapshotName string // Name sans dataset (the part after the '@')
|
||||
Name string // Full dataset@snapname
|
||||
Dataset string
|
||||
Creation time.Time
|
||||
GUID int64
|
||||
}
|
||||
|
||||
func Cmd(ctx context.Context, arg string, a ...any) ([]byte, error) {
|
||||
if len(a) > 0 {
|
||||
arg = fmt.Sprintf(arg, a...)
|
||||
}
|
||||
|
||||
cmd := exec.CommandContext(ctx, "/bin/sh", "-c", arg)
|
||||
|
||||
fmt.Printf("zfs: %+v\n", arg)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return out, err
|
||||
}
|
||||
return out, err
|
||||
}
|
||||
Reference in New Issue
Block a user