zfs: support destroy

This commit is contained in:
Christian Schwarz
2017-07-01 18:21:18 +02:00
parent c22190e981
commit c7f140a00f
2 changed files with 41 additions and 0 deletions

View File

@ -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
}