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>
{
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;
}