From: Rishabh Dave Date: Wed, 5 Nov 2025 08:55:54 +0000 (+0530) Subject: pybind/cephfs: add python binding for symlinkat() X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ebfcc6d190331936f1518d06385a2421161860f5;p=ceph.git pybind/cephfs: add python binding for symlinkat() Signed-off-by: Rishabh Dave --- diff --git a/src/pybind/cephfs/c_cephfs.pxd b/src/pybind/cephfs/c_cephfs.pxd index e177d00d9961..dd6326527b26 100644 --- a/src/pybind/cephfs/c_cephfs.pxd +++ b/src/pybind/cephfs/c_cephfs.pxd @@ -113,6 +113,7 @@ cdef extern from "cephfs/libcephfs.h" nogil: int ceph_unlink(ceph_mount_info *cmount, const char *path) int ceph_unlinkat(ceph_mount_info *cmount, int dirfd, const char *relpath, int flags) int ceph_symlink(ceph_mount_info *cmount, const char *existing, const char *newname) + int ceph_symlinkat(ceph_mount_info *cmount, const char *existing, int fd, const char *newname) int ceph_readlink(ceph_mount_info *cmount, const char *path, char *buf, int64_t size) int ceph_readlinkat(ceph_mount_info *cmount, const int dirfd, char *path, char *buf, int64_t size) int ceph_setxattr(ceph_mount_info *cmount, const char *path, const char *name, diff --git a/src/pybind/cephfs/cephfs.pyx b/src/pybind/cephfs/cephfs.pyx index adafd4d876e3..e49d62f24e90 100644 --- a/src/pybind/cephfs/cephfs.pyx +++ b/src/pybind/cephfs/cephfs.pyx @@ -2349,7 +2349,26 @@ cdef class LibCephFS(object): ret = ceph_symlink(self.cluster, _existing, _newname) if ret < 0: raise make_ex(ret, "error in symlink") - + + def symlinkat(self, existing, fd, newname): + self.require_state("mounted") + + if not isinstance(fd, int): + raise TypeError('"fd" must be of type int') + + existing = cstr(existing, 'existing') + newname = cstr(newname, 'newname') + cdef: + int _fd = fd + char* _existing = existing + char* _newname = newname + + with nogil: + ret = ceph_symlinkat(self.cluster, _existing, _fd, _newname) + + if ret < 0: + raise make_ex(ret, "error in symlinkat") + def link(self, existing, newname): """ Create a link. diff --git a/src/pybind/cephfs/mock_cephfs.pxi b/src/pybind/cephfs/mock_cephfs.pxi index 19cafd04e1b5..12075cb77c2e 100644 --- a/src/pybind/cephfs/mock_cephfs.pxi +++ b/src/pybind/cephfs/mock_cephfs.pxi @@ -143,6 +143,9 @@ cdef nogil: pass int ceph_symlink(ceph_mount_info *cmount, const char *existing, const char *newname): pass + int ceph_symlinkat(ceph_mount_info *cmount, const char *existing, int fd, + const char *newname): + pass int ceph_readlink(ceph_mount_info *cmount, const char *path, char *buf, int64_t size): pass int ceph_readlinkat(ceph_mount_info *cmount, const int dirfd, char *path,