summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKevin Greenan <kmgreen2@gmail.com>2015-01-08 12:15:19 -0800
committerKevin Greenan <kmgreen2@gmail.com>2015-01-19 10:15:17 -0800
commit4913e72f9991cf20c6bd92088348daea9874fe9e (patch)
tree5c137ce9aaf748d13060fb2948e2d74cb46523b7 /src
parent1c33592d2d5f93b72f61a1bea90ed0b32f978e9e (diff)
downloadpyeclib-4913e72f9991cf20c6bd92088348daea9874fe9e.tar.gz
Fix the checksum unit tests for crc32.
Diffstat (limited to 'src')
-rw-r--r--src/c/pyeclib_c/pyeclib_c.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/c/pyeclib_c/pyeclib_c.c b/src/c/pyeclib_c/pyeclib_c.c
index 2a34e06..444220b 100644
--- a/src/c/pyeclib_c/pyeclib_c.c
+++ b/src/c/pyeclib_c/pyeclib_c.c
@@ -882,7 +882,7 @@ pyeclib_c_get_metadata(PyObject *self, PyObject *args)
*
* @param pyeclib_obj_handle
* @param fragment_metadata_list list of fragment metadata headers
- * @return -1 if no errors, or the index of the first problem checksum
+ * @return -1 if no errors, -2 if stipe-level error, or the index of the first problem checksum
*/
static PyObject*
pyeclib_c_check_metadata(PyObject *self, PyObject *args)
@@ -890,6 +890,7 @@ pyeclib_c_check_metadata(PyObject *self, PyObject *args)
PyObject *pyeclib_obj_handle = NULL;
pyeclib_t *pyeclib_handle = NULL;
PyObject *fragment_metadata_list = NULL; /* param, fragment metadata */
+ fragment_metadata_t *c_fragment_metadata = NULL; /* metadata buffer for a single fragment */
char **c_fragment_metadata_list = NULL; /* c version of metadata */
int fragment_metadata_size; /* size of the metadata payload */
int num_fragments; /* k + m from EC algorithm */
@@ -933,7 +934,19 @@ pyeclib_c_check_metadata(PyObject *self, PyObject *args)
ret = liberasurecode_verify_stripe_metadata(pyeclib_handle->ec_desc, c_fragment_metadata_list,
num_fragments);
-
+
+ if (ret == -EINVALIDPARAMS || ret == 0) {
+ ret = -1;
+ } else if (ret == -EBADCHKSUM) {
+ for (i = 0; i < num_fragments; i++) {
+ c_fragment_metadata = (fragment_metadata_t*)c_fragment_metadata_list[i];
+ if (c_fragment_metadata->chksum_mismatch == 1) {
+ ret = c_fragment_metadata->idx;
+ break;
+ }
+ }
+ }
+
ret_obj = PyLong_FromLong((long)ret);
goto exit;