mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-24 05:50:22 +00:00
9152b4c2c7
Bumps [github.com/ceph/go-ceph](https://github.com/ceph/go-ceph) from 0.29.1-0.20240925141413-065319c78733 to 0.30.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/commits/v0.30.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>
74 lines
2.2 KiB
Go
74 lines
2.2 KiB
Go
package rbd
|
|
|
|
/*
|
|
#include <errno.h>
|
|
*/
|
|
import "C"
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
|
|
"github.com/ceph/go-ceph/internal/errutil"
|
|
)
|
|
|
|
func getError(err C.int) error {
|
|
if err != 0 {
|
|
if err == -C.ENOENT {
|
|
return ErrNotFound
|
|
}
|
|
return errutil.GetError("rbd", int(err))
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// getErrorIfNegative converts a ceph return code to error if negative.
|
|
// This is useful for functions that return a usable positive value on
|
|
// success but a negative error number on error.
|
|
func getErrorIfNegative(ret C.int) error {
|
|
if ret >= 0 {
|
|
return nil
|
|
}
|
|
return getError(ret)
|
|
}
|
|
|
|
// Public go errors:
|
|
|
|
var (
|
|
// ErrNoIOContext may be returned if an api call requires an IOContext and
|
|
// it is not provided.
|
|
ErrNoIOContext = errors.New("IOContext is missing")
|
|
// ErrNoName may be returned if an api call requires a name and it is
|
|
// not provided.
|
|
ErrNoName = errors.New("RBD image does not have a name")
|
|
// ErrSnapshotNoName may be returned if an api call requires a snapshot
|
|
// name and it is not provided.
|
|
ErrSnapshotNoName = errors.New("RBD snapshot does not have a name")
|
|
// ErrImageNotOpen may be returned if an api call requires an open image handle and one is not provided.
|
|
ErrImageNotOpen = errors.New("RBD image not open")
|
|
// ErrImageIsOpen may be returned if an api call requires a closed image handle and one is not provided.
|
|
ErrImageIsOpen = errors.New("RBD image is open")
|
|
// ErrNotFound may be returned from an api call when the requested item is
|
|
// missing.
|
|
ErrNotFound = fmt.Errorf("RBD image not found: %w", errutil.GetError("rbd", -C.ENOENT))
|
|
// ErrNoNamespaceName maye be returned if an api call requires a namespace
|
|
// name and it is not provided.
|
|
ErrNoNamespaceName = errors.New("Namespace value is missing")
|
|
|
|
// revive:disable:exported for compatibility with old versions
|
|
RbdErrorImageNotOpen = ErrImageNotOpen
|
|
RbdErrorNotFound = ErrNotFound
|
|
// revive:enable:exported
|
|
|
|
// ErrExist indicates a non-specific already existing resource.
|
|
ErrExist = getError(-C.EEXIST)
|
|
// ErrNotExist indicates a non-specific missing resource.
|
|
ErrNotExist = getError(-C.ENOENT)
|
|
// ErrNotImplemented indicates a function is not implemented in by librbd.
|
|
ErrNotImplemented = getError(-C.ENOSYS)
|
|
|
|
// Private errors:
|
|
|
|
errRange = getError(-C.ERANGE)
|
|
)
|