mirror of
https://github.com/ceph/go-ceph
synced 2025-01-09 07:19:58 +00:00
1899072b27
Now, the close function is idempotent wrt being called multiple times on a valid file. Additionally, check the state of the file in various functions to produce sensible errors, matching those cephfs itself returns, if the object was not constructed properly. Signed-off-by: John Mulligan <jmulligan@redhat.com>
52 lines
921 B
Go
52 lines
921 B
Go
package cephfs
|
|
|
|
/*
|
|
#include <errno.h>
|
|
*/
|
|
import "C"
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/ceph/go-ceph/internal/errutil"
|
|
)
|
|
|
|
// revive:disable:exported Temporarily live with stuttering
|
|
|
|
// CephFSError represents an error condition returned from the CephFS APIs.
|
|
type CephFSError int
|
|
|
|
// revive:enable:exported
|
|
|
|
// Error returns the error string for the CephFSError type.
|
|
func (e CephFSError) Error() string {
|
|
errno, s := errutil.FormatErrno(int(e))
|
|
if s == "" {
|
|
return fmt.Sprintf("cephfs: ret=%d", errno)
|
|
}
|
|
return fmt.Sprintf("cephfs: ret=%d, %s", errno, s)
|
|
}
|
|
|
|
func getError(e C.int) error {
|
|
if e == 0 {
|
|
return nil
|
|
}
|
|
return CephFSError(e)
|
|
}
|
|
|
|
// Public go errors:
|
|
|
|
const (
|
|
// ErrNotConnected may be returned when client is not connected
|
|
// to a cluster.
|
|
ErrNotConnected = CephFSError(-C.ENOTCONN)
|
|
)
|
|
|
|
// Private errors:
|
|
|
|
const (
|
|
errNameTooLong = CephFSError(-C.ENAMETOOLONG)
|
|
|
|
errInvalid = CephFSError(-C.EINVAL)
|
|
)
|