2 This module is a thin wrapper around libcephfs.
5 from cpython cimport PyObject, ref, exc
6 from libc cimport errno
7 from libc.stdint cimport *
8 from libc.stdlib cimport malloc, realloc, free
12 from collections import namedtuple
13 from datetime import datetime
18 # Are we running Python 2.x
19 if sys.version_info[0] < 3:
25 cdef extern from "Python.h":
26 # These are in cpython/string.pxd, but use "object" types instead of
27 # PyObject*, which invokes assumptions in cpython that we need to
28 # legitimately break to implement zero-copy string buffers in Image.read().
29 # This is valid use of the Python API and documented as a special case.
30 PyObject *PyBytes_FromStringAndSize(char *v, Py_ssize_t len) except NULL
31 char* PyBytes_AsString(PyObject *string) except NULL
32 int _PyBytes_Resize(PyObject **string, Py_ssize_t newsize) except -1
33 void PyEval_InitThreads()
36 cdef extern from "sys/statvfs.h":
38 unsigned long int f_bsize
39 unsigned long int f_frsize
40 unsigned long int f_blocks
41 unsigned long int f_bfree
42 unsigned long int f_bavail
43 unsigned long int f_files
44 unsigned long int f_ffree
45 unsigned long int f_favail
46 unsigned long int f_fsid
47 unsigned long int f_flag
48 unsigned long int f_namemax
49 unsigned long int f_padding[32]
52 cdef extern from "dirent.h":
55 unsigned long int d_off
56 unsigned short int d_reclen
61 cdef extern from "time.h":
62 ctypedef long int time_t
64 cdef extern from "time.h":
69 cdef extern from "sys/types.h":
70 ctypedef unsigned long mode_t
72 cdef extern from "cephfs/ceph_statx.h":
73 cdef struct statx "ceph_statx":
91 cdef extern from "cephfs/libcephfs.h" nogil:
92 cdef struct ceph_mount_info:
95 cdef struct ceph_dir_result:
98 ctypedef void* rados_t
100 const char *ceph_version(int *major, int *minor, int *patch)
102 int ceph_create(ceph_mount_info **cmount, const char * const id)
103 int ceph_create_from_rados(ceph_mount_info **cmount, rados_t cluster)
104 int ceph_init(ceph_mount_info *cmount)
105 void ceph_shutdown(ceph_mount_info *cmount)
107 int ceph_conf_read_file(ceph_mount_info *cmount, const char *path_list)
108 int ceph_conf_parse_argv(ceph_mount_info *cmount, int argc, const char **argv)
109 int ceph_conf_get(ceph_mount_info *cmount, const char *option, char *buf, size_t len)
110 int ceph_conf_set(ceph_mount_info *cmount, const char *option, const char *value)
112 int ceph_mount(ceph_mount_info *cmount, const char *root)
113 int ceph_unmount(ceph_mount_info *cmount)
114 int ceph_fstatx(ceph_mount_info *cmount, int fd, statx *stx, unsigned want, unsigned flags)
115 int ceph_statx(ceph_mount_info *cmount, const char *path, statx *stx, unsigned want, unsigned flags)
116 int ceph_statfs(ceph_mount_info *cmount, const char *path, statvfs *stbuf)
118 int ceph_mds_command(ceph_mount_info *cmount, const char *mds_spec, const char **cmd, size_t cmdlen,
119 const char *inbuf, size_t inbuflen, char **outbuf, size_t *outbuflen,
120 char **outs, size_t *outslen)
121 int ceph_rename(ceph_mount_info *cmount, const char *from_, const char *to)
122 int ceph_link(ceph_mount_info *cmount, const char *existing, const char *newname)
123 int ceph_unlink(ceph_mount_info *cmount, const char *path)
124 int ceph_symlink(ceph_mount_info *cmount, const char *existing, const char *newname)
125 int ceph_readlink(ceph_mount_info *cmount, const char *path, char *buf, int64_t size)
126 int ceph_setxattr(ceph_mount_info *cmount, const char *path, const char *name,
127 const void *value, size_t size, int flags)
128 int ceph_getxattr(ceph_mount_info *cmount, const char *path, const char *name,
129 void *value, size_t size)
130 int ceph_write(ceph_mount_info *cmount, int fd, const char *buf, int64_t size, int64_t offset)
131 int ceph_read(ceph_mount_info *cmount, int fd, char *buf, int64_t size, int64_t offset)
132 int ceph_flock(ceph_mount_info *cmount, int fd, int operation, uint64_t owner)
133 int ceph_close(ceph_mount_info *cmount, int fd)
134 int ceph_open(ceph_mount_info *cmount, const char *path, int flags, mode_t mode)
135 int ceph_mkdir(ceph_mount_info *cmount, const char *path, mode_t mode)
136 int ceph_mkdirs(ceph_mount_info *cmount, const char *path, mode_t mode)
137 int ceph_closedir(ceph_mount_info *cmount, ceph_dir_result *dirp)
138 int ceph_opendir(ceph_mount_info *cmount, const char *name, ceph_dir_result **dirpp)
139 int ceph_chdir(ceph_mount_info *cmount, const char *path)
140 dirent * ceph_readdir(ceph_mount_info *cmount, ceph_dir_result *dirp)
141 int ceph_rmdir(ceph_mount_info *cmount, const char *path)
142 const char* ceph_getcwd(ceph_mount_info *cmount)
143 int ceph_sync_fs(ceph_mount_info *cmount)
144 int ceph_fsync(ceph_mount_info *cmount, int fd, int syncdataonly)
145 int ceph_conf_parse_argv(ceph_mount_info *cmount, int argc, const char **argv)
146 void ceph_buffer_free(char *buf)
150 class Error(Exception):
154 class OSError(Error):
155 def __init__(self, errno, strerror):
157 self.strerror = strerror
160 return '[Errno {0}] {1}'.format(self.errno, self.strerror)
163 class PermissionError(OSError):
167 class ObjectNotFound(OSError):
171 class NoData(OSError):
175 class ObjectExists(OSError):
179 class IOError(OSError):
183 class NoSpace(OSError):
187 class InvalidValue(OSError):
191 class OperationNotSupported(OSError):
195 class LibCephFSStateError(Error):
199 class WouldBlock(OSError):
203 class OutOfRange(OSError):
207 IF UNAME_SYSNAME == "FreeBSD":
208 cdef errno_to_exception = {
209 errno.EPERM : PermissionError,
210 errno.ENOENT : ObjectNotFound,
212 errno.ENOSPC : NoSpace,
213 errno.EEXIST : ObjectExists,
214 errno.ENOATTR : NoData,
215 errno.EINVAL : InvalidValue,
216 errno.EOPNOTSUPP : OperationNotSupported,
217 errno.ERANGE : OutOfRange,
218 errno.EWOULDBLOCK: WouldBlock,
221 cdef errno_to_exception = {
222 errno.EPERM : PermissionError,
223 errno.ENOENT : ObjectNotFound,
225 errno.ENOSPC : NoSpace,
226 errno.EEXIST : ObjectExists,
227 errno.ENODATA : NoData,
228 errno.EINVAL : InvalidValue,
229 errno.EOPNOTSUPP : OperationNotSupported,
230 errno.ERANGE : OutOfRange,
231 errno.EWOULDBLOCK: WouldBlock,
235 cdef make_ex(ret, msg):
237 Translate a librados return code into an exception.
239 :param ret: the return code
241 :param msg: the error message to use
243 :returns: a subclass of :class:`Error`
246 if ret in errno_to_exception:
247 return errno_to_exception[ret](ret, msg)
249 return Error(ret, msg + (": error code %d" % ret))
252 class DirEntry(namedtuple('DirEntry',
253 ['d_ino', 'd_off', 'd_reclen', 'd_type', 'd_name'])):
258 return self.d_type == self.DT_DIR
260 def is_symbol_file(self):
261 return self.d_type == self.DT_LNK
264 return self.d_type == self.DT_REG
266 StatResult = namedtuple('StatResult',
267 ["st_dev", "st_ino", "st_mode", "st_nlink", "st_uid",
268 "st_gid", "st_rdev", "st_size", "st_blksize",
269 "st_blocks", "st_atime", "st_mtime", "st_ctime"])
271 cdef class DirResult(object):
272 cdef ceph_dir_result *handler
275 def cstr(val, name, encoding="utf-8", opt=False):
277 Create a byte string from a Python string
279 :param basestring val: Python string
280 :param str name: Name of the string parameter, for exceptions
281 :param str encoding: Encoding to use
282 :param bool opt: If True, None is allowed
284 :raises: :class:`InvalidArgument`
286 if opt and val is None:
288 if isinstance(val, bytes):
290 elif isinstance(val, unicode):
291 return val.encode(encoding)
293 raise TypeError('%s must be a string' % name)
296 def cstr_list(list_str, name, encoding="utf-8"):
297 return [cstr(s, name) for s in list_str]
300 def decode_cstr(val, encoding="utf-8"):
302 Decode a byte string into a Python string.
304 :param bytes val: byte string
305 :rtype: unicode or None
310 return val.decode(encoding)
313 cdef char* opt_str(s) except? NULL:
319 cdef char ** to_bytes_array(list_bytes):
320 cdef char **ret = <char **>malloc(len(list_bytes) * sizeof(char *))
322 raise MemoryError("malloc failed")
323 for i in xrange(len(list_bytes)):
324 ret[i] = <char *>list_bytes[i]
328 cdef void* realloc_chk(void* ptr, size_t size) except NULL:
329 cdef void *ret = realloc(ptr, size)
331 raise MemoryError("realloc failed")
335 cdef class LibCephFS(object):
336 """libcephfs python wrapper"""
338 cdef public object state
339 cdef ceph_mount_info *cluster
341 def require_state(self, *args):
342 if self.state in args:
344 raise LibCephFSStateError("You cannot perform that operation on a "
345 "CephFS object in state %s." % (self.state))
347 def __cinit__(self, conf=None, conffile=None, auth_id=None, rados_inst=None):
348 """Create a libcephfs wrapper
350 :param conf dict opt: settings overriding the default ones and conffile
351 :param conffile str opt: the path to ceph.conf to override the default settings
352 :auth_id str opt: the id used to authenticate the client entity
353 :rados_inst Rados opt: a rados.Rados instance
356 self.state = "uninitialized"
357 if rados_inst is not None:
358 if auth_id is not None or conffile is not None or conf is not None:
359 raise make_ex(errno.EINVAL,
360 "May not pass RADOS instance as well as other configuration")
362 self.create_with_rados(rados_inst)
364 self.create(conf, conffile, auth_id)
366 def create_with_rados(self, rados.Rados rados_inst):
369 ret = ceph_create_from_rados(&self.cluster, rados_inst.cluster)
371 raise Error("libcephfs_initialize failed with error code: %d" % ret)
372 self.state = "configuring"
374 def create(self, conf=None, conffile=None, auth_id=None):
375 if conf is not None and not isinstance(conf, dict):
376 raise TypeError("conf must be dict or None")
377 cstr(conffile, 'configfile', opt=True)
378 auth_id = cstr(auth_id, 'auth_id', opt=True)
381 char* _auth_id = opt_str(auth_id)
385 ret = ceph_create(&self.cluster, <const char*>_auth_id)
387 raise Error("libcephfs_initialize failed with error code: %d" % ret)
389 self.state = "configuring"
390 if conffile is not None:
391 # read the default conf file when '' is given
394 self.conf_read_file(conffile)
396 for key, value in conf.iteritems():
397 self.conf_set(key, value)
399 def conf_read_file(self, conffile=None):
400 conffile = cstr(conffile, 'conffile', opt=True)
402 char *_conffile = opt_str(conffile)
404 ret = ceph_conf_read_file(self.cluster, <const char*>_conffile)
406 raise make_ex(ret, "error calling conf_read_file")
408 def conf_parse_argv(self, argv):
409 self.require_state("configuring")
410 cargv = cstr_list(argv, 'argv')
412 int _argc = len(argv)
413 char **_argv = to_bytes_array(cargv)
417 ret = ceph_conf_parse_argv(self.cluster, _argc,
418 <const char **>_argv)
420 raise make_ex(ret, "error calling conf_parse_argv")
426 Unmount and destroy the ceph mount handle.
428 if self.state in ["initialized", "mounted"]:
430 ceph_shutdown(self.cluster)
431 self.state = "shutdown"
437 def __exit__(self, type_, value, traceback):
441 def __dealloc__(self):
446 Get the version number of the ``libcephfs`` C library.
448 :returns: a tuple of ``(major, minor, extra)`` components of the
456 ceph_version(&major, &minor, &extra)
457 return (major, minor, extra)
459 def conf_get(self, option):
460 self.require_state("configuring", "initialized", "mounted")
462 option = cstr(option, 'option')
464 char *_option = option
470 ret_buf = <char *>realloc_chk(ret_buf, length)
472 ret = ceph_conf_get(self.cluster, _option, ret_buf, length)
474 return decode_cstr(ret_buf)
475 elif ret == -errno.ENAMETOOLONG:
477 elif ret == -errno.ENOENT:
480 raise make_ex(ret, "error calling conf_get")
484 def conf_set(self, option, val):
485 self.require_state("configuring", "initialized", "mounted")
487 option = cstr(option, 'option')
488 val = cstr(val, 'val')
490 char *_option = option
494 ret = ceph_conf_set(self.cluster, _option, _val)
496 raise make_ex(ret, "error calling conf_set")
499 self.require_state("configuring")
501 ret = ceph_init(self.cluster)
503 raise make_ex(ret, "error calling ceph_init")
504 self.state = "initialized"
507 if self.state == "configuring":
509 self.require_state("initialized")
511 ret = ceph_mount(self.cluster, "/")
513 raise make_ex(ret, "error calling ceph_mount")
514 self.state = "mounted"
517 self.require_state("mounted")
519 ret = ceph_unmount(self.cluster)
521 raise make_ex(ret, "error calling ceph_unmount")
522 self.state = "initialized"
524 def statfs(self, path):
525 self.require_state("mounted")
526 path = cstr(path, 'path')
532 ret = ceph_statfs(self.cluster, _path, &statbuf)
534 raise make_ex(ret, "statfs failed: %s" % path)
535 return {'f_bsize': statbuf.f_bsize,
536 'f_frsize': statbuf.f_frsize,
537 'f_blocks': statbuf.f_blocks,
538 'f_bfree': statbuf.f_bfree,
539 'f_bavail': statbuf.f_bavail,
540 'f_files': statbuf.f_files,
541 'f_ffree': statbuf.f_ffree,
542 'f_favail': statbuf.f_favail,
543 'f_fsid': statbuf.f_fsid,
544 'f_flag': statbuf.f_flag,
545 'f_namemax': statbuf.f_namemax}
548 self.require_state("mounted")
550 ret = ceph_sync_fs(self.cluster)
552 raise make_ex(ret, "sync_fs failed")
554 def fsync(self, int fd, int syncdataonly):
555 self.require_state("mounted")
557 ret = ceph_fsync(self.cluster, fd, syncdataonly)
559 raise make_ex(ret, "fsync failed")
562 self.require_state("mounted")
564 ret = ceph_getcwd(self.cluster)
567 def chdir(self, path):
568 self.require_state("mounted")
570 path = cstr(path, 'path')
571 cdef char* _path = path
573 ret = ceph_chdir(self.cluster, _path)
575 raise make_ex(ret, "chdir failed")
577 def opendir(self, path):
578 self.require_state("mounted")
580 path = cstr(path, 'path')
583 ceph_dir_result *dir_handler
585 ret = ceph_opendir(self.cluster, _path, &dir_handler);
587 raise make_ex(ret, "opendir failed")
589 d.handler = dir_handler
592 def readdir(self, DirResult dir_handler):
593 self.require_state("mounted")
595 cdef ceph_dir_result *_dir_handler = dir_handler.handler
597 dirent = ceph_readdir(self.cluster, _dir_handler)
601 return DirEntry(d_ino=dirent.d_ino,
603 d_reclen=dirent.d_reclen,
604 d_type=dirent.d_type,
605 d_name=dirent.d_name)
607 def closedir(self, DirResult dir_handler):
608 self.require_state("mounted")
610 ceph_dir_result *_dir_handler = dir_handler.handler
613 ret = ceph_closedir(self.cluster, _dir_handler)
615 raise make_ex(ret, "closedir failed")
617 def mkdir(self, path, mode):
618 self.require_state("mounted")
619 path = cstr(path, 'path')
620 if not isinstance(mode, int):
621 raise TypeError('mode must be an int')
626 ret = ceph_mkdir(self.cluster, _path, _mode)
628 raise make_ex(ret, "error in mkdir '%s'" % path)
630 def mkdirs(self, path, mode):
631 self.require_state("mounted")
632 path = cstr(path, 'path')
633 if not isinstance(mode, int):
634 raise TypeError('mode must be an int')
640 ret = ceph_mkdirs(self.cluster, _path, _mode)
642 raise make_ex(ret, "error in mkdirs '%s'" % path)
644 def rmdir(self, path):
645 self.require_state("mounted")
646 path = cstr(path, 'path')
647 cdef char* _path = path
648 ret = ceph_rmdir(self.cluster, _path)
650 raise make_ex(ret, "error in rmdir '%s'" % path)
652 def open(self, path, flags, mode=0):
653 self.require_state("mounted")
654 path = cstr(path, 'path')
656 if not isinstance(mode, int):
657 raise TypeError('mode must be an int')
658 if isinstance(flags, str):
661 cephfs_flags = os.O_RDONLY
669 cephfs_flags |= os.O_TRUNC | os.O_CREAT
670 elif access_flags > 0 and c == '+':
673 raise make_ex(errno.EOPNOTSUPP,
674 "open flags doesn't support %s" % c)
676 if access_flags == 1:
677 cephfs_flags |= os.O_RDONLY;
678 elif access_flags == 2:
679 cephfs_flags |= os.O_WRONLY;
681 cephfs_flags |= os.O_RDWR;
683 elif isinstance(flags, int):
686 raise TypeError("flags must be a string or an integer")
690 int _flags = cephfs_flags
694 ret = ceph_open(self.cluster, _path, _flags, _mode)
696 raise make_ex(ret, "error in open '%s'" % path)
700 self.require_state("mounted")
701 if not isinstance(fd, int):
702 raise TypeError('fd must be an int')
705 ret = ceph_close(self.cluster, _fd)
707 raise make_ex(ret, "error in close")
709 def read(self, fd, offset, l):
710 self.require_state("mounted")
711 if not isinstance(offset, int):
712 raise TypeError('offset must be an int')
713 if not isinstance(l, int):
714 raise TypeError('l must be an int')
715 if not isinstance(fd, int):
716 raise TypeError('fd must be an int')
719 int64_t _offset = offset
723 PyObject* ret_s = NULL
725 ret_s = PyBytes_FromStringAndSize(NULL, _length)
727 ret_buf = PyBytes_AsString(ret_s)
729 ret = ceph_read(self.cluster, _fd, ret_buf, _length, _offset)
731 raise make_ex(ret, "error in read")
734 _PyBytes_Resize(&ret_s, ret)
738 # We DECREF unconditionally: the cast to object above will have
739 # INCREFed if necessary. This also takes care of exceptions,
740 # including if _PyString_Resize fails (that will free the string
741 # itself and set ret_s to NULL, hence XDECREF).
742 ref.Py_XDECREF(ret_s)
744 def write(self, fd, buf, offset):
745 self.require_state("mounted")
746 if not isinstance(fd, int):
747 raise TypeError('fd must be an int')
748 if not isinstance(buf, bytes):
749 raise TypeError('buf must be a bytes')
750 if not isinstance(offset, int):
751 raise TypeError('offset must be an int')
756 int64_t _offset = offset
758 size_t length = len(buf)
761 ret = ceph_write(self.cluster, _fd, _data, length, _offset)
763 raise make_ex(ret, "error in write")
766 def flock(self, fd, operation, owner):
767 self.require_state("mounted")
768 if not isinstance(fd, int):
769 raise TypeError('fd must be an int')
770 if not isinstance(operation, int):
771 raise TypeError('operation must be an int')
776 uint64_t _owner = owner
779 ret = ceph_flock(self.cluster, _fd, _op, _owner)
781 raise make_ex(ret, "error in write")
784 def getxattr(self, path, name, size=255):
785 self.require_state("mounted")
787 path = cstr(path, 'path')
788 name = cstr(name, 'name')
794 size_t ret_length = size
798 ret_buf = <char *>realloc_chk(ret_buf, ret_length)
800 ret = ceph_getxattr(self.cluster, _path, _name, ret_buf,
804 raise make_ex(ret, "error in getxattr")
810 def setxattr(self, path, name, value, flags):
811 self.require_state("mounted")
813 name = cstr(name, 'name')
814 path = cstr(path, 'path')
815 if not isinstance(flags, int):
816 raise TypeError('flags must be a int')
817 if not isinstance(value, bytes):
818 raise TypeError('value must be a bytes')
824 size_t _value_len = len(value)
828 ret = ceph_setxattr(self.cluster, _path, _name,
829 _value, _value_len, _flags)
831 raise make_ex(ret, "error in setxattr")
833 def stat(self, path):
834 self.require_state("mounted")
835 path = cstr(path, 'path')
842 # FIXME: replace magic number with CEPH_STATX_BASIC_STATS
843 ret = ceph_statx(self.cluster, _path, &stx, 0x7ffu, 0)
845 raise make_ex(ret, "error in stat: %s" % path)
846 return StatResult(st_dev=stx.stx_dev, st_ino=stx.stx_ino,
847 st_mode=stx.stx_mode, st_nlink=stx.stx_nlink,
848 st_uid=stx.stx_uid, st_gid=stx.stx_gid,
849 st_rdev=stx.stx_rdev, st_size=stx.stx_size,
850 st_blksize=stx.stx_blksize,
851 st_blocks=stx.stx_blocks,
852 st_atime=datetime.fromtimestamp(stx.stx_atime.tv_sec),
853 st_mtime=datetime.fromtimestamp(stx.stx_mtime.tv_sec),
854 st_ctime=datetime.fromtimestamp(stx.stx_ctime.tv_sec))
857 self.require_state("mounted")
858 if not isinstance(fd, int):
859 raise TypeError('fd must be an int')
866 # FIXME: replace magic number with CEPH_STATX_BASIC_STATS
867 ret = ceph_fstatx(self.cluster, _fd, &stx, 0x7ffu, 0)
869 raise make_ex(ret, "error in fsat")
870 return StatResult(st_dev=stx.stx_dev, st_ino=stx.stx_ino,
871 st_mode=stx.stx_mode, st_nlink=stx.stx_nlink,
872 st_uid=stx.stx_uid, st_gid=stx.stx_gid,
873 st_rdev=stx.stx_rdev, st_size=stx.stx_size,
874 st_blksize=stx.stx_blksize,
875 st_blocks=stx.stx_blocks,
876 st_atime=datetime.fromtimestamp(stx.stx_atime.tv_sec),
877 st_mtime=datetime.fromtimestamp(stx.stx_mtime.tv_sec),
878 st_ctime=datetime.fromtimestamp(stx.stx_ctime.tv_sec))
880 def symlink(self, existing, newname):
881 self.require_state("mounted")
882 existing = cstr(existing, 'existing')
883 newname = cstr(newname, 'newname')
885 char* _existing = existing
886 char* _newname = newname
889 ret = ceph_symlink(self.cluster, _existing, _newname)
891 raise make_ex(ret, "error in symlink")
893 def link(self, existing, newname):
894 self.require_state("mounted")
895 existing = cstr(existing, 'existing')
896 newname = cstr(newname, 'newname')
898 char* _existing = existing
899 char* _newname = newname
902 ret = ceph_link(self.cluster, _existing, _newname)
904 raise make_ex(ret, "error in link")
906 def readlink(self, path, size):
907 self.require_state("mounted")
908 path = cstr(path, 'path')
916 buf = <char *>realloc_chk(buf, _size)
918 ret = ceph_readlink(self.cluster, _path, buf, _size)
920 raise make_ex(ret, "error in readlink")
925 def unlink(self, path):
926 self.require_state("mounted")
927 path = cstr(path, 'path')
928 cdef char* _path = path
930 ret = ceph_unlink(self.cluster, _path)
932 raise make_ex(ret, "error in unlink: %s" % path)
934 def rename(self, src, dst):
935 self.require_state("mounted")
937 src = cstr(src, 'source')
938 dst = cstr(dst, 'destination')
945 ret = ceph_rename(self.cluster, _src, _dst)
947 raise make_ex(ret, "error in rename '%s' to '%s'" % (src, dst))
949 def mds_command(self, mds_spec, args, input_data):
951 :return 3-tuple of output status int, output status string, output data
953 mds_spec = cstr(mds_spec, 'mds_spec')
954 args = cstr_list(args, 'args')
955 input_data = cstr(input_data, 'input_data')
958 char *_mds_spec = opt_str(mds_spec)
959 char **_cmd = to_bytes_array(args)
960 size_t _cmdlen = len(args)
962 char *_inbuf = input_data
963 size_t _inbuf_len = len(input_data)
972 ret = ceph_mds_command(self.cluster, _mds_spec,
973 <const char **>_cmd, _cmdlen,
974 <const char*>_inbuf, _inbuf_len,
975 &_outbuf, &_outbuf_len,
978 my_outs = decode_cstr(_outs[:_outs_len])
979 my_outbuf = _outbuf[:_outbuf_len]
981 ceph_buffer_free(_outs)
983 ceph_buffer_free(_outbuf)
984 return (ret, my_outbuf, my_outs)
986 return (ret, b"", "")