Changeset 296 in MondoRescue
- Timestamp:
- Jan 11, 2006, 10:10:31 AM (19 years ago)
- Location:
- branches/2.06/mondo
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.06/mondo/ChangeLog
r294 r296 12 12 - Abort|Warn when one of the include|exclude dirs (-I|-E) does not exist 13 13 (Bruno Cornec/Jeffs) 14 - Replaced partimagehack with ntfsclone from ntfsprogs package. 15 (Andree Leidenfrost) 14 16 15 17 v2.06 (2005-12-23) -
branches/2.06/mondo/mondo/common/libmondo-archive-EXT.h
r259 r296 27 27 extern int slice_up_file_etc(struct s_bkpinfo *bkpinfo, 28 28 char *biggie_filename, 29 char * partimagehack_fifo,29 char *ntfsprog_fifo, 30 30 long biggie_file_number, 31 31 long noof_biggie_files, 32 bool use_ partimagehack);32 bool use_ntfsprog); 33 33 extern int verify_data(struct s_bkpinfo *bkpinfo); 34 34 extern void wipe_archives(char *d); -
branches/2.06/mondo/mondo/common/libmondo-archive.c
r260 r296 2162 2162 char *bigfile_fname; 2163 2163 char *sz_devfile; 2164 char * partimagehack_fifo = NULL;2164 char *ntfsprog_fifo = NULL; 2165 2165 /*@ long *********************************************** */ 2166 2166 long biggie_file_number = 0; … … 2174 2174 FILE *ftmp = NULL; 2175 2175 bool delete_when_done; 2176 bool use_ partimagehack;2176 bool use_ntfsprog; 2177 2177 /*@ long long ****************************************** */ 2178 2178 long long biggie_fsize; … … 2209 2209 for (fgets(bigfile_fname, MAX_STR_LEN, fin); !feof(fin); 2210 2210 fgets(bigfile_fname, MAX_STR_LEN, fin), biggie_file_number++) { 2211 use_ partimagehack= FALSE;2211 use_ntfsprog = FALSE; 2212 2212 if (bigfile_fname[strlen(bigfile_fname) - 1] < 32) { 2213 2213 bigfile_fname[strlen(bigfile_fname) - 1] = '\0'; … … 2223 2223 delete_when_done = TRUE; 2224 2224 } else { 2225 // Call partimagehackif it's a /dev entry (i.e. a partition to be imaged)2225 // Call ntfsclone (formerly partimagehack) if it's a /dev entry (i.e. a partition to be imaged) 2226 2226 log_msg(2, "bigfile_fname = %s", bigfile_fname); 2227 use_ partimagehack= FALSE;2227 use_ntfsprog = FALSE; 2228 2228 if (!strncmp(bigfile_fname, "/dev/", 5) 2229 2229 && is_dev_an_NTFS_dev(bigfile_fname)) { 2230 use_ partimagehack= TRUE;2230 use_ntfsprog = TRUE; 2231 2231 log_msg(2, 2232 "Calling partimagehackin background because %s is an NTFS partition",2232 "Calling ntfsclone in background because %s is an NTFS partition", 2233 2233 bigfile_fname); 2234 2234 sprintf(sz_devfile, "/tmp/%d.%d.000", … … 2236 2236 (int) (random() % 32768)); 2237 2237 mkfifo(sz_devfile, 0x770); 2238 partimagehack_fifo = sz_devfile;2238 ntfsprog_fifo = sz_devfile; 2239 2239 switch (pid = fork()) { 2240 2240 case -1: … … 2242 2242 case 0: 2243 2243 log_msg(2, 2244 "CHILD - fip - calling feed_into_ partimage(%s, %s)",2244 "CHILD - fip - calling feed_into_ntfsprog(%s, %s)", 2245 2245 bigfile_fname, sz_devfile); 2246 res = feed_into_ partimage(bigfile_fname, sz_devfile);2246 res = feed_into_ntfsprog(bigfile_fname, sz_devfile); 2247 2247 exit(res); 2248 2248 break; 2249 2249 default: 2250 2250 log_msg(2, 2251 "feed_into_ partimage() called in background --- pid=%ld",2251 "feed_into_ntfsprog() called in background --- pid=%ld", 2252 2252 (long int) (pid)); 2253 2253 } … … 2256 2256 else { 2257 2257 sz_devfile[0] = '\0'; 2258 partimagehack_fifo = NULL;2258 ntfsprog_fifo = NULL; 2259 2259 } 2260 2260 … … 2265 2265 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 2266 2266 write_header_block_to_stream(biggie_fsize, bigfile_fname, 2267 use_ partimagehack?2267 use_ntfsprog ? 2268 2268 BLK_START_A_PIHBIGGIE : 2269 2269 BLK_START_A_NORMBIGGIE); … … 2271 2271 res = 2272 2272 slice_up_file_etc(bkpinfo, bigfile_fname, 2273 partimagehack_fifo, biggie_file_number,2274 noof_biggie_files, use_ partimagehack);2273 ntfsprog_fifo, biggie_file_number, 2274 noof_biggie_files, use_ntfsprog); 2275 2275 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 2276 2276 write_header_block_to_stream(0, … … 3270 3270 * 3271 3271 * @param biggie_filename The file to chop up. 3272 * @param partimagehack_fifo The FIFO to partimagehackif this is an imagedev, NULL otherwise.3272 * @param ntfsprog_fifo The FIFO to ntfsclone if this is an imagedev, NULL otherwise. 3273 3273 * @param biggie_file_number The sequence number of this biggie file (starting from 0). 3274 3274 * @param noof_biggie_files The number of biggie files there are total. … … 3279 3279 int 3280 3280 slice_up_file_etc(struct s_bkpinfo *bkpinfo, char *biggie_filename, 3281 char * partimagehack_fifo, long biggie_file_number,3282 long noof_biggie_files, bool use_ partimagehack)3281 char *ntfsprog_fifo, long biggie_file_number, 3282 long noof_biggie_files, bool use_ntfsprog) 3283 3283 { 3284 3284 … … 3329 3329 3330 3330 biggiestruct.for_backward_compatibility = '\n'; 3331 biggiestruct.use_ partimagehack = use_partimagehack;3331 biggiestruct.use_ntfsprog = use_ntfsprog; 3332 3332 if (!(tempblock = (char *) malloc(256 * 1024))) { 3333 3333 fatal_error("malloc error 256*1024"); … … 3347 3347 fatal_error("bkpinfo->optimal_set_size is insanely small"); 3348 3348 } 3349 if ( partimagehack_fifo) {3350 file_to_openin = partimagehack_fifo;3349 if (ntfsprog_fifo) { 3350 file_to_openin = ntfsprog_fifo; 3351 3351 strcpy(checksum_line, "IGNORE"); 3352 3352 log_msg(2, 3353 3353 "Not calculating checksum for %s: it would take too long", 3354 3354 biggie_filename); 3355 totallength = get_phys_size_of_drive(biggie_filename)*1024*1024LL; 3355 if ( !find_home_of_exe("ntfsresize")) { 3356 fatal_error("ntfsresize not found"); 3357 } 3358 sprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename); 3359 log_it("command = %s", command); 3360 strcpy (tmp, call_program_and_get_last_line_of_output(command)); 3361 log_it("res of it = %s", tmp); 3362 totallength = atoll(tmp); 3356 3363 } else { 3357 3364 file_to_openin = biggie_filename; -
branches/2.06/mondo/mondo/common/libmondo-archive.h
r259 r296 29 29 void set_bit_N_of_array(char *array, int N, bool true_or_false); 30 30 int slice_up_file_etc(struct s_bkpinfo *bkpinfo, char *biggie_filename, 31 char * partimagehack_fifo,31 char *ntfsprog_fifo, 32 32 long biggie_file_number, long noof_biggie_files, 33 bool use_ partimagehack);33 bool use_ntfsprog); 34 34 int verify_data(struct s_bkpinfo *bkpinfo); 35 35 void wipe_archives(char *d); -
branches/2.06/mondo/mondo/common/libmondo-files.c
r273 r296 865 865 char *biggielist; 866 866 char *comment; 867 char *tmp; 868 char *command; 867 869 868 870 /*@ long ******************************************************** */ … … 878 880 malloc_string(biggielist); 879 881 malloc_string(comment); 882 malloc_string(tmp); 883 malloc_string(command); 880 884 log_it("Calculating size of all biggiefiles (in total)"); 881 885 sprintf(biggielist, "%s/biggielist.txt", bkpinfo->tmpdir); … … 892 896 } 893 897 if (0 == strncmp(fname, "/dev/", 5)) { 894 file_len_K = get_phys_size_of_drive(fname) * 1024L; 898 if (is_dev_an_NTFS_dev(fname)) { 899 if ( !find_home_of_exe("ntfsresize")) { 900 fatal_error("ntfsresize not found"); 901 } 902 sprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", fname); 903 log_it("command = %s", command); 904 strcpy (tmp, call_program_and_get_last_line_of_output(command)); 905 log_it("res of it = %s", tmp); 906 file_len_K = atoll(tmp) / 1024L; 907 } else { 908 file_len_K = get_phys_size_of_drive(fname) * 1024L; 909 } 895 910 } else { 896 911 file_len_K = (long) (length_of_file(fname) / 1024); … … 915 930 paranoid_free(biggielist); 916 931 paranoid_free(comment); 932 paranoid_free(tmp); 933 paranoid_free(command); 917 934 return (scratchL); 918 935 } -
branches/2.06/mondo/mondo/common/libmondo-fork-EXT.h
r128 r296 14 14 char *cmd); 15 15 extern int copy_from_src_to_dest(FILE *, FILE *, char); 16 extern int feed_into_ partimage(char *input_device, char *output_fname);17 extern int feed_outfrom_ partimage(char *output_device, char *input_fifo);16 extern int feed_into_ntfsprog(char *input_device, char *output_fname); 17 extern int feed_outfrom_ntfsprog(char *output_device, char *input_fifo); -
branches/2.06/mondo/mondo/common/libmondo-fork.c
r154 r296 4 4 - subroutines for handling forking/pthreads/etc. 5 5 6 7 01/20/2006 8 - replaced partimagehack with ntfsclone 6 9 7 10 06/20/2004 … … 493 496 494 497 495 496 /**497 * Thread callback to run a command (partimage) in the background.498 * @param xfb A transfer block of @c char, containing:499 * - xfb:[0] A marker, should be set to 2. Decremented to 1 while the command is running and 0 when it's finished.500 * - xfb:[1] The command's return value, if xfb:[0] is 0.501 * - xfb+2: A <tt>NULL</tt>-terminated string containing the command to be run.502 * @return NULL to pthread_join.503 */504 void *call_partimage_in_bkgd(void *xfb)505 {506 char *transfer_block;507 int retval = 0;508 509 g_buffer_pid = getpid();510 unlink("/tmp/null");511 log_msg(1, "starting");512 transfer_block = (char *) xfb;513 transfer_block[0]--; // should now be 1514 retval = system(transfer_block + 2);515 if (retval) {516 log_OS_error("partimage returned an error");517 }518 transfer_block[1] = retval;519 transfer_block[0]--; // should now be 0520 g_buffer_pid = 0;521 log_msg(1, "returning");522 pthread_exit(NULL);523 }524 525 526 /**527 * File to touch if we want partimage to wait for us.528 */529 #define PAUSE_PARTIMAGE_FNAME "/tmp/PAUSE-PARTIMAGE-FOR-MONDO"530 531 498 /** 532 499 * Apparently unused. @bug This has a purpose, but what? … … 535 502 #define PIMP_END_SZ "ENDENDEND0xBBC10xBBC2T231hc81h42vws89ff3kff9a82gv34r7fghbka" 536 503 537 /** 538 * Marker to start the next subvolume for Partimage. 539 */ 540 #define NEXT_SUBVOL_PLEASE "I-grew-up-on-the-crime-side,-the-New-York-Times-side,-where-staying-alive-was-no-jive" 541 542 /** 543 * Marker to end the partimage file. 544 */ 545 #define NO_MORE_SUBVOLS "On-second-hand,momma-bounced-on-old-man,-and-so-we-moved-to-Shaolin-Land." 504 505 546 506 547 507 int copy_from_src_to_dest(FILE * f_orig, FILE * f_archived, char direction) … … 674 634 675 635 636 637 676 638 /** 677 * Call partimage from @p input_device to @p output_fname. 678 * @param input_device The device to read. 679 * @param output_fname The file to write. 680 * @return 0 for success, nonzero for failure. 681 */ 682 int dynamically_create_pipes_and_copy_from_them_to_output_file(char 683 *input_device, 684 char 685 *output_fname) 686 { 687 char *curr_fifo; 688 char *prev_fifo; 689 char *next_fifo; 690 char *command; 691 char *sz_call_to_partimage; 692 int fifo_number = 0; 693 struct stat buf; 694 pthread_t partimage_thread; 695 int res = 0; 696 char *tmpstub; 697 FILE *fout; 698 FILE *fin; 699 char *tmp; 700 701 malloc_string(tmpstub); 702 malloc_string(curr_fifo); 703 malloc_string(prev_fifo); 704 malloc_string(next_fifo); 705 malloc_string(command); 706 malloc_string(sz_call_to_partimage); 707 malloc_string(tmp); 708 709 log_msg(1, "g_tmpfs_mountpt = %s", g_tmpfs_mountpt); 710 if (g_tmpfs_mountpt && g_tmpfs_mountpt[0] 711 && does_file_exist(g_tmpfs_mountpt)) { 712 strcpy(tmpstub, g_tmpfs_mountpt); 713 } else { 714 strcpy(tmpstub, "/tmp"); 715 } 716 paranoid_system("rm -f /tmp/*PARTIMAGE*"); 717 sprintf(command, "rm -Rf %s/pih-fifo-*", tmpstub); 718 paranoid_system(command); 719 sprintf(tmpstub + strlen(tmpstub), "/pih-fifo-%ld", 720 (long int) random()); 721 mkfifo(tmpstub, S_IRWXU | S_IRWXG); // never used, though... 722 sprintf(curr_fifo, "%s.%03d", tmpstub, fifo_number); 723 sprintf(next_fifo, "%s.%03d", tmpstub, fifo_number + 1); 724 mkfifo(curr_fifo, S_IRWXU | S_IRWXG); 725 mkfifo(next_fifo, S_IRWXU | S_IRWXG); // make sure _next_ fifo already exists before we call partimage 726 sz_call_to_partimage[0] = 2; 727 sz_call_to_partimage[1] = 0; 728 sprintf(sz_call_to_partimage + 2, 729 "partimagehack " PARTIMAGE_PARAMS 730 " save %s %s > /tmp/stdout 2> /tmp/stderr", input_device, 731 tmpstub); 732 log_msg(5, "curr_fifo = %s", curr_fifo); 733 log_msg(5, "next_fifo = %s", next_fifo); 734 log_msg(5, "sz_call_to_partimage call is '%s'", 735 sz_call_to_partimage + 2); 736 if (!lstat(output_fname, &buf) && S_ISREG(buf.st_mode)) { 737 log_msg(5, "Deleting %s", output_fname); 738 unlink(output_fname); 739 } 740 if (!(fout = fopen(output_fname, "w"))) { 741 fatal_error("Unable to openout to output_fname"); 742 } 743 res = 744 pthread_create(&partimage_thread, NULL, call_partimage_in_bkgd, 745 (void *) sz_call_to_partimage); 746 if (res) { 747 fatal_error("Failed to create thread to call partimage"); 748 } 749 log_msg(1, "Running fore/back at same time"); 750 log_to_screen("Working with partimagehack..."); 751 while (sz_call_to_partimage[0] > 0) { 752 sprintf(tmp, "%s\n", NEXT_SUBVOL_PLEASE); 753 if (fwrite(tmp, 1, 128, fout) != 128) { 754 fatal_error("Cannot write interim block"); 755 } 756 log_msg(5, "fifo_number=%d", fifo_number); 757 log_msg(4, "Cat'ting %s", curr_fifo); 758 if (!(fin = fopen(curr_fifo, "r"))) { 759 fatal_error("Unable to openin from fifo"); 760 } 761 // if (!sz_call_to_partimage[0]) { break; } 762 log_msg(5, "Deleting %s", prev_fifo); 763 unlink(prev_fifo); // just in case 764 copy_from_src_to_dest(fin, fout, 'w'); 765 paranoid_fclose(fin); 766 fifo_number++; 767 strcpy(prev_fifo, curr_fifo); 768 strcpy(curr_fifo, next_fifo); 769 log_msg(5, "Creating %s", next_fifo); 770 sprintf(next_fifo, "%s.%03d", tmpstub, fifo_number + 1); 771 mkfifo(next_fifo, S_IRWXU | S_IRWXG); // make sure _next_ fifo exists before we cat this one 772 system("sync"); 773 sleep(5); 774 } 775 sprintf(tmp, "%s\n", NO_MORE_SUBVOLS); 776 if (fwrite(tmp, 1, 128, fout) != 128) { 777 fatal_error("Cannot write interim block"); 778 } 779 if (fwrite(tmp, 1, 128, fout) != 128) { 780 fatal_error("Cannot write interim block"); 781 } 782 if (fwrite(tmp, 1, 128, fout) != 128) { 783 fatal_error("Cannot write interim block"); 784 } 785 if (fwrite(tmp, 1, 128, fout) != 128) { 786 fatal_error("Cannot write interim block"); 787 } 788 paranoid_fclose(fout); 789 log_to_screen("Cleaning up after partimagehack..."); 790 log_msg(3, "Final fifo_number=%d", fifo_number); 791 paranoid_system("sync"); 792 unlink(next_fifo); 793 unlink(curr_fifo); 794 unlink(prev_fifo); 795 log_to_screen("Finished cleaning up."); 796 797 // if (!lstat(sz_wait_for_this_file, &statbuf)) 798 // { log_msg(3, "WARNING! %s was not processed.", sz_wait_for_this_file); } 799 log_msg(2, "Waiting for pthread_join() to join."); 800 pthread_join(partimage_thread, NULL); 801 res = sz_call_to_partimage[1]; 802 log_msg(2, "pthread_join() joined OK."); 803 log_msg(1, "Partimagehack(save) returned %d", res); 804 unlink(tmpstub); 805 paranoid_free(curr_fifo); 806 paranoid_free(prev_fifo); 807 paranoid_free(next_fifo); 808 paranoid_free(tmpstub); 809 paranoid_free(tmp); 810 paranoid_free(command); 811 return (res); 812 } 813 814 815 /** 816 * Feed @p input_device through partimage to @p output_fname. 639 * Feed @p input_device through ntfsclone to @p output_fname. 817 640 * @param input_device The device to image. 818 641 * @param output_fname The file to write. 819 642 * @return 0 for success, nonzero for failure. 820 643 */ 821 int feed_into_ partimage(char *input_device, char *output_fname)644 int feed_into_ntfsprog(char *input_device, char *output_fname) 822 645 { 823 646 // BACKUP 824 int res; 647 int res = -1; 648 char*command; 825 649 826 650 if (!does_file_exist(input_device)) { 827 651 fatal_error("input device does not exist"); 828 652 } 829 if (!find_home_of_exe("partimagehack")) { 830 fatal_error("partimagehack not found"); 831 } 832 res = 833 dynamically_create_pipes_and_copy_from_them_to_output_file 834 (input_device, output_fname); 653 if ( !find_home_of_exe("ntfsclone")) { 654 fatal_error("ntfsclone not found"); 655 } 656 malloc_string(command); 657 sprintf(command, "ntfsclone --force --save-image --overwrite %s %s", output_fname, input_device); 658 res = run_program_and_log_output(command, 5); 659 paranoid_free(command); 835 660 return (res); 836 661 } … … 1000 825 1001 826 1002 #define PIH_LOG "/var/log/partimage-debug.log"1003 1004 827 1005 828 /** 1006 * Feed @p input_fifo through partimage (restore) to @p output_device.1007 * @param input_fifo The partimage file to read.829 * Feed @p input_fifo through ntfsclone (restore) to @p output_device. 830 * @param input_fifo The ntfsclone file to read. 1008 831 * @param output_device Where to put the output. 1009 * @return The return value of partimagehack (0 for success). 1010 * @bug Probably unnecessary, as the partimage is just a sparse file. We could use @c dd to restore it. 832 * @return The return value of ntfsclone (0 for success). 1011 833 */ 1012 int feed_outfrom_ partimage(char *output_device, char *input_fifo)834 int feed_outfrom_ntfsprog(char *output_device, char *input_fifo) 1013 835 { 1014 836 // RESTORE 1015 char *tmp; 1016 // char *command; 1017 char *stuff; 1018 char *sz_call_to_partimage; 1019 pthread_t partimage_thread; 1020 int res; 1021 char *curr_fifo; 1022 char *prev_fifo; 1023 char *oldest_fifo; 1024 char *next_fifo; 1025 char *afternxt_fifo; 1026 int fifo_number = 0; 1027 char *tmpstub; 1028 FILE *fin; 1029 FILE *fout; 1030 1031 malloc_string(curr_fifo); 1032 malloc_string(prev_fifo); 1033 malloc_string(next_fifo); 1034 malloc_string(afternxt_fifo); 1035 malloc_string(oldest_fifo); 1036 malloc_string(tmp); 1037 sz_call_to_partimage = malloc(1000); 1038 malloc_string(stuff); 1039 malloc_string(tmpstub); 1040 1041 log_msg(1, "output_device=%s", output_device); 1042 log_msg(1, "input_fifo=%s", input_fifo); 1043 /* I don't trust g_tmpfs_mountpt 1044 if (g_tmpfs_mountpt[0]) 1045 { 1046 strcpy(tmpstub, g_tmpfs_mountpt); 1047 } 1048 else 1049 { 1050 */ 1051 strcpy(tmpstub, "/tmp"); 1052 // } 1053 log_msg(1, "tmpstub was %s", tmpstub); 1054 strcpy(stuff, tmpstub); 1055 sprintf(tmpstub, "%s/pih-fifo-%ld", stuff, (long int) random()); 1056 log_msg(1, "tmpstub is now %s", tmpstub); 1057 unlink("/tmp/PARTIMAGEHACK-POSITION"); 1058 unlink(PAUSE_PARTIMAGE_FNAME); 1059 paranoid_system("rm -f /tmp/*PARTIMAGE*"); 1060 sprintf(curr_fifo, "%s.%03d", tmpstub, fifo_number); 1061 sprintf(next_fifo, "%s.%03d", tmpstub, fifo_number + 1); 1062 sprintf(afternxt_fifo, "%s.%03d", tmpstub, fifo_number + 2); 1063 mkfifo(PIH_LOG, S_IRWXU | S_IRWXG); 1064 mkfifo(curr_fifo, S_IRWXU | S_IRWXG); 1065 mkfifo(next_fifo, S_IRWXU | S_IRWXG); // make sure _next_ fifo already exists before we call partimage 1066 mkfifo(afternxt_fifo, S_IRWXU | S_IRWXG); 1067 system("cat " PIH_LOG " > /dev/null &"); 1068 log_msg(3, "curr_fifo = %s", curr_fifo); 1069 log_msg(3, "next_fifo = %s", next_fifo); 1070 if (!does_file_exist(input_fifo)) { 1071 fatal_error("input fifo does not exist"); 1072 } 1073 if (!(fin = fopen(input_fifo, "r"))) { 1074 fatal_error("Unable to openin from input_fifo"); 1075 } 1076 if (!find_home_of_exe("partimagehack")) { 1077 fatal_error("partimagehack not found"); 1078 } 1079 sz_call_to_partimage[0] = 2; 1080 sz_call_to_partimage[1] = 0; 1081 sprintf(sz_call_to_partimage + 2, 1082 "partimagehack " PARTIMAGE_PARAMS 1083 " restore %s %s > /dev/null 2>> %s", output_device, curr_fifo, 1084 MONDO_LOGFILE); 1085 log_msg(1, "output_device = %s", output_device); 1086 log_msg(1, "curr_fifo = %s", curr_fifo); 1087 log_msg(1, "sz_call_to_partimage+2 = %s", sz_call_to_partimage + 2); 1088 res = 1089 pthread_create(&partimage_thread, NULL, call_partimage_in_bkgd, 1090 (void *) sz_call_to_partimage); 1091 if (res) { 1092 fatal_error("Failed to create thread to call partimage"); 1093 } 1094 log_msg(1, "Running fore/back at same time"); 1095 log_msg(2, " Trying to openin %s", input_fifo); 1096 if (!does_file_exist(input_fifo)) { 1097 log_msg(2, "Warning - %s does not exist", input_fifo); 1098 } 1099 while (!does_file_exist("/tmp/PARTIMAGEHACK-POSITION")) { 1100 log_msg(6, "Waiting for partimagehack (restore) to start"); 1101 sleep(1); 1102 } 1103 while (sz_call_to_partimage[0] > 0) { 1104 if (fread(tmp, 1, 128, fin) != 128) { 1105 fatal_error("Cannot read introductory block"); 1106 } 1107 if (strstr(tmp, NEXT_SUBVOL_PLEASE)) { 1108 log_msg(2, "Great. Next subvol coming up."); 1109 } else if (strstr(tmp, NO_MORE_SUBVOLS)) { 1110 log_msg(2, "Great. That was the last subvol."); 1111 break; 1112 } else { 1113 log_msg(2, "WTF is this? '%s'", tmp); 1114 fatal_error("Unknown interim block"); 1115 } 1116 if (feof(fin)) { 1117 log_msg(1, "Eof(fin) detected. Breaking."); 1118 break; 1119 } 1120 log_msg(3, "Processing subvol %d", fifo_number); 1121 log_msg(5, "fifo_number=%d", fifo_number); 1122 if (!(fout = fopen(curr_fifo, "w"))) { 1123 fatal_error("Cannot openout to curr_fifo"); 1124 } 1125 log_msg(6, "Deleting %s", oldest_fifo); 1126 copy_from_src_to_dest(fout, fin, 'r'); 1127 paranoid_fclose(fout); 1128 fifo_number++; 1129 unlink(oldest_fifo); // just in case 1130 strcpy(oldest_fifo, prev_fifo); 1131 strcpy(prev_fifo, curr_fifo); 1132 strcpy(curr_fifo, next_fifo); 1133 strcpy(next_fifo, afternxt_fifo); 1134 sprintf(afternxt_fifo, "%s.%03d", tmpstub, fifo_number + 2); 1135 log_msg(6, "Creating %s", afternxt_fifo); 1136 mkfifo(afternxt_fifo, S_IRWXU | S_IRWXG); // make sure _next_ fifo already exists before we access current fifo 1137 fflush(fin); 1138 // system("sync"); 1139 usleep(1000L * 100L); 1140 } 1141 paranoid_fclose(fin); 1142 paranoid_system("sync"); 1143 log_msg(1, "Partimagehack has finished. Great. Fin-closing."); 1144 log_msg(1, "Waiting for pthread_join"); 1145 pthread_join(partimage_thread, NULL); 1146 res = sz_call_to_partimage[1]; 1147 log_msg(1, "Yay. Partimagehack (restore) returned %d", res); 1148 unlink(prev_fifo); 1149 unlink(curr_fifo); 1150 unlink(next_fifo); 1151 unlink(afternxt_fifo); 1152 unlink(PIH_LOG); 1153 paranoid_free(tmp); 1154 paranoid_free(sz_call_to_partimage); 1155 paranoid_free(stuff); 1156 paranoid_free(prev_fifo); 1157 paranoid_free(curr_fifo); 1158 paranoid_free(next_fifo); 1159 paranoid_free(afternxt_fifo); 1160 paranoid_free(oldest_fifo); 1161 paranoid_free(tmpstub); 837 int res = -1; 838 char *command; 839 840 if ( !find_home_of_exe("ntfsclone")) { 841 fatal_error("ntfsclone not found"); 842 } 843 malloc_string(command); 844 sprintf(command, "ntfsclone --force --restore-image --overwrite %s %s", output_device, input_fifo); 845 res = run_program_and_log_output(command, 5); 846 paranoid_free(command); 1162 847 return (res); 1163 848 } -
branches/2.06/mondo/mondo/common/libmondo-fork.h
r128 r296 15 15 int run_external_binary_with_percentage_indicator_NEW(char *tt, char *cmd); 16 16 int copy_from_src_to_dest(FILE *, FILE *, char); 17 int feed_into_ partimage(char *input_device, char *output_fname);18 int feed_outfrom_ partimage(char *output_device, char *input_fifo);17 int feed_into_ntfsprog(char *input_device, char *output_fname); 18 int feed_outfrom_ntfsprog(char *output_device, char *input_fifo); -
branches/2.06/mondo/mondo/common/libmondo-verify.c
r273 r296 433 433 if (res && !strncmp(biggiestruct.filename, " /dev/", 5)) { 434 434 log_msg(3, 435 "Ignoring differences between %s and live filesystem because it's a device and therefore the archives are stored via partimagehack, not dd.",435 "Ignoring differences between %s and live filesystem because it's a device and therefore the archives are stored via ntfsclone, not dd.", 436 436 biggiestruct.filename); 437 437 log_msg(3, -
branches/2.06/mondo/mondo/common/mondostructures.h
r128 r296 359 359 * 360 360 * This is useful for backing up NTFS partitions. 361 * @c partimage is used to back up only the used sectors, so the space tradeoff is not bad.361 * @c ntfsclone is used to back up only the used sectors, so the space tradeoff is not bad. 362 362 * However, several caveats apply to such a partition: 363 363 * - It must not be mounted during the backup 364 * - It must be in a format that partimage knows how to handle364 * - It must be in a format that ntfsclone knows how to handle, i.e. NTFS 365 365 * - It cannot be verified during the verify or compare phase 366 366 * - It may not be resized or selectively restored at restore-time (all or nothing) … … 678 678 */ 679 679 struct stat properties; 680 bool use_ partimagehack;680 bool use_ntfsprog; 681 681 }; 682 682 -
branches/2.06/mondo/mondo/common/my-stuff.h
r237 r296 277 277 #define BLK_STOP_BIGGIEFILES 39 ///< Marker block: stop the biggiefile section. 278 278 #define BLK_START_A_NORMBIGGIE 40 ///< Marker block: start a normal biggiefile. 279 #define BLK_START_A_PIHBIGGIE 41 ///< Marker block: start a partimagehack'd biggiefile279 #define BLK_START_A_PIHBIGGIE 41 ///< Marker block: start a ntfsprog'd biggiefile 280 280 #define BLK_START_EXTENDED_ATTRIBUTES 45 ///< Marker block: start xattr/acl info 281 281 #define BLK_STOP_EXTENDED_ATTRIBUTES 46 ///< Marker block: stop xattr/acl info … … 518 518 #define DEFAULT_DEBUG_LEVEL 4 ///< By default, don't log messages with a loglevel higher than this. 519 519 520 #define SZ_ PARTIMAGE_VOLSIZE "1048576" // was 4096521 #define PARTIMAGE_PARAMS "-z0 -V" SZ_PARTIMAGE_VOLSIZE " -o -b -d -g1"520 #define SZ_NTFSPROG_VOLSIZE "1048576" // was 4096 521 #define NTFSPROG_PARAMS "-z0 -V" SZ_NTFSPROG_VOLSIZE " -o -b -d -g1" 522 522 523 523 #define MNT_CDROM "/mnt/cdrom" -
branches/2.06/mondo/mondo/common/newt-specific.c
r273 r296 394 394 kill_anything_like_this("/mondo/do-not"); 395 395 kill_anything_like_this("tmp.mondo"); 396 kill_anything_like_this(" partimagehack");396 kill_anything_like_this("ntfsclone"); 397 397 sync(); 398 398 sprintf(tmp, "umount %s", g_tmpfs_mountpt); -
branches/2.06/mondo/mondo/mondoarchive/main.c
r259 r296 275 275 diffs = 0; 276 276 say_at_end[0] = '\0'; 277 unlink("/var/log/partimagehack-debug.log");278 277 printf("Initializing...\n"); 279 278 if (!(bkpinfo = malloc(sizeof(struct s_bkpinfo)))) { -
branches/2.06/mondo/mondo/mondoarchive/mondo-cli.c
r289 r296 711 711 if (flag_set['x']) { 712 712 strncpy(bkpinfo->image_devs, flag_val['x'], MAX_STR_LEN / 4); 713 if (run_program_and_log_output("which partimagehack", 2)) {714 fatal_error("Please install partimagehack RPM/tarball.");713 if (run_program_and_log_output("which ntfsclone", 2)) { 714 fatal_error("Please install ntfsprogs package/tarball."); 715 715 } 716 716 } -
branches/2.06/mondo/mondo/mondorestore/mondo-restore.c
r273 r296 1365 1365 /** malloc ***/ 1366 1366 char *checksum, *outfile_fname, *tmp, *bzip2_command, 1367 * partimagehack_command, *suffix, *sz_devfile;1367 *ntfsprog_command, *suffix, *sz_devfile; 1368 1368 char *bigblk; 1369 1369 char *p; … … 1372 1372 long sliceno; 1373 1373 long siz; 1374 char partimagehack_fifo[MAX_STR_LEN];1374 char ntfsprog_fifo[MAX_STR_LEN]; 1375 1375 char *file_to_openout = NULL; 1376 1376 struct s_filename_and_lstat_info biggiestruct; 1377 1377 struct utimbuf the_utime_buf, *ubuf; 1378 bool use_ partimage_hack = FALSE;1378 bool use_ntfsprog_hack = FALSE; 1379 1379 pid_t pid; 1380 1380 int res = 0; … … 1391 1391 malloc_string(tmp); 1392 1392 malloc_string(bzip2_command); 1393 malloc_string( partimagehack_command);1393 malloc_string(ntfsprog_command); 1394 1394 malloc_string(suffix); 1395 1395 malloc_string(sz_devfile); … … 1448 1448 1449 1449 log_msg(1, "DEFINITELY restoring %s", biggiestruct.filename); 1450 if (biggiestruct.use_ partimagehack) {1450 if (biggiestruct.use_ntfsprog) { 1451 1451 if (strncmp(biggiestruct.filename, "/dev/", 5)) { 1452 1452 log_msg(1, 1453 "I was in error when I set biggiestruct.use_ partimagehackto TRUE.");1453 "I was in error when I set biggiestruct.use_ntfsprog to TRUE."); 1454 1454 log_msg(1, "%s isn't even in /dev", biggiestruct.filename); 1455 biggiestruct.use_ partimagehack= FALSE;1456 } 1457 } 1458 1459 if (biggiestruct.use_ partimagehack) // if it's an NTFS device1455 biggiestruct.use_ntfsprog = FALSE; 1456 } 1457 } 1458 1459 if (biggiestruct.use_ntfsprog) // if it's an NTFS device 1460 1460 // if (!strncmp ( biggiestruct.filename, "/dev/", 5)) 1461 1461 { 1462 1462 g_loglevel = 4; 1463 use_ partimage_hack = TRUE;1463 use_ntfsprog_hack = TRUE; 1464 1464 log_msg(2, 1465 "Calling partimagehackin background because %s is an NTFS /dev entry",1465 "Calling ntfsclone in background because %s is an NTFS /dev entry", 1466 1466 outfile_fname); 1467 1467 sprintf(sz_devfile, "/tmp/%d.%d.000", (int) (random() % 32768), 1468 1468 (int) (random() % 32768)); 1469 1469 mkfifo(sz_devfile, 0x770); 1470 strcpy( partimagehack_fifo, sz_devfile);1471 file_to_openout = partimagehack_fifo;1470 strcpy(ntfsprog_fifo, sz_devfile); 1471 file_to_openout = ntfsprog_fifo; 1472 1472 switch (pid = fork()) { 1473 1473 case -1: … … 1475 1475 case 0: 1476 1476 log_msg(3, 1477 "CHILD - fip - calling feed_outfrom_ partimage(%s, %s)",1478 biggiestruct.filename, partimagehack_fifo);1477 "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)", 1478 biggiestruct.filename, ntfsprog_fifo); 1479 1479 res = 1480 feed_outfrom_ partimage(biggiestruct.filename,1481 partimagehack_fifo);1480 feed_outfrom_ntfsprog(biggiestruct.filename, 1481 ntfsprog_fifo); 1482 1482 // log_msg(3, "CHILD - fip - exiting"); 1483 1483 exit(res); … … 1485 1485 default: 1486 1486 log_msg(3, 1487 "feed_into_ partimage() called in background --- pid=%ld",1487 "feed_into_ntfsprog() called in background --- pid=%ld", 1488 1488 (long int) (pid)); 1489 1489 } 1490 1490 } else { 1491 use_ partimage_hack = FALSE;1492 partimagehack_fifo[0] = '\0';1491 use_ntfsprog_hack = FALSE; 1492 ntfsprog_fifo[0] = '\0'; 1493 1493 file_to_openout = outfile_fname; 1494 1494 if (!does_file_exist(outfile_fname)) // yes, it looks weird with the '!' but it's correct that way … … 1517 1517 return (1); 1518 1518 } 1519 log_msg(3, "Opened out to %s", outfile_fname); // CD/DVD --> mondorestore --> partimagehack--> hard disk itself1519 log_msg(3, "Opened out to %s", outfile_fname); // CD/DVD --> mondorestore --> ntfsclone --> hard disk itself 1520 1520 1521 1521 for (sliceno = 1, finished = FALSE; !finished;) { … … 1626 1626 g_loglevel = old_loglevel; 1627 1627 1628 if (use_ partimage_hack) {1629 log_msg(3, "Waiting for partimage to finish");1628 if (use_ntfsprog_hack) { 1629 log_msg(3, "Waiting for ntfsclone to finish"); 1630 1630 sprintf(tmp, 1631 " ps ax | grep \" partimagehack\" | grep -v grep > /dev/null 2> /dev/null");1631 " ps ax | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null"); 1632 1632 while (system(tmp) == 0) { 1633 1633 sleep(1); 1634 1634 } 1635 log_it("OK, partimage has really finished");1635 log_it("OK, ntfsclone has really finished"); 1636 1636 } 1637 1637 … … 1649 1649 paranoid_free(tmp); 1650 1650 paranoid_free(bzip2_command); 1651 paranoid_free( partimagehack_command);1651 paranoid_free(ntfsprog_command); 1652 1652 paranoid_free(suffix); 1653 1653 paranoid_free(sz_devfile); … … 1679 1679 long long biggiefile_size, //UNUSED 1680 1680 struct s_node *filelist, 1681 int use_ partimagehack,1681 int use_ntfsprog, 1682 1682 char *pathname_of_last_file_restored) 1683 1683 { … … 1689 1689 char *command; 1690 1690 char *outfile_fname; 1691 char * partimagehack_command;1691 char *ntfsprog_command; 1692 1692 char *sz_devfile; 1693 char * partimagehack_fifo;1693 char *ntfsprog_fifo; 1694 1694 char *file_to_openout = NULL; 1695 1695 … … 1703 1703 long long slice_siz; 1704 1704 bool dummy_restore = FALSE; 1705 bool use_ partimage_hack = FALSE;1705 bool use_ntfsprog_hack = FALSE; 1706 1706 pid_t pid; 1707 1707 struct s_filename_and_lstat_info biggiestruct; … … 1710 1710 1711 1711 malloc_string(tmp); 1712 malloc_string( partimagehack_fifo);1712 malloc_string(ntfsprog_fifo); 1713 1713 malloc_string(outfile_fname); 1714 1714 malloc_string(command); 1715 1715 malloc_string(sz_devfile); 1716 malloc_string( partimagehack_command);1716 malloc_string(ntfsprog_command); 1717 1717 old_loglevel = g_loglevel; 1718 1718 assert(bkpinfo != NULL); … … 1721 1721 1722 1722 pathname_of_last_file_restored[0] = '\0'; 1723 if (use_ partimagehack== BLK_START_A_PIHBIGGIE) {1724 use_ partimagehack= 1;1723 if (use_ntfsprog == BLK_START_A_PIHBIGGIE) { 1724 use_ntfsprog = 1; 1725 1725 log_msg(1, "%s --- pih=YES", orig_bf_fname); 1726 } else if (use_ partimagehack== BLK_START_A_NORMBIGGIE) {1727 use_ partimagehack= 0;1726 } else if (use_ntfsprog == BLK_START_A_NORMBIGGIE) { 1727 use_ntfsprog = 0; 1728 1728 log_msg(1, "%s --- pih=NO", orig_bf_fname); 1729 1729 } else { 1730 use_ partimagehack= 0;1730 use_ntfsprog = 0; 1731 1731 log_msg(1, "%s --- pih=NO (weird marker though)", orig_bf_fname); 1732 1732 } … … 1754 1754 } 1755 1755 1756 if (use_ partimagehack) {1756 if (use_ntfsprog) { 1757 1757 if (strncmp(orig_bf_fname, "/dev/", 5)) { 1758 1758 log_msg(1, 1759 "I was in error when I set use_ partimagehackto TRUE.");1759 "I was in error when I set use_ntfsprog to TRUE."); 1760 1760 log_msg(1, "%s isn't even in /dev", orig_bf_fname); 1761 use_ partimagehack= FALSE;1762 } 1763 } 1764 1765 if (use_ partimagehack) {1761 use_ntfsprog = FALSE; 1762 } 1763 } 1764 1765 if (use_ntfsprog) { 1766 1766 g_loglevel = 4; 1767 1767 strcpy(outfile_fname, orig_bf_fname); 1768 use_ partimage_hack = TRUE;1768 use_ntfsprog_hack = TRUE; 1769 1769 log_msg(2, 1770 "Calling partimagehackin background because %s is a /dev entry",1770 "Calling ntfsclone in background because %s is a /dev entry", 1771 1771 outfile_fname); 1772 1772 sprintf(sz_devfile, "/tmp/%d.%d.000", (int) (random() % 32768), 1773 1773 (int) (random() % 32768)); 1774 1774 mkfifo(sz_devfile, 0x770); 1775 strcpy( partimagehack_fifo, sz_devfile);1776 file_to_openout = partimagehack_fifo;1775 strcpy(ntfsprog_fifo, sz_devfile); 1776 file_to_openout = ntfsprog_fifo; 1777 1777 switch (pid = fork()) { 1778 1778 case -1: … … 1780 1780 case 0: 1781 1781 log_msg(3, 1782 "CHILD - fip - calling feed_outfrom_ partimage(%s, %s)",1783 outfile_fname, partimagehack_fifo);1782 "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)", 1783 outfile_fname, ntfsprog_fifo); 1784 1784 res = 1785 feed_outfrom_ partimage(outfile_fname, partimagehack_fifo);1785 feed_outfrom_ntfsprog(outfile_fname, ntfsprog_fifo); 1786 1786 // log_msg(3, "CHILD - fip - exiting"); 1787 1787 exit(res); … … 1789 1789 default: 1790 1790 log_msg(3, 1791 "feed_into_ partimage() called in background --- pid=%ld",1791 "feed_into_ntfsprog() called in background --- pid=%ld", 1792 1792 (long int) (pid)); 1793 1793 } … … 1801 1801 orig_bf_fname); 1802 1802 } 1803 use_ partimage_hack = FALSE;1804 partimagehack_fifo[0] = '\0';1803 use_ntfsprog_hack = FALSE; 1804 ntfsprog_fifo[0] = '\0'; 1805 1805 file_to_openout = outfile_fname; 1806 1806 if (!does_file_exist(outfile_fname)) // yes, it looks weird with the '!' but it's correct that way … … 1879 1879 pathname_of_last_file_restored); 1880 1880 1881 if (use_ partimage_hack) {1882 log_msg(3, "Waiting for partimage to finish");1881 if (use_ntfsprog_hack) { 1882 log_msg(3, "Waiting for ntfsclone to finish"); 1883 1883 sprintf(tmp, 1884 " ps ax | grep \" partimagehack\" | grep -v grep > /dev/null 2> /dev/null");1884 " ps ax | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null"); 1885 1885 while (system(tmp) == 0) { 1886 1886 sleep(1); 1887 1887 } 1888 log_msg(3, "OK, partimage has really finished");1888 log_msg(3, "OK, ntfsclone has really finished"); 1889 1889 } 1890 1890 … … 1903 1903 paranoid_free(outfile_fname); 1904 1904 paranoid_free(command); 1905 paranoid_free( partimagehack_command);1905 paranoid_free(ntfsprog_command); 1906 1906 paranoid_free(sz_devfile); 1907 paranoid_free( partimagehack_fifo);1907 paranoid_free(ntfsprog_fifo); 1908 1908 g_loglevel = old_loglevel; 1909 1909 return (retval);
Note:
See TracChangeset
for help on using the changeset viewer.