ocfs2-tools/0023-dx_dirs-check-callback-iter-dx_func-return-value-in-.patch

41 lines
1.3 KiB
Diff

From d4bbb81a8e6870155eb939a1f9d6def456fa3b91 Mon Sep 17 00:00:00 2001
From: Coly Li <coly.li@suse.de>
Date: Mon, 26 Apr 2010 22:35:02 +0800
Subject: [PATCH 23/30] dx_dirs: check callback iter->dx_func() return value in dx_iterator()
This patch makes dx_iterator() check returned value of callback
iter->dx_func(). If an error returned from the callback, dx_iterator()
returns OCFS2_EXTENT_ERROR to stop the iteration.
Thanks to Tao Ma for catching the error.
Signed-off-by: Coly Li <coly.li@suse.de>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Tao Ma <tao.ma@oracle.com>
---
libocfs2/dir_iterate.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/libocfs2/dir_iterate.c b/libocfs2/dir_iterate.c
index d044bb8..9f2ff7e 100644
--- a/libocfs2/dir_iterate.c
+++ b/libocfs2/dir_iterate.c
@@ -347,8 +347,13 @@ static int dx_iterator(ocfs2_filesys *fs,
}
dx_leaf = (struct ocfs2_dx_leaf *)iter->leaf_buf;
- iter->dx_func(fs, &dx_leaf->dl_list, iter->dx_root, dx_leaf,
+ err = iter->dx_func(fs, &dx_leaf->dl_list, iter->dx_root, dx_leaf,
iter->dx_priv_data);
+ /* callback dx_func() is defined by users, the return value does not
+ * follow libocfs2 error codes. Don't touch iter->err and just stop
+ * the iteration here.*/
+ if (err)
+ return OCFS2_EXTENT_ERROR;
blkno++;
}
--
1.7.0.2