ceph-csi/vendor/github.com/ceph/go-ceph/rbd/snapshot_rename.go
dependabot[bot] d05847ee73 rebase: bump github.com/ceph/go-ceph from 0.20.0 to 0.21.0
Bumps [github.com/ceph/go-ceph](https://github.com/ceph/go-ceph) from 0.20.0 to 0.21.0.
- [Release notes](https://github.com/ceph/go-ceph/releases)
- [Changelog](https://github.com/ceph/go-ceph/blob/master/docs/release-process.md)
- [Commits](https://github.com/ceph/go-ceph/compare/v0.20.0...v0.21.0)

---
updated-dependencies:
- dependency-name: github.com/ceph/go-ceph
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-26 17:29:31 +00:00

36 lines
756 B
Go

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
}