2023-11-20 11:00:31 +00:00
|
|
|
package cephfs
|
|
|
|
|
|
|
|
/*
|
|
|
|
#include <errno.h>
|
|
|
|
*/
|
|
|
|
import "C"
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"github.com/ceph/go-ceph/internal/errutil"
|
|
|
|
)
|
|
|
|
|
|
|
|
func getError(e C.int) error {
|
2024-10-21 20:38:00 +00:00
|
|
|
return errutil.GetError("cephfs", int(e))
|
2023-11-20 11:00:31 +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)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Public go errors:
|
|
|
|
|
|
|
|
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")
|
|
|
|
|
|
|
|
// ErrNotConnected may be returned when client is not connected
|
|
|
|
// to a cluster.
|
2024-10-21 20:38:00 +00:00
|
|
|
ErrNotConnected = getError(-C.ENOTCONN)
|
2023-11-20 11:00:31 +00:00
|
|
|
// ErrNotExist indicates a non-specific missing resource.
|
2024-10-21 20:38:00 +00:00
|
|
|
ErrNotExist = getError(-C.ENOENT)
|
2023-11-20 11:00:31 +00:00
|
|
|
|
2024-10-21 20:38:00 +00:00
|
|
|
// Private errors:
|
2023-11-20 11:00:31 +00:00
|
|
|
|
2024-10-21 20:38:00 +00:00
|
|
|
errInvalid = getError(-C.EINVAL)
|
|
|
|
errNameTooLong = getError(-C.ENAMETOOLONG)
|
|
|
|
errRange = getError(-C.ERANGE)
|
2023-11-20 11:00:31 +00:00
|
|
|
)
|