mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-25 01:44:43 +01:00
zfs: support destroy
This commit is contained in:
parent
c22190e981
commit
c7f140a00f
@ -112,3 +112,22 @@ func ZFSListFilesystemVersions(fs DatasetPath, filter FilesystemVersionFilter) (
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func ZFSDestroyFilesystemVersion(filesystem DatasetPath, version FilesystemVersion) (err error) {
|
||||
|
||||
datasetPath := version.ToAbsPath(filesystem)
|
||||
|
||||
// Sanity check...
|
||||
if strings.IndexAny(datasetPath, "@#") == -1 {
|
||||
return fmt.Errorf("sanity check failed: no @ character found in dataset path: %s", datasetPath)
|
||||
}
|
||||
|
||||
err = ZFSDestroy(datasetPath)
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Check for EBUSY, special meaning to us
|
||||
return
|
||||
|
||||
}
|
||||
|
22
zfs/zfs.go
22
zfs/zfs.go
@ -182,3 +182,25 @@ func ZFSSet(fs DatasetPath, prop, val string) (err error) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func ZFSDestroy(dataset string) (err error) {
|
||||
|
||||
cmd := exec.Command(ZFS_BINARY, "destroy", dataset)
|
||||
|
||||
stderr := bytes.NewBuffer(make([]byte, 0, 1024))
|
||||
cmd.Stderr = stderr
|
||||
|
||||
if err = cmd.Start(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = cmd.Wait(); err != nil {
|
||||
err = ZFSError{
|
||||
Stderr: stderr.Bytes(),
|
||||
WaitErr: err,
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user