func (r *RadosIoCtx) SnapGetName(snapid RadosSnapId) (string, error) { var snapname [MAX_NAME_LEN]C.char cerr := C.rados_ioctx_snap_get_name(*r.ctx, C.rados_snap_t(snapid), &snapname[0], MAX_NAME_LEN) if cerr < 0 { return "", errors.New("get snap name failed") } return C.GoString(&snapname[0]), nil }
// ReverseLookupSnapshot returns the name of the given pool snapshot id. func (pool *Pool) ReverseLookupSnapshot(snapId SnapshotId) (string, error) { id := C.rados_snap_t(snapId) bufLen := 8 for { bufAddr := bufferAddress(bufLen) ret := C.rados_ioctx_snap_get_name(pool.context, id, bufAddr, C.int(bufLen)) if int(ret) == -int(syscall.ERANGE) { bufLen *= 2 continue } if ret < 0 { err := toRadosError(ret) err.Message = fmt.Sprintf("Unable to reverse lookup pool snapshot id %d.", snapId) return "", err } name := C.GoString(bufAddr) return name, nil } }