Skip to content

Commit 2439bcb

Browse files
pybind: convert ceph errno to host-based errno
Fixes: https://tracker.ceph.com/issues/72401 Signed-off-by: Rishabh Dave <[email protected]>
1 parent 2ca8838 commit 2439bcb

File tree

2 files changed

+47
-43
lines changed

2 files changed

+47
-43
lines changed

src/pybind/cephfs/cephfs.pyx

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -62,47 +62,47 @@ CEPH_SETATTR_BTIME = 0x200
6262

6363
CEPH_NOSNAP = -2
6464

65-
# errno definitions
66-
cdef enum:
67-
EBLOCKLISTED = 108
68-
EPERM = 1
69-
ESTALE = 116
70-
ENOSPC = 28
71-
ETIMEDOUT = 110
72-
EIO = 5
73-
ENOTCONN = 107
74-
EEXIST = 17
75-
EINTR = 4
76-
EINVAL = 22
77-
EBADF = 9
78-
EROFS = 30
79-
EAGAIN = 11
80-
EACCES = 13
81-
ELOOP = 40
82-
EISDIR = 21
83-
ENOENT = 2
84-
ENOTDIR = 20
85-
ENAMETOOLONG = 36
86-
EBUSY = 16
87-
EDQUOT = 122
88-
EFBIG = 27
89-
ERANGE = 34
90-
ENXIO = 6
91-
ECANCELED = 125
92-
ENODATA = 61
93-
EOPNOTSUPP = 95
94-
EXDEV = 18
95-
ENOMEM = 12
96-
ENOTRECOVERABLE = 131
97-
ENOSYS = 38
98-
EWOULDBLOCK = EAGAIN
99-
ENOTEMPTY = 39
100-
EDEADLK = 35
101-
EDEADLOCK = EDEADLK
102-
EDOM = 33
103-
EMLINK = 31
104-
ETIME = 62
105-
EOLDSNAPC = 85
65+
# XXX: errno definitions, hard-coded numbers here are errnos defined by Linux
66+
# that are used for the Ceph on-the-wire status codes.
67+
EBLOCKLISTED = ceph_to_hostos_errno(108)
68+
EPERM = ceph_to_hostos_errno(1)
69+
ESTALE = ceph_to_hostos_errno(116)
70+
ENOSPC = ceph_to_hostos_errno(28)
71+
ETIMEDOUT = ceph_to_hostos_errno(110)
72+
EIO = ceph_to_hostos_errno(5)
73+
ENOTCONN = ceph_to_hostos_errno(107)
74+
EEXIST = ceph_to_hostos_errno(17)
75+
EINTR = ceph_to_hostos_errno(4)
76+
EINVAL = ceph_to_hostos_errno(22)
77+
EBADF = ceph_to_hostos_errno(9)
78+
EROFS = ceph_to_hostos_errno(30)
79+
EAGAIN = ceph_to_hostos_errno(11)
80+
EWOULDBLOCK = EAGAIN
81+
EACCES = ceph_to_hostos_errno(13)
82+
ELOOP = ceph_to_hostos_errno(40)
83+
EISDIR = ceph_to_hostos_errno(21)
84+
ENOENT = ceph_to_hostos_errno(2)
85+
ENOTDIR = ceph_to_hostos_errno(20)
86+
ENAMETOOLONG = ceph_to_hostos_errno(36)
87+
EBUSY = ceph_to_hostos_errno(16)
88+
EDQUOT = ceph_to_hostos_errno(122)
89+
EFBIG = ceph_to_hostos_errno(27)
90+
ERANGE = ceph_to_hostos_errno(34)
91+
ENXIO = ceph_to_hostos_errno(6)
92+
ECANCELED = ceph_to_hostos_errno(125)
93+
ENODATA = ceph_to_hostos_errno(61)
94+
EOPNOTSUPP = ceph_to_hostos_errno(95)
95+
EXDEV = ceph_to_hostos_errno(18)
96+
ENOMEM = ceph_to_hostos_errno(12)
97+
ENOTRECOVERABLE = ceph_to_hostos_errno(131)
98+
ENOSYS = ceph_to_hostos_errno(38)
99+
ENOTEMPTY = ceph_to_hostos_errno(39)
100+
EDEADLK = ceph_to_hostos_errno(35)
101+
EDEADLOCK = EDEADLK
102+
EDOM = ceph_to_hostos_errno(33)
103+
EMLINK = ceph_to_hostos_errno(31)
104+
ETIME = ceph_to_hostos_errno(62)
105+
EOLDSNAPC = ceph_to_hostos_errno(85)
106106

107107
cdef extern from "Python.h":
108108
# These are in cpython/string.pxd, but use "object" types instead of
@@ -512,7 +512,7 @@ cdef class LibCephFS(object):
512512
with nogil:
513513
ret = ceph_create_from_rados(&self.cluster, rados_inst.cluster)
514514
if ret != 0:
515-
raise Error("libcephfs_initialize failed with error code: %d" % ret)
515+
raise Error(f"libcephfs_initialize failed with error code: {ret}")
516516
self.state = "configuring"
517517

518518
NO_CONF_FILE = -1
@@ -541,7 +541,7 @@ cdef class LibCephFS(object):
541541
with nogil:
542542
ret = ceph_create(&self.cluster, <const char*>_auth_id)
543543
if ret != 0:
544-
raise Error("libcephfs_initialize failed with error code: %d" % ret)
544+
raise Error(f"libcephfs_initialize failed with error code: {ret}")
545545

546546
self.state = "configuring"
547547
if conffile in (self.NO_CONF_FILE, None):

src/pybind/cephfs/types.pxd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,7 @@ ELSE:
5555
unsigned short int d_reclen
5656
unsigned char d_type
5757
char d_name[256]
58+
59+
cdef extern from "../../include/platform_errno.h":
60+
ctypedef signed int int32_t;
61+
int32_t ceph_to_hostos_errno(int32_t e)

0 commit comments

Comments
 (0)