]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_ceph_new: proper error handling to readdir
authorShachar Sharon <ssharon@redhat.com>
Wed, 17 Jul 2024 08:41:13 +0000 (11:41 +0300)
committerGünther Deschner <gd@samba.org>
Mon, 29 Jul 2024 14:51:37 +0000 (14:51 +0000)
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 <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/modules/vfs_ceph_new.c

index 9259d597ffba7b4d84ef5adb603723921361f32a..e106a9bb4cb925ca97796666ec6c3480db9701e1 100644 (file)
@@ -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;
 }