From: Rishabh Dave Date: Wed, 5 Nov 2025 13:43:16 +0000 (+0530) Subject: pybind/cephfs: add python bindings for chmodat() X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4114b697209037e4e1a5ced2aa6ff62f6e53416e;p=ceph.git pybind/cephfs: add python bindings for chmodat() Signed-off-by: Rishabh Dave --- diff --git a/src/pybind/cephfs/c_cephfs.pxd b/src/pybind/cephfs/c_cephfs.pxd index dd6326527b26..dd92eb3ee65e 100644 --- a/src/pybind/cephfs/c_cephfs.pxd +++ b/src/pybind/cephfs/c_cephfs.pxd @@ -177,9 +177,13 @@ cdef extern from "cephfs/libcephfs.h" nogil: int ceph_lazyio_propagate(ceph_mount_info *cmount, int fd, int64_t offset, size_t count) int ceph_lazyio_synchronize(ceph_mount_info *cmount, int fd, int64_t offset, size_t count) int ceph_fallocate(ceph_mount_info *cmount, int fd, int mode, int64_t offset, int64_t length) + int ceph_chmod(ceph_mount_info *cmount, const char *path, mode_t mode) int ceph_lchmod(ceph_mount_info *cmount, const char *path, mode_t mode) int ceph_fchmod(ceph_mount_info *cmount, int fd, mode_t mode) + int ceph_chmodat(ceph_mount_info *cmount, int dirfd, const char *relpath, + mode_t mode, int flags) + int ceph_chown(ceph_mount_info *cmount, const char *path, int uid, int gid) int ceph_lchown(ceph_mount_info *cmount, const char *path, int uid, int gid) int ceph_fchown(ceph_mount_info *cmount, int fd, int uid, int gid) diff --git a/src/pybind/cephfs/cephfs.pyx b/src/pybind/cephfs/cephfs.pyx index e49d62f24e90..33c90d2d8a17 100644 --- a/src/pybind/cephfs/cephfs.pyx +++ b/src/pybind/cephfs/cephfs.pyx @@ -1274,6 +1274,29 @@ cdef class LibCephFS(object): if ret < 0: raise make_ex(ret, "error in chmod {}".format(path.decode('utf-8'))) + def chmodat(self, dirfd, relpath, mode, flags) -> None: + self.require_state("mounted") + + if not isinstance(dirfd, int): + raise TypeError('"dirfd "must be an int') + if not isinstance(mode, int): + raise TypeError('mode must be an int') + if not isinstance(flags, int): + raise TypeError('flags must be an int') + + relpath = cstr(relpath, 'relpath') + cdef: + int _dirfd = dirfd + char* _relpath = relpath + int _mode = mode + int _flags = flags + + with nogil: + ret = ceph_chmodat(self.cluster, _dirfd, _relpath, _mode, _flags) + + if ret < 0: + raise make_ex(ret, f"error in chmod {relpath.decode('utf-8')}") + def lchmod(self, path, mode) -> None: """ Change file mode. If the path is a symbolic link, it won't be dereferenced. diff --git a/src/pybind/cephfs/mock_cephfs.pxi b/src/pybind/cephfs/mock_cephfs.pxi index 12075cb77c2e..766a7d1c75b0 100644 --- a/src/pybind/cephfs/mock_cephfs.pxi +++ b/src/pybind/cephfs/mock_cephfs.pxi @@ -255,12 +255,17 @@ cdef nogil: pass int ceph_fallocate(ceph_mount_info *cmount, int fd, int mode, int64_t offset, int64_t length): pass + int ceph_chmod(ceph_mount_info *cmount, const char *path, mode_t mode): pass int ceph_lchmod(ceph_mount_info *cmount, const char *path, mode_t mode): pass int ceph_fchmod(ceph_mount_info *cmount, int fd, mode_t mode): pass + int ceph_chmodat(ceph_mount_info *cmount, int dirfd, const char *relpath, + mode_t mode, int flags): + pass + int ceph_chown(ceph_mount_info *cmount, const char *path, int uid, int gid): pass int ceph_lchown(ceph_mount_info *cmount, const char *path, int uid, int gid):