2020-03-30 20:22:07 +00:00
|
|
|
package cephfs
|
|
|
|
|
|
|
|
/*
|
|
|
|
#include <errno.h>
|
|
|
|
*/
|
|
|
|
import "C"
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/ceph/go-ceph/internal/errutil"
|
|
|
|
)
|
|
|
|
|
2020-07-13 23:58:54 +00:00
|
|
|
// cephFSError represents an error condition returned from the CephFS APIs.
|
|
|
|
type cephFSError int
|
2020-03-30 20:22:07 +00:00
|
|
|
|
2020-07-13 23:58:54 +00:00
|
|
|
// Error returns the error string for the cephFSError type.
|
|
|
|
func (e cephFSError) Error() string {
|
2020-03-30 20:22:07 +00:00
|
|
|
errno, s := errutil.FormatErrno(int(e))
|
|
|
|
if s == "" {
|
|
|
|
return fmt.Sprintf("cephfs: ret=%d", errno)
|
|
|
|
}
|
|
|
|
return fmt.Sprintf("cephfs: ret=%d, %s", errno, s)
|
|
|
|
}
|
|
|
|
|
2020-07-13 23:58:54 +00:00
|
|
|
func (e cephFSError) Errno() int {
|
|
|
|
return int(e)
|
|
|
|
}
|
|
|
|
|
2020-03-30 20:22:07 +00:00
|
|
|
func getError(e C.int) error {
|
|
|
|
if e == 0 {
|
|
|
|
return nil
|
|
|
|
}
|
2020-07-13 23:58:54 +00:00
|
|
|
return cephFSError(e)
|
2020-03-30 20:22:07 +00:00
|
|
|
}
|
2020-04-10 17:35:49 +00:00
|
|
|
|
2020-04-20 18:31:39 +00:00
|
|
|
// Public go errors:
|
|
|
|
|
|
|
|
const (
|
|
|
|
// ErrNotConnected may be returned when client is not connected
|
|
|
|
// to a cluster.
|
2020-07-13 23:58:54 +00:00
|
|
|
ErrNotConnected = cephFSError(-C.ENOTCONN)
|
2020-04-20 18:31:39 +00:00
|
|
|
)
|
|
|
|
|
2020-04-10 17:35:49 +00:00
|
|
|
// Private errors:
|
|
|
|
|
|
|
|
const (
|
2020-07-13 23:58:54 +00:00
|
|
|
errInvalid = cephFSError(-C.EINVAL)
|
|
|
|
errNameTooLong = cephFSError(-C.ENAMETOOLONG)
|
|
|
|
errNoEntry = cephFSError(-C.ENOENT)
|
2020-04-10 17:35:49 +00:00
|
|
|
)
|