]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/cephfs: add python binding for mkdirat()
authorRishabh Dave <ridave@redhat.com>
Tue, 4 Nov 2025 10:56:58 +0000 (16:26 +0530)
committerRishabh Dave <ridave@redhat.com>
Thu, 16 Apr 2026 12:37:56 +0000 (18:07 +0530)
Signed-off-by: Rishabh Dave <ridave@redhat.com>
src/pybind/cephfs/c_cephfs.pxd
src/pybind/cephfs/cephfs.pyx
src/pybind/cephfs/mock_cephfs.pxi

index 88fd6abb4f8b7f306ee0cba2a256c5272669cc19..57a3f498e047fe1fc7a366fb2d0a9143ad8ed7ef 100644 (file)
@@ -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)
index 7a3b4668d7e84de9402b6ab1a10a842de8c86a67..b71ba0ca458648c0fa4f20e05444ae254c207fa8 100644 (file)
@@ -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.
index 006575c9a8579be03924b838c11cade1a4f7bf50..505cfe91223e83388e5eb61f836271271c094ebe 100644 (file)
@@ -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):