Changeset 2207 in MondoRescue


Ignore:
Timestamp:
May 15, 2009, 3:59:12 AM (15 years ago)
Author:
Bruno Cornec
Message:

-Preparation to integrate some stable functions

Location:
branches/2.2.9/mondo/src
Files:
1 deleted
1 edited

Legend:

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

    r2206 r2207  
    1010
    1111#include "my-stuff.h"
     12#include "mr_str.h"
    1213#include "mondostructures.h"
    1314#include "libmondo-mountlist.h"
     
    3738 * @param mountlist The mountlist to check.
    3839 * @param drive The drive to check (e.g. @c /dev/hda).
    39  * @param flaws_str Where to put the found flaws (human-readable).
    40  * @return The number of flaws found (0 for success).
     40 * @return The flaws string found (NULL for success) allocated to be freed
    4141 * @see evaluate_mountlist
    4242 */
    43 int evaluate_drive_within_mountlist(struct mountlist_itself *mountlist,
    44                                     char *drive, char *flaws_str)
     43char *evaluate_drive_within_mountlist(struct mountlist_itself *mountlist, char *drive)
    4544#ifdef __FreeBSD__
    4645{
     
    7170
    7271    /*@ initialize ***************************************************** */
    73     flaws_str[0] = '\0';
    7472    prev_part_no = 0;
    7573    tmp[0] = '\0';
     
    8078    if (physical_drive_size < 0) {
    8179        sprintf(tmp, " %s does not exist.", drive);
    82         strcat(flaws_str, tmp);
     80        asprintf(&flaws_str, "%s", tmp);
    8381    } else {
    8482        sprintf(tmp, "%s is %ld MB", drive, physical_drive_size);
     
    105103                sprintf(tmp, " Can only have up to 'h' in disklabel.");
    106104                log_it(tmp);
    107                 strcat(flaws_str, tmp);
     105                mr_strcat(flaws_str, tmp);
    108106                res++;
    109107            }
     
    120118                if (!strstr(flaws_str, tmp)) {
    121119                    log_it(tmp);
    122                     strcat(flaws_str, tmp);
     120                    mr_strcat(flaws_str, tmp);
    123121                    res++;
    124122                }
     
    129127                sprintf(tmp, " %s is tiny!", device);
    130128                log_it(tmp);
    131                 strcat(flaws_str, tmp);
     129                mr_strcat(flaws_str, tmp);
    132130                res++;
    133131            }
     
    141139                sprintf(tmp, " %s has a weird mountpoint.", device);
    142140                log_it(tmp);
    143                 strcat(flaws_str, tmp);
     141                mr_strcat(flaws_str, tmp);
    144142                res++;
    145143            }
     
    148146                sprintf(tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);
    149147                log_it(tmp);
    150                 strcat(flaws_str, tmp);
     148                mr_strcat(flaws_str, tmp);
    151149                res++;
    152150            }
     
    167165        }
    168166        if (((pos >= 0) || npos) && foundsome) {
    169             sprintf(flaws_str + strlen(flaws_str),
    170                     " %s has both DD and PC-style partitions.", drive);
     167            mr_strcat(flaws_str, " %s has both DD and PC-style partitions.", drive);
    171168            return ++res;       // fatal error
    172169        }
     
    180177                    sprintf(tmp, " Gap prior to %s.", device);
    181178                    log_it(tmp);
    182                     strcat(flaws_str, tmp);
     179                    mr_strcat(flaws_str, tmp);
    183180                    res++;
    184181                } else if (curr_part_no > 5
     
    187184                            prev_part_no, curr_part_no);
    188185                    log_it(tmp);
    189                     strcat(flaws_str, tmp);
     186                    mr_strcat(flaws_str, tmp);
    190187                    res++;
    191188                }
     
    198195                sprintf(tmp, " Partition %ss4 is occupied.", drive);
    199196                log_it(tmp);
    200                 strcat(flaws_str, tmp);
     197                mr_strcat(flaws_str, tmp);
    201198                res++;
    202199            }
     
    213210                if (!strstr(flaws_str, tmp)) {
    214211                    log_it(tmp);
    215                     strcat(flaws_str, tmp);
     212                    mr_strcat(flaws_str, tmp);
    216213                    res++;
    217214                }
     
    222219                sprintf(tmp, " %s is tiny!", device);
    223220                log_it(tmp);
    224                 strcat(flaws_str, tmp);
     221                mr_strcat(flaws_str, tmp);
    225222                res++;
    226223            }
     
    234231                sprintf(tmp, " %s has a weird mountpoint.", device);
    235232                log_it(tmp);
    236                 strcat(flaws_str, tmp);
     233                mr_strcat(flaws_str, tmp);
    237234                res++;
    238235            }
     
    241238                sprintf(tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);
    242239                log_it(tmp);
    243                 strcat(flaws_str, tmp);
     240                mr_strcat(flaws_str, tmp);
    244241                res++;
    245242            }
     
    257254                    sprintf(tmp, " Can only have up to 'h' in disklabel.");
    258255                    log_it(tmp);
    259                     strcat(flaws_str, tmp);
     256                    mr_strcat(flaws_str, tmp);
    260257                    res++;
    261258                }
     
    272269                    if (!strstr(flaws_str, tmp)) {
    273270                        log_it(tmp);
    274                         strcat(flaws_str, tmp);
     271                        mr_strcat(flaws_str, tmp);
    275272                        res++;
    276273                    }
     
    281278                    sprintf(tmp, " %s is tiny!", device);
    282279                    log_it(tmp);
    283                     strcat(flaws_str, tmp);
     280                    mr_strcat(flaws_str, tmp);
    284281                    res++;
    285282                }
     
    293290                    sprintf(tmp, " %s has a weird mountpoint.", device);
    294291                    log_it(tmp);
    295                     strcat(flaws_str, tmp);
     292                    mr_strcat(flaws_str, tmp);
    296293                    res++;
    297294                }
     
    301298                    sprintf(tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);
    302299                    log_it(tmp);
    303                     strcat(flaws_str, tmp);
     300                    mr_strcat(flaws_str, tmp);
    304301                    res++;
    305302                }
     
    320317                amount_allocated - physical_drive_size, drive);
    321318        log_it(tmp);
    322         strcat(flaws_str, tmp);
     319        mr_strcat(flaws_str, tmp);
    323320        res++;
    324321    } else if (amount_allocated < physical_drive_size - 1) {    /* NOT AN ERROR, JUST A WARNING :-) */
     
    326323                physical_drive_size - amount_allocated, drive);
    327324        log_it(tmp);
    328         strcat(flaws_str, tmp);
     325        mr_strcat(flaws_str, tmp);
    329326    }
    330327    if (res) {
     
    517514
    518515    drivelist = malloc(sizeof(struct list_of_disks));
    519     malloc_string(tmp);
    520516    malloc_string(flaws_str);
    521517    assert(mountlist != NULL);
     
    533529            (drivelist->el[i].device,
    534530             DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE)) {
    535             sprintf(tmp, " Not evaluating %s (I don't know how yet)",
     531            asprintf(&tmp, " Not evaluating %s (I don't know how yet)",
    536532                    drivelist->el[i].device);
    537533            log_it(tmp);
    538             tmp[0] = '\0';
     534            paranoid_free(tmp);
    539535        } else {
    540             if (!evaluate_drive_within_mountlist
    541                 (mountlist, drivelist->el[i].device, tmp)) {
    542                 res++;
    543             }
    544         }
    545         strcat(flaws_str, tmp);
     536            if ((tmp = evaluate_drive_within_mountlist(mountlist, drivelist->el[i].device)) == NULL) {
     537                res++;
     538            }
     539        }
     540        log_msg(8,"Entry: %d (%s)", i, drivelist->el[i].device);
     541        log_msg(8,"Adding: %s to %s", tmp, flaws_str);
     542        strncat(flaws_str, tmp, MAX_STR_LEN -1);
     543        paranoid_free(tmp);
    546544    }
    547545    res += look_for_duplicate_mountpoints(mountlist, flaws_str);
Note: See TracChangeset for help on using the changeset viewer.