From: Shachar Sharon Date: Mon, 17 Jun 2024 13:59:05 +0000 (+0300) Subject: vfs_ceph_new: use low-level APIs for lchown X-Git-Tag: tdb-1.4.12~77 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=beb21324c9a554f50d8d99af2a1b7fe8a17c8ebb;p=thirdparty%2Fsamba.git vfs_ceph_new: use low-level APIs for lchown Use libcephfs' low-level API ceph_ll_setattr to implement VFS lchown_fn hook. Use to standard pattern of iget/iput to allow operation by Inode reference. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15686 Signed-off-by: Shachar Sharon Reviewed-by: Guenther Deschner Reviewed-by: Anoop C S --- diff --git a/source3/modules/vfs_ceph_new.c b/source3/modules/vfs_ceph_new.c index 22228d32b78..d005eb7d92f 100644 --- a/source3/modules/vfs_ceph_new.c +++ b/source3/modules/vfs_ceph_new.c @@ -447,6 +447,28 @@ static int vfs_ceph_ll_getattr(const struct vfs_handle_struct *handle, return ret; } +static int vfs_ceph_ll_chown(struct vfs_handle_struct *handle, + const struct vfs_ceph_iref *iref, + uid_t uid, + gid_t gid) +{ + struct ceph_statx stx = {.stx_uid = uid, .stx_gid = gid}; + struct UserPerm *uperm = NULL; + int ret = -1; + + uperm = vfs_ceph_userperm_new(handle); + if (uperm == NULL) { + return -ENOMEM; + } + ret = ceph_ll_setattr(handle->data, + iref->inode, + &stx, + CEPH_STATX_UID | CEPH_STATX_GID, + uperm); + vfs_ceph_userperm_del(uperm); + return ret; +} + /* Ceph Inode-refernce get/put wrappers */ static int vfs_ceph_iget(const struct vfs_handle_struct *handle, uint64_t ino, @@ -1401,12 +1423,22 @@ static int vfs_ceph_lchown(struct vfs_handle_struct *handle, gid_t gid) { int result; + struct vfs_ceph_iref iref = {0}; + DBG_DEBUG("[CEPH] lchown(%p, %s, %d, %d)\n", handle, smb_fname->base_name, uid, gid); - result = ceph_lchown(handle->data, smb_fname->base_name, uid, gid); + + result = vfs_ceph_igetl(handle, smb_fname, &iref); + if (result != 0) { + goto out; + } + + result = vfs_ceph_ll_chown(handle, &iref, uid, gid); + vfs_ceph_iput(handle, &iref); +out: DBG_DEBUG("[CEPH] lchown(...) = %d\n", result); return status_code(result); }