Changeset 2971


Ignore:
Timestamp:
Mar 27, 2012, 12:45:33 PM (7 years ago)
Author:
bruno
Message:
  • Stores the UUID of MD devices into the generated raidtab, in order to allow fixing #596
Location:
branches/3.0/mondo/src/common
Files:
2 edited

Legend:

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

    r2970 r2971  
    30463046
    30473047    (void) fwrite((void *) &biggiestruct, 1, sizeof(biggiestruct), fout);
    3048     if (fout) {
     3048    if (fout != NULL) {
    30493049        paranoid_fclose(fout);
    30503050    }
  • branches/3.0/mondo/src/common/libmondo-raid.c

    r2869 r2971  
    980980  FILE   *fin;
    981981  int    res = 0, row, i, index_min;
     982  int v = 0;
    982983  int lastpos = 0;
    983984  size_t len = 0;
    984985  char   *token;
    985986  char *string = NULL;
     987  char *cmd = NULL;
    986988  char *pos;
    987989  char type;
     
    10071009    while (*pos == ' ') pos += 1;
    10081010    mr_asprintf(&strtmp, "%s", pos);
    1009     strcpy(string, strtmp);
    1010     paranoid_free(strtmp);
     1011    mr_free(string);
     1012    string = strtmp;
    10111013    // if we have newline after only spaces, this is a blank line, update
    10121014    // counters, otherwise do normal parsing
     
    10291031    mr_asprintf(&strtmp,"%s%s", device_prefix, token);
    10301032    strcpy(raidlist->el[raidlist->entries].raid_device, strtmp);
    1031     paranoid_free(strtmp);
     1033    mr_free(strtmp);
    10321034    mr_free(token);
     1035    // store the UUID value in the additional_vars structure
     1036    v = raidlist->el[raidlist->entries].additional_vars.entries;
     1037    strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].label, "UUID");
     1038    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    v++;
     1042    raidlist->el[raidlist->entries].additional_vars.entries = v;
    10331043    // skip ':' and status
    10341044    token = mr_strtok (string, delims, &lastpos);
     
    10381048      log_msg(1, "RAID device '%s' inactive.\n",
    10391049         raidlist->el[raidlist->entries].raid_device);
    1040       paranoid_free(string);
     1050      mr_free(string);
    10411051      mr_free(token);
    10421052      return 1;
     
    10691079    } else {
    10701080      log_msg(1, "Unknown RAID level '%s'.\n", token);
    1071       paranoid_free(string);
    1072       paranoid_free(token);
     1081      mr_free(string);
     1082      mr_free(token);
    10731083      return 1;
    10741084    }
     
    10931103        mr_asprintf(&strtmp,"%s%s", device_prefix, token);
    10941104        strcpy(raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].device, strtmp);
    1095         paranoid_free(strtmp);
     1105        mr_free(strtmp);
    10961106        raidlist->el[raidlist->entries].data_disks.entries++;
    10971107        break;
     
    11001110        mr_asprintf(&strtmp,"%s%s", device_prefix, token);
    11011111        strcpy(raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].device, strtmp);
    1102         paranoid_free(strtmp);
     1112        mr_free(strtmp);
    11031113        raidlist->el[raidlist->entries].spare_disks.entries++;
    11041114        break;
     
    11071117        mr_asprintf(&strtmp,"%s%s", device_prefix, token);
    11081118        strcpy(raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].device, strtmp);
    1109         paranoid_free(strtmp);
     1119        mr_free(strtmp);
    11101120        raidlist->el[raidlist->entries].failed_disks.entries++;
    11111121        log_it("At least one failed disk found in RAID array.\n");
     
    11131123      default: // error
    11141124        log_msg(1, "Unknown device type '%c'\n", type);
    1115         paranoid_free(string);
    1116         paranoid_free(token);
     1125        mr_free(string);
     1126        mr_free(token);
    11171127        return 1;
    11181128        break;
     
    11711181        if (pos < string) {
    11721182          log_it("String underflow!\n");
    1173           paranoid_free(string);
     1183          mr_free(string);
    11741184          return 1;
    11751185        }
     
    11961206        if (pos < string) {
    11971207          printf("ERROR: String underflow!\n");
    1198           paranoid_free(string);
     1208          mr_free(string);
    11991209          return 1;
    12001210        }
     
    12161226  fclose(fin);
    12171227  // free string
    1218   paranoid_free(string);
     1228  mr_free(string);
    12191229  // return success
    12201230  return 0;
Note: See TracChangeset for help on using the changeset viewer.