From: Rishabh Dave Date: Tue, 4 Nov 2025 10:56:58 +0000 (+0530) Subject: pybind/cephfs: add python binding for mkdirat() X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6ee0ef33e3f86c778b11dfcde71427040bd34e70;p=ceph.git pybind/cephfs: add python binding for mkdirat() Signed-off-by: Rishabh Dave --- diff --git a/src/pybind/cephfs/c_cephfs.pxd b/src/pybind/cephfs/c_cephfs.pxd index 88fd6abb4f8b..57a3f498e047 100644 --- a/src/pybind/cephfs/c_cephfs.pxd +++ b/src/pybind/cephfs/c_cephfs.pxd @@ -143,6 +143,7 @@ cdef extern from "cephfs/libcephfs.h" nogil: int ceph_openat(ceph_mount_info *cmount, int dirfd, const char *relpath, int flags, mode_t mode) int ceph_mkdir(ceph_mount_info *cmount, const char *path, mode_t mode) + int ceph_mkdirat(ceph_mount_info *cmount, int dirfd, const char *relpath, mode_t mode) int ceph_mksnap(ceph_mount_info *cmount, const char *path, const char *name, mode_t mode, snap_metadata *snap_metadata, size_t nr_snap_metadata) int ceph_rmsnap(ceph_mount_info *cmount, const char *path, const char *name) int ceph_get_snap_info(ceph_mount_info *cmount, const char *path, snap_info *snap_info) diff --git a/src/pybind/cephfs/cephfs.pyx b/src/pybind/cephfs/cephfs.pyx index 7a3b4668d7e8..b71ba0ca4586 100644 --- a/src/pybind/cephfs/cephfs.pyx +++ b/src/pybind/cephfs/cephfs.pyx @@ -1143,6 +1143,25 @@ cdef class LibCephFS(object): if ret < 0: raise make_ex(ret, "error in mkdir {}".format(path.decode('utf-8'))) + def mkdirat(self, dirfd, relpath, mode): + self.require_state("mounted") + if not isinstance(mode, int): + raise TypeError('"mode" must be an int') + if not isinstance(dirfd, int): + raise TypeError('"_dirfd" must be an int') + + relpath = cstr(relpath, 'relpath') + cdef: + char* _relpath = relpath + int _mode = mode + int _dirfd = dirfd + + with nogil: + ret = ceph_mkdirat(self.cluster, _dirfd, _relpath, _mode) + + if ret < 0: + raise make_ex(ret, f"error in mkdirat: {relpath.decode('utf-8')}") + def mksnap(self, path, name, mode, metadata={}) -> int: """ Create a snapshot. diff --git a/src/pybind/cephfs/mock_cephfs.pxi b/src/pybind/cephfs/mock_cephfs.pxi index 006575c9a857..505cfe91223e 100644 --- a/src/pybind/cephfs/mock_cephfs.pxi +++ b/src/pybind/cephfs/mock_cephfs.pxi @@ -196,6 +196,8 @@ cdef nogil: int ceph_mkdir(ceph_mount_info *cmount, const char *path, mode_t mode): pass + int ceph_mkdirat(ceph_mount_info *cmount, int dirfd, const char *relpath, mode_t mode): + pass int ceph_mksnap(ceph_mount_info *cmount, const char *path, const char *name, mode_t mode, snap_metadata *snap_metadata, size_t nr_snap_metadata): pass int ceph_rmsnap(ceph_mount_info *cmount, const char *path, const char *name):