mirror of
https://github.com/zrepl/zrepl.git
synced 2025-06-01 23:56:28 +02:00
zfs: implement ZFSSet
This commit is contained in:
parent
d37bdc3d7a
commit
6a420e872e
24
zfs/zfs.go
24
zfs/zfs.go
@ -159,3 +159,27 @@ func ZFSRecv(fs DatasetPath, stream io.Reader, additionalArgs ...string) (err er
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ZFSSet(fs DatasetPath, prop, val string) (err error) {
|
||||||
|
|
||||||
|
if strings.ContainsRune(prop, '=') {
|
||||||
|
panic("prop contains rune '=' which is the delimiter between property name and value")
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd := exec.Command(ZFS_BINARY, "set", fmt.Sprintf("%s=%s", prop, val), fs.ToString())
|
||||||
|
|
||||||
|
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…
x
Reference in New Issue
Block a user