mirror of
https://github.com/samba-team/samba.git
synced 2025-02-03 13:47:25 +03:00
vfs_ceph_new: handle errno properly for 'readdir'
Take special care for readdir errno setting: in case of error, update errno by libcephfs (and protect from possible over-write by debug logging); in the case of successful result or end-of-stream restore errno to its previous value before calling the readdir_fn VFS hook. 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> Autobuild-User(master): Günther Deschner <gd@samba.org> Autobuild-Date(master): Wed Aug 7 14:20:02 UTC 2024 on atb-devel-224 (cherry picked from commit aa043a5808b73fc272de585c1446372fa3f21d08)
This commit is contained in:
parent
07f156d843
commit
ce958aeef1
@ -1482,19 +1482,20 @@ 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;
|
||||
int saved_errno = errno;
|
||||
|
||||
DBG_DEBUG("[CEPH] readdir(%p, %p)\n", handle, dirp);
|
||||
|
||||
errno = 0;
|
||||
result = vfs_ceph_ll_readdir(handle, dircfh);
|
||||
errval = errno;
|
||||
if ((result == NULL) && (errval != 0)) {
|
||||
DBG_DEBUG("[CEPH] readdir(...) = %d\n", errval);
|
||||
if ((result == NULL) && (errno != 0)) {
|
||||
saved_errno = errno;
|
||||
DBG_DEBUG("[CEPH] readdir(...) = %d\n", errno);
|
||||
} else {
|
||||
DBG_DEBUG("[CEPH] readdir(...) = %p\n", result);
|
||||
}
|
||||
/* re-assign errno to avoid possible over-write by DBG_DEBUG */
|
||||
errno = errval;
|
||||
|
||||
errno = saved_errno;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user