Changeset 171 in MondoRescue for trunk/mondo/mondo/common/libmondo-archive.c


Ignore:
Timestamp:
Dec 8, 2005, 5:20:29 PM (18 years ago)
Author:
bcornec
Message:

memory management continues:

  • mondoarchive handled completely
  • bkpinfo, begining of dyn. alloc.
  • lot of changes around memory everywhere

=> even if it compiles, i'm pretty sure it doesn't work yet (even not tried)

File:
1 edited

Legend:

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

    r168 r171  
    298298    /*@ buffers ******************************************************** */
    299299    char *command;
    300     char *zipparams;
     300    char *zipparams = NULL;
    301301    char *tmp, *tmp1;
    302302
     
    325325
    326326
    327         if (bkpinfo->compression_level > 0) {
     327    if (bkpinfo->compression_level > 0) {
    328328        asprintf(&tmp, "%s/do-not-compress-these", g_mondo_home);
    329329        //       -b %ld, TAPE_BLOCK_SIZE
     
    333333            asprintf(&tmp1, "%s -E %s", zipparams, tmp);
    334334            paranoid_free(zipparams)
    335                 zipparams = tmp1;
     335            zipparams = tmp1;
    336336        } else {
    337             asprintf(&zipparams, "");
     337            asprintf(&zipparams, " ");
    338338            log_msg(3, "%s not found. Cannot exclude zipfiles, etc.", tmp);
    339339        }
    340340        paranoid_free(tmp)
    341341    } else {
    342         asprintf(&zipparams, "");
     342        asprintf(&zipparams, " ");
    343343    }
    344344
     
    582582    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    583583        asprintf(&tape_size_sz, "%ld", bkpinfo->media_size[1]);
    584         asprintf(&tape_device, "%s", bkpinfo->media_device);
     584        asprintf(&tape_device, bkpinfo->media_device);
    585585    } else {
    586         asprintf(&tape_size_sz, "");
    587         asprintf(&tape_device, "");
     586        asprintf(&tape_size_sz, " ");
     587        asprintf(&tape_device, " ");
    588588    }
    589589    if (bkpinfo->use_lzo) {
     
    825825        asprintf(&tmp, " NONBOOTABLE");
    826826    } else {
    827         asprintf(&tmp, "");
     827        asprintf(&tmp, " ");
    828828    }
    829829
     
    20072007                       "Please wait. This may take some time.", "",
    20082008                       estimated_total_noof_slices);
     2009    paranoid_free(tmp);
     2010
    20092011    if (!(fin = fopen(biggielist_fname, "r"))) {
    20102012        log_OS_error("Unable to openin biggielist");
     
    20782080                                    noof_biggie_files, use_partimagehack);
    20792081            if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    2080                 write_header_block_to_stream(0,
    2081                                              calc_checksum_of_file
    2082                                              (bigfile_fname),
    2083                                              BLK_STOP_A_BIGGIE);
     2082                tmp = calc_checksum_of_file(bigfile_fname);
     2083                write_header_block_to_stream(0, tmp, BLK_STOP_A_BIGGIE);
     2084                paranoid_free(tmp);
    20842085            }
    20852086            retval += res;
     
    20902091                p = bigfile_fname;
    20912092            }
    2092             paranoid_free(tmp);
    20932093            if (res) {
    20942094                asprintf(&tmp, "Archiving %s ... Failed!", bigfile_fname);
     
    27722772/**
    27732773 * Make sure the user has a valid CD-R(W) in the CD drive.
    2774  * @param cdrw_dev Set to the CD-R(W) device checked.
     2774 * @param cdrw_device Set to the CD-R(W) device checked.
    27752775 * @param keep_looping If TRUE, keep pestering user until they insist
    27762776 * or insert a correct CD; if FALSE, only check once.
    27772777 * @return 0 (there was an OK CD in the drive) or 1 (there wasn't).
    27782778 */
    2779 int
    2780 interrogate_disk_currently_in_cdrw_drive(char *cdrw_dev, bool keep_looping)
     2779char *interrogate_disk_currently_in_cdrw_drive()
    27812780{
    2782     int res = 0;
    2783     char *bkp;
    27842781    char *cdrecord;
    2785 
    2786     asprintf(&bkp, "%s", cdrw_dev);
    2787     if (find_cdrw_device(cdrw_dev)) {
    2788         strcpy(cdrw_dev, bkp);
    2789     } else {
     2782    char *cdrw_device;
     2783
     2784    if ((cdrw_device = find_cdrw_device()) != NULL) {
    27902785        if (!system("which cdrecord > /dev/null 2> /dev/null")) {
    2791             asprintf(&cdrecord, "cdrecord dev=%s -atip", cdrw_dev);
     2786            asprintf(&cdrecord, "cdrecord dev=%s -atip", cdrw_device);
    27922787        } else if (!system("which dvdrecord > /dev/null 2> /dev/null")) {
    2793             asprintf(&cdrecord, "cdrecord dev=%s -atip", cdrw_dev);
     2788            asprintf(&cdrecord, "cdrecord dev=%s -atip", cdrw_device);
    27942789        } else {
    2795             asprintf(&cdrecord, "%s", "");
    2796             log_msg(2, "Oh well. I guess I'll just pray then.");
     2790            asprintf(&cdrecord, " ");
     2791            log_msg(2, "Found no cdrecord nor dvdrecord in path.");
    27972792        }
    27982793        if (cdrecord[0]) {
    2799             if (!keep_looping) {
    28002794                retract_CD_tray_and_defeat_autorun();
    2801                 res = run_program_and_log_output(cdrecord, 5);
    2802             } else {
    2803                 while ((res = run_program_and_log_output(cdrecord, 5))) {
    2804                     retract_CD_tray_and_defeat_autorun();
    2805                     if (ask_me_yes_or_no
    2806                         ("Unable to examine CD. Are you sure this is a valid CD-R(W) CD?"))
    2807                     {
    2808                         log_msg(1, "Well, he insisted...");
    2809                         break;
    2810                     }
    2811                 }
    2812             }
     2795                run_program_and_log_output(cdrecord, 5);
    28132796        }
    28142797        paranoid_free(cdrecord);
    28152798    }
    2816     paranoid_free(bkp);
    2817 //  retract_CD_tray_and_defeat_autorun();
    2818     return (res);
     2799    return(cdrw_device);
    28192800}
    28202801
     
    28342815    char *szmsg;
    28352816    char *cdrom_dev;
    2836     char *cdrw_dev;
     2817    char *cdrw_device = NULL;
    28372818    char *our_serial_str;
    28382819    bool ok_go_ahead_burn_it;
     
    28442825    char *szunmount;
    28452826
    2846     malloc_string(cdrom_dev);
    2847     malloc_string(cdrw_dev);
    2848 
    28492827    asprintf(&szmsg, "I am about to burn %s #%d",
    28502828             media_descriptor_string(g_backup_media_type),
     
    28622840  gotos_make_me_puke:
    28632841    ok_go_ahead_burn_it = TRUE;
    2864     if (!find_cdrom_device(cdrom_dev, FALSE)) {
     2842    cdrom_dev = find_cdrom_device(FALSE);
     2843    if (cdrom_dev != NULL) {
    28652844/* When enabled, it made CD eject-and-retract when wrong CD inserted.. Weird
    28662845      log_msg(2, "paafcd: Retracting CD-ROM drive if possible" );
     
    28802859            log_to_screen("If there's a CD/DVD in the drive, it's blank.");
    28812860            asprintf(&our_serial_str, "%s", "");
    2882             /*
    2883                if (interrogate_disk_currently_in_cdrw_drive(cdrw_dev, FALSE))
    2884                {
    2885                ok_go_ahead_burn_it = FALSE;
    2886                log_to_screen("There isn't a writable CD/DVD in the drive.");
    2887                }
    2888                else
    2889                {
    2890                log_to_screen("Confirmed. There is a blank CD/DVD in the drive.");
    2891                }
    2892              */
    28932861        } else if (!does_file_exist(szcdno)
    28942862                   || !does_file_exist(szserfname)) {
     
    29382906                "paafcd: Can't find CD-ROM drive. Perhaps it has a blank %s in it?",
    29392907                media_descriptor_string(g_backup_media_type));
    2940         if (interrogate_disk_currently_in_cdrw_drive(cdrw_dev, FALSE)) {
     2908        if ((cdrw_device = interrogate_disk_currently_in_cdrw_drive(cdrw_device)) != NULL) {
    29412909            ok_go_ahead_burn_it = FALSE;
    29422910            log_to_screen("There isn't a writable %s in the drive.",
    29432911                          media_descriptor_string(g_backup_media_type));
    29442912        }
     2913        paranoid_free(cdrw_device);
    29452914    }
    29462915    paranoid_free(mtpt);
     
    29672936        log_msg(2, "paafcd: OK, going ahead and burning it.");
    29682937    }
     2938    paranoid_free(cdrom_dev);
    29692939
    29702940    log_msg(2,
     
    29742944    log_to_screen("Proceeding w/ %s in drive.",
    29752945                  media_descriptor_string(g_backup_media_type));
    2976     paranoid_free(cdrom_dev);
    2977     paranoid_free(cdrw_dev);
    29782946    if (pmountable) {
    29792947        if (attempt_to_mount_returned_this) {
     
    34973465            && (bkpinfo->backup_media_type == cdr
    34983466                || bkpinfo->backup_media_type == cdrw)) {
    3499             if (find_cdrom_device(tmp, FALSE))  // make sure find_cdrom_device() finds, records CD-R's loc
     3467            if ((tmp = find_cdrom_device(FALSE)) == NULL)   // make sure find_cdrom_device() finds, records CD-R's loc
    35003468            {
    35013469                log_msg(3, "*Sigh* Mike, I hate your computer.");
     
    35043472            else {
    35053473                log_msg(3, "Great. Found Mike's CD-ROM drive.");
     3474                paranoid_free(tmp);
    35063475            }
    35073476        }
     
    35943563                            "Verifying archives against live filesystem");
    35953564        if (bkpinfo->backup_media_type == cdstream) {
    3596             strcpy(bkpinfo->media_device, "/dev/cdrom");
     3565            paranoid_alloc(bkpinfo->media_device,
     3566                            "/dev/cdrom");
    35973567        }
    35983568        verify_tape_backups(bkpinfo);
     
    36083578        g_current_media_number = cdno;
    36093579        if (bkpinfo->backup_media_type != iso) {
    3610             find_cdrom_device(bkpinfo->media_device, FALSE);    // replace 0,0,0 with /dev/cdrom
     3580            paranoid_free(bkpinfo->media_device);
     3581            bkpinfo->media_device = find_cdrom_device(FALSE);
    36113582        }
    36123583        chdir("/");
     
    36473618
    36483619        run_program_and_log_output("umount " MNT_CDROM, FALSE);
    3649 //        if (bkpinfo->backup_media_type != iso && !bkpinfo->please_dont_eject_when_restoring)
    3650 //{
    36513620        eject_device(bkpinfo->media_device);
    3652 //}
    36533621    }
    36543622    diffs = count_lines_in_file("/tmp/changed.files");
Note: See TracChangeset for help on using the changeset viewer.