Changeset 1154 in MondoRescue for branches/stable/mondo
- Timestamp:
- Feb 13, 2007, 12:34:08 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/src/common/libmondo-archive.c
r1152 r1154 2406 2406 assert(bkpinfo != NULL); 2407 2407 /* slice big files */ 2408 malloc_string(biggielist);2409 malloc_string(xattr_fname);2410 malloc_string(acl_fname);2411 2408 mvaddstr_and_log_it(g_currentY, 0, 2412 2409 "Archiving large files to media "); 2413 sprintf(biggielist, "%s/archives/biggielist.txt", bkpinfo->scratchdir);2410 mr_asprintf(&biggielist, "%s/archives/biggielist.txt", bkpinfo->scratchdir); 2414 2411 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); 2416 2413 } 2417 2414 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); 2423 2419 paranoid_system(command); 2424 2420 mr_free(command); … … 2434 2430 if (g_getfattr) { 2435 2431 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); 2438 2433 paranoid_system(command); 2439 2434 mr_free(command); … … 2441 2436 if (g_getfacl) { 2442 2437 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); 2445 2439 paranoid_system(command); 2446 2440 mr_free(command); … … 2453 2447 mr_free(blah); 2454 2448 } 2449 if (g_getfattr) { 2450 mr_free(xattr_fname); 2451 } 2452 if (g_getfacl) { 2453 mr_free(acl_fname); 2454 } 2455 2455 2456 res = make_slices_and_images(bkpinfo, biggielist); 2457 mr_free(biggielist); 2458 2456 2459 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 2457 2460 write_header_block_to_stream((off_t)0, "end-of-biggiefiles", … … 2465 2468 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 2466 2469 } 2467 mr_free(biggielist);2468 mr_free(xattr_fname);2469 mr_free(acl_fname);2470 2470 return (retval); 2471 2471 } … … 2510 2510 2511 2511 /*@ buffers ******************************************************** */ 2512 char *tmp, *curr_file, *cf; 2512 char *tmp = NULL; 2513 char *curr_file = NULL; 2514 char *cf = NULL; 2513 2515 2514 2516 /*@ long ************************************************************ */ … … 2517 2519 2518 2520 assert(bkpinfo != NULL); 2519 malloc_string(curr_file);2520 tmp = mr_malloc(1200);2521 2521 would_occupy = space_occupied_by_cd(bkpinfo->scratchdir); 2522 2522 va_start(ap, files_to_add); // initialize the variable arguments … … 2525 2525 continue; 2526 2526 } 2527 strcpy(curr_file, cf);2527 mr_asprintf(&curr_file, cf); 2528 2528 if (!does_file_exist(curr_file)) { 2529 2529 mr_msg(1, … … 2534 2534 would_occupy += length_of_file(curr_file) / 1024; 2535 2535 } 2536 mr_free(curr_file); 2536 2537 } 2537 2538 va_end(ap); … … 2541 2542 } 2542 2543 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); 2544 2546 retval += res; 2545 2547 if (res) { … … 2553 2555 continue; 2554 2556 } 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); 2559 2561 res = run_program_and_log_output(tmp, 5); 2560 2562 retval += res; … … 2564 2566 mr_msg(8, "Moved %s to CD OK", tmp); 2565 2567 } 2568 mr_free(tmp); 2569 mr_free(curr_file); 2566 2570 // unlink (curr_file); 2567 2571 } … … 2572 2576 "Warning - errors occurred while I was adding files to CD dir"); 2573 2577 } 2574 mr_free(tmp);2575 mr_free(curr_file);2576 2578 return (retval); 2577 2579 } 2578 2580 2579 2581 /* @} - end of LLarchiveGroup */ 2580 2581 2582 2583 2584 2585 2586 2582 2587 2583 … … 2601 2597 { 2602 2598 /*@ 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; 2609 2605 2610 2606 /*@ int *************************************************************** */ … … 2616 2612 bool root_disk_exists = FALSE; 2617 2613 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);2624 2614 assert(bkpinfo != NULL); 2625 2615 assert_string_is_neither_NULL_nor_zerolength(imagesdir); 2626 2627 2616 2628 2617 if (!ask_me_yes_or_no … … 2635 2624 system("/usr/sbin/fdcontrol -F 1722 /dev/fd0.1722"); 2636 2625 #endif 2637 strcpy(bootdisk_dev, DEFAULT_1722MB_DISK);2626 mr_asprintf(&bootdisk_dev, DEFAULT_1722MB_DISK); 2638 2627 } else if (does_device_exist(BACKUP_1722MB_DISK)) { 2639 sprintf(bootdisk_dev, "/dev/fd0H1722");2628 mr_asprintf(&bootdisk_dev, "/dev/fd0H1722"); 2640 2629 } else { 2641 2630 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"); 2646 2634 if (!does_device_exist(datadisk_dev)) { 2647 2635 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 2653 2638 ("Do you want me to format the disks before I write to them?"); 2654 2639 2655 /* boot disk */2640 /* boot disk */ 2656 2641 if (ask_me_OK_or_cancel("About to write boot disk")) { 2657 2642 log_to_screen("Writing boot floppy"); 2658 2643 #ifdef __FreeBSD__ 2659 sprintf(tmp, "%s/mindi-kern.1722.img", imagesdir);2644 mr_asprintf(&tmp, "%s/mindi-kern.1722.img", imagesdir); 2660 2645 if (format_first) { 2661 2646 format_disk(bootdisk_dev); 2662 2647 } 2663 2648 res += write_image_to_floppy(bootdisk_dev, tmp); 2649 mr_free(tmp); 2650 2664 2651 if (ask_me_OK_or_cancel("About to write 1.44MB mfsroot disk")) { 2665 2652 log_to_screen("Writing mfsroot floppy"); … … 2667 2654 format_disk(datadisk_dev); 2668 2655 } 2669 sprintf(tmp, "%s/mindi-mfsroot.1440.img", imagesdir);2656 mr_asprintf(&tmp, "%s/mindi-mfsroot.1440.img", imagesdir); 2670 2657 write_image_to_floppy(datadisk_dev, tmp); 2658 mr_free(tmp); 2671 2659 } 2672 2660 #else 2673 sprintf(bootdisk_file, "%s/mindi-bootroot.1722.img", imagesdir);2661 mr_asprintf(&bootdisk_file, "%s/mindi-bootroot.1722.img", imagesdir); 2674 2662 if (does_file_exist(bootdisk_file)) { 2675 2663 if (format_first) { … … 2678 2666 res += write_image_to_floppy(bootdisk_dev, bootdisk_file); 2679 2667 } 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); 2682 2671 root_disk_exists = TRUE; 2683 2672 if (!does_file_exist(rootdisk_file) … … 2687 2676 log_to_screen 2688 2677 ("Failed to find boot/root floppy images. Oh dear."); 2678 mr_free(bootdisk_file); 2679 mr_free(rootdisk_file); 2680 mr_free(bootdisk_dev); 2689 2681 return (1); 2690 2682 } … … 2692 2684 format_disk(datadisk_dev); 2693 2685 } 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 */2698 2686 res += write_image_to_floppy(datadisk_dev, bootdisk_file); 2699 2687 if (ask_me_OK_or_cancel("About to write root disk")) { … … 2702 2690 format_disk(datadisk_dev); 2703 2691 } 2704 sprintf(tmp, "cat %s > %s", rootdisk_file, datadisk_dev);2692 mr_asprintf(&tmp, "cat %s > %s", rootdisk_file, datadisk_dev); 2705 2693 mr_msg(1, "tmp = '%s'", tmp); 2706 2694 res += … … 2708 2696 ("Writing root floppy", tmp); 2709 2697 // 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); 2712 2704 #endif 2713 2705 } 2706 mr_free(bootdisk_dev); 2707 2714 2708 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 2715 2709 log_to_screen … … 2718 2712 } 2719 2713 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); 2721 2715 mr_msg(3, tmp); 2722 2716 if (!does_file_exist(tmp)) { … … 2724 2718 break; 2725 2719 } 2726 sprintf(comment, "About to write data disk #%d", i);2720 mr_asprintf(&comment, "About to write data disk #%d", i); 2727 2721 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); 2729 2724 log_to_screen(comment); 2725 mr_free(comment); 2730 2726 if (format_first) { 2731 2727 res += format_disk(datadisk_dev); … … 2733 2729 res += write_image_to_floppy(datadisk_dev, tmp); 2734 2730 } 2735 } 2731 mr_free(tmp); 2732 } 2733 /* In case of break free mem as well */ 2736 2734 mr_free(tmp); 2737 mr_free(comment);2738 mr_free(bootdisk_dev);2739 2735 mr_free(datadisk_dev); 2740 2736 return (res); 2741 2737 } 2742 2743 2744 2745 2746 2747 2748 2738 2749 2739 … … 2758 2748 */ 2759 2749 2760 int offer_to_write_boot_floppies_to_physical_disks(struct s_bkpinfo 2761 *bkpinfo) 2762 { 2750 int offer_to_write_boot_floppies_to_physical_disks(struct s_bkpinfo *bkpinfo) { 2751 2763 2752 int res = 0; 2764 2753 … … 2773 2762 #else 2774 2763 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")) 2776 2767 #endif 2777 2768 { … … 2793 2784 return (res); 2794 2785 } 2795 2796 2797 2786 2798 2787 … … 2834 2823 char start_chr; 2835 2824 char stop_chr; 2836 char *curr_file, *cf; 2825 char *curr_file = NULL; 2826 char *cf = NULL; 2837 2827 /*@ long long ****************************************************** */ 2838 2828 off_t length_of_incoming_file = (off_t)0; … … 2841 2831 2842 2832 assert(bkpinfo != NULL); 2843 malloc_string(curr_file);2844 2833 va_start(ap, files_to_add); 2845 2834 for (cf = files_to_add; cf != NULL; cf = va_arg(ap, char *)) { … … 2847 2836 continue; 2848 2837 } 2849 strcpy(curr_file, cf);2838 mr_asprintf(&curr_file, cf); 2850 2839 if (!does_file_exist(curr_file)) { 2851 2840 mr_msg(1, … … 2853 2842 curr_file); 2854 2843 } 2855 /* create header chars */2844 /* create header chars */ 2856 2845 start_chr = BLK_START_AN_AFIO_OR_SLICE; 2857 2846 stop_chr = BLK_STOP_AN_AFIO_OR_SLICE; 2858 /* ask for new tape if necessary */2847 /* ask for new tape if necessary */ 2859 2848 length_of_incoming_file = length_of_file(curr_file); 2860 2849 write_header_block_to_stream(length_of_incoming_file, curr_file, … … 2870 2859 retval += res; 2871 2860 unlink(curr_file); 2872 /* write closing header */ 2861 mr_free(curr_file); 2862 /* write closing header */ 2873 2863 write_header_block_to_stream((off_t)0, "finished-writing-file", stop_chr); 2874 2864 } … … 2879 2869 "Warning - errors occurred while I was adding file to tape"); 2880 2870 } 2881 mr_free(curr_file);2882 2871 return (retval); 2883 2872 } 2884 2873 2885 2874 /* @} - end of LLarchiveGroup */ 2886 2887 2875 2888 2876 … … 2946 2934 2947 2935 2948 2949 2950 2951 2952 2953 2954 2955 2936 /** 2956 2937 * Asks the user to put a CD-R(W) in the drive. … … 2963 2944 2964 2945 /*@ 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; 2970 2952 bool ok_go_ahead_burn_it; 2971 2953 int cd_number = -1; 2972 2954 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; 2977 2959 2978 2960 malloc_string(tmp); … … 3122 3104 3123 3105 3124 3125 3126 3127 3128 3129 3130 3106 /** 3131 3107 * Set the <tt>N</tt>th bit of @c array to @c true_or_false. … … 3155 3131 3156 3132 /* @} - end of utilityGroup */ 3157 3158 3159 3160 3161 3162 3163 3133 3164 3134 … … 3189 3159 3190 3160 /*@ 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; 3197 3169 /*@ pointers ************************************************** */ 3198 char *pB; 3199 FILE *fin, *fout; 3170 char *pB = NULL; 3171 FILE *fin = NULL; 3172 FILE *fout = NULL; 3200 3173 3201 3174 /*@ bool ****************************************************** */ … … 3208 3181 long optimal_set_size; 3209 3182 bool should_I_compress_slices; 3210 char *suffix ; // for compressed slices3183 char *suffix = NULL; // for compressed slices 3211 3184 3212 3185 /*@ long long ************************************************** */ … … 3218 3191 int retval = 0; 3219 3192 int res = 0; 3193 size_t n = 0; 3220 3194 3221 3195 /*@ structures ************************************************** */ … … 3230 3204 malloc_string(curr_slice_fname_compressed); 3231 3205 malloc_string(file_to_archive); 3232 malloc_string(suffix);3233 3206 command = mr_malloc(MAX_STR_LEN * 8); 3234 3207 … … 3239 3212 if (is_this_file_compressed(biggie_filename) 3240 3213 || bkpinfo->compression_level == 0) { 3241 suffix[0] = '\0';3214 mr_asprintf(&suffix, ""); 3242 3215 // log_it("%s is indeed compressed :-)", filename); 3243 3216 should_I_compress_slices = FALSE; 3244 3217 } else { 3245 strcpy(suffix, bkpinfo->zip_suffix);3218 mr_asprintf(&suffix, bkpinfo->zip_suffix); 3246 3219 should_I_compress_slices = TRUE; 3247 3220 } … … 3389 3362 slice_num); 3390 3363 } 3391 #ifndef _XWIN3392 3364 if (!g_text_mode) { 3393 3365 newtDrawRootText(0, g_noof_rows - 2, tmp); … … 3396 3368 mr_msg(2, tmp); 3397 3369 } 3398 #else3399 mr_msg(2, tmp);3400 #endif3401 3370 strcpy(file_to_archive, curr_slice_fname_compressed); 3402 3371 g_current_progress++; … … 3447 3416 return (retval); 3448 3417 } 3449 3450 3451 3452 3453 3418 3454 3419
Note:
See TracChangeset
for help on using the changeset viewer.