From: Shachar Sharon Date: Wed, 17 Jul 2024 08:41:13 +0000 (+0300) Subject: vfs_ceph_new: proper error handling to readdir X-Git-Tag: tdb-1.4.12~69 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=24a3423949e127177c019a0d126c6f7523e61984;p=thirdparty%2Fsamba.git vfs_ceph_new: proper error handling to readdir Error handling in the case of 'ceph_readdir' is done by setting 'errno' deep within libcephfs code. In case of error, emit proper debug message and re-update errno to avoid possible over-write by logging mechanism. 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 9259d597ffb..e106a9bb4cb 100644 --- a/source3/modules/vfs_ceph_new.c +++ b/source3/modules/vfs_ceph_new.c @@ -985,11 +985,19 @@ static struct dirent *vfs_ceph_readdir(struct vfs_handle_struct *handle, { const struct vfs_ceph_fh *dircfh = (const struct vfs_ceph_fh *)dirp; struct dirent *result = NULL; + int errval = 0; DBG_DEBUG("[CEPH] readdir(%p, %p)\n", handle, dirp); + errno = 0; result = vfs_ceph_ll_readdir(handle, dircfh); - DBG_DEBUG("[CEPH] readdir(...) = %p\n", result); - + errval = errno; + if ((result == NULL) && (errval != 0)) { + DBG_DEBUG("[CEPH] readdir(...) = %d\n", errval); + } else { + DBG_DEBUG("[CEPH] readdir(...) = %p\n", result); + } + /* re-assign errno to avoid possible over-write by DBG_DEBUG */ + errno = errval; return result; }