-/*
- * Remove CHUNK entries from dumps that ultimately failed from our report.
- */
-void strip_failed_chunks(
- find_result_t **output_find)
-{
- find_result_t *cur, *prev = NULL, *failed = NULL, *failures = NULL;
-
- /* Generate a list of failures */
- for(cur=*output_find; cur; cur=cur->next) {
- if(!cur->hostname || !cur->diskname ||
- !cur->timestamp || !cur->label)
- continue;
-
- if(strcmp(cur->status, "OK")){
- failed = alloc(SIZEOF(find_result_t));
- memcpy(failed, cur, SIZEOF(find_result_t));
- failed->next = failures;
- failures = failed;
- }
- }
-
- /* Now if a CHUNK matches the parameters of a failed dump, remove it */
- for(failed=failures; failed; failed=failed->next) {
- prev = NULL;
- cur = *output_find;
- while (cur != NULL) {
- find_result_t *next = cur->next;
- if(!cur->hostname || !cur->diskname ||
- !cur->timestamp || !cur->label || !cur->partnum ||
- !strcmp(cur->partnum, "--") || strcmp(cur->status, "OK")) {
- prev = cur;
- cur = next;
- }
- else if(!strcmp(cur->hostname, failed->hostname) &&
- !strcmp(cur->diskname, failed->diskname) &&
- !strcmp(cur->timestamp, failed->timestamp) &&
- !strcmp(cur->label, failed->label) &&
- cur->level == failed->level){
- amfree(cur->diskname);
- amfree(cur->hostname);
- amfree(cur->label);
- amfree(cur->timestamp);
- amfree(cur->partnum);
- amfree(cur->status);
- cur = next;
- if (prev) {
- amfree(prev->next);
- prev->next = next;
- } else {
- amfree(*output_find);
- *output_find = next;
- }
- }
- else {
- prev = cur;
- cur = next;
- }
-
- }
- }
-
- for(failed=failures; failed;) {
- find_result_t *fai = failed->next;
- fai = failed->next;
- amfree(failed);
- failed=fai;
- }
-}
-