Changeset 1161 in MondoRescue
- Timestamp:
- Feb 14, 2007, 1:13:49 PM (18 years ago)
- Location:
- trunk/mondo/src/common
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/src/common/libmondo-archive.c
r1106 r1161 13 13 #include <sys/ipc.h> 14 14 #include <stdarg.h> 15 #include <stdlib.h> 15 16 #include <unistd.h> 16 17 … … 19 20 #include "mr_conf.h" 20 21 #include "mr_mem.h" 22 #include "mr_msg.h" 21 23 #include "mr_err.h" 22 24 #include "mr_str.h" … … 207 209 unsigned int res = 0; 208 210 int tries = 0; 209 char *command; 210 char *tmp; 211 char *p; 211 char *command = NULL; 212 char *tmp = NULL; 213 char *p =NULL; 214 char *tmp1 = NULL; 212 215 213 216 if (!does_file_exist(filelist)) { … … 330 333 log_to_screen(tmp); 331 334 mr_free(tmp); 332 335 return (1); 333 336 } 334 337 mr_asprintf(&tmp, "echo hi > %s 2> /dev/null", fname); … … 349 352 zipparams = tmp1; 350 353 } else { 351 mr_asprintf(&zipparams, " ");352 354 mr_msg(3, "%s not found. Cannot exclude zipfiles, etc.", tmp); 353 355 } … … 440 442 { 441 443 int retval = 0, res = 0; 442 char *tmp ;444 char *tmp = NULL; 443 445 444 446 assert(bkpinfo != NULL); 445 447 set_g_cdrom_and_g_dvd_to_bkpinfo_value(bkpinfo); 448 446 449 if (bkpinfo->backup_media_type == dvd) { 447 450 #ifdef DVDRWFORMAT … … 468 471 } 469 472 470 /*471 mr_asprintf(&tmp, "wc -l %s/archives/filelist.full > %s/archives/filelist.count",bkpinfo->scratchdir, bkpinfo->scratchdir);472 if (run_program_and_log_output(tmp, 2))473 { fatal_error("Failed to count filelist.full"); }474 */475 473 mr_asprintf(&tmp, "gzip -9 %s/archives/filelist.full", 476 474 bkpinfo->scratchdir); … … 507 505 run_program_and_log_output(tmp, 1); 508 506 mr_free(tmp); 507 retval += make_those_afios_phase(bkpinfo); // backup regular files 509 508 retval += make_those_slices_phase(bkpinfo); // backup BIG files 510 509 retval += do_that_final_phase(bkpinfo); // clean up … … 577 576 578 577 mr_asprintf(&tmp, 579 "echo '%s' | tr -s ' ' '\n' | grep -E '^/dev/.*$' | tr -s '\n' ' ' | awk '{print $0\"\\n\";}'", 580 bkpinfo->exclude_paths); 578 "echo '%s' | tr -s ' ' '\n' | grep -E '^/dev/.*$' | tr -s '\n' ' ' | awk '{print $0\"\\n\";}'", 579 bkpinfo->exclude_paths); 580 581 581 devs_to_exclude = call_program_and_get_last_line_of_output(tmp); 582 582 mr_free(tmp); 583 583 584 mr_asprintf(&tmp, "devs_to_exclude = '%s'", devs_to_exclude); 584 585 mr_msg(2, tmp); … … 596 597 } 597 598 lines_in_filelist = count_lines_in_file(tmp); 598 mr_free(tmp);599 mr_asprintf(&tmp, "%s/LAST-FILELIST-NUMBER", bkpinfo->tmpdir);600 599 last_filelist_number = last_line_of_file(tmp); 601 600 mr_free(tmp); 601 602 602 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 603 603 mr_asprintf(&tape_size_sz, "%ld", bkpinfo->media_size[1]); … … 675 675 if (bkpinfo->boot_loader != '\0') { 676 676 mr_asprintf(&tmp, "User specified boot loader. It is '%c'.", 677 677 bkpinfo->boot_loader); 678 678 mr_msg(2, tmp); 679 679 mr_free(tmp); … … 683 683 if (bkpinfo->boot_device != NULL) { 684 684 mr_asprintf(&tmp, "User specified boot device. It is '%s'.", 685 685 bkpinfo->boot_device); 686 686 mr_msg(2, tmp); 687 687 mr_free(tmp); … … 757 757 } 758 758 mr_asprintf(&tmp, "Your boot loader is %s and it boots from %s", 759 759 bootldr_str, bkpinfo->boot_device); 760 760 log_to_screen(tmp); 761 761 mr_free(tmp); … … 780 780 log_OS_error("Unable to make mnt floppy directory"); 781 781 } 782 mr_free(command); 782 783 783 784 /* Prepare interface with mindi through a configuration file … … 927 928 mr_msg(2, command); 928 929 929 930 930 res = run_program_and_log_to_screen(command, "Generating boot+data disks"); 931 931 mr_free(command); … … 941 941 942 942 mr_asprintf(&command, 943 944 943 "cp -f %s/images/mindi.iso /var/cache/mindi/mondorescue.iso", 944 bkpinfo->scratchdir); 945 945 mr_msg(2, command); 946 946 run_program_and_log_output(command, FALSE); … … 949 949 if (bkpinfo->nonbootable_backup) { 950 950 mr_asprintf(&command, "cp -f %s/all.tar.gz %s/images", 951 951 bkpinfo->tmpdir, bkpinfo->scratchdir); 952 952 if (system(command)) { 953 953 fatal_error("Unable to create temporary duff tarball"); 954 mr_free(command); 955 } 956 } 954 } 955 mr_free(command); 956 957 } 958 /* 957 959 mr_asprintf(&command, "cp -f %s/mindi-*oot*.img %s/images", 958 960 bkpinfo->tmpdir, bkpinfo->scratchdir); … … 960 962 run_program_and_log_output(command, FALSE); 961 963 mr_free(command); 962 964 */ 963 965 mr_asprintf(&tmp, "cp -f %s/images/all.tar.gz %s", 964 966 bkpinfo->scratchdir, bkpinfo->tmpdir); … … 1032 1034 1033 1035 struct s_bkpinfo *bkpinfo; 1034 char *tmp ;1036 char *tmp = NULL; 1035 1037 int res = 0, retval = 0; 1036 1038 int *p_archival_threads_running; … … 1115 1117 this_thread_no, archiving_set_no); 1116 1118 res = archive_this_fileset(bkpinfo, archiving_filelist_fname, 1117 1118 1119 archiving_afioball_fname, 1120 archiving_set_no); 1119 1121 mr_free(archiving_afioball_fname); 1120 1122 mr_free(archiving_filelist_fname); … … 1157 1159 this_thread_no); 1158 1160 mr_free(archiving_filelist_fname); 1161 mr_free(archiving_afioball_fname); 1159 1162 pthread_exit(NULL); 1160 1163 } … … 1276 1279 paranoid_system(command); 1277 1280 mr_free(command); 1281 1278 1282 wipe_archives(bkpinfo->scratchdir); 1279 1283 mvaddstr_and_log_it(g_currentY++, 74, "Done."); … … 1309 1313 1310 1314 /*@ buffers *********************************************************** */ 1311 char *command ;1315 char *command = NULL; 1312 1316 char *tempfile; 1313 1317 … … 1334 1338 /* if not Debian then go ahead & use fdformat */ 1335 1339 tempfile = call_program_and_get_last_line_of_output("mktemp -q /tmp/mondo.XXXXXXXX"); 1336 mr_asprintf(&command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile, 1337 tempfile, tempfile); 1340 mr_asprintf(&command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile, tempfile, tempfile); 1338 1341 mr_msg(3, command); 1339 1342 open_evalcall_form(title); … … 1395 1398 char *title; 1396 1399 1397 1398 1400 assert_string_is_neither_NULL_nor_zerolength(device); 1401 1399 1402 if (!system("which superformat > /dev/null 2> /dev/null")) { 1400 1403 mr_asprintf(&command, "superformat %s", device); … … 1441 1444 } 1442 1445 } 1446 1443 1447 1444 1448 /** … … 1480 1484 char *storing_filelist_fname; 1481 1485 char *storing_afioball_fname; 1482 char *tmp ;1486 char *tmp = NULL; 1483 1487 char *media_usage_comment; 1484 1488 pthread_t archival_thread[ARCH_THREADS]; … … 1714 1718 1715 1719 /*@ buffers ****************************************** */ 1716 char *tmp ;1720 char *tmp = NULL; 1717 1721 char *old_pwd; 1718 char *result_sz ;1719 char *message_to_screen ;1720 char *sz_blank_disk ;1721 char *tmp2 ;1722 char *tmp3 ;1722 char *result_sz = NULL; 1723 char *message_to_screen = NULL; 1724 char *sz_blank_disk = NULL; 1725 char *tmp2 = NULL; 1726 char *tmp3 = NULL; 1723 1727 bool cd_is_mountable; 1724 1728 … … 1757 1761 if (bkpinfo->call_before_iso != NULL) { 1758 1762 mr_asprintf(&message_to_screen, "Running pre-ISO call for CD#%d", 1759 1763 g_current_media_number); 1760 1764 res = eval_call_to_make_ISO(bkpinfo, bkpinfo->call_before_iso, 1761 1762 1765 destfile, g_current_media_number, 1766 MONDO_LOGFILE, message_to_screen); 1763 1767 if (res) { 1764 1768 log_to_screen("%s...failed", message_to_screen); … … 1772 1776 if (bkpinfo->call_make_iso != NULL) { 1773 1777 mr_msg(2, "bkpinfo->call_make_iso = %s", bkpinfo->call_make_iso); 1778 /* Useless ? 1774 1779 mr_asprintf(&tmp, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir); 1780 */ 1775 1781 mr_asprintf(&message_to_screen, "Making an ISO (%s #%d)", 1776 1782 bkpinfo->backup_media_string, … … 1930 1936 } 1931 1937 } 1938 mr_free(message_to_screen); 1932 1939 if (res) { 1933 1940 log_to_screen("%s...failed", result_sz); … … 1936 1943 } 1937 1944 retval += res; 1938 mr_free(message_to_screen);1939 1945 mr_free(result_sz); 1940 1946 } … … 2037 2043 2038 2044 /*@ pointers ******************************************* */ 2039 FILE *fin ;2040 char *p ;2045 FILE *fin = NULL; 2046 char *p = NULL; 2041 2047 2042 2048 /*@ buffers ******************************************** */ 2043 char *tmp ;2049 char *tmp = NULL; 2044 2050 char *bigfile_fname = NULL; 2045 char *sz_devfile ;2051 char *sz_devfile = NULL; 2046 2052 char *ntfsprog_fifo = NULL; 2047 2053 /*@ long *********************************************** */ … … 2100 2106 ftmp = fopen(bigfile_fname, "w"); 2101 2107 paranoid_fclose(ftmp); 2102 mr_asprintf(&tmp, "bigfile %s was deleted - creating a dummy",2103 bigfile_fname);2104 2108 delete_when_done = TRUE; 2105 2109 } else { … … 2116 2120 mr_asprintf(&sz_devfile, "%s/%d.%d.000", 2117 2121 bkpinfo->tmpdir, 2118 2119 2122 (int) (random() % 32768), 2123 (int) (random() % 32768)); 2120 2124 mkfifo(sz_devfile, 0x770); 2121 2125 ntfsprog_fifo = sz_devfile; … … 2128 2132 bigfile_fname, sz_devfile); 2129 2133 res = feed_into_ntfsprog(bigfile_fname, sz_devfile); 2134 mr_free(sz_devfile); 2130 2135 exit(res); 2131 2136 break; … … 2134 2139 "feed_into_ntfsprog() called in background --- pid=%ld", 2135 2140 (long int) (pid)); 2136 2137 2141 mr_free(sz_devfile); 2142 break; 2138 2143 } 2139 2144 } … … 2144 2149 2145 2150 // Whether partition or biggiefile, just do your thang :-) 2146 mr_msg( 2, "Bigfile #%ld is '%s' (%ld KB)",2151 mr_msg(5, "Bigfile #%ld is '%s' (%ld KB)", 2147 2152 biggie_file_number + 1, bigfile_fname, 2148 2153 (long) biggie_fsize >> 10); … … 2174 2179 mr_asprintf(&tmp, "Archiving %s ... OK!", bigfile_fname); 2175 2180 } 2176 2181 mr_msg(4,tmp); 2182 mr_free(tmp); 2177 2183 if (delete_when_done) { 2178 2184 unlink(bigfile_fname); … … 2180 2186 } 2181 2187 } 2182 #ifndef _XWIN2183 2188 if (!g_text_mode) { 2184 2189 newtDrawRootText(0, g_noof_rows - 2, tmp); 2185 2190 newtRefresh(); 2186 2191 } 2187 #endif 2188 } 2189 mr_free(tmp); 2192 } 2190 2193 mr_free(bigfile_fname); 2191 2194 paranoid_fclose(fin); … … 2212 2215 2213 2216 /*@ buffers ********************************************** */ 2214 char *curr_filelist_fname ;2215 char *curr_afioball_fname ;2216 char *curr_xattr_list_fname ;2217 char *curr_acl_list_fname ;2218 char * tmp;2219 char * media_usage_comment;2217 char *curr_filelist_fname = NULL; 2218 char *curr_afioball_fname = NULL; 2219 char *curr_xattr_list_fname = NULL; 2220 char *curr_acl_list_fname = NULL; 2221 char *media_usage_comment = NULL; 2222 char *tmp = NULL; 2220 2223 2221 2224 /* BERLIOS: Useless ? … … 2254 2257 mr_msg(1, "Archiving set %ld", curr_set_no); 2255 2258 res = archive_this_fileset(bkpinfo, curr_filelist_fname, 2256 2259 curr_afioball_fname, curr_set_no); 2257 2260 retval += res; 2258 2261 if (res) { … … 2399 2402 2400 2403 /*@ buffers ************************************************** */ 2401 char *biggielist ;2402 char *command ;2403 char *blah ;2404 char *xattr_fname ;2405 char *acl_fname ;2404 char *biggielist = NULL; 2405 char *command = NULL; 2406 char *blah = NULL; 2407 char *xattr_fname = NULL; 2408 char *acl_fname = NULL; 2406 2409 2407 2410 assert(bkpinfo != NULL); … … 2419 2422 2420 2423 mr_asprintf(&command, "cp %s/biggielist.txt %s", bkpinfo->tmpdir, 2421 2424 biggielist); 2422 2425 paranoid_system(command); 2423 2426 mr_free(command); … … 2515 2518 2516 2519 /*@ buffers ******************************************************** */ 2517 char *tmp, *curr_file, *cf; 2520 char *tmp = NULL; 2521 char *curr_file = NULL; 2522 char *cf = NULL; 2518 2523 2519 2524 /*@ long ************************************************************ */ … … 2528 2533 continue; 2529 2534 } 2530 mr_asprintf(&curr_file, "%s",cf);2535 mr_asprintf(&curr_file, cf); 2531 2536 if (!does_file_exist(curr_file)) { 2532 2537 mr_msg(1, … … 2558 2563 continue; 2559 2564 } 2560 mr_asprintf(&curr_file, "%s",cf);2565 mr_asprintf(&curr_file, cf); 2561 2566 2562 2567 mr_asprintf(&tmp, "mv -f %s %s/archives/", curr_file, … … 2600 2605 { 2601 2606 /*@ buffer ************************************************************ */ 2602 char *tmp ;2603 char *comment ;2604 char *bootdisk_dev ;2605 char *datadisk_dev ;2606 char *bootdisk_file ;2607 char *rootdisk_file ;2607 char *tmp = NULL; 2608 char *comment = NULL; 2609 char *bootdisk_dev =NULL; 2610 char *datadisk_dev = NULL; 2611 char *bootdisk_file = NULL; 2612 char *rootdisk_file = NULL; 2608 2613 2609 2614 /*@ int *************************************************************** */ … … 2617 2622 assert(bkpinfo != NULL); 2618 2623 assert_string_is_neither_NULL_nor_zerolength(imagesdir); 2619 2620 2624 2621 2625 if (!ask_me_yes_or_no … … 2628 2632 system("/usr/sbin/fdcontrol -F 1722 /dev/fd0.1722"); 2629 2633 #endif 2630 mr_asprintf(&bootdisk_dev, "%s",DEFAULT_1722MB_DISK);2634 mr_asprintf(&bootdisk_dev, DEFAULT_1722MB_DISK); 2631 2635 } else if (does_device_exist(BACKUP_1722MB_DISK)) { 2632 2636 mr_asprintf(&bootdisk_dev, "/dev/fd0H1722"); … … 2635 2639 mr_asprintf(&bootdisk_dev, DEFAULT_1722MB_DISK); 2636 2640 } 2637 mr_asprintf(&datadisk_dev, " %s", "/dev/fd0");2641 mr_asprintf(&datadisk_dev, "/dev/fd0"); 2638 2642 if (!does_device_exist(datadisk_dev)) { 2639 2643 mr_msg(1, "Warning - can't find a 1.44MB floppy device *sigh*"); 2640 mr_free(datadisk_dev);2641 mr_asprintf(&datadisk_dev, "%s", "/dev/fd0");2642 2644 } 2643 2645 format_first = ask_me_yes_or_no 2644 2646 ("Do you want me to format the disks before I write to them?"); 2645 2647 2646 /* boot disk */2648 /* boot disk */ 2647 2649 if (ask_me_OK_or_cancel("About to write boot disk")) { 2648 2650 log_to_screen("Writing boot floppy"); … … 2705 2707 } 2706 2708 mr_free(rootdisk_file); 2707 mr_free(bootdisk_file); 2708 } 2709 2710 } 2711 mr_free(bootdisk_file); 2709 2712 #endif 2710 2713 } … … 2734 2737 res += write_image_to_floppy(datadisk_dev, tmp); 2735 2738 } 2736 } 2739 mr_free(tmp); 2740 } 2741 /* In case of break free mem as well */ 2737 2742 mr_free(tmp); 2738 2743 mr_free(datadisk_dev); … … 2751 2756 */ 2752 2757 2753 int 2754 offer_to_write_boot_floppies_to_physical_disks(struct s_bkpinfo *bkpinfo) 2755 { 2758 int offer_to_write_boot_floppies_to_physical_disks(struct s_bkpinfo *bkpinfo) { 2759 2756 2760 int res = 0; 2757 2761 … … 2827 2831 char start_chr; 2828 2832 char stop_chr; 2829 char *curr_file, *cf; 2833 char *curr_file = NULL; 2834 char *cf = NULL; 2830 2835 /*@ long long ****************************************************** */ 2831 2836 off_t length_of_incoming_file = (off_t)0; … … 2839 2844 continue; 2840 2845 } 2841 mr_asprintf(&curr_file, "%s",cf);2846 mr_asprintf(&curr_file, cf); 2842 2847 if (!does_file_exist(curr_file)) { 2843 2848 mr_msg(1, … … 3115 3120 3116 3121 /*@ buffers ************************************************** */ 3117 char *tmp, *checksum_line = NULL, *command; 3118 char *tempblock; 3119 char *curr_slice_fname_uncompressed; 3120 char *curr_slice_fname_compressed; 3121 char *file_to_archive; 3122 char *file_to_openin; 3122 char *tmp = NULL; 3123 char *checksum_line = NULL; 3124 char *command = NULL; 3125 char *tempblock = NULL; 3126 char *curr_slice_fname_uncompressed = NULL; 3127 char *curr_slice_fname_compressed = NULL; 3128 char *file_to_archive = NULL; 3129 char *file_to_openin = NULL; 3123 3130 /*@ pointers ************************************************** */ 3124 char *pB; 3125 FILE *fin, *fout; 3131 char *pB = NULL; 3132 FILE *fin = NULL; 3133 FILE *fout = NULL; 3126 3134 3127 3135 /*@ bool ****************************************************** */ … … 3134 3142 long optimal_set_size; 3135 3143 bool should_I_compress_slices; 3136 char *suffix ; // for compressed slices3144 char *suffix = NULL; // for compressed slices 3137 3145 3138 3146 /*@ long long ************************************************** */ … … 3158 3166 if (is_this_file_compressed(biggie_filename) 3159 3167 || bkpinfo->compression_level == 0) { 3160 mr_asprintf(&suffix, " %s", "");3168 mr_asprintf(&suffix, ""); 3161 3169 // log_it("%s is indeed compressed :-)", filename); 3162 3170 should_I_compress_slices = FALSE; 3163 3171 } else { 3164 mr_asprintf(&suffix, "%s",bkpinfo->zip_suffix);3172 mr_asprintf(&suffix, bkpinfo->zip_suffix); 3165 3173 should_I_compress_slices = TRUE; 3166 3174 } … … 3199 3207 log_OS_error("Unable to popen-in command"); 3200 3208 mr_free(command); 3209 mr_free(suffix); 3201 3210 return (1); 3202 3211 } … … 3207 3216 } 3208 3217 lstat(biggie_filename, &biggiestruct.properties); 3209 if (strlen( checksum_line) <= MAX_STR_LEN) {3218 if (strlen(biggie_filename) <= MAX_STR_LEN) { 3210 3219 strcpy(biggiestruct.filename, biggie_filename); 3211 3220 } else { … … 3229 3238 fout = fopen(tmp, "w"); 3230 3239 mr_free(tmp); 3240 3231 3241 (void) fwrite((void *) &biggiestruct, 1, sizeof(biggiestruct), fout); 3232 3242 paranoid_fclose(fout); … … 3240 3250 log_to_screen(tmp); 3241 3251 mr_free(tmp); 3242 3243 3252 mr_free(suffix); 3244 3253 return (1); … … 3262 3271 if (!(fout = fopen(curr_slice_fname_uncompressed, "w"))) { 3263 3272 log_OS_error(curr_slice_fname_uncompressed); 3264 3265 3273 mr_free(curr_slice_fname_uncompressed); 3266 3274 mr_free(curr_slice_fname_compressed); … … 3268 3276 return (1); 3269 3277 } 3270 if (!(tempblock = (char *) malloc(256 * 1024))) { 3271 fatal_error("malloc error 256*1024"); 3272 } 3278 tempblock = mr_malloc(256 * 1024); 3273 3279 if ((i == bkpinfo->optimal_set_size / 256) 3274 3280 && (totalread < 1.1 * totallength)) { … … 3279 3285 (void) fwrite(tempblock, 1, blksize, fout); 3280 3286 } else { 3287 mr_free(tempblock); 3288 mr_free(curr_slice_fname_uncompressed); 3289 mr_free(curr_slice_fname_compressed); 3281 3290 break; 3282 3291 } … … 3302 3311 log_OS_error(command); 3303 3312 } 3304 // did_I_compress_slice = TRUE; 3313 mr_free(command); 3314 // did_I_compress_slice = TRUE; 3305 3315 } else { 3306 3316 /* BERLIOS: Useless … … 3310 3320 */ 3311 3321 res = 0; // don't do it :) 3312 // 3322 // did_I_compress_slice = FALSE; 3313 3323 } 3314 3324 retval += res; … … 3329 3339 slice_num); 3330 3340 } 3331 #ifndef _XWIN3332 3341 if (!g_text_mode) { 3333 3342 newtDrawRootText(0, g_noof_rows - 2, tmp); … … 3336 3345 mr_msg(2, tmp); 3337 3346 } 3338 #else3339 mr_msg(2, tmp);3340 #endif3341 3347 mr_free(tmp); 3342 mr_asprintf(&file_to_archive, "%s",curr_slice_fname_compressed);3348 mr_asprintf(&file_to_archive, curr_slice_fname_compressed); 3343 3349 g_current_progress++; 3344 3350 } else { /* if i==0 then ... */ 3345 3351 3346 3352 finished = TRUE; 3347 mr_asprintf(&file_to_archive, "%s", 3348 curr_slice_fname_uncompressed); 3353 mr_asprintf(&file_to_archive, curr_slice_fname_uncompressed); 3349 3354 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 3350 3355 break; … … 3405 3410 { 3406 3411 /*@ buffers ********************************************* */ 3407 char *tmp ;3408 char *dir ;3412 char *tmp = NULL; 3413 char *dir = NULL; 3409 3414 3410 3415 assert_string_is_neither_NULL_nor_zerolength(d); … … 3461 3466 3462 3467 /*@ buffers ************************************************** */ 3463 char *tmp ;3468 char *tmp = NULL; 3464 3469 3465 3470 assert(bkpinfo != NULL); … … 3634 3639 } 3635 3640 } 3636 /*3637 if (using_nfs)3638 {3639 mr_asprintf(&tmp,"mv -f %s %s/%s/", isofile, bkpinfo->isodir, bkpinfo->nfs_remote_dir);3640 if (run_program_and_log_output(tmp, FALSE))3641 { log_to_screen("Unable to move ISO to NFS dir"); }3642 }3643 */3644 3641 mr_free(isofile); 3645 3642 … … 3684 3681 { 3685 3682 int res = 0, retval = 0, cdno = 0; 3686 char *tmp ;3683 char *tmp = NULL; 3687 3684 long diffs = 0; 3688 3685 … … 3869 3866 /* @} - end of utilityGroup */ 3870 3867 3871 void setenv_mondo_share(void) { 3872 3873 setenv("MONDO_SHARE", MONDO_SHARE, 1); 3874 setenv("MONDORESTORECFG", MONDORESTORECFG, 1); 3875 setenv("MONDO_CACHE", MONDO_CACHE, 1); 3868 void setenv_mondo_var(void) { 3869 3870 char *tmp = NULL; 3871 char *p = NULL; 3872 char *path_min = "/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin"; 3873 3874 mr_setenv("MONDO_SHARE",MONDO_SHARE); 3875 mr_setenv("MONDORESTORECFG",MONDORESTORECFG); 3876 mr_setenv("MONDO_CACHE",MONDO_CACHE); 3877 3878 if ((p = getenv("PATH")) == NULL) { 3879 mr_asprintf(&p,path_min); 3880 } 3881 mr_asprintf(&tmp, "%s:%s",p, path_min); 3882 mr_free(p); 3883 mr_setenv("PATH",tmp); 3884 mr_free(tmp); 3876 3885 } 3877 3886 -
trunk/mondo/src/common/libmondo-devices.c
r1086 r1161 18 18 #include "libmondo-stream-EXT.h" 19 19 #include "mr_mem.h" 20 #include "mr_msg.h" 20 21 21 22 #include <sys/ioctl.h> … … 169 170 bool am_I_in_disaster_recovery_mode(void) 170 171 { 171 char *tmp, *comment; 172 char *tmp = NULL; 173 char *comment = NULL; 172 174 bool is_this_a_ramdisk = FALSE; 173 175 … … 219 221 * @ingroup stringGroup 220 222 */ 221 char *bkptype_to_string(t_bkptype bt)223 static char *bkptype_to_string(t_bkptype bt) 222 224 { 223 225 char *output = NULL; 224 225 mr_free(output);226 226 227 227 switch (bt) { … … 250 250 mr_asprintf(&output, _("udev")); 251 251 break; 252 case usb: 253 mr_asprintf(&output, _("usb")); 254 break; 252 255 default: 253 256 mr_asprintf(&output, _("default")); … … 268 271 int eject_device(char *dev) 269 272 { 270 char *command ;273 char *command = NULL; 271 274 int res1 = 0, res2 = 0; 272 275 … … 309 312 int inject_device(char *dev) 310 313 { 311 char *command ;314 char *command = NULL; 312 315 int i; 313 316 … … 337 340 338 341 /*@ buffers *********************************************************** */ 339 char *tmp ;340 bool ret ;342 char *tmp = NULL; 343 bool ret = FALSE; 341 344 342 345 assert_string_is_neither_NULL_nor_zerolength(device); … … 380 383 { 381 384 /*@ buffers **************************************************** */ 382 char *program ;385 char *program = NULL; 383 386 char *incoming = NULL; 384 char *searchstr ;385 char *tmp ;387 char *searchstr = NULL; 388 char *tmp = NULL; 386 389 387 390 /*@ ints ******************************************************* */ … … 444 447 { 445 448 /*@ buffers **************************************************** */ 446 char *command ;449 char *command = NULL; 447 450 448 451 /*@ end vars *************************************************** */ … … 475 478 { 476 479 /*@ buffers **************************************************** */ 477 char *command ;480 char *command = NULL; 478 481 /*@ end vars *************************************************** */ 479 482 int ret; … … 1148 1151 /*@ buffers ***************************************************** */ 1149 1152 char *incoming = NULL; 1150 char *device_with_tab ;1151 char *device_with_space ;1152 char *tmp ;1153 char *device_with_tab = NULL; 1154 char *device_with_space = NULL; 1155 char *tmp = NULL; 1153 1156 size_t n = 0; 1154 1157 … … 1190 1193 { 1191 1194 paranoid_pclose(fin); 1195 mr_free(incoming); 1192 1196 return(TRUE); 1193 1197 } … … 1232 1236 mr_free(mddevice); 1233 1237 mr_asprintf(&mddevice, "vn%ic", vndev++); 1234 1235 1238 mr_free(command); 1236 1239 mr_asprintf(&command, "vnconfig %s %s", mddevice, fname); … … 1281 1284 ("/sbin/sysctl -n kern.osreldate")) < 500000) { 1282 1285 mr_asprintf(&command, "vnconfig -d %s", dname); 1283 ret = system(command);1284 mr_free(command);1285 return(ret);1286 1286 } else { 1287 1287 mr_asprintf(&command, "mdconfig -d -u %s", dname); 1288 ret = system(command); 1289 mr_free(command); 1290 return(ret); 1291 } 1292 /*NOTREACHED*/ return 255; 1288 } 1289 ret = system(command); 1290 mr_free(command); 1291 return(ret); 1293 1292 } 1294 1293 #endif … … 1315 1314 1316 1315 /*@ buffers ********************************************************* */ 1317 char *tmp ;1318 char *request ;1316 char *tmp = NULL; 1317 char *request = NULL; 1319 1318 1320 1319 assert(bkpinfo != NULL); … … 1328 1327 return; 1329 1328 } 1330 1331 1329 mr_asprintf(&tmp, "mkdir -p " MNT_CDROM); 1332 1330 run_program_and_log_output(tmp, 5); … … 1708 1706 mr_asprintf(&comment, 1709 1707 _("How much data (in Megabytes) will each media store?")); 1710 if (!popup_and_get_string(_("Size"), comment, sz_size )) {1708 if (!popup_and_get_string(_("Size"), comment, sz_size, 5)) { 1711 1709 log_to_screen(_("User has chosen not to backup the PC")); 1712 1710 finish(1); 1713 1711 } 1712 mr_free(comment); 1714 1713 for (i = 0; i <= MAX_NOOF_MEDIA; i++) { 1715 1714 bkpinfo->media_size[i] = atoi(sz_size); … … 1719 1718 finish(1); 1720 1719 } 1721 mr_free(comment);1722 1720 } 1723 1721 if (bkpinfo->disaster_recovery) { … … 1769 1767 1770 1768 mr_free(command); 1771 mr_asprintf(&command, "echo hi > %s/%s/.dummy.txt",1772 bkpinfo->isodir,bkpinfo->nfs_remote_dir);1769 mr_asprintf(&command, "echo hi > '%s/%s/.dummy.txt'", bkpinfo->isodir, 1770 bkpinfo->nfs_remote_dir); 1773 1771 } 1774 1772 mr_free(command); … … 1984 1982 log_it("media size = %ld", bkpinfo->media_size[1]); 1985 1983 log_it("media type = %s", bkpinfo->backup_media_string); 1986 mr_free(tmp);1987 1984 log_it("prefix = %s", bkpinfo->prefix); 1988 1985 log_it("compression = %ld", bkpinfo->compression_level); … … 2021 2018 */ 2022 2019 } 2023 2024 2025 2020 /* @} - end of utilityGroup */ 2021 2026 2022 2027 2023 /** … … 2034 2030 { 2035 2031 char *tmp = NULL; 2036 2037 2032 char *command = NULL; 2033 char *sz = NULL; 2038 2034 int i = 0; 2039 2035 … … 2086 2082 bool set_dev_to_this_if_rx_OK(char *output, char *dev) 2087 2083 { 2088 char *command ;2084 char *command = NULL; 2089 2085 2090 2086 mr_free(output); … … 2142 2138 mr_free(mountdev); 2143 2139 mr_free(tmp); 2144 2145 2140 return (cd_number); 2146 2141 } … … 2200 2195 * @note Under Linux, all drives are examined, not just @p which_device. 2201 2196 */ 2197 char which_boot_loader(char *which_device) 2198 { 2202 2199 #ifdef __FreeBSD__ 2203 char which_boot_loader(char *which_device)2204 {2205 2200 int count_lilos = 0; 2206 2201 int count_grubs = 0; … … 2241 2236 return ('U'); 2242 2237 } 2243 }2244 2245 2238 #else 2246 2247 char which_boot_loader(char *which_device)2248 /* which_device is allocated here and needs to be freed by caller */2249 {2250 2239 /*@ buffer ***************************************************** */ 2251 2240 char *list_drives_cmd; … … 2310 2299 return ('U'); 2311 2300 } 2312 } 2313 #endif 2301 #endif 2302 } 2314 2303 2315 2304 … … 2435 2424 mr_free(tmp); 2436 2425 mr_msg(0, "Found %s partition table format type", output); 2437 return (output); 2438 } 2439 2426 return(output); 2427 } 2440 2428 /* @} - end of deviceGroup */ -
trunk/mondo/src/common/libmondo-fifo.c
r1086 r1161 28 28 #include "libmondo.h" 29 29 #include "mr_mem.h" 30 #include "mr_msg.h" 30 31 31 32 /** … … 155 156 void kill_buffer() 156 157 { 157 char *tmp ;158 char *command ;158 char *tmp = NULL; 159 char *command = NULL; 159 160 160 161 sync(); … … 175 176 mr_asprintf(&command, "kill %s", tmp); 176 177 mr_msg(2, "kill_buffer() --- command = %s", command); 177 178 178 if (strlen(tmp) > 0) { 179 179 run_program_and_log_output(command, TRUE); -
trunk/mondo/src/common/libmondo-filelist.c
r1106 r1161 19 19 #include "mr_str.h" 20 20 #include "mr_mem.h" 21 #include "mr_msg.h" 21 22 22 23 #include <time.h> … … 332 333 then update_progress_form() won't show the "time taken / time remaining" 333 334 line. The bug only crops up AFTER the call to chop_filelist(). Weird. */ 334 #ifndef _XWIN335 335 if (!g_text_mode) { 336 336 open_progress_form("", "", "", "", 100); … … 339 339 newtPopWindow(); 340 340 } 341 #endif342 341 return (curr_set_no + 1); 343 342 } … … 386 385 } 387 386 filelist->ch = '\0'; 388 mr_free( (void *)filelist);387 mr_free(filelist); 389 388 depth--; 390 389 if (depth == 0) { … … 490 489 { 491 490 char *command = NULL; 492 char *tmp = NULL;493 491 int retval = 0; 494 492 … … 542 540 mr_asprintf(&masklist, "/tmp/%d.%d.mask", (int) (random() % 32768), 543 541 (int) (random() % 32768)); 542 544 543 mr_asprintf(&command, "cp -f %s %s", orig_msklist, masklist); 545 544 run_program_and_log_output(command, 1); … … 752 751 return (add_string_at_node(node->right, string_to_add)); 753 752 } 753 754 754 // walk down tree if appropriate 755 755 if (node->down != NULL && node->ch == char_to_add) { … … 765 765 return (1); 766 766 } 767 767 768 // add here 768 769 newnode = (struct s_node *) mr_malloc(sizeof(struct s_node)); … … 1216 1217 long g_skeleton_entries = 0; 1217 1218 1218 1219 1219 /** 1220 1220 * Wrapper around mondo_makefilelist(). … … 1234 1234 /*@ int **************************************************** */ 1235 1235 int res = 0; 1236 /*@ buffers ************************************************ */1237 1236 1238 1237 assert(bkpinfo != NULL); … … 1343 1342 system(strtmp); 1344 1343 mr_free(strtmp); 1345 mr_free(tmp);1346 1347 1344 mr_asprintf(&tmp, "wc -l %s | awk '{print $1;}'", skeleton_filelist); 1348 1345 tmp1 = call_program_and_get_last_line_of_output(tmp); … … 1522 1519 char *tmp1 = NULL; 1523 1520 char *tmp2 = NULL; 1524 char *sz_datefile ;1521 char *sz_datefile = NULL; 1525 1522 char *sz_filelist = NULL; 1526 1523 char *exclude_paths = NULL; … … 1734 1731 size_t len = 0; // Scrub's patch doesn't work without that 1735 1732 1736 // mr_msg(1, "use_star = %s", (use_star)?"TRUE":"FALSE");1737 1733 mr_msg(5, "starting"); 1738 1734 mr_msg(5, "needles_list_fname = %s", needles_list_fname); -
trunk/mondo/src/common/libmondo-files.c
r1106 r1161 45 45 /*@ buffers ***************************************************** */ 46 46 static char *output = NULL; 47 char *command; 48 char *tmp; 47 48 char *command = NULL; 49 char *tmp = NULL; 49 50 size_t n = 0; 50 51 … … 94 95 95 96 /*@ buffers ***************************************************** */ 96 char *command ;97 char *command = NULL; 97 98 char *incoming = NULL; 98 char *tmp ;99 char *tmp = NULL; 99 100 100 101 /*@ long ******************************************************** */ … … 207 208 if (!(fout = fopen(outfname, "w"))) { 208 209 log_OS_error("Unable to openout outfname"); 210 mr_free(infname); 209 211 mr_free(outfname); 210 212 return; … … 600 602 void register_pid(pid_t pid, char *name_str) 601 603 { 602 char *tmp ;603 char *lockfile_fname ;604 char *tmp = NULL; 605 char *lockfile_fname = NULL; 604 606 int res; 605 607 size_t n = 0; … … 754 756 } 755 757 756 757 758 /** 758 759 * Determine the amount of space (in KB) occupied by a mounted CD. … … 942 943 { 943 944 /*@ Char buffers ** */ 944 char *command ;945 char *command = NULL; 945 946 char *tmp; 946 947 char old_pwd[MAX_STR_LEN]; … … 964 965 mr_free(command); 965 966 966 mr_asprintf(&tmp, "%s/payload.tgz", g_mondo_home);967 968 967 /* i18n */ 969 968 mr_asprintf(&command, CP_BIN " --parents /usr/share/locale/*/LC_MESSAGES/mondo.mo %s",bkpinfo->scratchdir); … … 972 971 mr_free(command); 973 972 973 mr_asprintf(&tmp, "%s/payload.tgz", g_mondo_home); 974 974 if (does_file_exist(tmp)) { 975 975 log_it("Untarring payload %s to scratchdir %s", tmp, … … 1114 1114 "ifconfig %s | awk '{print $5}' | head -n1", nfs_dev); 1115 1115 mac_addr = call_program_and_get_last_line_of_output(command); 1116 mr_free(command); 1117 1116 1118 mr_asprintf(&command, 1117 "ifconfig | grep -E '%s' | grep -v '%s' | head -n1 | cut -d' ' -f1", mac_addr );1119 "ifconfig | grep -E '%s' | grep -v '%s' | head -n1 | cut -d' ' -f1", mac_addr, nfs_dev); 1118 1120 mr_free(nfs_dev); 1119 1121 nfs_dev = call_program_and_get_last_line_of_output(command); … … 1125 1127 1126 1128 mr_free(nfs_dev); 1127 mr_free(tmp);1128 1129 1129 fd1 = mr_fopen(MONDORESTORECFG, "a"); 1130 1130 mr_fprintf(fd1, "nfs-dev %s\n", nfs_dev); … … 1266 1266 int make_grub_install_scriptlet(char *outfile) 1267 1267 { 1268 FILE *fout ;1269 char *tmp ;1268 FILE *fout = NULL; 1269 char *tmp = NULL; 1270 1270 int retval = 0; 1271 1271 -
trunk/mondo/src/common/libmondo-fork.c
r1086 r1161 69 69 70 70 /*@ buffers *** */ 71 char *midway_call, *ultimate_call, *tmp, *command, 72 *cd_number_str; 73 char *p; 71 char *midway_call, *ultimate_call, *tmp; 72 char *p = NULL; 73 char *cd_number_str = NULL; 74 char *command = NULL; 75 74 76 75 77 /*@*********** End Variables ***************************************/ … … 80 82 assert_string_is_neither_NULL_nor_zerolength(isofile); 81 83 assert_string_is_neither_NULL_nor_zerolength(logstub); 84 82 85 midway_call = mr_malloc(1200); 83 86 ultimate_call = mr_malloc(1200); … … 260 263 261 264 /*@ buffers **************************************************** */ 262 char *tmp ;263 char *command ;264 char *lockfile ;265 char *tmp = NULL; 266 char *command = NULL; 267 char *lockfile = NULL; 265 268 266 269 /*@ end vars *************************************************** */ … … 304 307 res = pclose(fin); 305 308 /* Log actual pclose errors. */ 306 if (errno) 309 if (errno) { 307 310 mr_msg(5, "pclose err: %d", errno); 311 } 308 312 /* Check if we have a valid status. If we do, extract the called program's exit code. */ 309 313 /* If we don't, highlight this fact by returning -1. */ … … 590 594 591 595 /*@ buffers *********************************************************** */ 592 char *command ;596 char *command = NULL; 593 597 /*@ pointers ********************************************************** */ 594 598 static int chldres = 0; -
trunk/mondo/src/common/libmondo-mountlist.c
r1086 r1161 17 17 #include "newt-specific-EXT.h" 18 18 #include "mr_mem.h" 19 #include "mr_m em.h"19 #include "mr_msg.h" 20 20 21 21 /*@unused@*/
Note:
See TracChangeset
for help on using the changeset viewer.