Changeset 1663 in MondoRescue for branches/stable/mondo/src/common/libmondo-verify.c
- Timestamp:
- Sep 27, 2007, 12:21:18 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/src/common/libmondo-verify.c
r1609 r1663 25 25 //static char cvsid[] = "$Id$"; 26 26 27 char *vfy_tball_fname(struct s_bkpinfo *, char *, int);28 29 30 27 /** 31 28 * The number of the most recently verified afioball. … … 37 34 extern char *g_getfattr; 38 35 extern char *MONDO_LOGFILE; 36 37 /* Reference to global bkpinfo */ 38 extern struct s_bkpinfo *bkpinfo; 39 40 41 /** 42 * Generate the filename of a tarball to verify. 43 * @param bkpinfo The backup information structure. @c bkpinfo->zip_suffix is the only field used. 44 * @param mountpoint The directory where the CD/DVD/ISO is mounted. 45 * @param setno The afioball number to get the location of. 46 * @return The absolute path to the afioball. 47 * @note The returned string points to static data that will be overwritten with each call. 48 * @ingroup stringGroup 49 */ 50 char *vfy_tball_fname(char *mountpoint, int setno) 51 { 52 /*@ buffers ******************************************************* */ 53 static char output[MAX_STR_LEN]; 54 55 assert(bkpinfo != NULL); 56 assert_string_is_neither_NULL_nor_zerolength(mountpoint); 57 sprintf(output, "%s/archives/%d.star.%s", mountpoint, setno, 58 bkpinfo->zip_suffix); 59 if (!does_file_exist(output)) { 60 sprintf(output, "%s/archives/%d.afio.%s", mountpoint, setno, 61 bkpinfo->zip_suffix); 62 } 63 return (output); 64 } 65 39 66 40 67 /** … … 116 143 * @return The number of sets containing differences (0 for success). 117 144 */ 118 int verify_afioballs_on_CD( struct s_bkpinfo *bkpinfo,char *mountpoint)145 int verify_afioballs_on_CD(char *mountpoint) 119 146 { 120 147 … … 134 161 set_number < 9999 135 162 && 136 !does_file_exist(vfy_tball_fname 137 (bkpinfo, mountpoint, set_number)); 163 !does_file_exist(vfy_tball_fname(mountpoint, set_number)); 138 164 set_number++); 139 if (!does_file_exist(vfy_tball_fname( bkpinfo,mountpoint, set_number))) {165 if (!does_file_exist(vfy_tball_fname(mountpoint, set_number))) { 140 166 return (0); 141 167 } … … 160 186 161 187 for (total_sets = set_number; 162 does_file_exist(vfy_tball_fname( bkpinfo,mountpoint, total_sets));188 does_file_exist(vfy_tball_fname(mountpoint, total_sets)); 163 189 total_sets++) { 164 190 mr_msg(1, "total_sets = %d", total_sets); 165 191 } 166 192 for (; 167 does_file_exist(vfy_tball_fname( bkpinfo,mountpoint, set_number));193 does_file_exist(vfy_tball_fname(mountpoint, set_number)); 168 194 set_number++) { 169 195 percentage = … … 173 199 mr_msg(1, "set = %d", set_number); 174 200 retval += 175 verify_an_afioball_from_CD(bkpinfo, 176 vfy_tball_fname(bkpinfo, mountpoint, 177 set_number)); 201 verify_an_afioball_from_CD(vfy_tball_fname(mountpoint, set_number)); 178 202 } 179 203 g_last_afioball_number = set_number - 1; … … 192 216 * @return The number of differences (0 for perfect biggiefiles). 193 217 */ 194 int verify_all_slices_on_CD( struct s_bkpinfo *bkpinfo,char *mtpt)218 int verify_all_slices_on_CD(char *mtpt) 195 219 { 196 220 … … 291 315 bkpinfo->restore_path, 292 316 biggiestruct.filename); 293 mr_asprintf(&tmp, "echo \"%s/%s not found\" >> /tmp/biggies.changed",317 mr_asprintf(&tmp, "echo \"%s/%s not found\" >> %s/biggies.changed", 294 318 bkpinfo->restore_path, 295 biggiestruct.filename); 319 biggiestruct.filename, 320 bkpinfo->tmpdir); 296 321 system(tmp); 297 322 mr_free(tmp); … … 396 421 * @return 0, always. 397 422 */ 398 int verify_a_tarball( struct s_bkpinfo *bkpinfo,char *tarball_fname)423 int verify_a_tarball(char *tarball_fname) 399 424 { 400 425 /*@ buffers ********************************************************* */ … … 522 547 */ 523 548 int 524 verify_an_afioball_from_CD( struct s_bkpinfo *bkpinfo,char *tarball_fname)549 verify_an_afioball_from_CD(char *tarball_fname) 525 550 { 526 551 … … 528 553 int res = 0; 529 554 530 assert(bkpinfo != NULL);531 555 assert_string_is_neither_NULL_nor_zerolength(tarball_fname); 532 556 … … 535 559 fatal_error("Cannot verify nonexistent afioball"); 536 560 } 537 res = verify_a_tarball( bkpinfo,tarball_fname);561 res = verify_a_tarball(tarball_fname); 538 562 return (res); 539 563 } … … 550 574 */ 551 575 int 552 verify_an_afioball_from_stream(struct s_bkpinfo *bkpinfo, char *orig_fname, 553 long long size) 576 verify_an_afioball_from_stream(char *orig_fname, long long size) 554 577 { 555 578 … … 579 602 580 603 mr_asprintf(&tarball_fname, "%s/tmpfs/temporary-%s", bkpinfo->tmpdir, p); 581 read_file_from_stream_to_file( bkpinfo,tarball_fname, size);582 res = verify_a_tarball( bkpinfo,tarball_fname);604 read_file_from_stream_to_file(tarball_fname, size); 605 res = verify_a_tarball(tarball_fname); 583 606 if (res) { 584 607 mr_msg(0, "Afioball '%s' no longer matches your live filesystem", p); … … 599 622 */ 600 623 int 601 verify_a_biggiefile_from_stream(struct s_bkpinfo *bkpinfo, 602 char *biggie_fname, long long size) 624 verify_a_biggiefile_from_stream(char *biggie_fname, long long size) 603 625 { 604 626 … … 642 664 wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr); 643 665 } 644 res = read_file_from_stream_to_file( bkpinfo,test_file, slice_siz);666 res = read_file_from_stream_to_file(test_file, slice_siz); 645 667 unlink(test_file); 646 668 res = … … 672 694 mr_free(tmp); 673 695 674 mr_asprintf(&tmp, "echo \"%s\" >> /tmp/biggies.changed",675 biggie_fname);696 mr_asprintf(&tmp, "echo \"%s\" >> %s/biggies.changed", 697 biggie_fname, bkpinfo->tmpdir); 676 698 system(tmp); 677 699 mr_free(tmp); … … 692 714 * @return 0 for success (even if there are differences); nonzero for a tape error. 693 715 */ 694 int verify_afioballs_from_stream( struct s_bkpinfo *bkpinfo)716 int verify_afioballs_from_stream() 695 717 { 696 718 /*@ int ********************************************************** */ … … 722 744 } 723 745 log_to_screen(_("Verifying regular archives on tape")); 724 total_afioballs = get_last_filelist_number( bkpinfo) + 1;746 total_afioballs = get_last_filelist_number() + 1; 725 747 open_progress_form(_("Verifying filesystem"), 726 748 _("I am verifying archives against your live filesystem now."), … … 733 755 if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) { 734 756 res = 735 read_EXAT_files_from_tape( bkpinfo,&size, fname, &ctrl_chr,757 read_EXAT_files_from_tape(&size, fname, &ctrl_chr, 736 758 curr_xattr_list_fname, 737 759 curr_acl_list_fname); … … 758 780 iamhere("Reading EXAT files from tape"); 759 781 res = 760 read_EXAT_files_from_tape( bkpinfo,&size, fname, &ctrl_chr,782 read_EXAT_files_from_tape(&size, fname, &ctrl_chr, 761 783 curr_xattr_list_fname, 762 784 curr_acl_list_fname); … … 772 794 mr_free(tmp); 773 795 774 res = verify_an_afioball_from_stream( bkpinfo,fname, size);796 res = verify_an_afioball_from_stream(fname, size); 775 797 if (res) { 776 798 mr_asprintf(&tmp, _("Afioball %ld differs from live filesystem"), … … 801 823 * @return 0 for success (even if there are differences); nonzero for a tape error. 802 824 */ 803 int verify_biggiefiles_from_stream( struct s_bkpinfo *bkpinfo)825 int verify_biggiefiles_from_stream() 804 826 { 805 827 … … 843 865 iamhere("Grabbing the EXAT biggiefiles"); 844 866 res = 845 read_EXAT_files_from_tape( bkpinfo,&size, orig_fname,867 read_EXAT_files_from_tape(&size, orig_fname, 846 868 &ctrl_chr, curr_xattr_list_fname, 847 869 curr_acl_list_fname); … … 883 905 orig_fname); 884 906 res = 885 verify_a_biggiefile_from_stream( bkpinfo,logical_fname, size);907 verify_a_biggiefile_from_stream(logical_fname, size); 886 908 mr_free(logical_fname); 887 909 retval += res; … … 911 933 * @ingroup verifyGroup 912 934 */ 913 int verify_cd_image( struct s_bkpinfo *bkpinfo)935 int verify_cd_image() 914 936 { 915 937 … … 949 971 popup_and_OK(_("Please push CD tray closed.")); 950 972 } 951 if (find_and_mount_actual_cd( bkpinfo,mountpoint)) {973 if (find_and_mount_actual_cd(mountpoint)) { 952 974 log_to_screen(_("failed to mount actual CD")); 953 975 return (1); … … 998 1020 mr_free(tmp); 999 1021 1000 verify_afioballs_on_CD( bkpinfo,mountpoint);1022 verify_afioballs_on_CD(mountpoint); 1001 1023 iamhere("before verify_all_slices"); 1002 verify_all_slices_on_CD( bkpinfo,mountpoint);1024 verify_all_slices_on_CD(mountpoint); 1003 1025 1004 1026 mr_asprintf(&command, "umount %s", mountpoint); … … 1045 1067 * @ingroup verifyGroup 1046 1068 */ 1047 int verify_tape_backups( struct s_bkpinfo *bkpinfo)1069 int verify_tape_backups() 1048 1070 { 1049 1071 … … 1062 1084 mr_msg(3, "verify_tape_backups --- starting"); 1063 1085 log_to_screen(_("Verifying backups")); 1064 openin_tape( bkpinfo);1086 openin_tape(); 1065 1087 1066 1088 /* verify archives themselves */ 1067 retval += verify_afioballs_from_stream( bkpinfo);1068 retval += verify_biggiefiles_from_stream( bkpinfo);1089 retval += verify_afioballs_from_stream(); 1090 retval += verify_biggiefiles_from_stream(); 1069 1091 1070 1092 /* find the final blocks */ 1071 1093 sync(); 1072 1094 sleep(2); 1073 closein_tape( bkpinfo);1095 closein_tape(); 1074 1096 1075 1097 /* close tape; exit */ 1076 paranoid_system 1077 ("rm -f /tmp/biggies.changed /tmp/changed.files.[0-9]* 2> /dev/null"); 1078 mr_asprintf(&changed_files_fname, "/tmp/changed.files.%d", 1079 (int) (random() % 32767)); 1098 mr_asprintf(&tmp,"rm -f %s/biggies.changed %s/changed.files 2> /dev/null", bkpinfo->tmpdir, bkpinfo->tmpdir); 1099 paranoid_system(tmp); 1100 mr_free(tmp); 1101 1102 mr_asprintf(&changed_files_fname, "%s/changed.files", bkpinfo->tmpdir); 1080 1103 mr_asprintf(&tmp, 1081 1104 "grep -E '^%s:.*$' %s | cut -d'\"' -f2 | sort -u | awk '{print \"/\"$0;};' | tr -s '/' '/' | grep -v \"(total of\" | grep -v \"incheckentry.*xwait\" | grep -vE '^/afio:.*$' | grep -vE '^dev/.*$' > %s", … … 1096 1119 mr_free(tmp); 1097 1120 1098 mr_asprintf(&tmp, "cat /tmp/biggies.changed >> %s", changed_files_fname);1121 mr_asprintf(&tmp, "cat %s/biggies.changed >> %s", bkpinfo->tmpdir, changed_files_fname); 1099 1122 paranoid_system(tmp); 1100 1123 mr_free(tmp); … … 1102 1125 diffs = count_lines_in_file(changed_files_fname); 1103 1126 if (diffs > 0) { 1104 mr_asprintf(&tmp, "cp -f %s %s", changed_files_fname, 1105 "/tmp/changed.files"); 1127 mr_asprintf(&tmp, "cp -f %s %s/changed.files", changed_files_fname, MINDI_CACHE); 1106 1128 run_program_and_log_output(tmp, FALSE); 1107 1129 mr_free(tmp); 1108 1130 1109 1131 mr_asprintf(&tmp, 1110 "%ld files differed from live filesystem; type less %s or less %s to see",1111 diffs, changed_files_fname, "/tmp/changed.files");1132 "%ld files differed from live filesystem; type less %s or less %s/changed.files to see", 1133 diffs, changed_files_fname, MINDI_CACHE); 1112 1134 mr_msg(0, tmp); 1113 1135 mr_free(tmp); 1114 1136 1115 1137 log_to_screen 1116 (_("See /tmp/changed.files for a list of nonmatching files."));1138 (_("See "MINDI_CACHE"/changed.files for a list of nonmatching files.")); 1117 1139 log_to_screen 1118 1140 (_("The files probably changed on filesystem, not on backup media.")); … … 1124 1146 1125 1147 1126 /**1127 * Generate the filename of a tarball to verify.1128 * @param bkpinfo The backup information structure. @c bkpinfo->zip_suffix is the only field used.1129 * @param mountpoint The directory where the CD/DVD/ISO is mounted.1130 * @param setno The afioball number to get the location of.1131 * @return The absolute path to the afioball.1132 * @note The returned string points to static data that will be overwritten with each call.1133 * @ingroup stringGroup1134 */1135 char *vfy_tball_fname(struct s_bkpinfo *bkpinfo, char *mountpoint,1136 int setno)1137 {1138 /*@ buffers ******************************************************* */1139 static char output[MAX_STR_LEN];1140 1141 assert(bkpinfo != NULL);1142 assert_string_is_neither_NULL_nor_zerolength(mountpoint);1143 sprintf(output, "%s/archives/%d.star.%s", mountpoint, setno,1144 bkpinfo->zip_suffix);1145 if (!does_file_exist(output)) {1146 sprintf(output, "%s/archives/%d.afio.%s", mountpoint, setno,1147 bkpinfo->zip_suffix);1148 }1149 return (output);1150 }
Note:
See TracChangeset
for help on using the changeset viewer.