Changeset 1154 in MondoRescue


Ignore:
Timestamp:
Feb 13, 2007, 12:34:08 AM (17 years ago)
Author:
Bruno Cornec
Message:

trunk merge continues

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/src/common/libmondo-archive.c

    r1152 r1154  
    24062406    assert(bkpinfo != NULL);
    24072407    /* slice big files */
    2408     malloc_string(biggielist);
    2409     malloc_string(xattr_fname);
    2410     malloc_string(acl_fname);
    24112408    mvaddstr_and_log_it(g_currentY, 0,
    24122409                        "Archiving large files to media           ");
    2413     sprintf(biggielist, "%s/archives/biggielist.txt", bkpinfo->scratchdir);
     2410    mr_asprintf(&biggielist, "%s/archives/biggielist.txt", bkpinfo->scratchdir);
    24142411    if (g_getfattr) {
    2415         sprintf(xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
     2412        mr_asprintf(&xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
    24162413    }
    24172414    if (g_getfacl) {
    2418         sprintf(acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
    2419     }
    2420 
    2421     mr_asprintf(&command, "cp %s/biggielist.txt %s", bkpinfo->tmpdir,
    2422             biggielist);
     2415        mr_asprintf(&acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
     2416    }
     2417
     2418    mr_asprintf(&command, "cp %s/biggielist.txt %s", bkpinfo->tmpdir, biggielist);
    24232419    paranoid_system(command);
    24242420    mr_free(command);
     
    24342430    if (g_getfattr) {
    24352431        get_fattr_list(biggielist, xattr_fname);
    2436         mr_asprintf(&command, "cp %s %s/archives/", xattr_fname,
    2437             bkpinfo->scratchdir);
     2432        mr_asprintf(&command, "cp %s %s/archives/", xattr_fname, bkpinfo->scratchdir);
    24382433        paranoid_system(command);
    24392434        mr_free(command);
     
    24412436    if (g_getfacl) {
    24422437        get_acl_list(biggielist, acl_fname);
    2443         mr_asprintf(&command, "cp %s %s/archives/", acl_fname,
    2444              bkpinfo->scratchdir);
     2438        mr_asprintf(&command, "cp %s %s/archives/", acl_fname, bkpinfo->scratchdir);
    24452439        paranoid_system(command);
    24462440        mr_free(command);
     
    24532447        mr_free(blah);
    24542448    }
     2449    if (g_getfattr) {
     2450        mr_free(xattr_fname);
     2451    }
     2452    if (g_getfacl) {
     2453        mr_free(acl_fname);
     2454    }
     2455
    24552456    res = make_slices_and_images(bkpinfo, biggielist);
     2457    mr_free(biggielist);
     2458
    24562459    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    24572460        write_header_block_to_stream((off_t)0, "end-of-biggiefiles",
     
    24652468        mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    24662469    }
    2467     mr_free(biggielist);
    2468     mr_free(xattr_fname);
    2469     mr_free(acl_fname);
    24702470    return (retval);
    24712471}
     
    25102510
    25112511    /*@ buffers ******************************************************** */
    2512     char *tmp, *curr_file, *cf;
     2512    char *tmp = NULL;
     2513    char *curr_file = NULL;
     2514    char *cf = NULL;
    25132515
    25142516    /*@ long ************************************************************ */
     
    25172519
    25182520    assert(bkpinfo != NULL);
    2519     malloc_string(curr_file);
    2520     tmp = mr_malloc(1200);
    25212521    would_occupy = space_occupied_by_cd(bkpinfo->scratchdir);
    25222522    va_start(ap, files_to_add); // initialize the variable arguments
     
    25252525            continue;
    25262526        }
    2527         strcpy(curr_file, cf);
     2527        mr_asprintf(&curr_file, cf);
    25282528        if (!does_file_exist(curr_file)) {
    25292529            mr_msg(1,
     
    25342534            would_occupy += length_of_file(curr_file) / 1024;
    25352535        }
     2536        mr_free(curr_file);
    25362537    }
    25372538    va_end(ap);
     
    25412542    }
    25422543    if (would_occupy / 1024 > bkpinfo->media_size[g_current_media_number]) {
    2543         res = write_iso_and_go_on(bkpinfo, FALSE);  /* FALSE because this is not the last CD we'll write */
     2544        /* FALSE because this is not the last CD we'll write */
     2545        res = write_iso_and_go_on(bkpinfo, FALSE);
    25442546        retval += res;
    25452547        if (res) {
     
    25532555            continue;
    25542556        }
    2555         strcpy(curr_file, cf);
    2556 
    2557         sprintf(tmp, "mv -f %s %s/archives/", curr_file,
    2558                 bkpinfo->scratchdir);
     2557        mr_asprintf(&curr_file, cf);
     2558
     2559        mr_asprintf(&tmp, "mv -f %s %s/archives/", curr_file,
     2560                 bkpinfo->scratchdir);
    25592561        res = run_program_and_log_output(tmp, 5);
    25602562        retval += res;
     
    25642566            mr_msg(8, "Moved %s to CD OK", tmp);
    25652567        }
     2568        mr_free(tmp);
     2569        mr_free(curr_file);
    25662570        //      unlink (curr_file);
    25672571    }
     
    25722576                "Warning - errors occurred while I was adding files to CD dir");
    25732577    }
    2574     mr_free(tmp);
    2575     mr_free(curr_file);
    25762578    return (retval);
    25772579}
    25782580
    25792581/* @} - end of LLarchiveGroup */
    2580 
    2581 
    2582 
    2583 
    2584 
    2585 
    25862582
    25872583
     
    26012597{
    26022598    /*@ buffer ************************************************************ */
    2603     char *tmp;
    2604     char *comment;
    2605     char *bootdisk_dev;
    2606     char *datadisk_dev;
    2607     char *bootdisk_file;
    2608     char *rootdisk_file;
     2599    char *tmp = NULL;
     2600    char *comment = NULL;
     2601    char *bootdisk_dev =NULL;
     2602    char *datadisk_dev = NULL;
     2603    char *bootdisk_file = NULL;
     2604    char *rootdisk_file = NULL;
    26092605
    26102606    /*@ int *************************************************************** */
     
    26162612    bool root_disk_exists = FALSE;
    26172613
    2618     malloc_string(tmp);
    2619     malloc_string(comment);
    2620     malloc_string(bootdisk_dev);
    2621     malloc_string(datadisk_dev);
    2622     malloc_string(rootdisk_file);
    2623     malloc_string(bootdisk_file);
    26242614    assert(bkpinfo != NULL);
    26252615    assert_string_is_neither_NULL_nor_zerolength(imagesdir);
    2626 
    26272616
    26282617    if (!ask_me_yes_or_no
     
    26352624        system("/usr/sbin/fdcontrol -F 1722 /dev/fd0.1722");
    26362625#endif
    2637         strcpy(bootdisk_dev, DEFAULT_1722MB_DISK);
     2626        mr_asprintf(&bootdisk_dev, DEFAULT_1722MB_DISK);
    26382627    } else if (does_device_exist(BACKUP_1722MB_DISK)) {
    2639         sprintf(bootdisk_dev, "/dev/fd0H1722");
     2628        mr_asprintf(&bootdisk_dev, "/dev/fd0H1722");
    26402629    } else {
    26412630        mr_msg(1, "Warning - can't find a 1.72MB floppy device *sigh*");
    2642         strcpy(bootdisk_dev, DEFAULT_1722MB_DISK);
    2643 //      return (1);
    2644     }
    2645     strcpy(datadisk_dev, "/dev/fd0");
     2631        mr_asprintf(&bootdisk_dev, DEFAULT_1722MB_DISK);
     2632    }
     2633    mr_asprintf(&datadisk_dev, "/dev/fd0");
    26462634    if (!does_device_exist(datadisk_dev)) {
    26472635        mr_msg(1, "Warning - can't find a 1.44MB floppy device *sigh*");
    2648         strcpy(datadisk_dev, "/dev/fd0");
    2649 //      return (1);
    2650     }
    2651     format_first =
    2652         ask_me_yes_or_no
     2636    }
     2637    format_first = ask_me_yes_or_no
    26532638        ("Do you want me to format the disks before I write to them?");
    26542639
    2655 /* boot disk */
     2640    /* boot disk */
    26562641    if (ask_me_OK_or_cancel("About to write boot disk")) {
    26572642        log_to_screen("Writing boot floppy");
    26582643#ifdef __FreeBSD__
    2659         sprintf(tmp, "%s/mindi-kern.1722.img", imagesdir);
     2644        mr_asprintf(&tmp, "%s/mindi-kern.1722.img", imagesdir);
    26602645        if (format_first) {
    26612646            format_disk(bootdisk_dev);
    26622647        }
    26632648        res += write_image_to_floppy(bootdisk_dev, tmp);
     2649        mr_free(tmp);
     2650
    26642651        if (ask_me_OK_or_cancel("About to write 1.44MB mfsroot disk")) {
    26652652            log_to_screen("Writing mfsroot floppy");
     
    26672654                format_disk(datadisk_dev);
    26682655            }
    2669             sprintf(tmp, "%s/mindi-mfsroot.1440.img", imagesdir);
     2656            mr_asprintf(&tmp, "%s/mindi-mfsroot.1440.img", imagesdir);
    26702657            write_image_to_floppy(datadisk_dev, tmp);
     2658            mr_free(tmp);
    26712659        }
    26722660#else
    2673         sprintf(bootdisk_file, "%s/mindi-bootroot.1722.img", imagesdir);
     2661        mr_asprintf(&bootdisk_file, "%s/mindi-bootroot.1722.img", imagesdir);
    26742662        if (does_file_exist(bootdisk_file)) {
    26752663            if (format_first) {
     
    26782666            res += write_image_to_floppy(bootdisk_dev, bootdisk_file);
    26792667        } else {
    2680             sprintf(bootdisk_file, "%s/mindi-boot.1440.img", imagesdir);
    2681             sprintf(rootdisk_file, "%s/mindi-root.1440.img", imagesdir);
     2668            mr_free(bootdisk_file);
     2669            mr_asprintf(&bootdisk_file, "%s/mindi-boot.1440.img", imagesdir);
     2670            mr_asprintf(&rootdisk_file, "%s/mindi-root.1440.img", imagesdir);
    26822671            root_disk_exists = TRUE;
    26832672            if (!does_file_exist(rootdisk_file)
     
    26872676                log_to_screen
    26882677                    ("Failed to find boot/root floppy images. Oh dear.");
     2678                mr_free(bootdisk_file);
     2679                mr_free(rootdisk_file);
     2680                mr_free(bootdisk_dev);
    26892681                return (1);
    26902682            }
     
    26922684                format_disk(datadisk_dev);
    26932685            }
    2694             /*
    2695                sprintf(tmp, "cat %s > %s", bootdisk_file, datadisk_dev);
    2696                res += run_external_binary_with_percentage_indicator_NEW("Writing boot floppy", tmp);
    2697              */
    26982686            res += write_image_to_floppy(datadisk_dev, bootdisk_file);
    26992687            if (ask_me_OK_or_cancel("About to write root disk")) {
     
    27022690                    format_disk(datadisk_dev);
    27032691                }
    2704                 sprintf(tmp, "cat %s > %s", rootdisk_file, datadisk_dev);
     2692                mr_asprintf(&tmp, "cat %s > %s", rootdisk_file, datadisk_dev);
    27052693                mr_msg(1, "tmp = '%s'", tmp);
    27062694                res +=
     
    27082696                    ("Writing root floppy", tmp);
    27092697//              res += write_image_to_floppy (datadisk_dev, rootdisk_file);
    2710             }
    2711         }
     2698                mr_free(tmp);
     2699            }
     2700            mr_free(rootdisk_file);
     2701           
     2702        }
     2703        mr_free(bootdisk_file);
    27122704#endif
    27132705    }
     2706    mr_free(bootdisk_dev);
     2707
    27142708    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    27152709        log_to_screen
     
    27182712    }
    27192713    for (i = 1; i < 99; i++) {
    2720         sprintf(tmp, "%s/mindi-data-%d.img", imagesdir, i);
     2714        mr_asprintf(&tmp, "%s/mindi-data-%d.img", imagesdir, i);
    27212715        mr_msg(3, tmp);
    27222716        if (!does_file_exist(tmp)) {
     
    27242718            break;
    27252719        }
    2726         sprintf(comment, "About to write data disk #%d", i);
     2720        mr_asprintf(&comment, "About to write data disk #%d", i);
    27272721        if (ask_me_OK_or_cancel(comment)) {
    2728             sprintf(comment, "Writing data disk #%3d", i);
     2722            mr_free(comment);
     2723            mr_asprintf(&comment, "Writing data disk #%3d", i);
    27292724            log_to_screen(comment);
     2725            mr_free(comment);
    27302726            if (format_first) {
    27312727                res += format_disk(datadisk_dev);
     
    27332729            res += write_image_to_floppy(datadisk_dev, tmp);
    27342730        }
    2735     }
     2731        mr_free(tmp);
     2732    }
     2733    /* In case of break free mem as well */
    27362734    mr_free(tmp);
    2737     mr_free(comment);
    2738     mr_free(bootdisk_dev);
    27392735    mr_free(datadisk_dev);
    27402736    return (res);
    27412737}
    2742 
    2743 
    2744 
    2745 
    2746 
    2747 
    27482738
    27492739
     
    27582748 */
    27592749
    2760 int offer_to_write_boot_floppies_to_physical_disks(struct s_bkpinfo
    2761                                                    *bkpinfo)
    2762 {
     2750int offer_to_write_boot_floppies_to_physical_disks(struct s_bkpinfo *bkpinfo) {
     2751   
    27632752    int res = 0;
    27642753
     
    27732762#else
    27742763        if (!does_file_exist("/var/cache/mindi/mindi-bootroot.1722.img")
    2775             && !does_file_exist("/var/cache/mindi/mindi-boot.1440.img"))
     2764            && !does_file_exist("/var/cache/mindi/mindi-boot.1440.img")
     2765            && !does_file_exist("/var/cache/mindi/mindi-boot.2880.img")
     2766            && !does_file_exist("/var/cache/mindi/mindi-boot.5760.img"))
    27762767#endif
    27772768        {
     
    27932784    return (res);
    27942785}
    2795 
    2796 
    27972786
    27982787
     
    28342823    char start_chr;
    28352824    char stop_chr;
    2836     char *curr_file, *cf;
     2825    char *curr_file = NULL;
     2826    char *cf = NULL;
    28372827    /*@ long long ****************************************************** */
    28382828    off_t length_of_incoming_file = (off_t)0;
     
    28412831
    28422832    assert(bkpinfo != NULL);
    2843     malloc_string(curr_file);
    28442833    va_start(ap, files_to_add);
    28452834    for (cf = files_to_add; cf != NULL; cf = va_arg(ap, char *)) {
     
    28472836            continue;
    28482837        }
    2849         strcpy(curr_file, cf);
     2838        mr_asprintf(&curr_file, cf);
    28502839        if (!does_file_exist(curr_file)) {
    28512840            mr_msg(1,
     
    28532842                    curr_file);
    28542843        }
    2855 /* create header chars */
     2844        /* create header chars */
    28562845        start_chr = BLK_START_AN_AFIO_OR_SLICE;
    28572846        stop_chr = BLK_STOP_AN_AFIO_OR_SLICE;
    2858 /* ask for new tape if necessary */
     2847        /* ask for new tape if necessary */
    28592848        length_of_incoming_file = length_of_file(curr_file);
    28602849        write_header_block_to_stream(length_of_incoming_file, curr_file,
     
    28702859        retval += res;
    28712860        unlink(curr_file);
    2872 /* write closing header */
     2861        mr_free(curr_file);
     2862        /* write closing header */
    28732863        write_header_block_to_stream((off_t)0, "finished-writing-file", stop_chr);
    28742864    }
     
    28792869                "Warning - errors occurred while I was adding file to tape");
    28802870    }
    2881     mr_free(curr_file);
    28822871    return (retval);
    28832872}
    28842873
    28852874/* @} - end of LLarchiveGroup */
    2886 
    28872875
    28882876
     
    29462934
    29472935
    2948 
    2949 
    2950 
    2951 
    2952 
    2953 
    2954 
    29552936/**
    29562937 * Asks the user to put a CD-R(W) in the drive.
     
    29632944
    29642945    /*@ buffers ********************************************* */
    2965     char *tmp;
    2966     char *szmsg;
    2967     char *cdrom_dev;
    2968     char *cdrw_dev;
    2969     char *our_serial_str;
     2946    char *tmp = NULL;
     2947    char *tmp1 = NULL;
     2948    char *szmsg = NULL;
     2949    char *cdrom_dev = NULL;
     2950    char *cdrw_dev = NULL;
     2951    char *our_serial_str = NULL;
    29702952    bool ok_go_ahead_burn_it;
    29712953    int cd_number = -1;
    29722954    int attempt_to_mount_returned_this = 999;
    2973     char *mtpt;
    2974     char *szcdno;
    2975     char *szserfname;
    2976     char *szunmount;
     2955    char *mtpt = NULL;
     2956    char *szcdno = NULL;
     2957    char *szserfname = NULL;
     2958    char *szunmount = NULL;
    29772959
    29782960    malloc_string(tmp);
     
    31223104
    31233105
    3124 
    3125 
    3126 
    3127 
    3128 
    3129 
    31303106/**
    31313107 * Set the <tt>N</tt>th bit of @c array to @c true_or_false.
     
    31553131
    31563132/* @} - end of utilityGroup */
    3157 
    3158 
    3159 
    3160 
    3161 
    3162 
    31633133
    31643134
     
    31893159
    31903160    /*@ buffers ************************************************** */
    3191     char *tmp, *checksum_line, *command;
    3192     char *tempblock;
    3193     char *curr_slice_fname_uncompressed;
    3194     char *curr_slice_fname_compressed;
    3195     char *file_to_archive;
    3196     char *file_to_openin;
     3161    char *tmp = NULL;
     3162    char *checksum_line = NULL;
     3163    char *command = NULL;
     3164    char *tempblock = NULL;
     3165    char *curr_slice_fname_uncompressed = NULL;
     3166    char *curr_slice_fname_compressed = NULL;
     3167    char *file_to_archive = NULL;
     3168    char *file_to_openin = NULL;
    31973169    /*@ pointers ************************************************** */
    3198     char *pB;
    3199     FILE *fin, *fout;
     3170    char *pB = NULL;
     3171    FILE *fin = NULL;
     3172    FILE *fout = NULL;
    32003173
    32013174    /*@ bool ****************************************************** */
     
    32083181    long optimal_set_size;
    32093182    bool should_I_compress_slices;
    3210     char *suffix;               // for compressed slices
     3183    char *suffix = NULL;                // for compressed slices
    32113184
    32123185    /*@ long long ************************************************** */
     
    32183191    int retval = 0;
    32193192    int res = 0;
     3193    size_t n = 0;
    32203194
    32213195    /*@ structures ************************************************** */
     
    32303204    malloc_string(curr_slice_fname_compressed);
    32313205    malloc_string(file_to_archive);
    3232     malloc_string(suffix);
    32333206    command = mr_malloc(MAX_STR_LEN * 8);
    32343207
     
    32393212    if (is_this_file_compressed(biggie_filename)
    32403213        || bkpinfo->compression_level == 0) {
    3241         suffix[0] = '\0';
     3214        mr_asprintf(&suffix, "");
    32423215        //      log_it("%s is indeed compressed :-)", filename);
    32433216        should_I_compress_slices = FALSE;
    32443217    } else {
    3245         strcpy(suffix, bkpinfo->zip_suffix);
     3218        mr_asprintf(&suffix, bkpinfo->zip_suffix);
    32463219        should_I_compress_slices = TRUE;
    32473220    }
     
    33893362                        slice_num);
    33903363            }
    3391 #ifndef _XWIN
    33923364            if (!g_text_mode) {
    33933365                newtDrawRootText(0, g_noof_rows - 2, tmp);
     
    33963368                mr_msg(2, tmp);
    33973369            }
    3398 #else
    3399             mr_msg(2, tmp);
    3400 #endif
    34013370            strcpy(file_to_archive, curr_slice_fname_compressed);
    34023371            g_current_progress++;
     
    34473416    return (retval);
    34483417}
    3449 
    3450 
    3451 
    3452 
    34533418
    34543419
Note: See TracChangeset for help on using the changeset viewer.