Changeset 3060 in MondoRescue for branches/3.0/mondo/src/mondorestore
- Timestamp:
- Nov 10, 2012, 5:05:37 AM (12 years ago)
- Location:
- branches/3.0/mondo/src/mondorestore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.0/mondo/src/mondorestore/mondo-prep.c
r3057 r3060 110 110 } 111 111 } 112 system("sync");113 system("sync");114 system("sync");112 paranoid_system("sync"); 113 paranoid_system("sync"); 114 paranoid_system("sync"); 115 115 popup_and_OK 116 116 ("I must now reboot. Please leave the boot media in the drive and repeat your actions - e.g. type 'nuke' - and it should work fine."); 117 system("reboot");117 paranoid_system("reboot"); 118 118 } 119 119 } … … 197 197 char *p; 198 198 char *q; 199 char *r; 199 200 200 201 /** int ***************************************************/ … … 272 273 log_msg(1, "OK, rewound i-want-my-lvm. Doing funky stuff..."); 273 274 rewind(fin); 274 for ( fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin);fgets(incoming, MAX_STR_LEN - 1, fin)) {275 for (r = fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin) && (r != NULL); r = fgets(incoming, MAX_STR_LEN - 1, fin)) { 275 276 fgetpos(fin, &orig_pos); 276 277 if (incoming[0] != '#') { … … 279 280 if (res && strstr(command, "create") && vacuum_pack) { 280 281 sleep(2); 281 system("sync");282 system("sync");283 system("sync");282 paranoid_system("sync"); 283 paranoid_system("sync"); 284 paranoid_system("sync"); 284 285 } 285 286 if ((p = strstr(incoming, "vgcreate"))) { 286 287 // include next line(s) if they end in /dev (cos we've got a broken i-want-my-lvm) 287 for ( fgets(tmp, MAX_STR_LEN - 1, fin); !feof(fin);fgets(tmp, MAX_STR_LEN - 1, fin)) {288 for (q = fgets(tmp, MAX_STR_LEN - 1, fin); !feof(fin) && (q != NULL); q = fgets(tmp, MAX_STR_LEN - 1, fin)) { 288 289 if (tmp[0] == '#') { 289 290 fsetpos(fin, &orig_pos); … … 393 394 } 394 395 sprintf(tmp, "echo \"%s\" >> /tmp/out.sh", command); 395 system(tmp);396 paranoid_system(tmp); 396 397 sleep(1); 397 398 } … … 410 411 paranoid_free(vgremove_sz); 411 412 // paranoid_free(do_this_last); 412 system("sync");413 system("sync");414 system("sync");413 paranoid_system("sync"); 414 paranoid_system("sync"); 415 paranoid_system("sync"); 415 416 sleep(1); 416 417 log_it("ENDING"); … … 451 452 /** pointers *********************************************************/ 452 453 char *p; 454 char *q; 453 455 454 456 /** init *************************************************************/ … … 480 482 finish(1); 481 483 } 482 for ( fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin)484 for (q = fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin) && (q != NULL) 483 485 && !strstr(incoming, old_mountlist->el[lino].device); 484 fgets(incoming, MAX_STR_LEN - 1, fin));486 q = fgets(incoming, MAX_STR_LEN - 1, fin)); 485 487 if (!feof(fin)) { 486 488 sprintf(tmp, "Investigating %s", 487 489 old_mountlist->el[lino].device); 488 490 log_it(tmp); 489 for ( fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin)491 for (q = fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin) && (q != NULL) 490 492 && !strstr(incoming, "raiddev"); 491 fgets(incoming, MAX_STR_LEN - 1, fin)) {493 q = fgets(incoming, MAX_STR_LEN - 1, fin)) { 492 494 if (strstr(incoming, OSSWAP("device", "drive")) 493 495 && !strchr(incoming, '#')) { … … 778 780 "for plex in `vinum lv -r %s | grep '^P' | tr '\t' ' ' | tr -s ' ' | cut -d' ' -f2`; do echo $plex; done > /tmp/plexes", 779 781 basename(device)); 780 system(program);782 paranoid_system(program); 781 783 if (g_fprep) { 782 784 fprintf(g_fprep, "%s\n", program); … … 792 794 793 795 mr_asprintf(&tmp, "vinum init %s", line); 794 system(tmp);796 paranoid_system(tmp); 795 797 paranoid_free(tmp); 796 798 … … 801 803 802 804 char status[MAX_STR_LEN / 4]; 803 fgets(status, MAX_STR_LEN / 4 - 1, pin); 805 if (fgets(status, MAX_STR_LEN / 4 - 1, pin)) { 806 // FIXME 807 } 804 808 pclose(pin); 805 809 … … 823 827 log_to_screen("Stopping %s", device); 824 828 stop_raid_device(device); 825 system("sync");829 paranoid_system("sync"); 826 830 sleep(1); 827 831 if (g_fprep) { … … 838 842 res = run_program_and_log_output(program, 1); 839 843 log_msg(1, "%s returned %d", program, res); 840 system("sync");844 paranoid_system("sync"); 841 845 sleep(3); 842 846 start_raid_device(device); … … 845 849 } 846 850 } 847 system("sync");851 paranoid_system("sync"); 848 852 sleep(2); 849 853 // log_to_screen("Starting %s", device); … … 851 855 // res = run_program_and_log_output(program, 1); 852 856 // log_msg(1, "%s returned %d", program, res); 853 // system("sync"); sleep(1);854 #endif 855 system("sync");857 // paranoid_system("sync"); sleep(1); 858 #endif 859 paranoid_system("sync"); 856 860 sleep(1); 857 861 newtResume(); … … 917 921 retval += res; 918 922 paranoid_free(program); 919 system("sync");923 paranoid_system("sync"); 920 924 sleep(1); 921 925 return (retval); … … 973 977 log_msg(1, "Stopping all RAID devices"); 974 978 stop_all_raid_devices(mountlist); 975 system("sync");976 system("sync");977 system("sync");979 paranoid_system("sync"); 980 paranoid_system("sync"); 981 paranoid_system("sync"); 978 982 sleep(2); 979 983 log_msg(1, "Prepare soft-RAIDs"); // prep and format too … … 997 1001 } 998 1002 } 999 system("sync");1000 system("sync");1001 system("sync");1003 paranoid_system("sync"); 1004 paranoid_system("sync"); 1005 paranoid_system("sync"); 1002 1006 sleep(2); 1003 1007 // This last step is probably necessary 1004 1008 // log_to_screen("Re-starting software RAIDs..."); 1005 1009 // start_all_raid_devices(mountlist); 1006 // system("sync"); system("sync");system("sync");1010 // paranoid_system("sync"); paranoid_system("sync"); paranoid_system("sync"); 1007 1011 // sleep(5); 1008 1012 // do LVMs now … … 1127 1131 ("Please choose 'yes' to reboot and try again; or 'no' to ignore this warning and continue.")) 1128 1132 { 1129 system("sync");1130 system("sync");1131 system("sync");1132 system("reboot");1133 paranoid_system("sync"); 1134 paranoid_system("sync"); 1135 paranoid_system("sync"); 1136 paranoid_system("reboot"); 1133 1137 } 1134 1138 } else { … … 1140 1144 } 1141 1145 newtSuspend(); 1142 system("clear");1146 paranoid_system("clear"); 1143 1147 newtResume(); 1144 1148 paranoid_free(tmp); … … 1515 1519 char *format; 1516 1520 char *tmp; 1521 char *tmp1 = NULL; 1517 1522 1518 1523 /** end *************************************************************/ … … 1634 1639 } 1635 1640 } 1636 system("sync");1641 paranoid_system("sync"); 1637 1642 #else 1638 1643 log_it("New, kernel-friendly partition remover"); … … 1695 1700 fput_string_one_char_at_a_time(pout_to_fdisk, "w\n"); 1696 1701 paranoid_pclose(pout_to_fdisk); 1697 system("sync");1702 paranoid_system("sync"); 1698 1703 log_msg(0,"------------------- fdisk.log looks like this ------------------"); 1699 1704 sprintf(tmp, "cat %s >> %s", FDISK_LOG, MONDO_LOGFILE); 1700 system(tmp);1705 paranoid_system(tmp); 1701 1706 // mark relevant partition as bootable 1702 1707 mr_asprintf(&tmp1,"make-me-bootable /tmp/mountlist.txt %s noaction",drivename); … … 1704 1709 mr_free(tmp1); 1705 1710 log_msg(0,"------------------- end of fdisk.log... ------------------"); 1706 system("sync");1711 paranoid_system("sync"); 1707 1712 sprintf(tmp, "tail -n6 %s | grep -F \"16: \"", FDISK_LOG); 1708 1713 if (!run_program_and_log_output(tmp, 5)) { … … 2032 2037 } 2033 2038 newtSuspend(); 2034 system("clear");2039 paranoid_system("clear"); 2035 2040 newtResume(); 2036 2041 paranoid_free(drivelist); … … 2314 2319 /** int *************************************************************/ 2315 2320 int retval = 0; 2316 #ifndef __FreeBSD__2317 int res;2318 #endif2319 2321 2320 2322 /** char ************************************************************/ … … 2328 2330 #endif 2329 2331 FILE *fin; 2332 char *q; 2330 2333 int i; 2331 2334 … … 2347 2350 return (1); 2348 2351 } 2349 for ( fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin);2350 fgets(incoming, MAX_STR_LEN - 1, fin)) {2352 for (q = fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin) && (q != NULL); 2353 q = fgets(incoming, MAX_STR_LEN - 1, fin)) { 2351 2354 retval += stop_raid_device(incoming); 2352 2355 } … … 2359 2362 return (1); 2360 2363 } 2361 for ( fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin);2362 fgets(incoming, MAX_STR_LEN - 1, fin)) {2364 for (q = fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin) && (q != NULL); 2365 q = fgets(incoming, MAX_STR_LEN - 1, fin)) { 2363 2366 for (p = incoming; 2364 2367 *p != '\0' && (*p != 'm' || *(p + 1) != 'd' … … 2368 2371 for (p = dev; *p > 32; p++); 2369 2372 *p = '\0'; 2370 re s= stop_raid_device(dev);2373 retval += stop_raid_device(dev); 2371 2374 } 2372 2375 } … … 2379 2382 paranoid_free(dev); 2380 2383 paranoid_free(incoming); 2381 system("sync");2382 system("sync");2383 system("sync");2384 paranoid_system("sync"); 2385 paranoid_system("sync"); 2386 paranoid_system("sync"); 2384 2387 sleep(1); 2385 2388 return (retval); -
branches/3.0/mondo/src/mondorestore/mondo-rstr-compare.c
r3056 r3060 93 93 return (1); 94 94 } 95 fread((void *) &biggiestruct, 1, sizeof(biggiestruct), fin); 95 if (fread((void *) &biggiestruct, 1, sizeof(biggiestruct), fin)) { 96 // FIXME 97 } 96 98 paranoid_fclose(fin); 97 99 … … 134 136 return (1); 135 137 } else { 136 fgets(original_cksum_ptr, MAX_STR_LEN - 1, fin); 138 if (fgets(original_cksum_ptr, MAX_STR_LEN - 1, fin)) { 139 // FIXME 140 } 137 141 paranoid_fclose(fin); 138 142 for (i = strlen(original_cksum_ptr); … … 245 249 int retval = 0; 246 250 int res; 247 long noof_lines;248 251 long archiver_errors; 249 252 bool use_star; … … 265 268 sprintf(filelist_name, MNT_CDROM "/archives/filelist.%d", 266 269 current_tarball_number); 267 268 noof_lines = count_lines_in_file(filelist_name);269 270 270 271 if (strstr(tarball_fname, ".bz2")) { … … 336 337 "sed s/': \\\"'/\\|/ %s | sed s/'\\\": '/\\|/ | cut -d'|' -f2 | sort -u | grep -vE \"^dev/.*\" >> "MONDO_CACHE"/changed.txt", 337 338 logfile); 338 system(command);339 paranoid_system(command); 339 340 archiver_errors = count_lines_in_file(logfile); 340 341 } else { … … 372 373 { 373 374 int retval = 0; 374 int res;375 375 int current_tarball_number = 0; 376 376 … … 439 439 log_to_screen(progress_str); 440 440 } else { 441 re s= compare_a_tarball(tarball_fname, current_tarball_number);441 retval += compare_a_tarball(tarball_fname, current_tarball_number); 442 442 443 443 g_current_progress++; … … 490 490 assert(bkpinfo != NULL); 491 491 492 getcwd(cwd, MAX_STR_LEN - 1); 493 chdir(bkpinfo->restore_path); 494 getcwd(new, MAX_STR_LEN - 1); 492 if (getcwd(cwd, MAX_STR_LEN - 1)) { 493 // FIXME 494 } 495 if (chdir(bkpinfo->restore_path)) { 496 //FIXME 497 } 498 if (getcwd(new, MAX_STR_LEN - 1)) { 499 // FIXME 500 } 495 501 insist_on_this_cd_number(g_current_media_number); 496 502 unlink(MONDO_CACHE"/changed.txt"); … … 498 504 resA = compare_all_tarballs(); 499 505 resB = compare_all_biggiefiles(); 500 chdir(cwd); 506 if (chdir(cwd)) { 507 // FIXME 508 } 501 509 noof_changed_files = count_lines_in_file(MONDO_CACHE"/changed.txt"); 502 510 if (noof_changed_files) { … … 633 641 634 642 log_msg(2, "calling popup_changelist_from_file()"); 635 getcwd(cwd, MAX_STR_LEN - 1); 636 chdir(bkpinfo->restore_path); 637 getcwd(new, MAX_STR_LEN - 1); 643 if (getcwd(cwd, MAX_STR_LEN - 1)) { 644 //FIXME 645 } 646 if (chdir(bkpinfo->restore_path)) { 647 // FIXME 648 } 649 if (getcwd(new, MAX_STR_LEN - 1)) { 650 //FIXME 651 } 638 652 popup_changelist_from_file(MONDO_CACHE"/changed.files"); 639 chdir(cwd); 653 if (chdir(cwd)) { 654 // FIXME 655 } 640 656 log_msg(2, "Returning from popup_changelist_from_file()"); 641 657 } … … 675 691 malloc_string(dir); 676 692 malloc_string(command); 677 getcwd(dir, MAX_STR_LEN); 678 chdir(bkpinfo->restore_path); 693 if (getcwd(dir, MAX_STR_LEN)) { 694 // FIXME 695 } 696 if (chdir(bkpinfo->restore_path)) { 697 // FIXME 698 } 679 699 680 700 sprintf(command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp", … … 692 712 } 693 713 res = verify_tape_backups(); 694 chdir(dir); 714 if (chdir(dir)) { 715 // FIXME 716 } 695 717 if (length_of_file(MONDO_CACHE"/changed.txt") > 2 696 718 && length_of_file(MONDO_CACHE"/changed.files") > 2) { … … 733 755 malloc_string(command); 734 756 735 getcwd(dir, MAX_STR_LEN); 736 chdir(bkpinfo->restore_path); 757 if (getcwd(dir, MAX_STR_LEN)) { 758 // FIXME 759 } 760 if (chdir(bkpinfo->restore_path)) { 761 // FIXME 762 } 737 763 sprintf(command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp", 738 764 bkpinfo->restore_path); … … 741 767 0, "Verifying archives against filesystem"); 742 768 res = verify_tape_backups(); 743 chdir(dir); 769 if (chdir(dir)) { 770 // FIXME 771 } 744 772 if (res) { 745 773 mvaddstr_and_log_it(g_currentY++, 74, "Failed."); -
branches/3.0/mondo/src/mondorestore/mondo-rstr-newt.c
r2879 r3060 136 136 /** int **************************************************************/ 137 137 int i = 0; 138 int num_to_add = 0;139 138 140 139 /** newt *************************************************************/ … … 231 230 strcpy(drive_to_add, device_str); 232 231 for (i = strlen(drive_to_add); isdigit(drive_to_add[i - 1]); i--); 233 num_to_add = atoi(drive_to_add + i);234 232 drive_to_add[i] = '\0'; 235 233 currline = mountlist->entries; … … 525 523 526 524 assert(raidrec != NULL); 527 system 528 ("grep Pers /proc/mdstat > /tmp/raid-personalities.txt 2> /dev/null"); 525 paranoid_system("grep Pers /proc/mdstat > /tmp/raid-personalities.txt 2> /dev/null"); 529 526 strcpy(personalities, 530 527 last_line_of_file("/tmp/raid-personalities.txt")); … … 2418 2415 newtComponent b2; 2419 2416 newtComponent b3; 2420 newtComponent b_res;2421 2417 2422 2418 … … 2429 2425 myForm = newtForm(NULL, NULL, 0); 2430 2426 newtFormAddComponents(myForm, b1, b2, b3, NULL); 2431 b_res = newtRunForm(myForm);2432 2427 newtFormDestroy(myForm); 2433 2428 newtPopWindow(); … … 2911 2906 printf 2912 2907 ("Which mode - (A)utomatic, (I)nteractive, \n(C)ompare only, or (E)xit to shell?\n--> "); 2913 fgets(tmp, MAX_STR_LEN - 1, stdin); 2908 if (fgets(tmp, MAX_STR_LEN - 1, stdin)) { 2909 // FIXME 2910 } 2914 2911 } 2915 2912 return (output); -
branches/3.0/mondo/src/mondorestore/mondorestore.c
r3056 r3060 767 767 int retval = 0; 768 768 int res = 0; 769 bool boot_loader_installed = FALSE;770 769 /** malloc **/ 771 770 char tmp[MAX_STR_LEN]; … … 846 845 log_to_screen("Preparing to format your disk(s)"); 847 846 sleep(1); 848 system("sync");847 paranoid_system("sync"); 849 848 log_to_screen("Please wait. This may take a few minutes."); 850 849 res += format_everything(mountlist, FALSE, raidlist); … … 881 880 log_msg(1, 882 881 "Great! Boot loader was installed. No need for msg at end."); 883 boot_loader_installed = TRUE;884 882 } 885 883 clean_blkid(); … … 919 917 } 920 918 g_I_have_just_nuked = TRUE; 921 /*922 if (!boot_loader_installed && !does_file_exist(DO_MBR_PLEASE))923 {924 log_to_screen("PLEASE RUN 'mondorestore --mbr' NOW TO INITIALIZE YOUR BOOT SECTOR");925 write_one_liner_data_file(DO_MBR_PLEASE, "mondorestore --mbr");926 }927 */928 919 return (retval); 929 920 } … … 1063 1054 *ntfsprog_command, *suffix, *sz_devfile; 1064 1055 char *bigblk; 1065 char *p;1066 1056 char *mds = NULL; 1067 1057 int retval = 0; … … 1116 1106 bigfileno + 1); 1117 1107 log_msg(3, tmp); 1118 p = checksum;1119 1108 } 1120 1109 … … 1344 1333 1345 1334 if (strcmp(outfile_fname, "/dev/null")) { 1346 chown(outfile_fname, biggiestruct.properties.st_uid, 1347 biggiestruct.properties.st_gid); 1335 if (chown(outfile_fname, biggiestruct.properties.st_uid, 1336 biggiestruct.properties.st_gid)) { 1337 // FIXME 1338 } 1348 1339 chmod(outfile_fname, biggiestruct.properties.st_mode); 1349 1340 ubuf->actime = biggiestruct.properties.st_atime; … … 1615 1606 if (strcmp(outfile_fname, "/dev/null")) { 1616 1607 chmod(outfile_fname, biggiestruct.properties.st_mode); 1617 chown(outfile_fname, biggiestruct.properties.st_uid, 1618 biggiestruct.properties.st_gid); 1608 if (chown(outfile_fname, biggiestruct.properties.st_uid, 1609 biggiestruct.properties.st_gid)) { 1610 // FIXME 1611 } 1619 1612 ubuf->actime = biggiestruct.properties.st_atime; 1620 1613 ubuf->modtime = biggiestruct.properties.st_mtime; … … 1831 1824 if (retval) { 1832 1825 mr_asprintf(&command, "cat %s >> %s", temp_log, MONDO_LOGFILE); 1833 system(command);1826 paranoid_system(command); 1834 1827 paranoid_free(command); 1835 1828 … … 2580 2573 max_val = atol(tmp) + 1; 2581 2574 2582 chdir(bkpinfo->restore_path); /* I don't know why this is needed _here_ but it seems to be. -HR, 02/04/2002 */ 2575 if (chdir(bkpinfo->restore_path)) { /* I don't know why this is needed _here_ but it seems to be. -HR, 02/04/2002 */ 2576 //FIXME 2577 } 2583 2578 2584 2579 run_program_and_log_output("pwd", 5); … … 2708 2703 log_msg(2, "restore_everything() --- starting"); 2709 2704 g_current_media_number = 1; 2710 getcwd(cwd, MAX_STR_LEN - 1); 2705 if (getcwd(cwd, MAX_STR_LEN - 1)) { 2706 // FIXME 2707 } 2711 2708 sprintf(tmp, "mkdir -p %s", bkpinfo->restore_path); 2712 2709 run_program_and_log_output(tmp, FALSE); 2713 2710 log_msg(1, "Changing dir to %s", bkpinfo->restore_path); 2714 chdir(bkpinfo->restore_path); 2715 getcwd(newpath, MAX_STR_LEN - 1); 2711 if (chdir(bkpinfo->restore_path)) { 2712 //FIXME 2713 } 2714 if (getcwd(newpath, MAX_STR_LEN - 1)) { 2715 // FIXME 2716 } 2716 2717 log_msg(1, "path is now %s", newpath); 2717 2718 log_msg(1, "restoring everything"); … … 2745 2746 resB = restore_all_biggiefiles_from_CD(filelist); 2746 2747 } 2747 chdir(cwd); 2748 if (chdir(cwd)) { 2749 //FIXME 2750 } 2748 2751 if (resA + resB) { 2749 2752 log_to_screen("Errors occurred while data was being restored."); … … 2936 2939 if (argc == 2 && strcmp(argv[1], "--edit-mountlist") == 0) { 2937 2940 #ifdef __FreeBSD__ 2938 system("mv -f /tmp/raidconf.txt /etc/raidtab");2941 paranoid_system("mv -f /tmp/raidconf.txt /etc/raidtab"); 2939 2942 if (!does_file_exist("/etc/raidtab")) 2940 system("vinum printconfig > /etc/raidtab");2943 paranoid_system("vinum printconfig > /etc/raidtab"); 2941 2944 #endif 2942 2945 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME); … … 2946 2949 res = let_user_edit_the_mountlist(mountlist, raidlist); 2947 2950 #ifdef __FreeBSD__ 2948 system("mv -f /etc/raidtab /tmp/raidconf.txt");2951 paranoid_system("mv -f /etc/raidtab /tmp/raidconf.txt"); 2949 2952 #endif 2950 2953 paranoid_MR_finish(res); … … 2959 2962 if (argc >= 2 && strcmp(argv[1], "--pih") == 0) { 2960 2963 if (system("mount | grep cdrom 2> /dev/null > /dev/null")) { 2961 system("mount " MNT_CDROM);2964 paranoid_system("mount " MNT_CDROM); 2962 2965 } 2963 2966 bkpinfo->compression_level = 1; … … 2969 2972 "Please wait. This may take some time.", 2970 2973 "", 1999); 2971 system("rm -Rf /tmp/*pih*");2974 paranoid_system("rm -Rf /tmp/*pih*"); 2972 2975 2973 2976 restore_a_biggiefile_from_CD(42, NULL, tmp); … … 3269 3272 if (strstr(bkpinfo->tmpdir,"mondo.tmp.") != NULL) { 3270 3273 sprintf(tmp, "rm -Rf %s", bkpinfo->tmpdir); 3271 system(tmp);3274 paranoid_system(tmp); 3272 3275 } 3273 3276 paranoid_MR_finish(retval); // frees global stuff plus bkpinfo
Note:
See TracChangeset
for help on using the changeset viewer.