Changeset 1948 in MondoRescue for branches/2.2.6/mondo/src/common/libmondo-stream.c
- Timestamp:
- May 26, 2008, 5:35:44 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.6/mondo/src/common/libmondo-stream.c
r1943 r1948 4 4 ...tools for talking to tapes, Monitas streams, etc. 5 5 6 7 07/108 - added ACL and XATTR support9 10 04/1711 - added bkpinfo->internal_tape_block_size12 - fixed bug in set_tape_block_size_with_mt()13 14 03/2515 - call 'mt' when opening tape in/out, to set block size to 32K16 17 02/06/200418 - only eject_device() at end of closein_tape() --- not closeout_tape()19 20 10/26/200321 - call eject_device() at end of closein_tape() and closeout_tape()22 23 09/2524 - added docu-header to each subroutine25 26 09/2027 - working on multi-tape code28 - friendlier message in insist_on_this_tape_number()29 - delay is now 5s30 31 09/1032 - adding multi-tape support33 - adding 'back catalog' of previous archives, so that we may resume34 from point of end-of-tape (approx.)35 36 09/0837 - cleaned up insist_on_this_tape_number() --- 10s delay for same tape now38 39 08/2740 - improved find_tape_device_and_size() --- tries /dev/osst*41 42 05/0543 - added Joshua Oreman's FreeBSD patches44 45 04/2446 - added lots of assert()'s and log_OS_error()'s47 48 04/06/200349 - use find_home_of_exe() instead of which50 51 12/13/200252 - cdrecord -scanbus call was missing 2> /dev/null53 54 11/2455 - disabled fatal_error("Bad marker")56 57 10/2958 - replaced convoluted grep wih wc (KP)59 60 09/0761 - removed g_end_of_tape_reached62 - lots of multitape-related fixes63 64 08/01 - 08/3165 - write 16MB of zeroes to end of tape when closing(out)66 - compensate for 'buffer' and its distortion of speed of writing/reading67 when writing/reading data disks at start of tape68 - rewrote lots of multitape stuff69 - wrote workaround to allow >2GB of archives w/buffering70 - do not close/reopen tape when starting to read/write from71 new tape: no need! 'buffer' handles all that; we're writing72 to/reading from a FIFO, so no need to close/reopen when new tape73 - write 8MB of zeroes at end of tape, just in case74 - re-enable various calls to *_evalcall_form75 - added g_end_of_tape_reached76 - fixed bugs in start_to_[read|write]_[to|from]_next_tape77 - added internal buffering, replacing the external 'buffer' exe78 - wait 10 seconds (after user inserts new tape), to79 let tape stabilize in drive80 - added insist_on_this_tape_number()81 - worked on find_tape_device_and_size()82 - cleaned up some log_it() calls83 - added find_tape_device_and_size()84 - replaced using_cdstream with backup_media_type85 - replace *_from_tape with *_from_stream86 - replace *_to_stream with *_to_stream87 88 07/01 - 07/3189 - leave 32MB at end of tape, to avoid overrunning90 - started [07/24/2002]91 6 */ 92 7 … … 753 668 return (0); 754 669 } 670 if (bkpinfo->use_obdr) { 671 skip_obdr(tapedev); 672 } 673 755 674 insist_on_this_tape_number(1); 756 675 sprintf(outfname, "%s/tmp/all.tar.gz", bkpinfo->tmpdir); … … 864 783 865 784 /** 866 * Start writing to a tape device for the backup. 785 * Return the non-rewinding device when passed the normal one 786 * @param tapedev The tape device to open for writing. 787 * @note the caller needs to free the string returned 788 */ 789 char *get_non_rewind_dev(char *tapedev) 790 { 791 792 char *ntapedev = NULL; 793 char *p = NULL; 794 char *q = NULL; 795 796 ntapedev = (char *)malloc(strlen(tapedev)+sizeof(char)); 797 p = strrchr(tapedev,'/'); 798 if (p == NULL) { 799 return(NULL); 800 } 801 802 /* Copy tapedev content up to the last / */ 803 q = tapedev; 804 while (q != p) { 805 *ntapedev = *q; 806 ntapedev++; 807 q++; 808 } 809 /* Copy the '/' */ 810 *ntapedev = *q; 811 ntapedev++; 812 q++; 813 /* Adds a 'n' - non-rewinding */ 814 *ntapedev = 'n'; 815 ntapedev++; 816 /* Copy the rest of tapedev */ 817 while (*q != '\0') { 818 *ntapedev = *q; 819 ntapedev++; 820 q++; 821 } 822 *ntapedev = '\0'; 823 if (mt_says_tape_exists(ntapedev)) { 824 log_it("Non-rewinding tape device is %s",ntapedev); 825 } else { 826 log_it("Unable to find non-rewinding tape device."); 827 ntapedev = NULL; 828 } 829 return(ntapedev); 830 } 831 832 833 /** 834 * Handle OBDR if we were asked to do so 867 835 * @param tapedev The tape device to open for writing. 868 836 * @return 0 for success, nonzero for failure. … … 870 838 * EXISTING DATA on the tape! 871 839 */ 840 void skip_obdr(char *tapedev) 841 { 842 char *command = NULL; 843 844 ntapedev = get_non_rewind_dev(tapedev); 845 if (ntapedev == NULL) { 846 log_it("Not skipping OBDR"); 847 } 848 849 asprintf(&command, "mt -f %s fsf 2", ntapedev); 850 run_program_and_log_output(command, 1); 851 paranoid_free(command); 852 } 853 854 int create_obdr(char *tapedev) 855 { 856 857 char *ntapedev = NULL; 858 char *command = NULL; 859 int res = 0; 860 861 ntapedev = get_non_rewind_dev(tapedev); 862 if (ntapedev == NULL) { 863 log_it("Skipping OBDR"); 864 return(1); 865 } 866 867 /* OBDR: First block 10 kB of zero bs = 512 */ 868 asprintf(&command, "mt -f %s compression off", tapedev); 869 res = run_program_and_log_output(command, 1); 870 paranoid_free(command); 871 872 asprintf(&command, "mt -f %s rewind", tapedev); 873 res = run_program_and_log_output(command, 1); 874 paranoid_free(command); 875 876 asprintf(&command, "mt -f %s setblk 512", ntapedev); 877 res = run_program_and_log_output(command, 1); 878 paranoid_free(command); 879 880 asprintf(&command, "dd if=/dev/zero of=%s bs=512 count=20", ntapedev); 881 res = run_program_and_log_output(command, 1); 882 paranoid_free(command); 883 884 /* OBDR: then ISO boot image bs = 2048 */ 885 asprintf(&command, "mt -f %s setblk 2048", ntapedev); 886 res = run_program_and_log_output(command, 1); 887 paranoid_free(command); 888 889 asprintf(&command, "dd if=%s of=%s bs=2048", ntapedev); 890 res = run_program_and_log_output(command, 1); 891 paranoid_free(command); 892 893 } 894 895 /** 896 * Start writing to a tape device for the backup. 897 * Handle OBDR if we were asked to do so 898 * @param tapedev The tape device to open for writing. 899 * @return 0 for success, nonzero for failure. 900 * @note This should be called ONLY from backup processes. It will OVERWRITE ANY 901 * EXISTING DATA on the tape! 902 */ 872 903 int openout_tape(char *tapedev, long internal_tape_block_size) 873 904 { 874 // char sz_call_to_buffer[MAX_STR_LEN];875 905 876 906 g_current_media_number = 1; … … 884 914 g_tapecatalog->entries = 0; 885 915 g_tape_posK = 0; 916 917 if (bkpindo->use_obdr) { 918 create_obdr(tapedev); 919 } 886 920 887 921 set_tape_block_size_with_mt(tapedev, internal_tape_block_size);
Note:
See TracChangeset
for help on using the changeset viewer.