Changeset 1954 in MondoRescue
- Timestamp:
- May 27, 2008, 1:13:52 PM (17 years ago)
- Location:
- branches/2.2.6/mondo/src/common
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.6/mondo/src/common/libmondo-archive.c
r1948 r1954 1250 1250 openout_cdstream(bkpinfo->media_device, bkpinfo->cdrw_speed); 1251 1251 } else { 1252 openout_tape( bkpinfo->media_device, bkpinfo->internal_tape_block_size); /* sets g_tape_stream */1252 openout_tape(); /* sets g_tape_stream */ 1253 1253 } 1254 1254 if (!g_tape_stream) { -
branches/2.2.6/mondo/src/common/libmondo-stream-EXT.h
r1647 r1954 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/2.2.6/mondo/src/common/libmondo-stream.c
r1953 r1954 605 605 606 606 607 int set_tape_block_size_with_mt(char *tapedev, 608 long internal_tape_block_size) 607 int set_tape_block_size_with_mt(long internal_tape_block_size) 609 608 { 610 609 char *tmp; 611 610 int res; 612 611 613 if (strncmp( tapedev, "/dev/", 5)) {612 if (strncmp(bkpinfo->media_device, "/dev/", 5)) { 614 613 log_msg(1, 615 614 "Not using 'mt setblk'. This isn't an actual /dev entry."); … … 617 616 } 618 617 malloc_string(tmp); 619 sprintf(tmp, "mt -f %s setblk %ld", tapedev, internal_tape_block_size);618 sprintf(tmp, "mt -f %s setblk %ld", bkpinfo->media_device, internal_tape_block_size); 620 619 res = run_program_and_log_output(tmp, 3); 621 620 paranoid_free(tmp); … … 678 677 /** 679 678 * Handle OBDR if we were asked to do so 679 * @param tapedev The tape device to open for reading. 680 */ 681 void skip_obdr() 682 { 683 char *command = NULL; 684 685 asprintf(&command, "mt -f %s fsf 2",bkpinfo->media_device); 686 run_program_and_log_output(command, 1); 687 paranoid_free(command); 688 689 set_tape_block_size_with_mt(bkpinfo->internal_tape_block_size); 690 691 } 692 693 /** 694 * Handle OBDR if we were asked to do so 680 695 * @param tapedev The tape device to open for writing. 681 696 * @return 0 for success, nonzero for failure. … … 683 698 * EXISTING DATA on the tape! 684 699 */ 685 void skip_obdr(char *tapedev) 686 { 687 char *command = NULL; 688 char *ntapedev = NULL; 689 690 ntapedev = get_non_rewind_dev(tapedev); 691 if (ntapedev == NULL) { 692 log_it("Not skipping OBDR"); 693 } 694 695 asprintf(&command, "mt -f %s fsf 2",ntapedev); 696 run_program_and_log_output(command, 1); 697 paranoid_free(command); 698 699 set_tape_block_size_with_mt(ntapedev, bkpinfo->internal_tape_block_size); 700 701 paranoid_free(ntapedev); 702 } 703 704 int create_obdr(char *tapedev) 705 { 706 707 char *ntapedev = NULL; 700 int create_obdr() 701 { 702 708 703 char *command = NULL; 709 704 int res = 0; 710 705 711 ntapedev = get_non_rewind_dev(tapedev);712 if (ntapedev == NULL) {713 log_it("Skipping OBDR");714 return(1);715 }716 717 706 /* OBDR: First block 10 kB of zero bs = 512 */ 718 asprintf(&command, "mt -f %s compression off", tapedev);707 asprintf(&command, "mt -f %s compression off",bkpinfo->media_device); 719 708 res = run_program_and_log_output(command, 1); 720 709 paranoid_free(command); 721 710 722 asprintf(&command, "mt -f %s rewind", tapedev);711 asprintf(&command, "mt -f %s rewind",bkpinfo->media_device); 723 712 res = run_program_and_log_output(command, 1); 724 713 paranoid_free(command); 725 714 726 set_tape_block_size_with_mt( ntapedev,512);727 728 asprintf(&command, "dd if=/dev/zero of=%s bs=512 count=20", ntapedev);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); 729 718 res = run_program_and_log_output(command, 1); 730 719 paranoid_free(command); 731 720 732 721 /* OBDR: then ISO boot image bs = 2048 */ 733 set_tape_block_size_with_mt( ntapedev,2048);734 735 asprintf(&command, "dd if=%s of=%s bs=2048",MINDI_CACHE"/mondorescue.iso", ntapedev);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); 736 725 res = run_program_and_log_output(command, 1); 737 726 paranoid_free(command); 738 727 739 set_tape_block_size_with_mt(ntapedev, bkpinfo->internal_tape_block_size); 740 741 paranoid_free(ntapedev); 728 set_tape_block_size_with_mt(bkpinfo->internal_tape_block_size); 742 729 } 743 730 … … 756 743 char fname[MAX_STR_LEN]; 757 744 char *datablock; 745 char *ntapedev = NULL; 758 746 char tmp[MAX_STR_LEN]; 759 747 char old_cwd[MAX_STR_LEN]; … … 786 774 return (0); 787 775 } 788 if (bkpinfo->use_obdr) { 789 skip_obdr(bkpinfo->media_device); 790 } else { 791 set_tape_block_size_with_mt(bkpinfo->media_device, 792 bkpinfo->internal_tape_block_size); 793 } 794 776 ntapedev = get_non_rewind_dev(bkpinfo->media_device); 777 if ((bkpinfo->use_obdr) && (ntapedev != NULL)) { 778 strncpy(bkpinfo->media_device,ntapedev,(size_t)(MAX_STR_LEN / 4)); 779 skip_obdr(); 780 } else { 781 if (ntapedev == 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 paranoid_free(ntapedev); 795 787 796 788 insist_on_this_tape_number(1); … … 909 901 * EXISTING DATA on the tape! 910 902 */ 911 int openout_tape(char *tapedev, long internal_tape_block_size) 912 { 913 914 g_current_media_number = 1; 915 if (g_tape_stream) { 916 log_it("FYI - I won't 'openout' the tape. It's already open."); 917 return (0); 918 } 919 if (!(g_tapecatalog = malloc(sizeof(struct s_tapecatalog)))) { 920 fatal_error("Cannot alloc mem for tape catalog"); 921 } 922 g_tapecatalog->entries = 0; 923 g_tape_posK = 0; 924 925 if (bkpinfo->use_obdr) { 926 create_obdr(tapedev); 927 } else { 928 set_tape_block_size_with_mt(tapedev, internal_tape_block_size); 929 } 930 log_it("Opening OUT tape"); 931 if (! 932 (g_tape_stream = 933 open_device_via_buffer(tapedev, 'w', internal_tape_block_size))) { 934 log_OS_error(g_tape_fifo); 935 log_to_screen("Cannot openin stream device"); 936 return (1); 937 } 903 int openout_tape() { 904 905 char *ntapedev = NULL; 906 907 g_current_media_number = 1; 908 if (g_tape_stream) { 909 log_it("FYI - I won't 'openout' the tape. It's already open."); 938 910 return (0); 911 } 912 if (!(g_tapecatalog = malloc(sizeof(struct s_tapecatalog)))) { 913 fatal_error("Cannot alloc mem for tape catalog"); 914 } 915 g_tapecatalog->entries = 0; 916 g_tape_posK = 0; 917 918 ntapedev = get_non_rewind_dev(bkpinfo->media_device); 919 if ((bkpinfo->use_obdr) && (ntapedev != NULL)) { 920 strncpy(bkpinfo->media_device,ntapedev,(size_t)(MAX_STR_LEN / 4)); 921 create_obdr(); 922 } else { 923 if (ntapedev == NULL) { 924 log_it("Not able to create OBDR - Restore will have to be done manually"); 925 } 926 set_tape_block_size_with_mt(bkpinfo->internal_tape_block_size); 927 } 928 paranoid_free(ntapedev); 929 log_it("Opening OUT tape"); 930 if (! 931 (g_tape_stream = 932 open_device_via_buffer(tapedev, 'w', bkpinfo->internal_tape_block_size))) { 933 log_OS_error(g_tape_fifo); 934 log_to_screen("Cannot openin stream device"); 935 return (1); 936 } 937 return (0); 939 938 } 940 939 -
branches/2.2.6/mondo/src/common/libmondo-stream.h
r1647 r1954 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);
Note:
See TracChangeset
for help on using the changeset viewer.