cephfs: use common error extraction function

Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
John Mulligan 2019-12-12 13:27:28 -05:00 committed by Niels de Vos
parent 887dec1c50
commit 72ea0669c2

View File

@ -10,19 +10,19 @@ import "C"
import ( import (
"fmt" "fmt"
"math"
"syscall"
"unsafe" "unsafe"
"github.com/ceph/go-ceph/errutil"
) )
type cephError int type cephError int
func (e cephError) Error() string { func (e cephError) Error() string {
if e == 0 { errno, s := errutil.FormatErrno(int(e))
return fmt.Sprintf("cephfs: no error given") if s == "" {
return fmt.Sprintf("cephfs: ret=%d", errno)
} }
err := syscall.Errno(uint(math.Abs(float64(e)))) return fmt.Sprintf("cephfs: ret=%d, %s", errno, s)
return fmt.Sprintf("cephfs: ret=(%d) %v", e, err)
} }
// MountInfo exports ceph's ceph_mount_info from libcephfs.cc // MountInfo exports ceph's ceph_mount_info from libcephfs.cc