2020-03-30 20:22:07 +00:00
|
|
|
package cephfs
|
|
|
|
|
|
|
|
/*
|
|
|
|
#include <errno.h>
|
|
|
|
*/
|
|
|
|
import "C"
|
|
|
|
|
|
|
|
import (
|
2020-06-29 20:02:07 +00:00
|
|
|
"errors"
|
2020-03-30 20:22:07 +00:00
|
|
|
|
|
|
|
"github.com/ceph/go-ceph/internal/errutil"
|
|
|
|
)
|
|
|
|
|
|
|
|
func getError(e C.int) error {
|
2024-10-02 13:50:05 +00:00
|
|
|
return errutil.GetError("cephfs", int(e))
|
2020-03-30 20:22:07 +00:00
|
|
|
}
|
2020-04-10 17:35:49 +00:00
|
|
|
|
2020-06-18 17:35:35 +00:00
|
|
|
// 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)
|
|
|
|
}
|
|
|
|
|
2020-04-20 18:31:39 +00:00
|
|
|
// Public go errors:
|
|
|
|
|
2020-06-29 20:02:07 +00:00
|
|
|
var (
|
|
|
|
// 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")
|
|
|
|
|
2020-04-20 18:31:39 +00:00
|
|
|
// ErrNotConnected may be returned when client is not connected
|
|
|
|
// to a cluster.
|
2024-10-02 13:50:05 +00:00
|
|
|
ErrNotConnected = getError(-C.ENOTCONN)
|
2023-11-09 08:05:12 +00:00
|
|
|
// ErrNotExist indicates a non-specific missing resource.
|
2024-10-02 13:50:05 +00:00
|
|
|
ErrNotExist = getError(-C.ENOENT)
|
2024-11-12 10:35:31 +00:00
|
|
|
// ErrOpNotSupported is returned in general for operations that are not
|
|
|
|
// supported.
|
|
|
|
ErrOpNotSupported = getError(-C.EOPNOTSUPP)
|
2020-04-20 18:31:39 +00:00
|
|
|
|
2024-10-02 13:50:05 +00:00
|
|
|
// Private errors:
|
2020-04-10 17:35:49 +00:00
|
|
|
|
2024-10-02 13:50:05 +00:00
|
|
|
errInvalid = getError(-C.EINVAL)
|
|
|
|
errNameTooLong = getError(-C.ENAMETOOLONG)
|
|
|
|
errRange = getError(-C.ERANGE)
|
2020-04-10 17:35:49 +00:00
|
|
|
)
|