Changeset 1977 in MondoRescue for branches/stable/mondo/src/common
- Timestamp:
- Jun 2, 2008, 10:49:01 AM (16 years ago)
- Location:
- branches/stable/mondo/src/common
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/src/common/libmondo-archive.c
r1939 r1977 60 60 /*@unused@*/ 61 61 //static char cvsid[] = "$Id$"; 62 // 63 extern char *get_non_rewind_dev(char *); 62 64 63 65 /* *************************** external global vars ******************/ … … 70 72 extern long long g_tape_posK; 71 73 extern char *g_tmpfs_mountpt; 72 extern bool g_cd_recovery;73 74 extern char *g_serial_string; 74 75 75 extern char *g_getfacl; 76 76 extern char *g_getfattr; … … 79 79 /* Reference to global bkpinfo */ 80 80 extern struct s_bkpinfo *bkpinfo; 81 82 81 83 82 … … 111 110 static int g_sem_id; 112 111 static int g_sem_key; 113 114 115 116 112 117 113 /** … … 540 536 char *use_lilo_sz = NULL; 541 537 char *bootdev = NULL; 538 char *ntapedev = NULL; 542 539 543 540 /*@ char ************************************************************** */ … … 586 583 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 587 584 mr_asprintf(&tape_size_sz, "%ld", bkpinfo->media_size); 585 ntapedev = get_non_rewind_dev(bkpinfo->media_device); 586 if ((bkpinfo->use_obdr) && (ntapedev != NULL)) { 587 mr_free(bkpinfo->media_device); 588 bkpinfo->media_device = ntapedev; 589 } else { 590 if (ntapedev == NULL) { 591 log_it("Not able to create OBDR - Restore will have to be done manually"); 592 } 593 } 588 594 mr_asprintf(&tape_device, bkpinfo->media_device); 589 595 } else { … … 858 864 mr_fprintf(fd1, "acl=no\n"); 859 865 } 866 if (bkpinfo->use_obdr) { 867 asprintf(&tmp1, "%s/OBDR", bkpinfo->tmpdir); 868 if (write_one_liner_data_file(tmp1, "TRUE")) { 869 log_msg(1, "%ld: Unable to write one-liner OBDR", 870 __LINE__); 871 } 872 paranoid_free(tmp1); 873 } 860 874 861 875 if (g_cd_recovery) { … … 1255 1269 openout_cdstream(bkpinfo->media_device, bkpinfo->writer_speed); 1256 1270 } else { 1257 openout_tape( bkpinfo->media_device, bkpinfo->internal_tape_block_size); /* sets g_tape_stream */1271 openout_tape(); /* sets g_tape_stream */ 1258 1272 } 1259 1273 if (!g_tape_stream) { … … 2144 2158 /* copy to CD (scratchdir) ... and an actual CD-R if necessary */ 2145 2159 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 2146 register_in_tape_catalog(fileset, curr_set_no, -1, 2147 curr_afioball_fname); 2148 maintain_collection_of_recent_archives(bkpinfo->tmpdir, 2149 curr_afioball_fname); 2160 register_in_tape_catalog(fileset, curr_set_no, -1, curr_afioball_fname); 2161 maintain_collection_of_recent_archives(bkpinfo->tmpdir, curr_afioball_fname); 2150 2162 iamhere("Writing EXAT files"); 2151 2163 res += -
branches/stable/mondo/src/common/libmondo-cli.c
r1939 r1977 199 199 /* Reference to global bkpinfo */ 200 200 extern struct s_bkpinfo *bkpinfo; 201 202 extern void free_MR_global_filenames(void); 201 203 202 204 /** … … 349 351 bkpinfo->internal_tape_block_size = DEFAULT_INTERNAL_TAPE_BLOCK_SIZE; 350 352 351 /* compulsory */353 /* compulsory */ 352 354 i = flag_set['c'] + flag_set['i'] + flag_set['n'] + 353 355 flag_set['t'] + flag_set['u'] + flag_set['r'] + 354 356 flag_set['w'] + flag_set['C'] + flag_set['U']; 355 if ( i == 0) {357 if ((i == 0) && (! bkpinfo->restore_data)) { 356 358 retval++; 357 359 log_to_screen("You must specify the media type\n"); … … 361 363 log_to_screen("Please specify only one media type\n"); 362 364 } 365 363 366 if (flag_set['K']) { 364 367 g_loglevel = atoi(flag_val['K']); 365 log_msg(1,"Loglevel forced to % s",g_loglevel);368 log_msg(1,"Loglevel forced to %d",g_loglevel); 366 369 if (g_loglevel < 3) { 367 370 g_loglevel = 3; 368 371 } 369 372 } 370 if (flag_set['L'] && flag_set['0']) { 373 374 if ((flag_set['L'] && flag_set['0']) && (! bkpinfo->restore_data)) { 371 375 retval++; 372 376 log_to_screen("You cannot have 'no compression' _and_ LZOP.\n"); 373 377 } 374 bkpinfo->backup_data = flag_set['O']; 378 if (! bkpinfo->restore_data) { 379 bkpinfo->backup_data = flag_set['O']; 380 } 375 381 bkpinfo->verify_data = flag_set['V']; 382 376 383 if (flag_set['I'] && !bkpinfo->backup_data) { 377 384 log_to_screen("-I switch is ignored if just verifying"); … … 401 408 } 402 409 } 403 if (flag_set['W']) { 410 411 if ((flag_set['W']) && (! bkpinfo->restore_data)) { 404 412 bkpinfo->nonbootable_backup = TRUE; 405 413 log_to_screen("Warning - you have opted for non-bootable backup"); … … 409 417 } 410 418 } 411 if (flag_set['t'] && flag_set['H']) { 419 420 if ((flag_set['t'] && flag_set['H']) && (! bkpinfo->restore_data)) { 412 421 fatal_error 413 422 ("Sorry, you may not nuke w/o warning from tape. Drop -H, please."); 414 423 } 424 415 425 if (flag_set['I']) { 416 426 if (!strcmp(bkpinfo->include_paths, "/")) { … … 430 440 if (q != NULL) { 431 441 *q = '\0'; 432 if ( stat(p, &buf) != 0) {442 if ((stat(p, &buf) != 0) && (! bkpinfo->restore_data)) { 433 443 log_msg(1, "ERROR ! %s doesn't exist", p); 434 444 fatal_error("ERROR ! You specified a directory to include which doesn't exist"); … … 436 446 p = q+1 ; 437 447 } else { 438 if ( stat(p, &buf) != 0) {448 if ((stat(p, &buf) != 0) && (! bkpinfo->restore_data)) { 439 449 log_msg(1, "ERROR ! %s doesn't exist", p); 440 450 fatal_error("ERROR ! You specified a directory to include which doesn't exist"); … … 456 466 457 467 if (g_kernel_version >= 2.6 && !flag_set['d'] 458 && (flag_set['c'] || flag_set['w']) ) {468 && (flag_set['c'] || flag_set['w']) && (! bkpinfo->restore_data)) { 459 469 fatal_error 460 470 ("If you are using the 2.6.x kernel, please specify the CD-R(W) device."); … … 471 481 strcpy(bkpinfo->include_paths, flag_val['J']); 472 482 } 473 if (flag_set['c'] || flag_set['w'] || flag_set['C'] || flag_set['r']) { 483 484 if ((flag_set['c'] || flag_set['w'] || flag_set['C'] || flag_set['r']) && (! bkpinfo->restore_data)) { 474 485 if (!flag_set['r'] && g_kernel_version <= 2.5 475 486 && strstr(flag_val['d'], "/dev/")) { … … 522 533 } 523 534 } 524 if (flag_set['t'] && !flag_set['d']) { 535 536 if ((flag_set['t'] && !flag_set['d']) && (! bkpinfo->restore_data)) { 525 537 log_it("Hmm! No tape drive specified. Let's see what we can do."); 526 538 if (find_tape_device_and_size(flag_val['d'], tmp)) { … … 540 552 if (! flag_set['d']) { 541 553 fatal_error 542 ("You need to specify a device file with -d for bootable USB device creation");543 } 544 if ( !flag_set['s']) {554 ("You need to specify a device file with -d for bootable USB device usage"); 555 } 556 if ((!flag_set['s']) && (! bkpinfo->restore_data)) { 545 557 fatal_error("You did not specify a size (-s) for your USB device. Aborting"); 546 558 } … … 559 571 } 560 572 } 561 if (!find_home_of_exe("growisofs")) {562 fatal_error563 ("Please install growisofs (probably part of dvd+rw-tools). If you want DVD support, you need it.");564 }565 if (!find_home_of_exe("dvd+rw-format")) {566 fatal_error567 ("Please install dvd+rw-format (probably part of dvd+rw-tools). If you want DVD support, you need it.");568 }569 573 if (strchr(flag_val['d'], ',')) { 570 574 fatal_error 571 575 ("Please don't give a SCSI node. Give a _device_, preferably a /dev entry, for the parameter of the -d flag."); 572 576 } 573 if (!flag_set['s']) { 574 sprintf(flag_val['s'], "%d", DEFAULT_DVD_DISK_SIZE); // 4.7 salesman's GB = 4.482 real GB = 4582 MB 575 strcat(flag_val['s'], "m"); 576 log_to_screen 577 ("You did not specify a size (-s) for DVD. I'm guessing %s.", 578 flag_val['s']); 579 flag_set['s'] = 1; 577 if (! bkpinfo->restore_data) { 578 if (!find_home_of_exe("growisofs")) { 579 fatal_error 580 ("Please install growisofs (probably part of dvd+rw-tools). If you want DVD support, you need it."); 581 } 582 if (!find_home_of_exe("dvd+rw-format")) { 583 fatal_error 584 ("Please install dvd+rw-format (probably part of dvd+rw-tools). If you want DVD support, you need it."); 585 } 586 if (!flag_set['s']) { 587 sprintf(flag_val['s'], "%d", DEFAULT_DVD_DISK_SIZE); // 4.7 salesman's GB = 4.482 real GB = 4582 MB 588 strcat(flag_val['s'], "m"); 589 log_to_screen 590 ("You did not specify a size (-s) for DVD. I'm guessing %s.", 591 flag_val['s']); 592 flag_set['s'] = 1; 593 } 580 594 } 581 595 /* … … 591 605 ("Please don't give a SCSI node. Give a _device_, preferably a /dev entry, for the parameter of the -d flag."); 592 606 } 593 if ( flag_set['O']) {607 if ((flag_set['O']) && (! bkpinfo->restore_data)) { 594 608 if (flag_set['s']) { 595 609 if (flag_set['t']) { … … 609 623 } 610 624 } 611 } else {/* CD|USB size */625 } else if (! bkpinfo->restore_data) { /* CD|USB size */ 612 626 if (flag_set['s']) { 613 627 if (process_the_s_switch(flag_val['s'])) { … … 619 633 } /* CD-RW */ 620 634 } 635 621 636 if (flag_set['n']) { 622 637 strncpy(bkpinfo->nfs_mount, flag_val['n'], MAX_STR_LEN); … … 636 651 log_msg(3, "isodir= %s", bkpinfo->isodir); 637 652 } 653 638 654 if (flag_set['c']) { 639 655 bkpinfo->backup_media_type = cdr; … … 702 718 q++; 703 719 /* End of bug fix */ 704 if ( stat(p, &buf) != 0) {720 if ((stat(p, &buf) != 0) && (! bkpinfo->restore_data)) { 705 721 log_msg(1, "WARNING ! %s doesn't exist", p); 706 722 } 707 723 p = q+1 ; 708 724 } else { 709 if ( stat(p, &buf) != 0) {725 if ((stat(p, &buf) != 0) && (! bkpinfo->restore_data)) { 710 726 log_msg(1, "WARNING ! %s doesn't exist", p); 711 727 } … … 719 735 4*MAX_STR_LEN - strlen(bkpinfo->exclude_paths)); 720 736 } 737 721 738 if (flag_set['e']) { 722 739 bkpinfo->please_dont_eject = TRUE; 723 740 } 724 if (flag_set['N']) // exclude NFS mounts & devices 741 742 if ((flag_set['N']) && (! bkpinfo->restore_data)) // exclude NFS mounts & devices 725 743 { 726 744 // strncpy(psz, list_of_NFS_devices_and_mounts(), MAX_STR_LEN); … … 733 751 bkpinfo->exclude_paths); 734 752 } 753 735 754 if (strlen(bkpinfo->exclude_paths) >= 4*MAX_STR_LEN) { 736 755 fatal_error 737 756 ("Your '-E' parameter is too long. Increase MAX_STR_LEN"); 738 757 } 758 739 759 if (flag_set['b']) { 740 760 strcpy(psz, flag_val['b']); … … 754 774 bkpinfo->internal_tape_block_size = itbs; 755 775 } 756 if (flag_set['D']) { 776 777 if ((flag_set['D']) && (! bkpinfo->restore_data)) { 757 778 bkpinfo->differential = 1; 758 779 // bkpinfo->differential = atoi (flag_val['D']); … … 762 783 } 763 784 } 785 764 786 if (flag_set['x']) { 765 787 strncpy(bkpinfo->image_devs, flag_val['x'], MAX_STR_LEN / 4); 766 if ( run_program_and_log_output("which ntfsclone", 2)) {788 if ((run_program_and_log_output("which ntfsclone", 2)) && (! bkpinfo->restore_data)) { 767 789 fatal_error("Please install ntfsprogs package/tarball."); 768 790 } 769 791 } 792 770 793 if (flag_set['m']) { 771 794 bkpinfo->manual_cd_tray = TRUE; 772 795 } 773 if (flag_set['k']) { 796 797 if ((flag_set['k']) && (! bkpinfo->restore_data)) { 774 798 strncpy(bkpinfo->kernel_path, flag_val['k'], MAX_STR_LEN); 775 799 if (!strcmp(bkpinfo->kernel_path, "failsafe")) { … … 785 809 } 786 810 } 811 787 812 if (flag_set['p']) { 788 813 strncpy(bkpinfo->prefix, flag_val['p'], MAX_STR_LEN / 4); 789 }790 814 log_msg(1,"Prefix forced to %s",bkpinfo->prefix); 815 } 791 816 792 817 if (flag_set['d']) { /* backup directory (if ISO/NFS) */ … … 801 826 strncpy(bkpinfo->nfs_remote_dir, flag_val['d'], MAX_STR_LEN); 802 827 } else { /* backup device (if tape/CD-R/CD-RW) */ 803 804 828 strncpy(bkpinfo->media_device, flag_val['d'], MAX_STR_LEN / 4); 805 829 } 806 830 } 807 831 808 if ( flag_set['n']) {832 if ((flag_set['n']) && (! bkpinfo->restore_data)) { 809 833 asprintf(&tmp1,"%s/%s/.dummy.txt", bkpinfo->isodir,bkpinfo->nfs_remote_dir); 810 834 sprintf(tmp, "echo hi > %s", tmp1); … … 839 863 } 840 864 841 if ( !flag_set['d'] && !flag_set['n'] && !flag_set['C']) {865 if ((!flag_set['d'] && !flag_set['n'] && !flag_set['C']) && (! bkpinfo->restore_data)) { 842 866 retval++; 843 867 log_to_screen("Please specify the backup device/directory.\n"); … … 845 869 ("You didn't use -d to specify the backup device/directory."); 846 870 } 847 /* optional, obscure */ 871 848 872 for (i = '0'; i <= '9'; i++) { 849 873 if (flag_set[i]) { … … 851 875 } /* not '\0' but '0' */ 852 876 } 877 853 878 if (flag_set['S']) { 854 879 sprintf(bkpinfo->scratchdir, "%s/mondo.scratch.%ld", flag_val['S'], 855 880 random() % 32768); 856 881 } 882 857 883 if (flag_set['T']) { 858 884 setup_tmpdir(flag_val['T']); … … 872 898 } 873 899 } 874 if (flag_set['A']) { 900 901 if ((flag_set['A']) && (! bkpinfo->restore_data)) { 875 902 strncpy(bkpinfo->call_after_iso, flag_val['A'], MAX_STR_LEN); 876 903 } 877 if (flag_set['B']) { 904 905 if ((flag_set['B']) && (! bkpinfo->restore_data)) { 878 906 strncpy(bkpinfo->call_before_iso, flag_val['B'], MAX_STR_LEN); 879 907 } 880 if (flag_set['H']) { 908 909 if ((flag_set['H']) && (! bkpinfo->restore_data)) { 881 910 g_cd_recovery = TRUE; 882 911 } 883 if (flag_set['l']) { 912 913 if ((flag_set['l']) && (! bkpinfo->restore_data)) { 884 914 #ifdef __FreeBSD__ 885 915 # define BOOT_LOADER_CHARS "GLBMR" … … 901 931 #undef BOOT_LOADER_CHARS 902 932 } 933 903 934 if (flag_set['f']) { 904 935 strncpy(bkpinfo->boot_device, … … 907 938 MAX_STR_LEN / 4); 908 939 } 909 if (flag_set['P']) { 940 941 if ((flag_set['P']) && (! bkpinfo->restore_data)) { 910 942 strncpy(bkpinfo->postnuke_tarball, flag_val['P'], MAX_STR_LEN); 911 943 } 944 912 945 if (flag_set['Q']) { 913 946 i = which_boot_loader(tmp); … … 916 949 finish(0); 917 950 } 918 if (flag_set['L']) { 951 952 if ((flag_set['L']) && (! bkpinfo->restore_data)) { 919 953 bkpinfo->use_lzo = TRUE; 920 954 if (run_program_and_log_output("which lzop", 2)) { … … 925 959 } 926 960 927 if ( flag_set['G']) {961 if ((flag_set['G']) && (! bkpinfo->restore_data)) { 928 962 bkpinfo->use_gzip = TRUE; 929 963 if (run_program_and_log_output("which gzip", 2)) { … … 934 968 } 935 969 936 if (!flag_set['o'] 937 && 938 !run_program_and_log_output 939 ("grep -Ei suse /etc/issue.net | grep -E '9.0' | grep 64", 2)) { 970 bkpinfo->use_obdr = FALSE; 971 if (flag_set['o']) { 972 if ((!flag_set['t']) && (! bkpinfo->restore_data)) { 973 log_to_screen("OBDR support is only available for tapes. Use the -t option"); 974 fatal_error("Aborting"); 975 } 976 bkpinfo->use_obdr = TRUE; 977 } 978 979 #ifndef __FreeBSD__ 980 if ((!is_this_a_valid_disk_format("vfat")) && (! bkpinfo->restore_data)) { 940 981 bkpinfo->make_cd_use_lilo = TRUE; 941 982 log_to_screen 942 ("Forcing you to use LILO. SuSE 9.0 (64-bit) has a broken mkfs.vfat binary."); 943 } 944 if (flag_set['o']) { 983 ("Your kernel appears not to support vfat filesystems. I am therefore"); 984 log_to_screen 985 ("using LILO instead of SYSLINUX as the media boot loader."); 986 } 987 if ((run_program_and_log_output("which mkfs.vfat", 2)) && (! bkpinfo->restore_data)) { 945 988 bkpinfo->make_cd_use_lilo = TRUE; 946 }947 #ifndef __FreeBSD__948 else {949 if (!is_this_a_valid_disk_format("vfat")) {950 bkpinfo->make_cd_use_lilo = TRUE;951 log_to_screen952 ("Your kernel appears not to support vfat filesystems. I am therefore");953 log_to_screen954 ("using LILO instead of SYSLINUX as the media boot loader.");955 }956 if (run_program_and_log_output("which mkfs.vfat", 2)) {957 bkpinfo->make_cd_use_lilo = TRUE;958 989 #ifdef __IA32__ 959 960 961 962 990 log_to_screen 991 ("Your filesystem is missing 'mkfs.vfat', so I cannot use SYSLINUX as"); 992 log_to_screen 993 ("your boot loader. I shall therefore use LILO instead."); 963 994 #endif 964 995 #ifdef __IA64__ 965 966 967 968 996 log_to_screen 997 ("Your filesystem is missing 'mkfs.vfat', so I cannot prepare the EFI"); 998 log_to_screen("environment correctly. Please install it."); 999 fatal_error("Aborting"); 969 1000 #endif 970 1001 } 971 1002 #ifdef __IA64__ 972 973 1003 /* We force ELILO usage on IA64 */ 1004 bkpinfo->make_cd_use_lilo = TRUE; 974 1005 #endif 975 }976 1006 #endif 977 1007 … … 980 1010 } 981 1011 982 if ( ! bkpinfo->restore_data) {1012 if (! bkpinfo->restore_data) { 983 1013 i = flag_set['O'] + flag_set['V']; 984 1014 if (i == 0) { 985 1015 retval++; 986 1016 log_to_screen("Specify backup (-O), verify (-V) or both (-OV).\n"); 1017 } 1018 } 1019 1020 if ((! bkpinfo->restore_data) && (flag_set['Z'])) { 1021 fatal_error 1022 ("The -Z switch is only valid in restore mode"); 1023 } 1024 1025 if (flag_set['Z']) { 1026 if (! strcmp(flag_val['Z'], "nuke")) { 1027 bkpinfo->restore_mode = nuke; 1028 } else if (! strcmp(flag_val['Z'], "interactive")) { 1029 bkpinfo->restore_mode = interactive; 1030 } else if (! strcmp(flag_val['Z'], "compare")) { 1031 bkpinfo->restore_mode = compare; 1032 } else if (! strcmp(flag_val['Z'], "mbr")) { 1033 bkpinfo->restore_mode = mbr; 1034 } else if (! strcmp(flag_val['Z'], "iso")) { 1035 bkpinfo->restore_mode = isoonly; 1036 } else if (! strcmp(flag_val['Z'], "isonuke")) { 1037 bkpinfo->restore_mode = isonuke; 1038 } else { 1039 bkpinfo->restore_mode = interactive; 987 1040 } 988 1041 } … … 1082 1135 void help_screen() 1083 1136 { 1084 log_msg(1, "Type 'man mondo -archive' for more information\n");1137 log_msg(1, "Type 'man mondoarchive' for more information\n"); 1085 1138 exit(1); 1086 1139 } … … 1141 1194 } 1142 1195 kill_buffer(); 1196 1197 free_MR_global_filenames(); 1198 1143 1199 fatal_error 1144 ("Mondo archive is terminating in response to a signal from the OS");1200 ("MondoRescue is terminating in response to a signal from the OS"); 1145 1201 finish(254); // just in case 1146 1202 } -
branches/stable/mondo/src/common/libmondo-devices.c
r1939 r1977 1749 1749 1750 1750 case tape: 1751 if (bkpinfo->media_device) { 1751 if ((!bkpinfo->restore_mode) && (find_tape_device_and_size(bkpinfo->media_device, sz_size))) { 1752 mr_msg(3, "Ok, using vanilla scsi tape."); 1753 mr_free(bkpinfo->media_device); 1754 mr_asprintf(&tmp,VANILLA_SCSI_TAPE); 1755 bkpinfo->media_device = tmp; 1756 1752 1757 if ((fin = fopen(bkpinfo->media_device, "r"))) { 1753 1758 paranoid_fclose(fin); … … 1795 1800 bkpinfo->media_size = 0L; 1796 1801 mr_msg(4, "media_size = %ld", bkpinfo->media_size); 1802 bkpinfo->use_obdr = ask_me_yes_or_no 1803 ("Do you want to activate OBDR support for your tapes ?"); 1797 1804 if (archiving_to_media) { 1798 1805 if ((bkpinfo->compression_level = … … 2196 2203 strcpy(exclude_these_directories, 2197 2204 call_program_and_get_last_line_of_output 2198 ("mount -t coda,ncpfs,nfs,smbfs,cifs,afs, ocfs,ocfs2,mvfs | tr -s '\t' ' ' | cut -d' ' -f3 | tr -s '\n' ' ' | awk '{print $0;}'"));2205 ("mount -t coda,ncpfs,nfs,smbfs,cifs,afs,gfs,ocfs,ocfs2,mvfs | tr -s '\t' ' ' | cut -d' ' -f3 | tr -s '\n' ' ' | awk '{print $0;}'")); 2199 2206 strcpy(exclude_these_devices, 2200 2207 call_program_and_get_last_line_of_output 2201 ("tr -s '\t' ' ' < /etc/fstab | grep -E '( (coda|ncpfs|nfs|smbfs|cifs|afs| ocfs|ocfs2|mvfs) )' | cut -d' ' -f1 | tr -s '\n' ' ' | awk '{print $0;}'"));2208 ("tr -s '\t' ' ' < /etc/fstab | grep -E '( (coda|ncpfs|nfs|smbfs|cifs|afs|gfs|ocfs|ocfs2|mvfs) )' | cut -d' ' -f1 | tr -s '\n' ' ' | awk '{print $0;}'")); 2202 2209 sprintf(result_sz, "%s", exclude_these_directories); 2203 2210 mr_free(exclude_these_devices); … … 2227 2234 mr_asprintf(&tmp, 2228 2235 call_program_and_get_last_line_of_output 2229 ("LANGUAGE=C df -m -P -t nonfs,msdosfs,ntfs,smbfs,smb,cifs,afs, ocfs,ocfs2,mvfs | tr -s '\t' ' ' | grep -vE \"none|Filesystem\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'"));2236 ("LANGUAGE=C df -m -P -t nonfs,msdosfs,ntfs,smbfs,smb,cifs,afs,gfs,ocfs,ocfs2,mvfs | tr -s '\t' ' ' | grep -vE \"none|Filesystem\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'")); 2230 2237 #else 2231 2238 mr_asprintf(&tmp, 2232 2239 call_program_and_get_last_line_of_output 2233 ("LANGUAGE=C df -m -P -x nfs -x vfat -x ntfs -x smbfs -x smb -x cifs -x afs -x ocfs -x ocfs2 -x mvfs | sed 's/ /devdev/' | tr -s '\t' ' ' | grep -vE \"none|Filesystem|/dev/shm\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'"));2240 ("LANGUAGE=C df -m -P -x nfs -x vfat -x ntfs -x smbfs -x smb -x cifs -x afs -x gfs -x ocfs -x ocfs2 -x mvfs | sed 's/ /devdev/' | tr -s '\t' ' ' | grep -vE \"none|Filesystem|/dev/shm\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'")); 2234 2241 #endif 2235 2242 -
branches/stable/mondo/src/common/libmondo-filelist.c
r1924 r1977 1603 1603 mr_asprintf(&exclude_paths, " %s %s %s %s %s %s . .. \ 1604 1604 " MNT_CDROM " " MNT_FLOPPY " /media /tmp /var/log/lastlog \ 1605 /proc /sys / root/images/mondo ", MINDI_CACHE, MONDO_CACHE, excp, tmp2, (tmpdir[0] == '/' && tmpdir[1] == '/') ? (tmpdir + 1) : tmpdir, (scratchdir[0] == '/' && scratchdir[1] == '/') ? (scratchdir + 1) : scratchdir);1606 paranoid_free(tmp2);1605 /proc /sys /var/cache/mondo ", MINDI_CACHE, MONDO_CACHE, excp, tmp2, (tmpdir[0] == '/' && tmpdir[1] == '/') ? (tmpdir + 1) : tmpdir, (scratchdir[0] == '/' && scratchdir[1] == '/') ? (scratchdir + 1) : scratchdir); 1606 mr_free(tmp2); 1607 1607 1608 1608 mr_msg(2, -
branches/stable/mondo/src/common/libmondo-stream-EXT.h
r1663 r1977 13 13 extern int openin_tape(); 14 14 extern int openout_cdstream(char *cddev, int speed); 15 extern int openout_tape( char *tapedev, long internal_tape_block_size);15 extern int openout_tape(); 16 16 extern int read_file_from_stream_to_file( 17 17 char *outfile, long long size); -
branches/stable/mondo/src/common/libmondo-stream.c
r1939 r1977 2 2 3 3 ...tools for talking to tapes, Monitas streams, etc. 4 4 5 */ 5 6 … … 364 365 int res = 0; 365 366 char *fname = (char *)&res; /* Should NOT be NULL */ 367 char *tmp = NULL; 366 368 367 369 // xattr … … 371 373 wrong_marker(BLK_START_EXAT_FILE, *pctrl_chr); 372 374 } 373 if (!strstr(fname, "xattr")) { 374 fatal_error("Wrong order for xattr, sunshine."); 375 if (strstr(fname, "xattr") == NULL) { 376 asprintf(&tmp,"Wrong order expected xattr, got %s, sunshine.", fname); 377 fatal_error(tmp); 375 378 } 376 379 read_file_from_stream_to_file(xattr_fname, *ptmp_size); 377 res = read_header_block_from_stream(ptmp_size, tmp_fname, pctrl_chr);380 res = read_header_block_from_stream(ptmp_size, fname, pctrl_chr); 378 381 if (*pctrl_chr != BLK_STOP_EXAT_FILE) { 379 382 wrong_marker(BLK_STOP_EXAT_FILE, *pctrl_chr); 380 383 } 381 384 mr_msg(1, "Got xattr"); 382 res = read_header_block_from_stream(ptmp_size, tmp_fname, pctrl_chr);385 res = read_header_block_from_stream(ptmp_size, fname, pctrl_chr); 383 386 if (*pctrl_chr != BLK_STOP_EXTENDED_ATTRIBUTES) { 384 387 wrong_marker(BLK_STOP_EXTENDED_ATTRIBUTES, *pctrl_chr); 385 388 } 386 res = read_header_block_from_stream(ptmp_size, tmp_fname, pctrl_chr);387 if ( pctrl_chr == BLK_START_AN_AFIO_OR_SLICE) {389 res = read_header_block_from_stream(ptmp_size, fname, pctrl_chr); 390 if (*pctrl_chr == BLK_START_AN_AFIO_OR_SLICE) { 388 391 log_msg(1, "No acl attributes found, skipping to afio files"); 389 392 return(0); 390 393 } else { 391 if ( pctrl_chr != BLK_START_EXTENDED_ATTRIBUTES) {394 if (*pctrl_chr != BLK_START_EXTENDED_ATTRIBUTES) { 392 395 wrong_marker(BLK_START_EXTENDED_ATTRIBUTES, *pctrl_chr); 393 396 } … … 397 400 if (g_getfacl) { 398 401 res = read_header_block_from_stream(ptmp_size, fname, pctrl_chr); 399 if (!strstr(fname, "acl")) {400 fatal_error("Wrong order for acl, sunshine.");401 }402 402 if (*pctrl_chr != BLK_START_EXAT_FILE) { 403 403 wrong_marker(BLK_START_EXAT_FILE, *pctrl_chr); 404 404 } 405 if (strstr(fname, "acl") == NULL) { 406 asprintf(&tmp,"Wrong order expected acl, got %s, sunshine.", fname); 407 fatal_error(tmp); 408 } 405 409 read_file_from_stream_to_file(acl_fname, *ptmp_size); 406 res = read_header_block_from_stream(ptmp_size, tmp_fname, pctrl_chr);410 res = read_header_block_from_stream(ptmp_size, fname, pctrl_chr); 407 411 if (*pctrl_chr != BLK_STOP_EXAT_FILE) { 408 412 wrong_marker(BLK_STOP_EXAT_FILE, *pctrl_chr); 409 413 } 410 res = read_header_block_from_stream(ptmp_size, tmp_fname, pctrl_chr);414 res = read_header_block_from_stream(ptmp_size, fname, pctrl_chr); 411 415 if (*pctrl_chr != BLK_STOP_EXTENDED_ATTRIBUTES) { 412 416 wrong_marker(BLK_STOP_EXTENDED_ATTRIBUTES, *pctrl_chr); … … 595 599 596 600 597 int set_tape_block_size_with_mt(char *tapedev, 598 long internal_tape_block_size) 601 int set_tape_block_size_with_mt(long internal_tape_block_size) 599 602 { 600 603 char *tmp; 601 604 int res; 602 605 603 if (strncmp( tapedev, "/dev/", 5)) {606 if (strncmp(bkpinfo->media_device, "/dev/", 5)) { 604 607 mr_msg(1, 605 608 "Not using 'mt setblk'. This isn't an actual /dev entry."); 606 609 return (0); 607 610 } 608 mr_asprintf(&tmp, "mt -f %s setblk %ld", tapedev, 609 internal_tape_block_size); 611 mr_asprintf(&tmp, "mt -f %s setblk %ld",bkpinfo->media_device,internal_tape_block_size); 610 612 res = run_program_and_log_output(tmp, 3); 611 613 mr_free(tmp); 612 614 return (res); 615 } 616 617 /** 618 * Return the non-rewinding device when passed the normal one 619 * @param tapedev The tape device to open for writing. 620 * @note the caller needs to free the string returned 621 */ 622 char *get_non_rewind_dev(char *tapedev) 623 { 624 625 char *ntapedev = NULL; 626 char *p = NULL; 627 char *q = NULL; 628 char *r = NULL; 629 630 ntapedev = (char *)malloc(strlen(tapedev)+sizeof(char)); 631 p = strrchr(tapedev,'/'); 632 if (p == NULL) { 633 log_it("Didn't find a '/' in %s",tapedev); 634 return(NULL); 635 } 636 637 /* Copy tapedev content up to the last / */ 638 q = tapedev; 639 r = ntapedev; 640 while (q != p) { 641 *r = *q; 642 r++; 643 q++; 644 } 645 /* Copy the '/' */ 646 *r = *q; 647 r++; 648 q++; 649 /* Adds a 'n' - non-rewinding */ 650 *r = 'n'; 651 r++; 652 /* Copy the rest of tapedev */ 653 while (*q != '\0') { 654 *r = *q; 655 r++; 656 q++; 657 } 658 *r = '\0'; 659 if (mt_says_tape_exists(ntapedev)) { 660 log_it("Non-rewinding tape device is %s",ntapedev); 661 } else { 662 log_it("Unable to find non-rewinding tape device."); 663 ntapedev = NULL; 664 } 665 return(ntapedev); 666 } 667 668 669 670 /** 671 * Handle OBDR if we were asked to do so 672 * @param tapedev The tape device to open for reading. 673 */ 674 int skip_obdr(void) 675 { 676 char *command = NULL; 677 int res = 0; 678 679 log_it("Skipping OBDR headers"); 680 asprintf(&command, "mt -f %s rewind",bkpinfo->media_device); 681 res = run_program_and_log_output(command, 1); 682 paranoid_free(command); 683 684 asprintf(&command, "mt -f %s fsf 2",bkpinfo->media_device); 685 res = run_program_and_log_output(command, 1); 686 paranoid_free(command); 687 688 set_tape_block_size_with_mt(bkpinfo->internal_tape_block_size); 689 return(res); 690 } 691 692 /** 693 * Handle OBDR if we were asked to do so 694 * @param tapedev The tape device to open for writing. 695 * @return 0 for success, nonzero for failure. 696 * @note This should be called ONLY from backup processes. It will OVERWRITE ANY 697 * EXISTING DATA on the tape! 698 */ 699 int create_obdr(void) 700 { 701 702 char *command = NULL; 703 int res = 0; 704 705 log_it("Creating OBDR headers"); 706 /* OBDR: First block 10 kB of zero bs = 512 */ 707 asprintf(&command, "mt -f %s compression off",bkpinfo->media_device); 708 res = run_program_and_log_output(command, 1); 709 paranoid_free(command); 710 711 asprintf(&command, "mt -f %s rewind",bkpinfo->media_device); 712 res += run_program_and_log_output(command, 1); 713 paranoid_free(command); 714 715 set_tape_block_size_with_mt(512); 716 717 asprintf(&command, "dd if=/dev/zero of=%s bs=512 count=20",bkpinfo->media_device); 718 res += run_program_and_log_output(command, 1); 719 paranoid_free(command); 720 721 /* OBDR: then ISO boot image bs = 2048 */ 722 set_tape_block_size_with_mt(2048); 723 724 asprintf(&command, "dd if=%s of=%s bs=2048",MINDI_CACHE"/mondorescue.iso",bkpinfo->media_device); 725 res += run_program_and_log_output(command, 1); 726 paranoid_free(command); 727 728 set_tape_block_size_with_mt(bkpinfo->internal_tape_block_size); 729 return(res); 613 730 } 614 731 … … 633 750 int i; 634 751 int j; 635 int res ;752 int res = 0; 636 753 long length, templong; 637 754 size_t k; … … 654 771 return (0); 655 772 } 773 774 // mondoarchive should have configured everything to give the right non-rew device 775 if ((bkpinfo->use_obdr) && (bkpinfo->media_device != NULL)) { 776 res = skip_obdr(); 777 if (res != 0) { 778 log_it("Not able to skip OBDR - Restore will have to be done manually"); 779 } 780 } else { 781 if (bkpinfo->media_device == NULL) { 782 log_it("Not able to skip OBDR - Restore will have to be done manually"); 783 } 784 set_tape_block_size_with_mt(bkpinfo->internal_tape_block_size); 785 } 786 656 787 insist_on_this_tape_number(1); 657 788 mr_asprintf(&outfname, "%s/tmp/all.tar.gz", bkpinfo->tmpdir); 658 789 make_hole_for_file(outfname); 659 660 set_tape_block_size_with_mt(bkpinfo->media_device,661 bkpinfo->internal_tape_block_size);662 790 663 791 log_it("Opening IN tape"); … … 762 890 /** 763 891 * Start writing to a tape device for the backup. 892 * Handle OBDR if we were asked to do so 764 893 * @param tapedev The tape device to open for writing. 765 894 * @return 0 for success, nonzero for failure. … … 767 896 * EXISTING DATA on the tape! 768 897 */ 769 int openout_tape( char *tapedev, long internal_tape_block_size)770 { 898 int openout_tape() { 899 771 900 g_current_media_number = 1; 772 901 if (g_tape_stream) { … … 777 906 g_tape_posK = 0; 778 907 779 set_tape_block_size_with_mt(tapedev, internal_tape_block_size); 908 if (bkpinfo->use_obdr) { 909 create_obdr(); 910 } else { 911 set_tape_block_size_with_mt(bkpinfo->internal_tape_block_size); 912 } 780 913 log_it("Opening OUT tape"); 781 914 if (! 782 915 (g_tape_stream = 783 open_device_via_buffer( tapedev, 'w', internal_tape_block_size))) {916 open_device_via_buffer(bkpinfo->media_device, 'w', internal_tape_block_size))) { 784 917 log_to_screen(_("Cannot openin stream device")); 785 918 return (1); -
branches/stable/mondo/src/common/libmondo-stream.h
r1663 r1977 14 14 int openin_tape(); 15 15 int openout_cdstream(char *cddev, int speed); 16 int openout_tape( char *tapedev, long internal_tape_block_size);16 int openout_tape(); 17 17 int read_file_from_stream_to_file(char *outfile, 18 18 long long size); -
branches/stable/mondo/src/common/libmondo-tools.c
r1924 r1977 677 677 678 678 void setup_tmpdir(char *path) { 679 679 680 680 char *tmp = NULL; 681 681 char *p = NULL; … … 687 687 paranoid_free(tmp); 688 688 } 689 689 690 690 if (path != NULL) { 691 691 asprintf(&tmp, "%s/mondo.tmp.XXXXXX", path); … … 758 758 } 759 759 bkpinfo->boot_device[0] = '\0'; 760 bkpinfo->restore_path[0] = '\0'; 760 bkpinfo->image_devs[0] = '\0'; 761 bkpinfo->compression_level = 3; 761 762 bkpinfo->do_not_compress_these[0] = '\0'; 762 763 bkpinfo->verify_data = FALSE; 763 764 bkpinfo->backup_data = FALSE; 764 765 bkpinfo->restore_data = FALSE; 766 bkpinfo->use_star = FALSE; 767 bkpinfo->internal_tape_block_size = DEFAULT_INTERNAL_TAPE_BLOCK_SIZE; 765 768 bkpinfo->disaster_recovery = 766 769 (am_I_in_disaster_recovery_mode()? TRUE : FALSE); … … 772 775 mr_asprintf(&tmp,mr_conf->prefix); 773 776 bkpinfo->prefix = tmp; 774 775 bkpinfo->make_filelist = TRUE; // unless -J supplied to mondoarchive 777 sensibly_set_tmpdir_and_scratchdir(); 778 776 779 bkpinfo->optimal_set_size = 0; 777 bkpinfo->backup_media_type = none;778 780 bkpinfo->backup_media_string[0] = '\0'; 779 781 strcpy(bkpinfo->include_paths, "/"); 782 bkpinfo->restore_path[0] = '\0'; 780 783 bkpinfo->call_before_iso[0] = '\0'; 781 784 bkpinfo->call_make_iso[0] = '\0'; 782 785 bkpinfo->call_after_iso[0] = '\0'; 783 bkpinfo->image_devs[0] = '\0';784 bkpinfo->postnuke_tarball[0] = '\0';785 786 bkpinfo->nfs_mount[0] = '\0'; 786 787 bkpinfo->nfs_remote_dir[0] = '\0'; 788 bkpinfo->postnuke_tarball[0] = '\0'; 787 789 bkpinfo->wipe_media_first = FALSE; 788 bkpinfo->differential = FALSE; 790 bkpinfo->differential = 0; 791 bkpinfo->please_dont_eject = FALSE; 789 792 bkpinfo->writer_speed = mr_conf->iso_burning_speed; 793 bkpinfo->manual_cd_tray = FALSE; 794 bkpinfo->nonbootable_backup = FALSE; 795 bkpinfo->make_cd_use_lilo = FALSE; 796 bkpinfo->use_obdr = FALSE; 797 bkpinfo->restore_mode = interactive; 790 798 } 791 799 -
branches/stable/mondo/src/common/mondostructures.h
r1904 r1977 127 127 */ 128 128 int index; 129 129 130 130 /** 131 131 * Type of disk. 132 132 */ 133 133 char type; // ' ' = data (default), S = spare, F = faulty 134 134 135 135 }; 136 136 … … 184 184 } t_archtype; 185 185 186 /** 187 * A type of file in the catalog of recent archives. 188 */ 189 typedef enum { 190 nuke = 0, /// Nuke mode 191 interactive, /// Interactive mode 192 compare, /// Compare mode 193 mbr, /// MBR mode 194 isoonly, /// ISO mode 195 isonuke, /// ISO+Nuke mode 196 } t_restore_mode; 197 186 198 187 199 #ifdef __FreeBSD__ … … 236 248 */ 237 249 int chunk_size; 238 250 239 251 /** 240 252 * The parity algorithm of this RAID device. (RAID5 only) … … 582 594 */ 583 595 bool make_cd_use_lilo; 596 597 /** 598 * If TRUE, make the the tape bootable. If FALSE, normal tape, the default 599 */ 600 bool use_obdr; 601 602 /** 603 * Nature of the restore 604 */ 605 t_restore_mode restore_mode; 584 606 }; 585 607
Note:
See TracChangeset
for help on using the changeset viewer.