Changeset 689 in MondoRescue for trunk/mondo/mondo/common


Ignore:
Timestamp:
Jul 17, 2006, 7:43:58 PM (18 years ago)
Author:
bcornec
Message:

Still other memory management improvements ( I hope :-)

Location:
trunk/mondo/mondo/common
Files:
8 edited

Legend:

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

    r688 r689  
    433433    if (bkpinfo->backup_media_type == dvd) {
    434434#ifdef DVDRWFORMAT
    435         if (!find_home_of_exe("dvd+rw-format")) {
     435        tmp = find_home_of_exe("dvd+rw-format");
     436        if (!tmp) {
    436437            fatal_error
    437438                ("Cannot find dvd+rw-format. Please install it or fix your PATH.");
    438439        }
     440        paranoid_free(tmp);
    439441#endif
    440         if (!find_home_of_exe("growisofs")) {
     442        tmp = find_home_of_exe("growisofs");
     443        if (!tmp) {
    441444            fatal_error
    442445                ("Cannot find growisofs. Please install it or fix your PATH.");
    443446        }
     447        paranoid_free(tmp);
    444448    }
    445449
     
    30563060                "Not calculating checksum for %s: it would take too long",
    30573061                biggie_filename);
    3058         if ( !find_home_of_exe("ntfsresize")) {
     3062        tmp = find_home_of_exe("ntfsresize");
     3063        if ( !tmp) {
    30593064            fatal_error("ntfsresize not found");
    30603065        }
    3061         sprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename);
     3066        paranoid_free(tmp);
     3067
     3068        asprintf(&command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename);
    30623069        log_it("command = %s", command);
    30633070        tmp = call_program_and_get_last_line_of_output(command);
     3071        paranoid_free(command);
     3072
    30643073        log_it("res of it = %s", tmp);
    30653074        totallength = (off_t)atoll(tmp);
  • trunk/mondo/mondo/common/libmondo-devices.c

    r688 r689  
    495495char *find_cdrw_device(void)
    496496{
    497     /*@ buffers ************************ */
    498     char *comment;
    499     char *tmp;
    500     char *cdr_exe;
    501     char *command;
    502     char *cdrw_device;
     497    char *comment = NULL;
     498    char *tmp = NULL;
     499    char *tmp1 = NULL;
     500    char *cdr_exe = NULL;
     501    char *command = NULL;
     502    char *cdrw_device = NULL;
    503503
    504504    if (g_cdrw_drive_is_here != NULL) {
     
    513513    }
    514514    run_program_and_log_output("insmod ide-scsi", -1);
    515     if (find_home_of_exe("cdrecord")) {
     515    tmp = find_home_of_exe("cdrecord");
     516    if (tmp) {
    516517        asprintf(&cdr_exe, "cdrecord");
    517518    } else {
    518519        asprintf(&cdr_exe, "dvdrecord");
    519520    }
    520     if (find_home_of_exe(cdr_exe)) {
     521    paranoid_free(tmp);
     522
     523    tmp1 = find_home_of_exe(cdr_exe);
     524    if (tmp1) {
    521525        asprintf(&command,
    522526                "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep CD | cut -d' ' -f2 | head -n1",
     
    527531        asprintf(&tmp, " ");
    528532    }
     533    paranoid_free(tmp1);
    529534    paranoid_free(cdr_exe);
    530535
     
    594599    }
    595600
    596     if (find_home_of_exe("cdrecord")) {
     601    tmp = find_home_of_exe("cdrecord");
     602    if (tmp) {
    597603        asprintf(&cdr_exe, "cdrecord");
    598604    } else {
    599605        asprintf(&cdr_exe, "dvdrecord");
    600606    }
    601     if (!find_home_of_exe(cdr_exe)) {
     607    paranoid_free(tmp);
     608
     609    tmp = find_home_of_exe(cdr_exe);
     610    if (!tmp) {
    602611        asprintf(&output, "/dev/cdrom");
    603612        log_msg(4, "Can't find cdrecord; assuming %s", output);
     
    612621        }
    613622    }
     623    paranoid_free(tmp);
    614624
    615625    asprintf(&command, "%s -scanbus 2> /dev/null", cdr_exe);
  • trunk/mondo/mondo/common/libmondo-filelist.c

    r688 r689  
    479479int get_acl_list(char *filelist, char *facl_fname)
    480480{
    481     char *command;
     481    char *command = NULL;
     482    char *tmp = NULL;
    482483    int retval = 0;
    483484
     
    486487    paranoid_free(command);
    487488
    488     if (find_home_of_exe("getfacl")) {
     489    tmp = find_home_of_exe("getfacl");
     490    if (tmp) {
    489491//      sort_file(filelist); // FIXME - filelist chopper sorts, so this isn't necessary
    490492        asprintf(&command,
     
    495497        paranoid_free(command);
    496498    }
     499    paranoid_free(tmp);
    497500    return (retval);
    498501}
     
    501504int get_fattr_list(char *filelist, char *fattr_fname)
    502505{
    503     char *command;
     506    char *command = NULL;
     507    char *tmp = NULL;
    504508    int retval = 0;
    505509
     
    508512    paranoid_free(command);
    509513
    510     if (find_home_of_exe("getfattr")) {
     514    tmp = find_home_of_exe("getfattr");
     515    if (tmp) {
    511516//      sort_file(filelist); // FIXME - filelist chopper sorts, so this isn't necessary
    512517        retval =
     
    514519                         fattr_fname);
    515520    }
     521    paranoid_free(tmp);
    516522    return (retval);
    517523}
  • trunk/mondo/mondo/common/libmondo-files.c

    r688 r689  
    738738            if (0 == strncmp(fname, "/dev/", 5)) {
    739739                if (is_dev_an_NTFS_dev(fname)) {
    740                     if ( !find_home_of_exe("ntfsresize")) {
     740                    tmp = find_home_of_exe("ntfsresize");
     741                    if (!tmp) {
    741742                        fatal_error("ntfsresize not found");
    742743                    }
     744                    paranoid_free(tmp);
     745
    743746                    asprintf(&command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", fname);
    744747                    log_it("command = %s", command);
  • trunk/mondo/mondo/common/libmondo-fork.c

    r688 r689  
    510510// BACKUP
    511511    int res = -1;
    512     char*command;
     512    char *command = NULL;
     513    char *tmp = NULL;
    513514
    514515    if (!does_file_exist(input_device)) {
    515516        fatal_error("input device does not exist");
    516517    }
    517     if ( !find_home_of_exe("ntfsclone")) {
     518    tmp = find_home_of_exe("ntfsclone");
     519    if (!tmp) {
    518520        fatal_error("ntfsclone not found");
    519521    }
    520     malloc_string(command);
    521     sprintf(command, "ntfsclone --force --save-image --overwrite %s %s", output_fname, input_device);
     522    paranoid_free(tmp);
     523
     524    asprintf(&command, "ntfsclone --force --save-image --overwrite %s %s", output_fname, input_device);
    522525    res = run_program_and_log_output(command, 5);
    523526    paranoid_free(command);
     527
    524528    unlink(output_fname);
    525529    return (res);
     
    678682// RESTORE
    679683    int res = -1;
    680     char *command;
    681 
    682     if ( !find_home_of_exe("ntfsclone")) {
     684    char *command = NULL;
     685    char *tmp = NULL;
     686
     687    tmp = find_home_of_exe("ntfsclone");
     688    if (!tmp) {
    683689        fatal_error("ntfsclone not found");
    684690    }
     691    paranoid_free(tmp);
     692
    685693    asprintf(&command, "ntfsclone --force --restore-image --overwrite %s %s", output_device, input_fifo);
    686694    res = run_program_and_log_output(command, 5);
  • trunk/mondo/mondo/common/libmondo-raid.c

    r688 r689  
    403403 * @return 0 if the line was read and stored successfully, 1 if we're at end of file.
    404404 */
    405 int get_next_raidtab_line(FILE * fin, char *label, char *value)
     405int get_next_raidtab_line(FILE *fin, char *label, char *value)
    406406{
    407407    char *incoming = NULL;
    408     char *p;
     408    char *p = NULL;
    409409    size_t n = 0;
    410410
    411411    assert(fin != NULL);
    412     assert(label != NULL);
    413     assert(value != NULL);
    414 
    415     label[0] = value[0] = '\0';
     412
    416413    if (feof(fin)) {
    417414        return (1);
     
    429426            p++;
    430427        }
    431         strcpy(label, incoming);
    432         strcpy(value, p);
    433         paranoid_free(incoming);
     428        label = incoming;
     429        value = p;
    434430        return (0);
    435431    }
     
    576572                               char *fname)
    577573{
    578     FILE *fin;
    579     char *label;
    580     char *value;
     574    FILE *fin = NULL;
     575    char *label = NULL;
     576    char *value = NULL;
    581577    int items;
    582578    int v;
     
    596592    items = 0;
    597593    log_it("Loading raidtab...");
    598     malloc_string(label);
    599     malloc_string(value);
    600594    get_next_raidtab_line(fin, label, value);
    601595    while (!feof(fin)) {
     
    605599        /* find the 'raiddev' entry, indicating the start of the block of info */
    606600        while (!feof(fin) && strcmp(label, "raiddev")) {
    607             strcpy(raidlist->el[items].additional_vars.el[v].label, label);
    608             strcpy(raidlist->el[items].additional_vars.el[v].value, value);
     601            raidlist->el[items].additional_vars.el[v].label = label;
     602            raidlist->el[items].additional_vars.el[v].value = value;
    609603            v++;
    610604            get_next_raidtab_line(fin, label, value);
     
    616610        }
    617611        log_msg(2, "Record #%d (%s) found", items, value);
    618         strcpy(raidlist->el[items].raid_device, value);
     612        raidlist->el[items].raid_device = value;
    619613        for (get_next_raidtab_line(fin, label, value);
    620614             !feof(fin) && strcmp(label, "raiddev");
     
    628622    log_msg(1, "Raidtab loaded successfully.");
    629623    log_msg(1, "%d RAID devices in raidtab", items);
    630     paranoid_free(label);
    631     paranoid_free(value);
    632624    return (0);
    633625}
     
    644636 */
    645637void
    646 process_raidtab_line(FILE * fin,
     638process_raidtab_line(FILE *fin,
    647639                     struct raid_device_record *raidrec,
    648640                     char *label, char *value)
     
    650642
    651643    /*@ add mallocs * */
    652     char *tmp;
    653     char *labelB;
    654     char *valueB;
    655 
    656     struct list_of_disks *disklist;
    657     int index;
    658     int v;
    659 
    660     malloc_string(labelB);
    661     malloc_string(valueB);
     644    char *tmp = NULL;
     645    char *labelB = NULL;
     646    char *valueB = NULL;
     647
     648    struct list_of_disks *disklist = NULL;
     649    int index = 0;
     650    int v = 0;
     651
    662652    assert(fin != NULL);
    663653    assert(raidrec != NULL);
     
    716706            add_disk_to_raid_device(disklist, value, index);
    717707        }
     708        paranoid_free(labelB);
     709        paranoid_free(valueB);
    718710    } else {
    719711        v = raidrec->additional_vars.entries;
    720         strcpy(raidrec->additional_vars.el[v].label, label);
    721         strcpy(raidrec->additional_vars.el[v].value, value);
     712        raidrec->additional_vars.el[v].label = label;
     713        raidrec->additional_vars.el[v].value = value;
    722714        raidrec->additional_vars.entries = ++v;
    723715    }
    724     paranoid_free(labelB);
    725     paranoid_free(valueB);
    726716}
    727717#endif
  • trunk/mondo/mondo/common/libmondo-stream.c

    r688 r689  
    222222    dev = NULL;
    223223    siz = NULL;
    224     if (find_home_of_exe("cdrecord")) {
     224    tmp = find_home_of_exe("cdrecord");
     225    if (tmp) {
    225226        asprintf(&cdr_exe, "cdrecord");
    226227    } else {
    227228        asprintf(&cdr_exe, "dvdrecord");
    228229    }
     230    paranoid_free(tmp);
     231
    229232    asprintf(&command, "%s -scanbus 2> /dev/null | grep -i tape | wc -l",
    230233             cdr_exe);
  • trunk/mondo/mondo/common/libmondo-tools.c

    r688 r689  
    348348    char *extra_cdrom_params = NULL;
    349349    char *mondo_mkisofs_sz = NULL;
    350     char *command;
    351     char *hostname, *ip_address;
     350    char *command = NULL;
     351    char *hostname = NULL, *ip_address = NULL;
    352352    int retval = 0;
    353353    long avm = 0;
    354     char *colon;
    355     char *cdr_exe;
    356     char *tmp;
    357     char *tmp1;
     354    char *colon = NULL;
     355    char *cdr_exe = NULL;
     356    char *tmp = NULL;
     357    char *tmp1 = NULL;
    358358    char call_before_iso_user[MAX_STR_LEN] = "\0";
    359359    int rdsiz_MB;
    360     char *iso_path;
     360    char *iso_path = NULL;
    361361
    362362    assert(bkpinfo != NULL);
     
    439439
    440440    if (bkpinfo->backup_media_type == dvd) {
    441         if (!(find_home_of_exe("growisofs"))) {
     441        tmp = find_home_of_exe("growisofs");
     442        if (!tmp) {
    442443            fatal_error("Please install growisofs.");
    443444        }
     445        paranoid_free(tmp);
     446
    444447        if (bkpinfo->nonbootable_backup) {
    445448            asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_NONBOOT);
     
    502505            }
    503506        }
    504         if (find_home_of_exe("cdrecord")) {
     507        tmp = find_home_of_exe("cdrecord");
     508        tmp1 = find_home_of_exe("dvdrecord");
     509        if (tmp) {
    505510            asprintf(&cdr_exe, "cdrecord");
    506         } else if (find_home_of_exe("dvdrecord")) {
     511        } else if (tmp1) {
    507512            asprintf(&cdr_exe, "dvdrecord");
    508513        } else {
    509514            fatal_error("Please install either cdrecord or dvdrecord.");
    510515        }
     516        paranoid_free(tmp);
     517        paranoid_free(tmp1);
     518
    511519        if (bkpinfo->nonbootable_backup) {
    512520            asprintf(&mondo_mkisofs_sz, "%s -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL_Version -V _CD#_", mrconf->mondo_iso_creation_cmd);
     
    829837
    830838    /*@ buffers ************ */
    831     char *tmp;
     839    char *tmp = NULL;
    832840
    833841    /*@ int's *************** */
     
    913921        /* IA64 always has one vfat partition for EFI even without Windows */
    914922        // retval +=
    915         if (!find_home_of_exe("ms-sys")) {
     923        tmp = find_home_of_exe("ms-sys");
     924        if (!tmp) {
    916925            log_to_screen(_("Please install ms-sys just in case."));
    917926        }
    918 #endif
    919     }
    920 
    921     if (!find_home_of_exe("cmp")) {
    922         if (!find_home_of_exe("true")) {
    923             whine_if_not_found("cmp");
    924         } else {
    925             log_to_screen
    926                 (_("Your system lacks the 'cmp' binary. I'll create a dummy cmp for you."));
    927             if (run_program_and_log_output
    928                 ("cp -f `which true` /usr/bin/cmp", 0)) {
    929                 fatal_error("Failed to create dummy 'cmp' file.");
    930             }
    931         }
    932     }
     927        paranoid_free(tmp);
     928#endif
     929    }
     930
     931    tmp = find_home_of_exe("cmp");
     932    if (!tmp) {
     933        whine_if_not_found("cmp");
     934    }
     935    paranoid_free(tmp);
     936
    933937    run_program_and_log_output
    934938        ("umount `mount | grep cdr | cut -d' ' -f3 | tr '\n' ' '`", 5);
Note: See TracChangeset for help on using the changeset viewer.