Changeset 1176 in MondoRescue for trunk/mondo/src/common/libmondo-mountlist.c


Ignore:
Timestamp:
Feb 16, 2007, 2:16:14 PM (17 years ago)
Author:
Bruno Cornec
Message:

Some merges from stable (synchro for mem. mngt)

File:
1 edited

Legend:

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

    r1161 r1176  
    22   $Id$
    33*/
     4
    45
    56/**
     
    2122/*@unused@*/
    2223//static char cvsid[] = "$Id$";
    23 
    24 /**
    25  * A global copy of @c bkpinfo, to aid in debugging. As the name implies, <em>don't use this</em>.
    26  * @ingroup globalGroup
    27  */
    28 struct s_bkpinfo *g_bkpinfo_DONTUSETHIS = NULL;
    2924
    3025/**
     
    7772    /*@ initialize ***************************************************** */
    7873    prev_part_no = 0;
    79     // BERLIOS: tmp[0] = '\0';
    8074
    8175
     
    8377
    8478    if (physical_drive_size < 0) {
    85         mr_asprintf(&tmp, " %s does not exist.", drive);
     79        mr_asprintf(&tmp, "%s %s does not exist.", flaw_str, drive);
     80        mr_free(flaw_str);
    8681        flaws_str = tmp;
    8782    } else {
     
    225220            return ++res;       // fatal error
    226221        }
     222
     223        mr_asprintf(&device, "%ss%d", drive, curr_part_no);
    227224        // BERLIOS : useless ? mr_asprintf(&mountpoint, mountlist->el[pos].mountpoint);
    228225        if (pos > 0 && !npos) {
    229             mr_asprintf(&device, "%ss%d", drive, curr_part_no);
    230226            /* gap in the partition list? */
    231227            if (curr_part_no - prev_part_no > 1) {
     
    346342                res++;
    347343            }
    348             mr_free(device);
    349344        } else {
    350345            /* Check subpartitions */
    351346            for (cur_sp_no = 'a'; cur_sp_no < 'z'; ++cur_sp_no) {
    352                 mr_asprintf(&device, "%ss%d%c", drive, curr_part_no,
    353                          cur_sp_no);
     347                mr_asprintf(&device, "%ss%d%c", drive, curr_part_no, cur_sp_no);
    354348                pos = find_device_in_mountlist(mountlist, device);
    355349                if (pos < 0) {
     
    446440                amount_allocated += mountlist->el[pos].size / 1024;
    447441                prev_sp_no = cur_sp_no;
    448                 mr_free(device);
    449             }
    450         }
     442            }
     443        }
     444        mr_free(device);
    451445
    452446        /* OK, continue with main loop */
     
    482476        flaws_str = tmp1;
    483477        mr_free(tmp);
     478        /* BERLIOS: Flawed since rev 1 !! */
     479        res++;
    484480    }
    485481    if (res) {
     
    521517
    522518    prev_part_no = 0;
    523     // BERLIOS : useless ? tmp[0] = '\0';
    524 
    525519
    526520    physical_drive_size = get_phys_size_of_drive(drive);
     
    582576                       || (curr_part_no <= 4 && prev_part_no > 0)) {
    583577                mr_asprintf(&tmp, " Gap between %s%d and %d.", drive,
    584                          prev_part_no, curr_part_no);
     578                        prev_part_no, curr_part_no);
    585579                log_it(tmp);
    586580                if (flaws_str) {
     
    716710        flaws_str = tmp1;
    717711        mr_free(tmp);
     712        /* BERLIOS: Flawed since rev 1 !! - Is it sure ?? */
     713        res++;
    718714    }
    719715
     
    743739
    744740    /*@ buffer *********************************************************** */
    745     struct list_of_disks *drivelist;
    746     char *tmp;
    747     char *tmp1;
    748     char *flaws_str;
     741    struct list_of_disks *drivelist = NULL;
     742    char *tmp = NULL;
     743    char *tmp1 = NULL;
     744    char *flaws_str = NULL;
    749745
    750746    /*@ int ************************************************************** */
     
    856852            && strcmp(curr_mountpoint, "raid")) {
    857853            mr_asprintf(&tmp, " %s %s's.", number_to_text(copies),
    858                      curr_mountpoint);
     854                    curr_mountpoint);
    859855            log_it(tmp);
    860856            mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
     
    887883
    888884    /*@ buffers ********************************************************* */
    889     char *drive;
    890     char *tmp;
     885    char *drive = NULL;
    891886
    892887    long long size;
     
    899894        mr_asprintf(&drive, mountlist->el[lino].device);
    900895        if (!strncmp(drive, RAID_DEVICE_STUB, strlen(RAID_DEVICE_STUB))) {
    901             mr_asprintf(&tmp,
    902                      "Not putting %s in list of drives: it's a virtual drive",
    903                      drive);
    904             mr_msg(8, tmp);
    905             mr_free(tmp);
     896            mr_msg(8, "Not putting %s in list of drives: it's a virtual drive", drive);
    906897            continue;
    907898        }
     
    909900        size = mountlist->el[lino].size;
    910901        if (size == 0) {
    911             mr_asprintf(&tmp,
    912                      "Not putting %s in list of drives: it has zero size (maybe an LVM volume)",
    913                      drive);
    914             mr_msg(8, tmp);
    915             mr_free(tmp);
     902            mr_msg(8, "Not putting %s in list of drives: it has zero size (maybe an LVM volume)", drive);
    916903            continue;
    917904        }
    918905
    919 /*
    920       for (i = strlen (drive); isdigit (drive[i - 1]); i--);
    921       drive[i] = '\0';
    922       if (get_phys_size_of_drive (drive) <= 0 && drive[i - 1] == 'p')
    923     {
    924       i--;
    925       drive[i] = '\0';
    926     }
    927       for (j = 0; j < noof_drives && strcmp (drivelist[j], drive) != 0; j++);
    928 */
    929 
    930         mr_asprintf(&tmp,
    931                  "Putting %s with size %lli in list of drives",
    932                  drive, size);
    933         mr_msg(8, tmp);
    934         mr_free(tmp);
     906        mr_msg(8, "Putting %s with size %lli in list of drives", drive, size);
    935907
    936908        (void) truncate_to_drive_name(drive);
     
    960932 */
    961933void make_list_of_unallocated_raid_partitions(struct mountlist_itself
    962                                               *output_list, struct mountlist_itself
    963                                               *mountlist, struct raidlist_itself
     934                                              *output_list,
     935                                              struct mountlist_itself
     936                                              *mountlist,
     937                                              struct raidlist_itself
    964938                                              *raidlist)
    965939{
     
    971945
    972946    /*@ buffers ********************************************************* */
    973     char *tmp;
     947    char *tmp = NULL;
    974948
    975949    assert(output_list != NULL);
     
    10431017int load_mountlist(struct mountlist_itself *mountlist, char *fname)
    10441018{
    1045     FILE *fin;
     1019    FILE *fin = NULL;
    10461020    /* malloc ** */
    10471021    char *incoming = NULL;
    1048     char *siz;
    1049     char *tmp;
    1050     char *p;
    1051 
    1052     int items;
    1053     int j;
     1022    char *siz = NULL;
     1023    char *tmp = NULL;
     1024    char *p = NULL;
     1025
     1026    int items = 0;
     1027    int j = 0;
    10541028    size_t n = 0;
    10551029
    10561030    assert(mountlist != NULL);
    10571031    assert_string_is_neither_NULL_nor_zerolength(fname);
    1058     malloc_string(siz);
     1032
    10591033    if (!(fin = fopen(fname, "r"))) {
    10601034        log_it("Unable to open mountlist - '%s'", fname);
    10611035        log_to_screen(_("Cannot open mountlist"));
    1062         mr_free(siz);
    10631036        return (1);
    10641037    }
    1065     items = 0;
     1038    malloc_string(siz);
    10661039    mr_getline(&incoming, &n, fin);
    10671040    log_it("Loading mountlist...");
     
    11301103            mr_free(tmp);
    11311104
    1132             mr_asprintf(&tmp,
    1133                      "%s %s %s %lld %s",
     1105            log_it("%s %s %s %lld %s",
    11341106                     mountlist->el[items].device,
    11351107                     mountlist->el[items].mountpoint,
     
    11371109                     mountlist->el[items].size,
    11381110                     mountlist->el[items].label);
    1139 
    1140             log_it(tmp);
    1141             mr_free(tmp);
    11421111            items++;
    11431112        }
     
    11491118
    11501119    log_it("Mountlist loaded successfully.");
    1151     mr_asprintf(&tmp, "%d entries in mountlist", items);
    1152     log_it(tmp);
    1153     mr_free(tmp);
     1120    log_it("%d entries in mountlist", items);
    11541121
    11551122    mr_free(siz);
    11561123    return (0);
    11571124}
    1158 
    11591125
    11601126
     
    12561222{
    12571223    /*@ mallocs *** */
    1258     char *device;
    1259     char *mountpoint;
    1260     char *format;
     1224    char *device = NULL;
     1225    char *mountpoint = NULL;
     1226    char *format = NULL;
    12611227
    12621228    long long size;
     
    12831249
    12841250    mountlist->el[b].size = size;
     1251    mr_free(device);
     1252    mr_free(mountpoint);
     1253    mr_free(format);
    12851254}
    12861255
Note: See TracChangeset for help on using the changeset viewer.