2022-05-13 22:19:38 +00:00
|
|
|
package rbd
|
|
|
|
|
|
|
|
// #cgo LDFLAGS: -lrbd
|
|
|
|
// #include <stdlib.h>
|
|
|
|
// #include <rbd/librbd.h>
|
|
|
|
import "C"
|
|
|
|
|
|
|
|
import (
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Rename a snapshot.
|
|
|
|
//
|
|
|
|
// Implements:
|
2023-02-09 17:23:11 +00:00
|
|
|
//
|
|
|
|
// int rbd_snap_rename(rbd_image_t image, const char *snapname,
|
2022-05-13 22:19:38 +00:00
|
|
|
// const char* dstsnapsname);
|
|
|
|
func (snapshot *Snapshot) Rename(destName string) error {
|
|
|
|
if err := snapshot.validate(imageNeedsIOContext | imageIsOpen | imageNeedsName | snapshotNeedsName); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
cSrcName := C.CString(snapshot.name)
|
|
|
|
cDestName := C.CString(destName)
|
|
|
|
defer C.free(unsafe.Pointer(cSrcName))
|
|
|
|
defer C.free(unsafe.Pointer(cDestName))
|
|
|
|
|
|
|
|
err := C.rbd_snap_rename(snapshot.image.image, cSrcName, cDestName)
|
|
|
|
if err != 0 {
|
|
|
|
return getError(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
snapshot.name = destName
|
|
|
|
return nil
|
|
|
|
}
|