Changeset 2323 in MondoRescue for branches/2.2.10/mondo/src/common/libmondo-verify.c
- Timestamp:
- Aug 18, 2009, 3:05:43 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-verify.c
r2321 r2323 93 93 assert_string_is_neither_NULL_nor_zerolength(stderr_fname); 94 94 95 mr_asprintf( &afio_found_changes, "%s.afio", ignorefiles_fname);95 mr_asprintf(afio_found_changes, "%s.afio", ignorefiles_fname); 96 96 paranoid_system("sync"); 97 97 98 98 log_msg(1, "Now scanning log file for 'afio: ' stuff"); 99 mr_asprintf( &command, "grep \"afio: \" %s | sed 's/afio: //' | grep -vE '^/dev/.*$' >> %s", stderr_fname, afio_found_changes);99 mr_asprintf(command, "grep \"afio: \" %s | sed 's/afio: //' | grep -vE '^/dev/.*$' >> %s", stderr_fname, afio_found_changes); 100 100 log_msg(2, command); 101 101 res = system(command); … … 107 107 108 108 log_msg(1, "Now scanning log file for 'star: ' stuff"); 109 mr_asprintf( &command, "grep \"star: \" %s | sed 's/star: //' | grep -vE '^/dev/.*$' >> %s", stderr_fname, afio_found_changes);109 mr_asprintf(command, "grep \"star: \" %s | sed 's/star: //' | grep -vE '^/dev/.*$' >> %s", stderr_fname, afio_found_changes); 110 110 log_msg(2, command); 111 111 res = system(command); … … 116 116 } 117 117 afio_diffs = count_lines_in_file(afio_found_changes); 118 mr_asprintf( &command, "sort %s %s %s | uniq -c | awk '{ if ($1==\"2\") {print $2;};}' | grep -v \"incheckentry xwait()\" > %s", ignorefiles_fname, afio_found_changes, afio_found_changes, changedfiles_fname);118 mr_asprintf(command, "sort %s %s %s | uniq -c | awk '{ if ($1==\"2\") {print $2;};}' | grep -v \"incheckentry xwait()\" > %s", ignorefiles_fname, afio_found_changes, afio_found_changes, changedfiles_fname); 119 119 mr_free(afio_found_changes); 120 120 log_msg(2, command); … … 167 167 } else { 168 168 retval++; 169 mr_asprintf( &tmp, "Warning - missing set(s) between %d and %d\n", g_last_afioball_number, set_number - 1);169 mr_asprintf(tmp, "Warning - missing set(s) between %d and %d\n", g_last_afioball_number, set_number - 1); 170 170 log_to_screen(tmp); 171 171 mr_free(tmp); … … 173 173 } 174 174 mds = media_descriptor_string(bkpinfo->backup_media_type); 175 mr_asprintf( &tmp, "Verifying %s #%d's tarballs", mds, g_current_media_number);175 mr_asprintf(tmp, "Verifying %s #%d's tarballs", mds, g_current_media_number); 176 176 mr_free(mds); 177 177 … … 269 269 log_it("before vsbf"); 270 270 mds = media_descriptor_string(bkpinfo->backup_media_type); 271 mr_asprintf( &tmp, "Verifying %s#%d's big files", mds, g_current_media_number);271 mr_asprintf(tmp, "Verifying %s#%d's big files", mds, g_current_media_number); 272 272 mr_free(mds); 273 273 … … 276 276 277 277 log_it("after vsbf"); 278 mr_asprintf( &mountpoint, "%s/archives", mtpt);278 mr_asprintf(mountpoint, "%s/archives", mtpt); 279 279 if (last_bigfile_num == -1) { 280 280 bigfile_num = 0; … … 302 302 paranoid_fclose(fin); 303 303 } 304 mr_asprintf( &tmp, "%s/%s", bkpinfo->restore_path, biggiestruct.filename);304 mr_asprintf(tmp, "%s/%s", bkpinfo->restore_path, biggiestruct.filename); 305 305 log_msg(2, "Opening biggiefile #%ld - '%s'", bigfile_num, tmp); 306 306 forig = fopen(tmp, "r"); … … 312 312 bkpinfo->restore_path, 313 313 biggiestruct.filename); 314 mr_asprintf( &tmp, "echo \"%s/%s not found\" >> %s/biggies.changed", bkpinfo->restore_path, biggiestruct.filename, bkpinfo->tmpdir);314 mr_asprintf(tmp, "echo \"%s/%s not found\" >> %s/biggies.changed", bkpinfo->restore_path, biggiestruct.filename, bkpinfo->tmpdir); 315 315 system(tmp); 316 316 mr_free(tmp); … … 333 333 g_current_media_number, bigfile_num, slice_num); 334 334 if (!does_file_exist(slice_fname(bigfile_num, slice_num, mountpoint, ""))) { 335 mr_asprintf( &command, "%s -dc %s 2>> %s", sz_exe, slice_fname(bigfile_num, slice_num, mountpoint, bkpinfo->zip_suffix), MONDO_LOGFILE);335 mr_asprintf(command, "%s -dc %s 2>> %s", sz_exe, slice_fname(bigfile_num, slice_num, mountpoint, bkpinfo->zip_suffix), MONDO_LOGFILE); 336 336 } else { 337 mr_asprintf( &command, "cat %s 2>> %s", slice_fname(bigfile_num, slice_num, mountpoint, ""), MONDO_LOGFILE);337 mr_asprintf(command, "cat %s 2>> %s", slice_fname(bigfile_num, slice_num, mountpoint, ""), MONDO_LOGFILE); 338 338 } 339 339 pin = popen(command, "r"); … … 432 432 433 433 log_it("Verifying fileset '%s'", tarball_fname); 434 mr_asprintf( &outlog, "%s/afio.log", bkpinfo->tmpdir);434 mr_asprintf(outlog, "%s/afio.log", bkpinfo->tmpdir); 435 435 /* if programmer forgot to say which compression thingy to use then find out */ 436 436 if (strstr(tarball_fname, ".lzo") … … 462 462 bkpinfo->use_star = TRUE; 463 463 if (strstr(tarball_fname, ".bz2")) 464 mr_asprintf( &command, "star -diff diffopts=mode,size,data file=%s -bz >> %s 2>> %s", tarball_fname, outlog, outlog);464 mr_asprintf(command, "star -diff diffopts=mode,size,data file=%s %s >> %s 2>> %s", tarball_fname, (strstr(tarball_fname, ".bz2")) ? "-bz" : " ", outlog, outlog); 465 465 } else { 466 466 bkpinfo->use_star = FALSE; 467 mr_asprintf( &command, "afio -r -P %s -Z %s >> %s 2>> %s", bkpinfo->zip_exe, tarball_fname, outlog, outlog);467 mr_asprintf(command, "afio -r -P %s -Z %s >> %s 2>> %s", bkpinfo->zip_exe, tarball_fname, outlog, outlog); 468 468 } 469 469 log_msg(6, "command=%s", command); … … 472 472 473 473 if (length_of_file(outlog) < 10) { 474 mr_asprintf( &command, "cat %s >> %s", outlog, MONDO_LOGFILE);474 mr_asprintf(command, "cat %s >> %s", outlog, MONDO_LOGFILE); 475 475 } else { 476 mr_asprintf( &command, "cut -d: -f%d %s | sort -u", (bkpinfo->use_star) ? 1 : 2, outlog);476 mr_asprintf(command, "cut -d: -f%d %s | sort -u", (bkpinfo->use_star) ? 1 : 2, outlog); 477 477 pin = popen(command, "r"); 478 478 if (pin) { … … 580 580 p++; 581 581 } 582 mr_asprintf( &tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir);582 mr_asprintf(tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir); 583 583 paranoid_system(tmp); 584 584 mr_free(tmp); 585 585 586 mr_asprintf( &tarball_fname, "%s/tmpfs/temporary-%s", bkpinfo->tmpdir, p);586 mr_asprintf(tarball_fname, "%s/tmpfs/temporary-%s", bkpinfo->tmpdir, p); 587 587 read_file_from_stream_to_file(tarball_fname, size); 588 588 res = verify_a_tarball(tarball_fname); … … 639 639 p++; 640 640 } 641 mr_asprintf( &test_file, "%s/temporary-%s", bkpinfo->tmpdir, p);641 mr_asprintf(test_file, "%s/temporary-%s", bkpinfo->tmpdir, p); 642 642 for (res = 643 643 read_header_block_from_stream(&slice_siz, slice_fnam, &ctrl_chr); … … 666 666 if (strcmp(biggie_cksum, orig_cksum)) { 667 667 log_msg(2, "orig cksum=%s; curr cksum=%s", biggie_cksum, orig_cksum); 668 mr_asprintf( &tmp, "%s has changed on live filesystem", biggie_fname);668 mr_asprintf(tmp, "%s has changed on live filesystem", biggie_fname); 669 669 log_to_screen(tmp); 670 670 mr_free(tmp); 671 671 672 mr_asprintf( &tmp, "echo \"%s\" >> %s/biggies.changed", biggie_fname, bkpinfo->tmpdir);672 mr_asprintf(tmp, "echo \"%s\" >> %s/biggies.changed", biggie_fname, bkpinfo->tmpdir); 673 673 system(tmp); 674 674 mr_free(tmp); … … 713 713 714 714 if (g_getfattr) { 715 mr_asprintf( &curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);715 mr_asprintf(curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir); 716 716 } 717 717 if (g_getfacl) { 718 mr_asprintf( &curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);718 mr_asprintf(curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir); 719 719 } 720 720 log_to_screen("Verifying regular archives on tape"); … … 749 749 res = read_header_block_from_stream(&size, fname, &ctrl_chr)) { 750 750 if (g_getfattr) { 751 mr_asprintf( &curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, current_afioball_number);751 mr_asprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, current_afioball_number); 752 752 } 753 753 if (g_getfacl) { 754 mr_asprintf( &curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, current_afioball_number);754 mr_asprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, current_afioball_number); 755 755 } 756 756 if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) { … … 770 770 wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr); 771 771 } 772 mr_asprintf( &tmp, "Verifying fileset #%ld", current_afioball_number);772 mr_asprintf(tmp, "Verifying fileset #%ld", current_afioball_number); 773 773 update_progress_form(tmp); 774 774 mr_free(tmp); … … 776 776 res = verify_an_afioball_from_stream(fname, size); 777 777 if (res) { 778 mr_asprintf( &tmp, "Afioball %ld differs from live filesystem", current_afioball_number);778 mr_asprintf(tmp, "Afioball %ld differs from live filesystem", current_afioball_number); 779 779 log_to_screen(tmp); 780 780 mr_free(tmp); … … 830 830 831 831 if (g_getfattr) { 832 mr_asprintf( &curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);832 mr_asprintf(curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir); 833 833 } 834 834 if (g_getfacl) { 835 mr_asprintf( &curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);836 } 837 mr_asprintf( &comment, "Verifying all bigfiles.");835 mr_asprintf(curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir); 836 } 837 mr_asprintf(comment, "Verifying all bigfiles."); 838 838 log_to_screen(comment); 839 839 res = read_header_block_from_stream(&size, orig_fname, &ctrl_chr); … … 878 878 p++; 879 879 } 880 mr_asprintf( &comment, "Verifying bigfile #%ld (%ld K)", current_biggiefile_number, (long) size >> 10);880 mr_asprintf(comment, "Verifying bigfile #%ld (%ld K)", current_biggiefile_number, (long) size >> 10); 881 881 update_progress_form(comment); 882 882 mr_free(comment); 883 883 884 mr_asprintf( &logical_fname, "%s/%s", bkpinfo->restore_path, orig_fname);884 mr_asprintf(logical_fname, "%s/%s", bkpinfo->restore_path, orig_fname); 885 885 res = verify_a_biggiefile_from_stream(logical_fname, size); 886 886 mr_free(logical_fname); … … 901 901 * Verify the USB device 902 902 * @param bkpinfo The backup information structure. Fields used: 903 * - @c bkpinfo->isodir904 903 * - @c bkpinfo->media_device 905 904 * - @c bkpinfo->tmpdir … … 931 930 assert(bkpinfo != NULL); 932 931 933 mr_asprintf( &fname, "%s1", bkpinfo->media_device);932 mr_asprintf(fname, "%s1", bkpinfo->media_device); 934 933 if (is_this_device_mounted(fname)) { 935 934 log_msg(1, "USB device mounted. Remounting it at the right place"); 936 mr_asprintf( &tmp, "umount %s", fname);935 mr_asprintf(tmp, "umount %s", fname); 937 936 run_program_and_log_output(tmp, FALSE); 938 937 paranoid_free(tmp); … … 941 940 942 941 log_msg(1, "Mounting USB device."); 943 mr_asprintf( &mountpoint, "%s/usb", bkpinfo->tmpdir);944 mr_asprintf( &tmp, "mkdir -p %s", mountpoint);942 mr_asprintf(mountpoint, "%s/usb", bkpinfo->tmpdir); 943 mr_asprintf(tmp, "mkdir -p %s", mountpoint); 945 944 run_program_and_log_output(tmp, FALSE); 946 945 paranoid_free(tmp); 947 946 /* Mindi always create one single parition on the USB dev */ 948 mr_asprintf( &tmp, "mount %s1 %s", bkpinfo->media_device, mountpoint);947 mr_asprintf(tmp, "mount %s1 %s", bkpinfo->media_device, mountpoint); 949 948 ret = run_program_and_log_output(tmp, FALSE); 950 949 paranoid_free(tmp); … … 956 955 sync(); 957 956 log_msg(2, "OK, I've mounted the USB Disk/Key\n"); 958 mr_asprintf( &tmp, "%s/archives/NOT-THE-LAST", mountpoint);957 mr_asprintf(tmp, "%s/archives/NOT-THE-LAST", mountpoint); 959 958 if (!does_file_exist(tmp)) { 960 959 log_msg … … 973 972 verify_all_slices_on_CD(mountpoint); 974 973 975 mr_asprintf( &tmp1, "umount %s", mountpoint);974 mr_asprintf(tmp1, "umount %s", mountpoint); 976 975 #ifdef __FreeBSD__ 977 976 ret += system(tmp1); … … 982 981 #endif 983 982 { 984 mr_asprintf( &tmp, "%s failed; unable to unmount USB device\n", tmp1);983 mr_asprintf(tmp, "%s failed; unable to unmount USB device\n", tmp1); 985 984 log_to_screen(tmp); 986 985 paranoid_free(tmp); … … 1031 1030 assert(bkpinfo != NULL); 1032 1031 1033 mr_asprintf( &mountpoint, "%s/cdrom", bkpinfo->tmpdir);1034 mr_asprintf( &fname, "%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, g_current_media_number);1032 mr_asprintf(mountpoint, "%s/cdrom", bkpinfo->tmpdir); 1033 mr_asprintf(fname, "%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, g_current_media_number); 1035 1034 1036 1035 mkdir(mountpoint, 1777); … … 1054 1053 mddevice = make_vn(fname); 1055 1054 if (ret) { 1056 mr_asprintf( &tmp, "make_vn of %s failed; unable to verify ISO\n", fname);1055 mr_asprintf(tmp, "make_vn of %s failed; unable to verify ISO\n", fname); 1057 1056 log_to_screen(tmp); 1058 1057 mr_free(tmp); … … 1061 1060 return (1); 1062 1061 } 1063 mr_asprintf( &command, "mount_cd9660 %s %s", mddevice, mountpoint);1062 mr_asprintf(command, "mount_cd9660 %s %s", mddevice, mountpoint); 1064 1063 #else 1065 mr_asprintf( &command, "mount -o loop,ro -t iso9660 %s %s", fname, mountpoint);1064 mr_asprintf(command, "mount -o loop,ro -t iso9660 %s %s", fname, mountpoint); 1066 1065 #endif 1067 1066 if (run_program_and_log_output(command, FALSE)) { 1068 mr_asprintf( &tmp, "%s failed; unable to mount ISO image\n", command);1067 mr_asprintf(tmp, "%s failed; unable to mount ISO image\n", command); 1069 1068 log_to_screen(tmp); 1070 1069 mr_free(tmp); … … 1077 1076 } 1078 1077 log_msg(2, "OK, I've mounted the ISO/CD\n"); 1079 mr_asprintf( &tmp, "%s/archives/NOT-THE-LAST", mountpoint);1078 mr_asprintf(tmp, "%s/archives/NOT-THE-LAST", mountpoint); 1080 1079 if (!does_file_exist(tmp)) { 1081 1080 log_msg … … 1097 1096 #ifdef __FreeBSD__ 1098 1097 ret = 0; 1099 mr_asprintf( &command, "umount %s", mountpoint);1098 mr_asprintf(command, "umount %s", mountpoint); 1100 1099 ret += system(command); 1101 1100 ret += kick_vn(mddevice); 1102 1101 if (ret) 1103 1102 #else 1104 mr_asprintf( &command, "umount %s", mountpoint);1103 mr_asprintf(command, "umount %s", mountpoint); 1105 1104 if (system(command)) 1106 1105 #endif 1107 1106 { 1108 mr_asprintf( &tmp, "%s failed; unable to unmount ISO image\n", command);1107 mr_asprintf(tmp, "%s failed; unable to unmount ISO image\n", command); 1109 1108 log_to_screen(tmp); 1110 1109 mr_free(tmp); … … 1118 1117 1119 1118 if (!does_file_exist(fname)) { 1120 mr_asprintf( &command, "umount %s", bkpinfo->media_device);1119 mr_asprintf(command, "umount %s", bkpinfo->media_device); 1121 1120 run_program_and_log_output(command, 2); 1122 1121 mr_free(command); … … 1165 1164 /* close tape; exit */ 1166 1165 // fclose(g_tape_stream); <-- not needed; is handled by closein_tape() 1167 mr_asprintf( &tmp, "rm -f %s/biggies.changed %s/changed.files 2> /dev/null", bkpinfo->tmpdir, bkpinfo->tmpdir);1166 mr_asprintf(tmp, "rm -f %s/biggies.changed %s/changed.files 2> /dev/null", bkpinfo->tmpdir, bkpinfo->tmpdir); 1168 1167 paranoid_system(tmp); 1169 1168 mr_free(tmp); 1170 1169 1171 mr_asprintf( &changed_files_fname, "%s/changed.files", bkpinfo->tmpdir);1172 mr_asprintf( &tmp, "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", (bkpinfo->use_star) ? "star" : "afio", MONDO_LOGFILE, changed_files_fname);1170 mr_asprintf(changed_files_fname, "%s/changed.files", bkpinfo->tmpdir); 1171 mr_asprintf(tmp, "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", (bkpinfo->use_star) ? "star" : "afio", MONDO_LOGFILE, changed_files_fname); 1173 1172 log_msg(2, "Running command to derive list of changed files"); 1174 1173 log_msg(2, tmp); … … 1182 1181 mr_free(tmp); 1183 1182 1184 mr_asprintf( &tmp, "cat %s/biggies.changed >> %s", bkpinfo->tmpdir, changed_files_fname);1183 mr_asprintf(tmp, "cat %s/biggies.changed >> %s", bkpinfo->tmpdir, changed_files_fname); 1185 1184 paranoid_system(tmp); 1186 1185 mr_free(tmp); … … 1188 1187 diffs = count_lines_in_file(changed_files_fname); 1189 1188 if (diffs > 0) { 1190 mr_asprintf( &tmp, "cp -f %s %s/changed.files", changed_files_fname, MONDO_CACHE);1189 mr_asprintf(tmp, "cp -f %s %s/changed.files", changed_files_fname, MONDO_CACHE); 1191 1190 run_program_and_log_output(tmp, FALSE); 1192 1191 mr_free(tmp);
Note:
See TracChangeset
for help on using the changeset viewer.