Ignore:
Timestamp:
Apr 4, 2012, 2:27:02 PM (12 years ago)
Author:
Bruno Cornec
Message:

r4626@localhost: bruno | 2012-03-30 16:24:25 +0200

  • Handle the md version as an additional param in raidtab per device to solve various bug reports, including the previous one mentioned today. Doesn't still fully work, as not generating correctly the -e option, whereas the raidrec structure is correct
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0/mondo/src/common/libmondo-raid.c

    r2982 r2989  
    598598{
    599599    FILE *fin;
    600     char *tmp;
    601600    char *label;
    602601    char *value;
     
    604603    int v;
    605604
    606     malloc_string(tmp);
    607     malloc_string(label);
    608     malloc_string(value);
    609605    assert(raidlist != NULL);
    610606    assert_string_is_neither_NULL_nor_zerolength(fname);
     
    613609        log_it("Raidtab is very small or non-existent. Ignoring it.");
    614610        raidlist->entries = 0;
    615         paranoid_free(tmp);
    616         paranoid_free(label);
    617         paranoid_free(value);
    618611        return (0);
    619612    }
    620613    if (!(fin = fopen(fname, "r"))) {
    621614        log_it("Cannot open raidtab");
    622         paranoid_free(tmp);
    623         paranoid_free(label);
    624         paranoid_free(value);
    625615        return (1);
    626616    }
     617    malloc_string(label);
     618    malloc_string(value);
    627619    items = 0;
    628620    log_it("Loading raidtab...");
     
    636628            strcpy(raidlist->el[items].additional_vars.el[v].label, label);
    637629            strcpy(raidlist->el[items].additional_vars.el[v].value, value);
     630            log_msg(2,"Found raidtab entry Label: %s Value: %s",raidlist->el[items].additional_vars.el[v].label,raidlist->el[items].additional_vars.el[v].value);
    638631            v++;
    639632            get_next_raidtab_line(fin, label, value);
    640             log_it(tmp);
    641633        }
    642634        raidlist->el[items].additional_vars.entries = v;
     
    658650    log_msg(1, "Raidtab loaded successfully.");
    659651    log_msg(1, "%d RAID devices in raidtab", items);
    660     paranoid_free(tmp);
    661652    paranoid_free(label);
    662653    paranoid_free(value);
     
    710701            raidrec->raid_level = atoi(value);
    711702        }
     703        log_msg(4,"Found raid level %d",raidrec->raid_level);
    712704    } else if (!strcmp(label, "nr-raid-disks")) {   /* ignore it */
    713705    } else if (!strcmp(label, "nr-spare-disks")) {  /* ignore it */
     
    730722            log_msg(1, "Unknown RAID parity algorithm '%s'\n.", value);
    731723        }
     724        log_msg(4,"Found raid parity %d",raidrec->parity);
    732725    } else if (!strcmp(label, "device")) {
    733726        get_next_raidtab_line(fin, labelB, valueB);
     
    755748        strcpy(raidrec->additional_vars.el[v].label, label);
    756749        strcpy(raidrec->additional_vars.el[v].value, value);
    757         raidrec->additional_vars.entries = ++v;
     750        log_msg(4,"Found additional raid pair #%d: %s / %s",v,raidrec->additional_vars.el[v].label,raidrec->additional_vars.el[v].value);
     751        v++;
     752        raidrec->additional_vars.entries = v;
    758753    }
    759754    paranoid_free(labelB);
     
    10421037            strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].label, "UUID");
    10431038            mr_asprintf(&cmd,"mdadm --detail %s | grep UUID | cut -d: -f2- | sed 's/^ *//'", raidlist->el[raidlist->entries].raid_device);
     1039            mr_asprintf(&strtmp, "%s", call_program_and_get_last_line_of_output(cmd));
     1040            strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].value, strtmp);
     1041            mr_free(strtmp);
     1042            v++;
     1043            // store the Version value in the additional_vars structure
     1044            strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].label, "Version");
     1045            mr_asprintf(&cmd,"mdadm --detail %s | grep Version | cut -d: -f2- | sed 's/^ *//'", raidlist->el[raidlist->entries].raid_device);
    10441046            mr_asprintf(&strtmp, "%s", call_program_and_get_last_line_of_output(cmd));
    10451047            strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].value, strtmp);
Note: See TracChangeset for help on using the changeset viewer.