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
1 changed files with 6 additions and 6 deletions

View File

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