]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/cephfs: add python bindings for openat()
authorRishabh Dave <ridave@redhat.com>
Thu, 23 Oct 2025 13:49:57 +0000 (19:19 +0530)
committerRishabh Dave <ridave@redhat.com>
Wed, 26 Nov 2025 13:25:12 +0000 (18:55 +0530)
Fixes: https://tracker.ceph.com/issues/72992
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 172ab135c5a54be145fa45bf34889adaa995dcf3..8245f12f69f62ce0db9510f003c5172a94c8689e 100644 (file)
@@ -116,8 +116,11 @@ cdef extern from "cephfs/libcephfs.h" nogil:
     int ceph_preadv(ceph_mount_info *cmount, int fd, iovec *iov, int iovcnt, int64_t offset)
     int ceph_flock(ceph_mount_info *cmount, int fd, int operation, uint64_t owner)
     int ceph_mknod(ceph_mount_info *cmount, const char *path, mode_t mode, dev_t rdev)
+
     int ceph_close(ceph_mount_info *cmount, int fd)
     int ceph_open(ceph_mount_info *cmount, const char *path, int flags, mode_t mode)
+    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_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)
index 728aeba3164062e561056e6af99bf272faf46a28..266580b04c088cebd7e0b6ca9672cfe86fd4bebb 100644 (file)
@@ -1470,6 +1470,23 @@ cdef class LibCephFS(object):
             raise make_ex(ret, "error in open {}".format(path.decode('utf-8')))
         return ret
 
+    def openat(self, dirfd, relpath, flags, mode):
+        self.require_state("mounted")
+
+        relpath = cstr(relpath, 'relpath')
+        cdef:
+            int dirfd_ = dirfd
+            int flags_ = flags
+            char* relpath_ = relpath
+            int mode_ = mode
+
+        with nogil:
+            ret = ceph_openat(self.cluster, dirfd_, relpath_, flags_, mode_)
+        if ret < 0:
+            raise make_ex(ret, f'error in openat {relpath}')
+        return ret
+
+
     def close(self, fd):
         """
         Close the open file.
index 7b92fbf4337de4ccbe66d637059fd08d13932138..717d6e468bb67bea65e757a3d158059d0c45f709 100644 (file)
@@ -163,10 +163,14 @@ cdef nogil:
         pass
     int ceph_mknod(ceph_mount_info *cmount, const char *path, mode_t mode, dev_t rdev):
         pass
+
     int ceph_close(ceph_mount_info *cmount, int fd):
         pass
     int ceph_open(ceph_mount_info *cmount, const char *path, int flags, mode_t mode):
         pass
+    int ceph_openat(ceph_mount_info *cmount, int dirfd, const char *relpath, int flags, mode_t mode):
+        pass
+
     int ceph_mkdir(ceph_mount_info *cmount, const char *path, 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):