Ignore:
Timestamp:
Aug 18, 2009, 3:05:43 PM (15 years ago)
Author:
Bruno Cornec
Message:

r3334@localhost: bruno | 2009-08-08 12:17:37 +0200

  • Change mr_asprintf interface to pass only the char * (makes bkpinfo usage more easy)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/common/libmondo-mountlist.c

    r2316 r2323  
    7373    /*@ initialize ***************************************************** */
    7474    prev_part_no = 0;
    75     mr_asprintf(&flaws_str, "%s", "");
     75    mr_asprintf(flaws_str, "%s", "");
    7676
    7777
     
    7979
    8080    if (physical_drive_size < 0) {
    81         mr_asprintf(&tmp, " %s does not exist.", drive);
     81        mr_asprintf(tmp, " %s does not exist.", drive);
    8282        mr_strcat(flaws_str, "%s", tmp);
    8383    } else {
    84         mr_asprintf(&tmp, "%s is %ld MB", drive, physical_drive_size);
     84        mr_asprintf(tmp, "%s is %ld MB", drive, physical_drive_size);
    8585    }
    8686    log_it(tmp);
     
    9090    /* check DD */
    9191    for (cur_sp_no = 'a'; cur_sp_no < 'z'; ++cur_sp_no) {
    92         mr_asprintf(&device, "%s%c", drive, cur_sp_no);
     92        mr_asprintf(device, "%s%c", drive, cur_sp_no);
    9393        if (find_device_in_mountlist(mountlist, device) >= 0) {
    9494            foundsome = TRUE;
     
    9898    if (foundsome) {
    9999        for (cur_sp_no = 'a'; cur_sp_no < 'z'; ++cur_sp_no) {
    100             mr_asprintf(&device, "%s%c", drive, cur_sp_no);
     100            mr_asprintf(device, "%s%c", drive, cur_sp_no);
    101101            pos = find_device_in_mountlist(mountlist, device);
    102102            if (pos < 0) {
     
    107107            /* is it too big? */
    108108            if (curr_part_no > 'h') {
    109                 mr_asprintf(&tmp, " Can only have up to 'h' in disklabel.");
     109                mr_asprintf(tmp, " Can only have up to 'h' in disklabel.");
    110110                log_it(tmp);
    111111                mr_strcat(flaws_str, tmp);
     
    121121            }
    122122            if (device_copies > 1) {
    123                 mr_asprintf(&tmp, " %s %s's.", number_to_text(device_copies), device);
     123                mr_asprintf(tmp, " %s %s's.", number_to_text(device_copies), device);
    124124                if (!strstr(flaws_str, tmp)) {
    125125                    log_it(tmp);
     
    132132            if (mountlist->el[pos].size < 8192
    133133                && strcmp(mountlist->el[pos].mountpoint, "lvm")) {
    134                 mr_asprintf(&tmp, " %s is tiny!", device);
     134                mr_asprintf(tmp, " %s is tiny!", device);
    135135                log_it(tmp);
    136136                mr_strcat(flaws_str, tmp);
     
    145145                && strcmp(mountlist->el[pos].mountpoint, "none")
    146146                && mountlist->el[pos].mountpoint[0] != '/') {
    147                 mr_asprintf(&tmp, " %s has a weird mountpoint.", device);
     147                mr_asprintf(tmp, " %s has a weird mountpoint.", device);
    148148                log_it(tmp);
    149149                mr_strcat(flaws_str, tmp);
     
    153153            /* is format sensible? */
    154154            if (!is_this_a_valid_disk_format(mountlist->el[pos].format)) {
    155                 mr_asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);
     155                mr_asprintf(tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);
    156156                log_it(tmp);
    157157                mr_strcat(flaws_str, tmp);
     
    172172        npos = 0;
    173173        for (cur_sp_no = 'a'; cur_sp_no <= 'h'; cur_sp_no++) {
    174             mr_asprintf(&tmp, "%ss%i%c", device, curr_part_no, cur_sp_no);
     174            mr_asprintf(tmp, "%ss%i%c", device, curr_part_no, cur_sp_no);
    175175            if (find_device_in_mountlist(mountlist, tmp) >= 0) {
    176176                npos++;
     
    191191            if (curr_part_no - prev_part_no > 1) {
    192192                if (prev_part_no == 0) {
    193                     mr_asprintf(&tmp, " Gap prior to %s.", device);
     193                    mr_asprintf(tmp, " Gap prior to %s.", device);
    194194                    log_it(tmp);
    195195                    mr_strcat(flaws_str, "%s", tmp);
     
    198198                } else if (curr_part_no > 5
    199199                           || (curr_part_no <= 4 && prev_part_no > 0)) {
    200                     mr_asprintf(&tmp, " Gap between %ss%d and %d.", drive, prev_part_no, curr_part_no);
     200                    mr_asprintf(tmp, " Gap between %ss%d and %d.", drive, prev_part_no, curr_part_no);
    201201                    log_it(tmp);
    202202                    mr_strcat(flaws_str, "%s", tmp);
     
    210210            if ((curr_part_no >= 5 && prev_part_no == 4)
    211211                && (strcmp(part_table_fmt, "MBR") == 0)) {
    212                 mr_asprintf(&tmp, " Partition %ss4 is occupied.", drive);
     212                mr_asprintf(tmp, " Partition %ss4 is occupied.", drive);
    213213                log_it(tmp);
    214214                mr_strcat(flaws_str, "%s", tmp);
     
    224224            }
    225225            if (device_copies > 1) {
    226                 mr_asprintf(&tmp, " %s %s's.", number_to_text(device_copies), device);
     226                mr_asprintf(tmp, " %s %s's.", number_to_text(device_copies), device);
    227227                if (!strstr(flaws_str, "%s", tmp)) {
    228228                    log_it(tmp);
     
    235235            if (mountlist->el[pos].size < 8192
    236236                && strcmp(mountlist->el[pos].mountpoint, "lvm")) {
    237                 mr_asprintf(&tmp, " %s is tiny!", device);
     237                mr_asprintf(tmp, " %s is tiny!", device);
    238238                log_it(tmp);
    239239                mr_strcat(flaws_str, "%s", tmp);
     
    248248                && strcmp(mountlist->el[pos].mountpoint, "none")
    249249                && mountlist->el[pos].mountpoint[0] != '/') {
    250                 mr_asprintf(&tmp, " %s has a weird mountpoint.", device);
     250                mr_asprintf(tmp, " %s has a weird mountpoint.", device);
    251251                log_it(tmp);
    252252                mr_strcat(flaws_str, "%s", tmp);
     
    256256            /* is format sensible? */
    257257            if (!is_this_a_valid_disk_format(mountlist->el[pos].format)) {
    258                 mr_asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);
     258                mr_asprintf(tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);
    259259                log_it(tmp);
    260260                mr_strcat(flaws_str, "%s", tmp);
     
    274274                /* is it too big? */
    275275                if (curr_part_no > 'h') {
    276                     mr_asprintf(&tmp, " Can only have up to 'h' in disklabel.");
     276                    mr_asprintf(tmp, " Can only have up to 'h' in disklabel.");
    277277                    log_it(tmp);
    278278                    mr_strcat(flaws_str, "%s", tmp);
     
    288288                }
    289289                if (device_copies > 1) {
    290                     mr_asprintf(&tmp, " %s %s's.", number_to_text(device_copies), device);
     290                    mr_asprintf(tmp, " %s %s's.", number_to_text(device_copies), device);
    291291                    if (!strstr(flaws_str, tmp)) {
    292292                        log_it(tmp);
     
    299299                if (mountlist->el[pos].size < 8192
    300300                    && strcmp(mountlist->el[pos].mountpoint, "lvm")) {
    301                     mr_asprintf(&tmp, " %s is tiny!", device);
     301                    mr_asprintf(tmp, " %s is tiny!", device);
    302302                    log_it(tmp);
    303303                    mr_strcat(flaws_str, "%s", tmp);
     
    312312                    && strcmp(mountlist->el[pos].mountpoint, "none")
    313313                    && mountlist->el[pos].mountpoint[0] != '/') {
    314                     mr_asprintf(&tmp, " %s has a weird mountpoint.", device);
     314                    mr_asprintf(tmp, " %s has a weird mountpoint.", device);
    315315                    log_it(tmp);
    316316                    mr_strcat(flaws_str, "%s", tmp);
     
    321321                if (!is_this_a_valid_disk_format
    322322                    (mountlist->el[pos].format)) {
    323                     mr_asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);
     323                    mr_asprintf(tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);
    324324                    log_it(tmp);
    325325                    mr_strcat(flaws_str, "%s", tmp);
     
    341341    if (amount_allocated > physical_drive_size) // Used to be +1, but what if you're 1 MB too high?
    342342    {
    343         mr_asprintf(&tmp, " %ld MB over-allocated on %s.",
     343        mr_asprintf(tmp, " %ld MB over-allocated on %s.",
    344344                amount_allocated - physical_drive_size, drive);
    345345        log_it(tmp);
     
    348348        res++;
    349349    } else if (amount_allocated < physical_drive_size - 1) {    /* NOT AN ERROR, JUST A WARNING :-) */
    350         mr_asprintf(&tmp, " %ld MB unallocated on %s.",
     350        mr_asprintf(tmp, " %ld MB unallocated on %s.",
    351351                physical_drive_size - amount_allocated, drive);
    352352        log_it(tmp);
     
    389389    assert_string_is_neither_NULL_nor_zerolength(drive);
    390390    assert(mountlist != NULL);
    391     mr_asprintf(&flaws_str, "%s", "");
     391    mr_asprintf(flaws_str, "%s", "");
    392392
    393393    prev_part_no = 0;
     
    396396
    397397    if (physical_drive_size < 0) {
    398         mr_asprintf(&tmp, " %s does not exist.", drive);
     398        mr_asprintf(tmp, " %s does not exist.", drive);
    399399        mr_strcat(flaws_str, "%s", tmp);
    400400        res++;
     
    403403        return(flaws_str);
    404404    } else {
    405         mr_asprintf(&tmp, "%s is %ld MB", drive, physical_drive_size);
     405        mr_asprintf(tmp, "%s is %ld MB", drive, physical_drive_size);
    406406        log_it(tmp);
    407407        mr_free(tmp);
     
    417417        if (curr_part_no - prev_part_no > 1) {
    418418            if (prev_part_no == 0) {
    419                 mr_asprintf(&tmp, " Gap prior to %s.", device);
     419                mr_asprintf(tmp, " Gap prior to %s.", device);
    420420                log_it(tmp);
    421421                mr_strcat(flaws_str, "%s", tmp);
     
    424424            } else if (curr_part_no > 5
    425425                       || (curr_part_no <= 4 && prev_part_no > 0)) {
    426                 mr_asprintf(&tmp, " Gap on %s between %d and %d.", drive,
     426                mr_asprintf(tmp, " Gap on %s between %d and %d.", drive,
    427427                        prev_part_no, curr_part_no);
    428428                log_it(tmp);
     
    437437        if ((curr_part_no >= 5 && prev_part_no == 4)
    438438            && (strcmp(part_table_fmt, "MBR") == 0)) {
    439             mr_asprintf(&tmp, " Partition 4 of %s is occupied.", drive);
     439            mr_asprintf(tmp, " Partition 4 of %s is occupied.", drive);
    440440            log_it(tmp);
    441441            mr_strcat(flaws_str, "%s", tmp);
     
    451451        }
    452452        if (device_copies > 1) {
    453             mr_asprintf(&tmp, " %s %s's.", number_to_text(device_copies), device);
     453            mr_asprintf(tmp, " %s %s's.", number_to_text(device_copies), device);
    454454            if (!strstr(flaws_str, tmp)) {
    455455                log_it(tmp);
     
    462462        if (mountlist->el[pos].size < 8192
    463463            && strcmp(mountlist->el[pos].mountpoint, "lvm")) {
    464             mr_asprintf(&tmp, " %s is tiny!", device);
     464            mr_asprintf(tmp, " %s is tiny!", device);
    465465            log_it(tmp);
    466466            mr_strcat(flaws_str, "%s", tmp);
     
    474474            && strcmp(mountlist->el[pos].mountpoint, "image")
    475475            && mountlist->el[pos].mountpoint[0] != '/') {
    476             mr_asprintf(&tmp, " %s has a weird mountpoint.", device);
     476            mr_asprintf(tmp, " %s has a weird mountpoint.", device);
    477477            log_it(tmp);
    478478            mr_strcat(flaws_str, "%s", tmp);
     
    482482        /* is format sensible? */
    483483        if (!is_this_a_valid_disk_format(mountlist->el[pos].format)) {
    484             mr_asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);
     484            mr_asprintf(tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);
    485485            log_it(tmp);
    486486            mr_strcat(flaws_str, "%s", tmp);
     
    496496    /* Over-allocated the disk? Unallocated space on disk? */
    497497    if (amount_allocated > physical_drive_size + 1) {
    498         mr_asprintf(&tmp, " %ld MB over-allocated on %s.",
     498        mr_asprintf(tmp, " %ld MB over-allocated on %s.",
    499499                amount_allocated - physical_drive_size, drive);
    500500        log_it(tmp);
     
    503503        res++;
    504504    } else if (amount_allocated < physical_drive_size - 1) {    /* NOT AN ERROR, JUST A WARNING :-) */
    505         mr_asprintf(&tmp, " %ld MB unallocated on %s.",
     505        mr_asprintf(tmp, " %ld MB unallocated on %s.",
    506506                physical_drive_size - amount_allocated, drive);
    507507        log_it(tmp);
     
    551551    assert(flaws_str_C != NULL);
    552552
    553     mr_asprintf(&flaws_str, "%s", "");
     553    mr_asprintf(flaws_str, "%s", "");
    554554
    555555    make_list_of_drives_in_mountlist(mountlist, drivelist);
     
    561561            (drivelist->el[i].device,
    562562             DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE)) {
    563             mr_asprintf(&tmp, " Not evaluating %s (I don't know how yet)", drivelist->el[i].device);
     563            mr_asprintf(tmp, " Not evaluating %s (I don't know how yet)", drivelist->el[i].device);
    564564            log_it(tmp);
    565565            paranoid_free(tmp);
     
    639639
    640640    for (currline = 0; currline < mountlist->entries; currline++) {
    641         mr_asprintf(&curr_mountpoint, "%s", mountlist->el[currline].mountpoint);
     641        mr_asprintf(curr_mountpoint, "%s", mountlist->el[currline].mountpoint);
    642642        for (i = 0, copies = 0, last_copy = -1; i < mountlist->entries;
    643643             i++) {
     
    651651        if (copies > 1 && last_copy == currline
    652652            && strcmp(curr_mountpoint, "raid")) {
    653             mr_asprintf(&tmp, " %s %s's.", number_to_text(copies), curr_mountpoint);
     653            mr_asprintf(tmp, " %s %s's.", number_to_text(copies), curr_mountpoint);
    654654            mr_strcat(flaws_str, "%s", tmp);
    655655            log_it(tmp);
     
    690690    for (lino = 0, noof_drives = 0; lino < mountlist->entries; lino++) {
    691691
    692         mr_asprintf(&drive, "%s", mountlist->el[lino].device);
     692        mr_asprintf(drive, "%s", mountlist->el[lino].device);
    693693        if (!strncmp(drive, RAID_DEVICE_STUB, strlen(RAID_DEVICE_STUB))) {
    694694            log_msg(8, "Not putting %s in list of drives: it's a virtual drive", drive);
     
    777777                       (void *) &mountlist->el[i],
    778778                       sizeof(struct mountlist_line));
    779                 mr_asprintf(&tmp, "%s is available; user may choose to add it to raid device", output_list->el[items - 1].device);
     779                mr_asprintf(tmp, "%s is available; user may choose to add it to raid device", output_list->el[items - 1].device);
    780780                log_it(tmp);
    781781                paranoid_free(tmp);
     
    895895            if (j < items) {
    896896                strcat(mountlist->el[items].device, "_dup");
    897                 mr_asprintf(&tmp, "Duplicate entry in mountlist - renaming to %s", mountlist->el[items].device);
     897                mr_asprintf(tmp, "Duplicate entry in mountlist - renaming to %s", mountlist->el[items].device);
    898898                log_it(tmp);
    899899                paranoid_free(tmp);
    900900            }
    901             mr_asprintf(&tmp, "%s", mountlist->el[items].device);
     901            mr_asprintf(tmp, "%s", mountlist->el[items].device);
    902902            if (strstr(tmp, "/dev/md/")) {
    903903                log_it("format_device() --- Contracting %s", tmp);
     
    10481048    assert(b >= 0);
    10491049
    1050     mr_asprintf(&device, "%s", mountlist->el[a].device);
    1051     mr_asprintf(&mountpoint, "%s", mountlist->el[a].mountpoint);
    1052     mr_asprintf(&format, "%s", mountlist->el[a].format);
     1050    mr_asprintf(device, "%s", mountlist->el[a].device);
     1051    mr_asprintf(mountpoint, "%s", mountlist->el[a].mountpoint);
     1052    mr_asprintf(format, "%s", mountlist->el[a].format);
    10531053
    10541054    size = mountlist->el[a].size;
Note: See TracChangeset for help on using the changeset viewer.