Changeset 688 in MondoRescue for trunk/mondo/mondo/common/libmondo-archive.c
- Timestamp:
- Jul 17, 2006, 3:44:46 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/mondo/common/libmondo-archive.c
r687 r688 27 27 #include <sys/ipc.h> 28 28 #include <stdarg.h> 29 #include <unistd.h> 29 30 #define DVDRWFORMAT 1 30 31 … … 230 231 log_msg(5, "command='%s'", command); 231 232 res = system(command); 232 asprintf(&tmp, "%s",last_line_of_file(MONDO_LOGFILE));233 tmp = last_line_of_file(MONDO_LOGFILE)); 233 234 log_msg(1, "res=%d; tmp='%s'", res, tmp); 234 235 if (bkpinfo->use_star && (res == 254 || res == 65024) … … 296 297 297 298 /*@ buffers ******************************************************** */ 298 char *command ;299 char *command = NULL; 299 300 char *zipparams = NULL; 300 char *tmp, *tmp1; 301 char *tmp = NULL; 302 char *tmp1 = NULL; 301 303 302 304 assert(bkpinfo != NULL); … … 389 391 390 392 if (g_tmpfs_mountpt[0] != '\0') { 391 i = atoi(call_program_and_get_last_line_of_output 392 ("df -m -P | grep dev/shm | grep -v none | tr -s ' ' '\t' | cut -f4")); 393 tmp = call_program_and_get_last_line_of_output 394 ("df -m -P | grep dev/shm | grep -v none | tr -s ' ' '\t' | cut -f4"); 395 i = atoi(tmp); 396 paranoid_free(tmp); 397 393 398 if (i > 0) { 394 399 if (free_ramdisk_space > i) { … … 466 471 copy_mondo_and_mindi_stuff_to_scratchdir(bkpinfo); // payload, too, if it exists 467 472 #if __FreeBSD__ == 5 468 strcpy(bkpinfo->kernel_path, "/boot/kernel/kernel");473 paranoid_alloc(bkpinfo->kernel_path, "/boot/kernel/kernel"); 469 474 #elif __FreeBSD__ == 4 470 strcpy(bkpinfo->kernel_path, "/kernel");475 paranoid_alloc(bkpinfo->kernel_path, "/kernel"); 471 476 #elif linux 472 477 if (figure_out_kernel_path_interactively_if_necessary … … 523 528 { 524 529 /*@ buffer ************************************************************ */ 525 char *tmp ;526 char *command ;527 char *use_lzo_sz ;528 char *use_comp_sz ;529 char *use_star_sz ;530 char *bootldr_str ;531 char *tape_device ;532 char *last_filelist_number ;533 char *broken_bios_sz ;534 char *cd_recovery_sz ;535 char *tape_size_sz ;536 char *devs_to_exclude ;537 char *use_lilo_sz ;538 char *value ;539 char *bootdev ;530 char *tmp = NULL; 531 char *command = NULL; 532 char *use_lzo_sz = NULL; 533 char *use_comp_sz = NULL; 534 char *use_star_sz = NULL; 535 char *bootldr_str = NULL; 536 char *tape_device = NULL; 537 char *last_filelist_number = NULL; 538 char *broken_bios_sz = NULL; 539 char *cd_recovery_sz = NULL; 540 char *tape_size_sz = NULL; 541 char *devs_to_exclude = NULL; 542 char *use_lilo_sz = NULL; 543 char *value = NULL; 544 char *bootdev = NULL; 540 545 541 546 … … 556 561 "echo '%s' | tr -s ' ' '\n' | grep -x '/dev/.*' | tr -s '\n' ' ' | awk '{print $0\"\\n\";}'", 557 562 bkpinfo->exclude_paths); 558 asprintf(&devs_to_exclude, 559 call_program_and_get_last_line_of_output(tmp)); 563 devs_to_exclude = call_program_and_get_last_line_of_output(tmp); 560 564 paranoid_free(tmp); 561 565 asprintf(&tmp, "devs_to_exclude = '%s'", devs_to_exclude); … … 576 580 paranoid_free(tmp); 577 581 asprintf(&tmp, "%s/LAST-FILELIST-NUMBER", bkpinfo->tmpdir); 578 asprintf(&last_filelist_number, last_line_of_file(tmp));582 last_filelist_number = last_line_of_file(tmp); 579 583 paranoid_free(tmp); 580 584 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { … … 617 621 if (!bkpinfo->nonbootable_backup 618 622 && (bkpinfo->boot_loader == '\0' 619 || bkpinfo->boot_device [0] == '\0')) {623 || bkpinfo->boot_device == NULL)) { 620 624 621 625 #ifdef __FreeBSD__ 622 asprintf(&bootdev, call_program_and_get_last_line_of_output 623 ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'")); 624 if (!bootdev[0]) { 626 bootdev = call_program_and_get_last_line_of_output 627 ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'"); 628 if (!bootdev) { 629 bootdev = call_program_and_get_last_line_of_output 630 ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'"); 631 } 632 #else 633 bootdev = call_program_and_get_last_line_of_output 634 ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"); 635 if (!bootdev) { 636 bootdev = call_program_and_get_last_line_of_output 637 ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"); 638 } 639 if ((bootdev) && (strstr(bootdev, "/dev/cciss/"))) { 625 640 paranoid_free(bootdev); 626 asprintf(&bootdev, call_program_and_get_last_line_of_output 627 ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'")); 628 } 629 #else 630 asprintf(&bootdev, call_program_and_get_last_line_of_output 631 ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'")); 632 if (strstr(bootdev, "/dev/cciss/")) { 633 paranoid_free(bootdev); 634 asprintf(&bootdev, call_program_and_get_last_line_of_output 635 ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | cut -dp -f1")); 636 } 637 if (!bootdev[0]) { 638 paranoid_free(bootdev); 639 asprintf(&bootdev, call_program_and_get_last_line_of_output 640 ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'")); 641 if (strstr(bootdev, "/dev/cciss/")) { 642 paranoid_free(bootdev); 643 asprintf(&bootdev, call_program_and_get_last_line_of_output 644 ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | cut -dp -f1")); 645 } 641 bootdev = call_program_and_get_last_line_of_output 642 ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | cut -dp -f1"); 646 643 } 647 644 #endif 648 if (bootdev [0])645 if (bootdev) 649 646 ch = which_boot_loader(bootdev); 650 647 else … … 658 655 bkpinfo->boot_loader = ch; 659 656 } 660 if (bkpinfo->boot_device [0] != '\0') {657 if (bkpinfo->boot_device != NULL) { 661 658 asprintf(&tmp, "User specified boot device. It is '%s'.", 662 659 bkpinfo->boot_device); 663 660 log_msg(2, tmp); 664 661 paranoid_free(tmp); 662 paranoid_free(bootdev); 665 663 } else { 666 strcpy(bkpinfo->boot_device, bootdev); 667 } 668 } 669 paranoid_free(bootdev); 664 bkpinfo->boot_device = bootdev; 665 } 666 } 670 667 671 668 if ( … … 797 794 estimated_total_noof_slices = 798 795 size_of_all_biggiefiles_K(bkpinfo) / bkpinfo->optimal_set_size + 1; 799 /* add nfs stuff here? */800 796 asprintf(&command, "mkdir -p %s/images", bkpinfo->scratchdir); 801 797 if (system(command)) { … … 916 912 log_to_screen("Mindi failed to create your boot+data disks."); 917 913 asprintf(&command, "grep 'Fatal error' /var/log/mindi.log"); 918 asprintf(&tmp, call_program_and_get_last_line_of_output(command));914 tmp = call_program_and_get_last_line_of_output(command); 919 915 paranoid_free(command); 920 916 if (strlen(tmp) > 1) { … … 1176 1172 asprintf(&data_disks_file, "%s/all.tar.gz", bkpinfo->tmpdir); 1177 1173 1178 asprintf(&g_serial_string, 1179 call_program_and_get_last_line_of_output("dd \ 1174 g_serial_string = call_program_and_get_last_line_of_output("dd \ 1180 1175 if=/dev/urandom bs=16 count=1 2> /dev/null | \ 1181 1176 hexdump | tr -s ' ' '0' | head -n1")); 1182 strip_spaces(g_serial_string);1183 1177 asprintf(&tmp, "%s...word.", g_serial_string); 1184 1178 paranoid_free(g_serial_string); … … 1271 1265 } 1272 1266 /* if not Debian then go ahead & use fdformat */ 1273 asprintf(&tempfile, "%s", 1274 call_program_and_get_last_line_of_output 1275 ("mktemp -q /tmp/mondo.XXXXXXXX")); 1267 tempfile = call_program_and_get_last_line_of_output("mktemp -q /tmp/mondo.XXXXXXXX")); 1276 1268 asprintf(&command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile, 1277 1269 tempfile, tempfile); … … 1729 1721 ("Failed to write to disk. I shall blank it and then try again."); 1730 1722 sleep(5); 1731 sy stem("sync");1723 sync(); 1732 1724 pause_for_N_seconds(5, "Letting DVD drive settle"); 1733 1725 … … 1921 1913 char *tmp; 1922 1914 char *command; 1915 bool ret = TRUE; 1923 1916 asprintf(&command, 1924 1917 "dd if=%s bs=512 count=1 2> /dev/null | strings | head -n1", 1925 1918 bigfile_fname); 1926 1919 log_msg(1, "command = '%s'", command); 1927 asprintf(&tmp, "%s", 1928 call_program_and_get_last_line_of_output(command)); 1920 tmp = call_program_and_get_last_line_of_output(command)); 1929 1921 log_msg(1, "--> tmp = '%s'", tmp); 1930 1922 paranoid_free(command); 1931 1923 if (strstr(tmp, "NTFS")) { 1932 1924 iamhere("TRUE"); 1933 paranoid_free(tmp);1934 return (TRUE);1935 1925 } else { 1936 1926 iamhere("FALSE"); 1937 paranoid_free(tmp); 1938 return (FALSE); 1939 } 1927 ret = FALSE; 1928 } 1929 paranoid_free(tmp); 1930 return(ret); 1940 1931 } 1941 1932 … … 2870 2861 log_to_screen("%s found in drive. It's a Mondo disk.", 2871 2862 media_descriptor_string(g_backup_media_type)); 2872 cd_number = atoi(last_line_of_file(szcdno)); 2863 tmp1 = last_line_of_file(szcdno); 2864 cd_number = atoi(tmp1); 2865 paranoid_free(tmp1); 2873 2866 asprintf(&tmp1, "cat %s 2> /dev/null", szserfname); 2874 asprintf(&our_serial_str, "%s", 2875 call_program_and_get_last_line_of_output(tmp1)); 2867 our_serial_str = call_program_and_get_last_line_of_output(tmp1); 2876 2868 paranoid_free(tmp1); 2877 2869 // FIXME - should be able to use last_line_of_file(), surely? … … 2916 2908 } 2917 2909 paranoid_free(mtpt); 2918 2919 /*2920 if (g_current_media_number > ask_for_one_if_more_than_this)2921 {2922 ok_go_ahead_burn_it = FALSE;2923 log_it("paafcd: %d > %d, so I'll definitely pause.", g_current_media_number > ask_for_one_if_more_than_this);2924 }2925 */2926 2910 2927 2911 if (!ok_go_ahead_burn_it) { … … 3077 3061 sprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename); 3078 3062 log_it("command = %s", command); 3079 strcpy (tmp, call_program_and_get_last_line_of_output(command));3063 tmp = call_program_and_get_last_line_of_output(command); 3080 3064 log_it("res of it = %s", tmp); 3081 3065 totallength = (off_t)atoll(tmp); 3066 paranoid_free(tmp); 3082 3067 } else { 3083 3068 file_to_openin = biggie_filename; … … 3105 3090 paranoid_free(checksum_line); 3106 3091 3107 asprintf(&tmp, "%s", 3108 slice_fname(biggie_file_number, 0, bkpinfo->tmpdir, "")); 3092 tmp = slice_fname(biggie_file_number, 0, bkpinfo->tmpdir, ""); 3109 3093 fout = fopen(tmp, "w"); 3110 3094 paranoid_free(tmp); … … 3124 3108 return (1); 3125 3109 } 3110 tmp = slice_fname(biggie_file_number, 0,bkpinfo->tmpdir, ""); 3126 3111 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 3127 res = move_files_to_stream(bkpinfo, 3128 slice_fname(biggie_file_number, 0, 3129 bkpinfo->tmpdir, ""), NULL); 3112 res = move_files_to_stream(bkpinfo,tmp,NULL); 3130 3113 } else { 3131 res = 3132 move_files_to_cd(bkpinfo, mrconf, 3133 slice_fname(biggie_file_number, 0, 3134 bkpinfo->tmpdir, ""), NULL); 3135 } 3114 res = move_files_to_cd(bkpinfo, mrconf, tmp, NULL); 3115 } 3116 paranoid_free(tmp); 3136 3117 i = bkpinfo->optimal_set_size / 256; 3137 3118 for (slice_num = 1; !finished; slice_num++) { 3138 asprintf(&curr_slice_fname_uncompressed, "%s", 3139 slice_fname(biggie_file_number, slice_num, 3140 bkpinfo->tmpdir, "")); 3141 asprintf(&curr_slice_fname_compressed, "%s", 3142 slice_fname(biggie_file_number, slice_num, 3143 bkpinfo->tmpdir, suffix)); 3119 curr_slice_fname_uncompressed = slice_fname(biggie_file_number, slice_num, bkpinfo->tmpdir, ""); 3120 curr_slice_fname_compressed = slice_fname(biggie_file_number, slice_num, bkpinfo->tmpdir, suffix)); 3144 3121 3145 3122 tmp = percent_media_full_comment(bkpinfo); … … 3573 3550 "Verifying archives against live filesystem"); 3574 3551 if (bkpinfo->backup_media_type == cdstream) { 3575 paranoid_alloc(bkpinfo->media_device, 3576 "/dev/cdrom"); 3552 paranoid_alloc(bkpinfo->media_device,"/dev/cdrom"); 3577 3553 } 3578 3554 verify_tape_backups(bkpinfo); … … 3588 3564 g_current_media_number = cdno; 3589 3565 if (bkpinfo->backup_media_type != iso) { 3590 paranoid_free(bkpinfo->media_device); 3591 bkpinfo->media_device = find_cdrom_device(FALSE); 3566 bkpinfo->media_device = find_cdrom_device(FALSE)); 3592 3567 } 3593 3568 chdir("/"); … … 3717 3692 } 3718 3693 if (((blockno + 1) % 128) == 0) { 3719 paranoid_system("sync"); /* fflush doesn't work; dunno why */3694 sync(); /* fflush doesn't work; dunno why */ 3720 3695 update_evalcall_form(percentage); 3721 3696 }
Note:
See TracChangeset
for help on using the changeset viewer.