2020-05-08 14:07:31 +00:00
|
|
|
package rados
|
|
|
|
|
|
|
|
/*
|
|
|
|
#include <errno.h>
|
|
|
|
*/
|
|
|
|
import "C"
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"github.com/ceph/go-ceph/internal/errutil"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Public go errors:
|
|
|
|
|
|
|
|
var (
|
2020-08-11 14:42:21 +00:00
|
|
|
// ErrNotConnected is returned when functions are called
|
|
|
|
// without a RADOS connection.
|
2024-10-21 20:38:00 +00:00
|
|
|
ErrNotConnected = getError(-C.ENOTCONN)
|
2020-08-11 14:42:21 +00:00
|
|
|
// ErrEmptyArgument may be returned if a function argument is passed
|
|
|
|
// a zero-length slice or map.
|
|
|
|
ErrEmptyArgument = errors.New("Argument must contain at least one item")
|
|
|
|
// ErrInvalidIOContext may be returned if an api call requires an IOContext
|
|
|
|
// but IOContext is not ready for use.
|
|
|
|
ErrInvalidIOContext = errors.New("IOContext is not ready for use")
|
2021-02-10 03:38:18 +00:00
|
|
|
// ErrOperationIncomplete is returned from write op or read op steps for
|
|
|
|
// which the operation has not been performed yet.
|
|
|
|
ErrOperationIncomplete = errors.New("Operation has not been performed yet")
|
2020-05-08 14:07:31 +00:00
|
|
|
|
|
|
|
// ErrNotFound indicates a missing resource.
|
2024-10-21 20:38:00 +00:00
|
|
|
ErrNotFound = getError(-C.ENOENT)
|
2020-05-08 14:07:31 +00:00
|
|
|
// ErrPermissionDenied indicates a permissions issue.
|
2024-10-21 20:38:00 +00:00
|
|
|
ErrPermissionDenied = getError(-C.EPERM)
|
2020-05-08 14:07:31 +00:00
|
|
|
// ErrObjectExists indicates that an exclusive object creation failed.
|
2024-10-21 20:38:00 +00:00
|
|
|
ErrObjectExists = getError(-C.EEXIST)
|
2020-05-08 14:07:31 +00:00
|
|
|
|
|
|
|
// RadosErrorNotFound indicates a missing resource.
|
|
|
|
//
|
|
|
|
// Deprecated: use ErrNotFound instead
|
|
|
|
RadosErrorNotFound = ErrNotFound
|
|
|
|
// RadosErrorPermissionDenied indicates a permissions issue.
|
|
|
|
//
|
|
|
|
// Deprecated: use ErrPermissionDenied instead
|
|
|
|
RadosErrorPermissionDenied = ErrPermissionDenied
|
2020-06-17 09:37:06 +00:00
|
|
|
|
2024-10-21 20:38:00 +00:00
|
|
|
// Private errors:
|
2020-06-17 09:37:06 +00:00
|
|
|
|
2024-10-21 20:38:00 +00:00
|
|
|
errNameTooLong = getError(-C.ENAMETOOLONG)
|
|
|
|
errRange = getError(-C.ERANGE)
|
2020-06-17 09:37:06 +00:00
|
|
|
)
|
2024-10-21 20:38:00 +00:00
|
|
|
|
|
|
|
func getError(errno C.int) error {
|
|
|
|
return errutil.GetError("rados", int(errno))
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
}
|