Changeset 1118 in MondoRescue
- Timestamp:
- Feb 9, 2007, 2:07:01 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/src/common/libmondo-archive.c
r1116 r1118 28 28 #include "libmondo-devices-EXT.h" 29 29 #include "libmondo-tools-EXT.h" 30 #include " libmondo-gui-EXT.h"30 #include "newt-specific-EXT.h" 31 31 #include "libmondo-fork-EXT.h" 32 32 #include "libmondo-files-EXT.h" … … 208 208 unsigned int res = 0; 209 209 int tries = 0; 210 char *command; 211 char *zipparams; 212 char *tmp; 213 char *p; 214 215 malloc_string(command); 216 malloc_string(zipparams); 217 malloc_string(tmp); 210 char *command = NULL; 211 char *tmp = NULL; 212 char *p =NULL; 213 char *tmp1 = NULL; 214 215 malloc_string(tmp1); 218 216 219 217 if (!does_file_exist(filelist)) { 220 sprintf(tmp, "(archive_this_fileset) - filelist %s does not exist", 221 filelist); 218 mr_asprintf(&tmp, 219 "(archive_this_fileset) - filelist %s does not exist", 220 filelist); 222 221 log_to_screen(tmp); 222 mr_free(tmp); 223 223 return (1); 224 224 } 225 225 226 sprintf(tmp, "echo hi > %s 2> /dev/null", fname);226 mr_asprintf(&tmp, "echo hi > %s 2> /dev/null", fname); 227 227 if (system(tmp)) { 228 228 fatal_error("Unable to write tarball to scratchdir"); 229 229 } 230 231 sprintf(command, "star H=star list=%s -c " STAR_ACL_SZ " file=%s", 232 filelist, fname); 230 mr_free(tmp); 231 232 mr_asprintf(&command, "star H=star list=%s -c " STAR_ACL_SZ " file=%s", 233 filelist, fname); 233 234 if (bkpinfo->use_lzo) { 234 235 fatal_error("Can't use lzop"); 235 236 } 236 237 if (bkpinfo->compression_level > 0) { 237 strcat(command, " -bz"); 238 } 239 sprintf(command + strlen(command), " 2>> %s", MONDO_LOGFILE); 238 mr_asprintf(&tmp, "%s -bz", command); 239 mr_free(command); 240 command = tmp; 241 } 242 mr_asprintf(&tmp, "%s 2>> %s", command, MONDO_LOGFILE); 243 mr_free(command); 244 command = tmp; 240 245 mr_msg(4, "command = '%s'", command); 241 246 … … 243 248 mr_msg(5, "command='%s'", command); 244 249 res = system(command); 245 strcpy(tmp , last_line_of_file(MONDO_LOGFILE));250 strcpy(tmp1, last_line_of_file(MONDO_LOGFILE)); 246 251 mr_msg(1, "res=%d; tmp='%s'", res, tmp); 247 252 if (bkpinfo->use_star && (res == 254 || res == 65024) … … 265 270 } 266 271 } 272 mr_free(command); 273 267 274 retval += res; 268 275 if (retval) { … … 273 280 } 274 281 275 mr_free(command);276 mr_free(zipparams);277 mr_free(tmp);278 282 return (retval); 279 283 } … … 301 305 { 302 306 303 /*@ int ************************************************************ ****/307 /*@ int ************************************************************ */ 304 308 int retval = 0; 305 309 int res = 0; … … 308 312 static int free_ramdisk_space = 9999; 309 313 310 /*@ buffers ************************************************************ */ 311 char *command; 312 char *zipparams; 313 char *tmp; 314 /*@ buffers ******************************************************** */ 315 char *command = NULL; 316 char *zipparams = NULL; 317 char *tmp = NULL; 318 char *tmp1 = NULL; 314 319 315 320 assert(bkpinfo != NULL); … … 322 327 } 323 328 324 malloc_string(command);325 malloc_string(zipparams);326 malloc_string(tmp);327 328 329 if (!does_file_exist(filelist)) { 329 sprintf(tmp, "(archive_this_fileset) - filelist %s does not exist", 330 filelist); 330 mr_asprintf(&tmp, 331 "(archive_this_fileset) - filelist %s does not exist", 332 filelist); 331 333 log_to_screen(tmp); 334 mr_free(tmp); 332 335 return (1); 333 336 } 334 sprintf(tmp, "echo hi > %s 2> /dev/null", fname);337 mr_asprintf(&tmp, "echo hi > %s 2> /dev/null", fname); 335 338 if (system(tmp)) { 336 339 fatal_error("Unable to write tarball to scratchdir"); 337 340 } 341 mr_free(tmp); 338 342 339 343 340 344 if (bkpinfo->compression_level > 0) { 341 sprintf(tmp, "%s/do-not-compress-these", g_mondo_home);345 mr_asprintf(&tmp, "%s/do-not-compress-these", g_mondo_home); 342 346 // -b %ld, TAPE_BLOCK_SIZE 343 sprintf(zipparams, "-Z -P %s -G %d -T 3k", bkpinfo->zip_exe,344 bkpinfo->compression_level);347 mr_asprintf(&zipparams, "-Z -P %s -G %d -T 3k", bkpinfo->zip_exe, 348 bkpinfo->compression_level); 345 349 if (does_file_exist(tmp)) { 346 strcat(zipparams, " -E "); 347 strcat(zipparams, tmp); 350 mr_asprintf(&tmp1, "%s -E %s", zipparams, tmp); 351 mr_free(zipparams); 352 zipparams = tmp1; 348 353 } else { 349 354 mr_msg(3, "%s not found. Cannot exclude zipfiles, etc.", tmp); 350 355 } 351 } else { 352 zipparams[0] = '\0'; 356 mr_free(tmp); 357 } else { 358 mr_asprintf(&zipparams, " "); 353 359 } 354 360 … … 363 369 fatal_error("scratchdir not found"); 364 370 } 365 sprintf(command, "rm -f %s %s. %s.gz %s.%s", fname, fname, fname,366 fname, bkpinfo->zip_suffix);371 mr_asprintf(&command, "rm -f %s %s. %s.gz %s.%s", fname, fname, fname, 372 fname, bkpinfo->zip_suffix); 367 373 paranoid_system(command); 368 369 sprintf(command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s", 370 TAPE_BLOCK_SIZE, zipparams, fname, filelist, MONDO_LOGFILE); 371 372 sprintf(tmp, "echo hi > %s 2> /dev/null", fname); 374 mr_free(command); 375 376 mr_asprintf(&command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s", 377 TAPE_BLOCK_SIZE, zipparams, fname, filelist, MONDO_LOGFILE); 378 mr_free(zipparams); 379 380 mr_asprintf(&tmp, "echo hi > %s 2> /dev/null", fname); 373 381 if (system(tmp)) { 374 382 fatal_error("Unable to write tarball to scratchdir"); 375 383 } 384 mr_free(tmp); 376 385 377 386 for (res = 99, tries = 0; tries < 3 && res != 0; tries++) { … … 386 395 } 387 396 } 397 mr_free(command); 398 388 399 retval += res; 389 400 if (retval) { … … 409 420 } 410 421 } 411 mr_free(command);412 mr_free(zipparams);413 mr_free(tmp);414 422 return (retval); 415 423 } 416 417 418 419 420 424 421 425 … … 435 439 { 436 440 int retval = 0, res = 0; 437 char *tmp ;441 char *tmp = NULL; 438 442 439 443 assert(bkpinfo != NULL); 440 444 set_g_cdrom_and_g_dvd_to_bkpinfo_value(bkpinfo); 441 malloc_string(tmp); 445 442 446 if (bkpinfo->backup_media_type == dvd) { 443 447 #ifdef DVDRWFORMAT … … 460 464 } 461 465 462 /* 463 sprintf(tmp, "wc -l %s/archives/filelist.full > %s/archives/filelist.count",bkpinfo->scratchdir, bkpinfo->scratchdir); 464 if (run_program_and_log_output(tmp, 2)) 465 { fatal_error("Failed to count filelist.full"); } 466 */ 467 sprintf(tmp, "gzip -9 %s/archives/filelist.full", bkpinfo->scratchdir); 466 mr_asprintf(&tmp, "gzip -9 %s/archives/filelist.full", 467 bkpinfo->scratchdir); 468 468 if (run_program_and_log_output(tmp, 2)) { 469 469 fatal_error("Failed to gzip filelist.full"); 470 470 } 471 sprintf(tmp, "cp -f %s/archives/*list*.gz %s", bkpinfo->scratchdir, 472 bkpinfo->tmpdir); 471 mr_free(tmp); 472 mr_asprintf(&tmp, "cp -f %s/archives/*list*.gz %s", bkpinfo->scratchdir, 473 bkpinfo->tmpdir); 473 474 if (run_program_and_log_output(tmp, 2)) { 474 475 fatal_error("Failed to copy to tmpdir"); 475 476 } 477 mr_free(tmp); 476 478 477 479 copy_mondo_and_mindi_stuff_to_scratchdir(bkpinfo); // payload, too, if it exists … … 493 495 } 494 496 retval += do_that_initial_phase(bkpinfo); // prepare 495 sprintf(tmp, "rm -f %s/images/*.iso", bkpinfo->scratchdir);497 mr_asprintf(&tmp, "rm -f %s/images/*.iso", bkpinfo->scratchdir); 496 498 run_program_and_log_output(tmp, 1); 499 mr_free(tmp); 497 500 retval += make_those_afios_phase(bkpinfo); // backup regular files 498 501 retval += make_those_slices_phase(bkpinfo); // backup BIG files … … 502 505 sleep(2); 503 506 } 504 mr_free(tmp);505 507 return (retval); 506 508 } 507 508 509 509 510 510 … … 525 525 * - @c media_size 526 526 * - @c nonbootable_backup 527 * - @c scratchdir528 527 * - @c tmpdir 529 528 * - @c use_lzo … … 538 537 { 539 538 /*@ buffer ************************************************************ */ 540 char *tmp; 541 char *scratchdir; 542 char *command; 543 char *bootldr_str; 544 char *last_filelist_number; 545 char *tape_size_sz; 546 char *devs_to_exclude; 547 char *value; 548 char *bootdev; 539 char *tmp = NULL; 540 char *command = NULL; 541 char *use_lzo_sz = NULL; 542 char *use_gzip_sz = NULL; 543 char *use_comp_sz = NULL; 544 char *use_star_sz = NULL; 545 char *bootldr_str = NULL; 546 char *tape_device = NULL; 547 char *last_filelist_number = NULL; 548 char *broken_bios_sz = NULL; 549 char *cd_recovery_sz = NULL; 550 char *tape_size_sz = NULL; 551 char *devs_to_exclude = NULL; 552 char *use_lilo_sz = NULL; 553 char *bootdev = NULL; 549 554 550 555 /*@ char ************************************************************** */ … … 554 559 long lines_in_filelist = 0; 555 560 556 /*@ int ************************************************************* */561 /*@ int ************************************************************* */ 557 562 int res = 0; 558 563 long estimated_total_noof_slices = 0; … … 562 567 563 568 assert(bkpinfo != NULL); 564 command = mr_malloc(1200);565 malloc_string(tmp);566 malloc_string(scratchdir);567 569 malloc_string(bootldr_str); 568 570 malloc_string(last_filelist_number); 569 malloc_string(tape_size_sz);570 571 malloc_string(devs_to_exclude); 571 malloc_string(value);572 572 malloc_string(bootdev); 573 573 574 strcpy(scratchdir, bkpinfo->scratchdir); 575 sprintf(tmp, 574 mr_asprintf(&tmp, 576 575 "echo '%s' | tr -s ' ' '\n' | grep -E '^/dev/.*$' | tr -s '\n' ' ' | awk '{print $0\"\\n\";}'", 577 576 bkpinfo->exclude_paths); 577 578 578 strcpy(devs_to_exclude, call_program_and_get_last_line_of_output(tmp)); 579 mr_free(tmp); 580 581 mr_asprintf(&tmp, "devs_to_exclude = '%s'", devs_to_exclude); 579 582 mr_msg(2, tmp); 583 mr_free(tmp); 580 584 mvaddstr_and_log_it(g_currentY, 0, 581 585 "Calling MINDI to create boot+data disks"); 582 sprintf(tmp, "%s/filelist.full", bkpinfo->tmpdir);586 mr_asprintf(&tmp, "%s/filelist.full", bkpinfo->tmpdir); 583 587 if (!does_file_exist(tmp)) { 584 sprintf(tmp, "%s/tmpfs/filelist.full", bkpinfo->tmpdir); 588 mr_free(tmp); 589 mr_asprintf(&tmp, "%s/tmpfs/filelist.full", bkpinfo->tmpdir); 585 590 if (!does_file_exist(tmp)) { 586 591 fatal_error … … 590 595 lines_in_filelist = count_lines_in_file(tmp); 591 596 strcpy(last_filelist_number, last_line_of_file(tmp)); 597 mr_free(tmp); 598 599 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 600 mr_asprintf(&tape_size_sz, "%ld", bkpinfo->media_size[1]); 601 mr_asprintf(&tape_device, bkpinfo->media_device); 602 } else { 603 mr_asprintf(&tape_size_sz, " "); 604 mr_asprintf(&tape_device, " "); 605 } 606 /* BERLIOS: This parameter is not used after? */ 607 mr_free(tape_size_sz); 608 if (bkpinfo->use_lzo) { 609 mr_asprintf(&use_lzo_sz, "yes"); 610 } else { 611 mr_asprintf(&use_lzo_sz, "no"); 612 } 613 if (bkpinfo->use_gzip) { 614 mr_asprintf(&use_gzip_sz, "yes"); 615 } else { 616 mr_asprintf(&use_gzip_sz, "no"); 617 } 618 if (bkpinfo->use_star) { 619 mr_asprintf(&use_star_sz, "yes"); 620 } else { 621 mr_asprintf(&use_star_sz, "no"); 622 } 623 624 if (bkpinfo->compression_level > 0) { 625 mr_asprintf(&use_comp_sz, "yes"); 626 } else { 627 mr_asprintf(&use_comp_sz, "no"); 628 } 629 630 mr_asprintf(&broken_bios_sz, "yes"); /* assume so */ 631 if (g_cd_recovery) { 632 mr_asprintf(&cd_recovery_sz, "yes"); 633 } else { 634 mr_asprintf(&cd_recovery_sz, "no"); 635 } 636 /* Field shared between LILO/ELILO */ 637 if (bkpinfo->make_cd_use_lilo) { 638 mr_asprintf(&use_lilo_sz, "yes"); 639 } else { 640 mr_asprintf(&use_lilo_sz, "no"); 641 } 592 642 593 643 if (!bkpinfo->nonbootable_backup … … 622 672 else 623 673 ch = 'U'; 674 624 675 if (bkpinfo->boot_loader != '\0') { 625 sprintf(tmp, "User specified boot loader. It is '%c'.",676 mr_asprintf(&tmp, "User specified boot loader. It is '%c'.", 626 677 bkpinfo->boot_loader); 627 678 mr_msg(2, tmp); 679 mr_free(tmp); 628 680 } else { 629 681 bkpinfo->boot_loader = ch; 630 682 } 631 683 if (bkpinfo->boot_device[0] != '\0') { 632 sprintf(tmp, "User specified boot device. It is '%s'.",684 mr_asprintf(&tmp, "User specified boot device. It is '%s'.", 633 685 bkpinfo->boot_device); 634 686 mr_msg(2, tmp); 687 mr_free(tmp); 635 688 } else { 636 689 strcpy(bkpinfo->boot_device, bootdev); … … 646 699 #endif 647 700 bkpinfo->boot_loader != 'L' && bkpinfo->boot_loader != 'G' 648 && bkpinfo->boot_loader != 'R' 649 && !bkpinfo->nonbootable_backup){701 && bkpinfo->boot_loader != 'R' && !bkpinfo->nonbootable_backup) 702 { 650 703 fatal_error 651 ("Please specify your boot loader and device, e.g. -l GRUB -f /dev/hda. 704 ("Please specify your boot loader and device, e.g. -l GRUB -f /dev/hda.\nType 'man mondoarchive' to read the manual."); 652 705 } 653 706 if (bkpinfo->boot_loader == 'L') { … … 655 708 if (!does_file_exist("/etc/lilo.conf")) { 656 709 fatal_error 657 ("The de facto standard location for your boot loader's config file is /etc/lilo.conf but I cannot find it there. What is wrong with your Linux distribution?");710 ("The de facto standard location for your boot loader's config file is /etc/lilo.conf.\nBut I cannot find it there. What is wrong with your Linux distribution?"); 658 711 } 659 712 } else if (bkpinfo->boot_loader == 'G') { … … 672 725 if (!does_file_exist("/etc/grub.conf")) { 673 726 fatal_error 674 ("The de facto standard location for your boot loader's config file is /etc/grub.conf but I cannot find it there. What is wrong with your Linux distribution?Try 'ln -s /boot/grub/menu.lst /etc/grub.conf'...");727 ("The de facto standard location for your boot loader's config file is /etc/grub.conf.\nBut I cannot find it there. What is wrong with your Linux distribution?\nTry 'ln -s /boot/grub/menu.lst /etc/grub.conf'..."); 675 728 } 676 729 } else if (bkpinfo->boot_loader == 'E') { 677 730 strcpy(bootldr_str, "ELILO"); 678 /* B CO: fix it for SuSE, Debian, Mandrake, ... */731 /* BERLIOS: fix it for SuSE, Debian, Mandrake, ... */ 679 732 if (!does_file_exist("/etc/elilo.conf") 680 733 && does_file_exist("/boot/efi/efi/redhat/elilo.conf")) { … … 685 738 if (!does_file_exist("/etc/elilo.conf")) { 686 739 fatal_error 687 ("The de facto mondo standard location for your boot loader's config file is /etc/elilo.conf but I cannot find it there. What is wrong with your Linux distribution?Try finding it under /boot/efi and do 'ln -s /boot/efi/..../elilo.conf /etc/elilo.conf'");740 ("The de facto mondo standard location for your boot loader's config file is /etc/elilo.conf\nBut I cannot find it there. What is wrong with your Linux distribution?\nTry finding it under /boot/efi and do 'ln -s /boot/efi/..../elilo.conf /etc/elilo.conf'"); 688 741 } 689 742 } else if (bkpinfo->boot_loader == 'R') { … … 702 755 strcpy(bootldr_str, "unknown"); 703 756 } 704 sprintf(tmp, "Your boot loader is %s and it boots from %s",757 mr_asprintf(&tmp, "Your boot loader is %s and it boots from %s", 705 758 bootldr_str, bkpinfo->boot_device); 706 759 log_to_screen(tmp); 760 mr_free(tmp); 761 mr_asprintf(&tmp, "%s/BOOTLOADER.DEVICE", bkpinfo->tmpdir); 762 if (write_one_liner_data_file(tmp, bkpinfo->boot_device)) { 763 mr_msg(1, "Unable to write one-liner boot device"); 764 765 } 707 766 708 767 estimated_total_noof_slices = 709 768 size_of_all_biggiefiles_K(bkpinfo) / bkpinfo->optimal_set_size + 1; 710 /* add nfs stuff here? */ 711 sprintf(command, "mkdir -p %s/images", bkpinfo->scratchdir); 769 mr_asprintf(&command, "mkdir -p %s/images", bkpinfo->scratchdir); 712 770 if (system(command)) { 713 771 res++; 714 772 log_OS_error("Unable to make images directory"); 715 773 } 716 sprintf(command, "mkdir -p %s%s", bkpinfo->scratchdir, MNT_FLOPPY); 774 mr_free(command); 775 776 mr_asprintf(&command, "mkdir -p %s%s", bkpinfo->scratchdir, MNT_FLOPPY); 717 777 if (system(command)) { 718 778 res++; 719 779 log_OS_error("Unable to make mnt floppy directory"); 720 780 } 781 mr_free(command); 721 782 722 783 /* Prepare interface with mindi through a configuration file … … 818 879 mr_fprintf(fd1, "use-cdrecovery no\n"); 819 880 } 881 820 882 if (bkpinfo->make_cd_use_lilo) { 821 883 mr_fprintf(fd1, "use-lilo yes\n"); … … 838 900 mr_fclose(fd1); 839 901 840 sprintf(command, "mindi --custom '%s' '%s/images'",902 mr_asprintf(&command, "mindi --custom '%s' '%s/images'", 841 903 bkpinfo->tmpdir, bkpinfo->scratchdir); 842 904 //bkpinfo->tmpdir, // parameter #2 … … 863 925 864 926 res = run_program_and_log_to_screen(command, "Generating boot+data disks"); 927 mr_free(command); 865 928 if (bkpinfo->nonbootable_backup) { 866 929 res = 0; … … 868 931 if (!res) { 869 932 log_to_screen("Boot+data disks were created OK"); 870 sprintf(command, "mkdir -p /var/cache/mindi/");933 mr_asprintf(&command, "mkdir -p /var/cache/mindi/"); 871 934 mr_msg(2, command); 872 935 run_program_and_log_output(command, FALSE); 873 sprintf(command, 936 mr_free(command); 937 938 mr_asprintf(&command, 874 939 "cp -f %s/images/mindi.iso /var/cache/mindi/mondorescue.iso", 875 940 bkpinfo->scratchdir); 876 941 mr_msg(2, command); 877 942 run_program_and_log_output(command, FALSE); 943 mr_free(command); 944 878 945 if (bkpinfo->nonbootable_backup) { 879 sprintf(command, "cp -f %s/all.tar.gz %s/images",946 mr_asprintf(&command, "cp -f %s/all.tar.gz %s/images", 880 947 bkpinfo->tmpdir, bkpinfo->scratchdir); 881 948 if (system(command)) { 882 949 fatal_error("Unable to create temporary duff tarball"); 883 950 } 884 } 951 mr_free(command); 952 953 } 954 /* BERLIOS: Not executed ? 885 955 sprintf(command, "cp -f %s/mindi-*oot*.img %s/images", 886 956 bkpinfo->tmpdir, bkpinfo->scratchdir); 887 sprintf(tmp, "cp -f %s/images/all.tar.gz %s", bkpinfo->scratchdir, 888 bkpinfo->tmpdir); 957 */ 958 mr_asprintf(&tmp, "cp -f %s/images/all.tar.gz %s", 959 bkpinfo->scratchdir, bkpinfo->tmpdir); 889 960 if (system(tmp)) { 890 961 fatal_error("Cannot find all.tar.gz in tmpdir"); 891 962 } 963 mr_free(tmp); 964 892 965 if (res) { 893 966 mvaddstr_and_log_it(g_currentY++, 74, "Errors."); … … 897 970 } else { 898 971 log_to_screen("Mindi failed to create your boot+data disks."); 899 strcpy(command, "grep 'Fatal error' /var/log/mindi.log"); 900 strcpy(tmp, call_program_and_get_last_line_of_output(command)); 972 mr_asprintf(&command, "grep 'Fatal error' /var/log/mindi.log"); 973 malloc_string(tmp); 974 strcpy(tmp,call_program_and_get_last_line_of_output(command)); 975 mr_free(command); 901 976 if (strlen(tmp) > 1) { 902 977 popup_and_OK(tmp); 903 978 } 904 } 905 mr_free(tmp); 906 mr_free(scratchdir); 979 mr_free(tmp); 980 } 907 981 mr_free(bootldr_str); 908 982 mr_free(last_filelist_number); 909 mr_free(tape_size_sz);910 983 mr_free(devs_to_exclude); 911 mr_free(value);912 984 mr_free(bootdev); 913 mr_free(command);914 985 return (res); 915 986 } 916 917 987 918 988 … … 962 1032 963 1033 struct s_bkpinfo *bkpinfo; 964 char *tmp ;1034 char *tmp = NULL; 965 1035 int res = 0, retval = 0; 966 1036 int *p_archival_threads_running; … … 970 1040 int this_thread_no = g_current_thread_no++; 971 1041 972 malloc_string(curr_xattr_list_fname);973 malloc_string(curr_acl_list_fname);974 1042 malloc_string(archiving_filelist_fname); 975 1043 malloc_string(archiving_afioball_fname); 976 malloc_string(tmp);977 1044 p_last_set_archived = (int *) inbuf; 978 1045 p_archival_threads_running = (int *) (inbuf + 4); … … 1018 1085 } 1019 1086 1020 sprintf(tmp, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir,1021 archiving_set_no - ARCH_BUFFER_NUM, bkpinfo->zip_suffix);1087 mr_asprintf(&tmp, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir, 1088 archiving_set_no - ARCH_BUFFER_NUM, bkpinfo->zip_suffix); 1022 1089 if (does_file_exist(tmp)) { 1023 mr_msg(4, "%s[%d:%d] - waiting for storer", FORTY_SPACES,1024 getpid(), this_thread_no);1090 mr_msg(4, "%s[%d:%d] - waiting for storer", 1091 FORTY_SPACES, getpid(), this_thread_no); 1025 1092 while (does_file_exist(tmp)) { 1026 1093 sleep(1); … … 1028 1095 mr_msg(4, "[%d] - continuing", getpid()); 1029 1096 } 1097 mr_free(tmp); 1030 1098 1031 1099 mr_msg(4, "%s[%d:%d] - EXATing %d...", FORTY_SPACES, getpid(), 1032 1100 this_thread_no, archiving_set_no); 1033 1101 if (g_getfattr) { 1034 sprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,1102 mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, 1035 1103 bkpinfo->tmpdir, archiving_set_no); 1036 1104 get_fattr_list(archiving_filelist_fname, curr_xattr_list_fname); 1105 mr_free(curr_xattr_list_fname); 1037 1106 } 1038 1107 if (g_getfacl) { 1039 sprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,1108 mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, 1040 1109 bkpinfo->tmpdir, archiving_set_no); 1041 1110 get_acl_list(archiving_filelist_fname, curr_acl_list_fname); 1111 mr_free(curr_acl_list_fname); 1042 1112 } 1043 1113 … … 1051 1121 1052 1122 if (res) { 1053 sprintf(tmp,1054 "Errors occurred while archiving set %ld. Please review logs.",1055 archiving_set_no);1123 mr_asprintf(&tmp, 1124 "Errors occurred while archiving set %ld. Please review logs.", 1125 archiving_set_no); 1056 1126 log_to_screen(tmp); 1127 mr_free(tmp); 1057 1128 } 1058 1129 if (!semaphore_p()) { … … 1084 1155 mr_free(archiving_filelist_fname); 1085 1156 mr_free(archiving_afioball_fname); 1086 mr_free(curr_xattr_list_fname);1087 mr_free(curr_acl_list_fname);1088 mr_free(tmp);1089 1157 pthread_exit(NULL); 1090 1158 } 1091 1092 1093 1094 1159 1095 1160 … … 1117 1182 1118 1183 mr_msg(1, "Closing tape/CD ... "); 1119 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) 1184 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 1120 1185 /* write tape/cdstream */ 1121 {1122 1186 closeout_tape(bkpinfo); 1123 } else 1187 } else { 1124 1188 /* write final ISO/USB */ 1125 {1126 1189 res = write_final_iso_if_necessary(bkpinfo); 1127 1190 retval += res; … … 1174 1237 assert(bkpinfo != NULL); 1175 1238 malloc_string(command); 1176 malloc_string(tmpfile); 1177 malloc_string(data_disks_file); 1178 sprintf(data_disks_file, "%s/all.tar.gz", bkpinfo->tmpdir); 1239 1240 mr_asprintf(&data_disks_file, "%s/all.tar.gz", bkpinfo->tmpdir); 1179 1241 1180 1242 snprintf(g_serial_string, MAX_STR_LEN - 1, … … 1187 1249 assert(strlen(g_serial_string) < MAX_STR_LEN); 1188 1250 1189 sprintf(tmpfile, "%s/archives/SERIAL-STRING", bkpinfo->scratchdir);1251 mr_asprintf(&tmpfile, "%s/archives/SERIAL-STRING", bkpinfo->scratchdir); 1190 1252 if (write_one_liner_data_file(tmpfile, g_serial_string)) { 1191 1253 mr_msg(1, "%ld: Failed to write serial string", __LINE__); 1192 1254 } 1255 mr_free(tmpfile); 1193 1256 1194 1257 mvaddstr_and_log_it(g_currentY, 0, "Preparing to archive your data"); … … 1207 1270 mr_msg(1, "Backing up to CD's"); 1208 1271 } 1209 1210 sprintf(command, "rm -f %s/%s/%s-[1-9]*.iso", bkpinfo->isodir, 1211 bkpinfo->nfs_remote_dir, bkpinfo->prefix); 1272 mr_free(data_disks_file); 1273 1274 mr_asprintf(&command, "rm -f %s/%s/%s-[1-9]*.iso", bkpinfo->isodir, 1275 bkpinfo->nfs_remote_dir, bkpinfo->prefix); 1212 1276 paranoid_system(command); 1277 mr_free(command); 1278 1213 1279 wipe_archives(bkpinfo->scratchdir); 1214 1280 mvaddstr_and_log_it(g_currentY++, 74, "Done."); … … 1219 1285 BLK_START_OF_BACKUP); 1220 1286 } 1221 mr_free(command);1222 mr_free(tmpfile);1223 mr_free(data_disks_file);1224 1287 return (retval); 1225 1288 } … … 1247 1310 1248 1311 /*@ buffers *********************************************************** */ 1249 char *command ;1312 char *command = NULL; 1250 1313 char *tempfile; 1251 1314 … … 1256 1319 assert_string_is_neither_NULL_nor_zerolength(title); 1257 1320 1258 malloc_string(command);1259 1321 malloc_string(tempfile); 1260 1322 #ifdef __FreeBSD__ … … 1276 1338 call_program_and_get_last_line_of_output 1277 1339 ("mktemp -q /tmp/mondo.XXXXXXXX")); 1278 sprintf(command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile, tempfile, 1279 tempfile); 1340 mr_asprintf(&command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile, tempfile, tempfile); 1280 1341 mr_msg(3, command); 1281 1342 open_evalcall_form(title); … … 1289 1350 maxtracks = 80; 1290 1351 } 1352 mr_free(command); 1353 1291 1354 for (sleep(1); does_file_exist(tempfile); sleep(1)) { 1292 1355 trackno = get_trackno_from_logfile(tempfile); … … 1310 1373 } 1311 1374 unlink(tempfile); 1312 mr_free(command);1313 1375 mr_free(tempfile); 1314 1376 return (res); 1315 1377 } 1378 1316 1379 1317 1380 /** … … 1336 1399 char *title; 1337 1400 1338 1339 1401 assert_string_is_neither_NULL_nor_zerolength(device); 1340 malloc_string(title); 1341 command = mr_malloc(1000); 1402 1342 1403 if (!system("which superformat > /dev/null 2> /dev/null")) { 1343 sprintf(command, "superformat %s", device);1404 mr_asprintf(&command, "superformat %s", device); 1344 1405 } else { 1345 1406 #ifdef __FreeBSD__ 1346 sprintf(command, "fdformat -y %s", device);1407 mr_asprintf(&command, "fdformat -y %s", device); 1347 1408 #else 1348 sprintf(command, "fdformat %s", device);1409 mr_asprintf(&command, "fdformat %s", device); 1349 1410 #endif 1350 1411 } 1351 sprintf(title, "Formatting disk %s", device);1412 mr_asprintf(&title, "Formatting disk %s", device); 1352 1413 while ((res = format_disk_SUB(command, title))) { 1353 1414 if (!ask_me_yes_or_no("Failed to format disk. Retry?")) { … … 1359 1420 return (res); 1360 1421 } 1422 1361 1423 1362 1424 /** … … 1383 1445 } 1384 1446 } 1385 1386 1387 1388 1389 1390 1391 1392 1447 1393 1448 … … 1470 1525 log_to_screen("Archiving regular files"); 1471 1526 mr_msg(5, "Go, Shorty. It's your birthday."); 1472 open_progress_form( "Backing up filesystem",1473 "I am backing up your live filesystem now.",1474 "Please wait. This may take a couple of hours.",1475 "Working...",1527 open_progress_form(_("Backing up filesystem"), 1528 _("I am backing up your live filesystem now."), 1529 _("Please wait. This may take a couple of hours."), 1530 _("Working..."), 1476 1531 get_last_filelist_number(bkpinfo) + 1); 1477 1532 … … 1519 1574 } 1520 1575 sleep(1); 1521 } else 1576 } else { 1522 1577 // store set N 1523 {1524 1578 sprintf(storing_filelist_fname, FILELIST_FNAME_RAW_SZ, 1525 1579 bkpinfo->tmpdir, storing_set_no); … … 1552 1606 storing_afioball_fname); 1553 1607 iamhere("Writing EXAT files"); 1554 res += 1555 write_EXAT_files_to_tape(bkpinfo, 1556 curr_xattr_list_fname, 1557 curr_acl_list_fname); 1558 // archives themselves 1608 res += write_EXAT_files_to_tape(bkpinfo, 1609 curr_xattr_list_fname, 1610 curr_acl_list_fname); 1611 // archives themselves 1559 1612 res += 1560 1613 move_files_to_stream(bkpinfo, storing_afioball_fname,
Note:
See TracChangeset
for help on using the changeset viewer.