ceph-csi/vendor/github.com/ceph/go-ceph/rbd/snapshot_rename.go
Prasanna Kumar Kalever 23c324898a rebase: bump go-ceph version to v0.16.0
go-ceph v0.16.0 contains subvolume metadata APIs and subvolume snapshot
metadata APIs.

Please note, as the APIs can not be tested in the go-ceph CI, it requires
build-tag `ceph_ci_untested`.

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2022-06-15 13:17:09 +00:00

38 lines
802 B
Go

//go:build ceph_preview
// +build ceph_preview
package rbd
// #cgo LDFLAGS: -lrbd
// #include <stdlib.h>
// #include <rbd/librbd.h>
import "C"
import (
"unsafe"
)
// Rename a snapshot.
//
// Implements:
// int rbd_snap_rename(rbd_image_t image, const char *snapname,
// 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
}