Changeset 2327 in MondoRescue for branches/2.2.10/mondo/src/mondorestore/mondorestore.c
- Timestamp:
- Aug 18, 2009, 3:20:37 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/mondorestore/mondorestore.c
r2326 r2327 360 360 char *tmp1 = NULL; 361 361 362 /* Clean up blkid cache file if they exist */ 363 mr_asprintf(tmp1,"%s/etc/blkid.tab",bkpinfo->restore_path); 364 (void)unlink(tmp1); 365 paranoid_free(tmp1); 366 mr_asprintf(tmp1,"%s/etc/blkid.tab.old",bkpinfo->restore_path); 367 (void)unlink(tmp1); 368 paranoid_free(tmp1); 362 if (bkpinfo->restore_path) { 363 /* Clean up blkid cache file if they exist */ 364 mr_asprintf(tmp1,"%s/etc/blkid.tab",bkpinfo->restore_path); 365 (void)unlink(tmp1); 366 paranoid_free(tmp1); 367 mr_asprintf(tmp1,"%s/etc/blkid.tab.old",bkpinfo->restore_path); 368 (void)unlink(tmp1); 369 paranoid_free(tmp1); 370 } 369 371 } 370 372 … … 375 377 char *editor = NULL; 376 378 377 /* Clean up multiconf cache file if they exist */ 378 mr_asprintf(tmp1,"%s/var/lib/multipath/bindings",bkpinfo->restore_path); 379 (void)unlink(tmp1); 380 paranoid_free(tmp1); 379 if (bkpinfo->restore_path) { 380 /* Clean up multiconf cache file if they exist */ 381 mr_asprintf(tmp1,"%s/var/lib/multipath/bindings",bkpinfo->restore_path); 382 (void)unlink(tmp1); 383 paranoid_free(tmp1); 384 } 381 385 382 386 /* Edit multipath.conf if needed to adapt wwid */ … … 425 429 * @return 0 for success, or the number of errors encountered. 426 430 */ 427 int 428 interactive_mode(struct mountlist_itself *mountlist, 429 struct raidlist_itself *raidlist) 431 int interactive_mode(struct mountlist_itself *mountlist, struct raidlist_itself *raidlist) 430 432 { 431 433 int retval = 0; … … 442 444 char *tmp1 = NULL; 443 445 char *fstab_fname; 444 char *old_restpath ;446 char *old_restpath = NULL; 445 447 446 448 struct s_node *filelist; … … 452 454 malloc_string(tmp); 453 455 malloc_string(fstab_fname); 454 malloc_string(old_restpath);455 456 assert(bkpinfo != NULL); 456 457 assert(mountlist != NULL); … … 460 461 461 462 if (g_text_mode) { 462 if (!ask_me_yes_or_no 463 ("Interactive Mode + textonly = experimental! Proceed anyway?")) 464 { 463 if (!ask_me_yes_or_no("Interactive Mode + textonly = experimental! Proceed anyway?")) { 465 464 fatal_error("Wise move."); 466 465 } … … 473 472 474 473 #ifdef __FreeBSD__ 475 if (strstr 476 (call_program_and_get_last_line_of_output("cat /tmp/cmdline"), 477 "noresize")) 474 if (strstr(call_program_and_get_last_line_of_output("cat /tmp/cmdline"), "noresize")) 478 475 #else 479 if (strstr 480 (call_program_and_get_last_line_of_output("cat /proc/cmdline"), 481 "noresize")) 476 if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "noresize")) 482 477 #endif 483 478 { … … 581 576 } 582 577 /* restore */ 583 if ((restore_all = 584 ask_me_yes_or_no("Do you want me to restore all of your data?"))) 585 { 578 if ((restore_all = ask_me_yes_or_no("Do you want me to restore all of your data?"))) { 586 579 log_msg(1, "Restoring all data"); 587 580 retval += restore_everything(NULL); 588 } else 589 if ((restore_all = 590 ask_me_yes_or_no 591 ("Do you want me to restore _some_ of your data?"))) { 592 strcpy(old_restpath, bkpinfo->restore_path); 581 } else if ((restore_all = ask_me_yes_or_no("Do you want me to restore _some_ of your data?"))) { 582 mr_asprintf(old_restpath, "%s", bkpinfo->restore_path); 593 583 for (done = FALSE; !done;) { 594 584 unlink("/tmp/filelist.full"); … … 610 600 tmp[0] = '\0'; // so we restore to [blank]/file/name :) 611 601 } 612 strcpy(bkpinfo->restore_path, tmp); 602 mr_free(bkpinfo->restore_path); 603 mr_asprintf(bkpinfo->restore_path, "%s", tmp); 613 604 log_msg(1, "Restoring subset"); 614 605 retval += restore_everything(filelist); 615 free_filelist(filelist);616 606 } else { 617 strcpy(bkpinfo->restore_path, old_restpath);618 free_filelist(filelist);607 mr_free(bkpinfo->restore_path); 608 mr_asprintf(bkpinfo->restore_path, "%s", old_restpath); 619 609 } 610 free_filelist(filelist); 620 611 mr_free(p); 621 612 622 if (!ask_me_yes_or_no 623 ("Restore another subset of your backup?")) { 613 if (!ask_me_yes_or_no("Restore another subset of your backup?")) { 624 614 done = TRUE; 625 615 } … … 628 618 } 629 619 } 630 strcpy(old_restpath, bkpinfo->restore_path); 631 } else { 632 mvaddstr_and_log_it(g_currentY++, 633 0, 634 "User opted not to restore any data. "); 620 mr_free(old_restpath); 621 } else { 622 mvaddstr_and_log_it(g_currentY++, 0, "User opted not to restore any data. "); 635 623 } 636 624 if (retval) { 637 mvaddstr_and_log_it(g_currentY++, 638 0, 639 "Errors occurred during the restore phase. "); 625 mvaddstr_and_log_it(g_currentY++, 0, "Errors occurred during the restore phase. "); 640 626 } 641 627 … … 685 671 paranoid_free(tmp); 686 672 paranoid_free(fstab_fname); 687 paranoid_free(old_restpath);688 673 log_it("Leaving interactive_mode()"); 689 674 return (retval); … … 942 927 int retval = 0; 943 928 944 /** malloc **/ 945 char *old_restpath; 929 char *old_restpath = NULL; 946 930 char *p = NULL; 947 931 948 932 struct mountlist_itself *mountlist = NULL; 949 // static950 933 struct raidlist_itself *raidlist = NULL; 951 934 struct s_node *filelist = NULL; … … 953 936 log_msg(1, "restore_to_live_filesystem() - starting"); 954 937 assert(bkpinfo != NULL); 955 malloc_string(old_restpath);956 938 mountlist = malloc(sizeof(struct mountlist_itself)); 957 939 raidlist = malloc(sizeof(struct raidlist_itself)); … … 960 942 } 961 943 962 strcpy(bkpinfo->restore_path, "/"); 944 mr_free(bkpinfo->restore_path); 945 mr_asprintf(bkpinfo->restore_path, "/"); 963 946 if (!g_restoring_live_from_cd && !g_restoring_live_from_nfs) { 964 947 popup_and_OK … … 990 973 if (!g_restoring_live_from_nfs && (filelist = process_filelist_and_biggielist())) { 991 974 save_filelist(filelist, "/tmp/selected-files.txt"); 992 strcpy(old_restpath, bkpinfo->restore_path);975 mr_asprintf(old_restpath, "%s", bkpinfo->restore_path); 993 976 p = popup_and_get_string("Restore path", "Restore files to where? )", bkpinfo->restore_path); 994 977 if (p != NULL) { 995 strcpy(bkpinfo->restore_path, p);996 mr_free(p);978 mr_free(bkpinfo->restore_path); 979 bkpinfo->restore_path = p; 997 980 998 981 log_it("Restoring everything"); 999 982 retval += restore_everything(filelist); 1000 free_filelist(filelist); 1001 strcpy(bkpinfo->restore_path, old_restpath); 1002 } else { 1003 free_filelist(filelist); 1004 } 1005 strcpy(bkpinfo->restore_path, old_restpath); 983 } 984 free_filelist(filelist); 985 mr_free(bkpinfo->restore_path); 986 bkpinfo->restore_path = old_restpath; 1006 987 } else { 1007 988 if (filelist != NULL) { … … 1022 1003 eject_device(bkpinfo->media_device); 1023 1004 } 1024 paranoid_free(old_restpath);1025 1005 free(mountlist); 1026 1006 free(raidlist); … … 2427 2407 * @return 0 for success, or the number of filesets that failed. 2428 2408 */ 2429 int 2430 restore_all_tarballs_from_stream(struct s_node *filelist) 2409 int restore_all_tarballs_from_stream(struct s_node *filelist) 2431 2410 { 2432 2411 int retval = 0; … … 2904 2883 g_restoring_live_from_nfs = TRUE; 2905 2884 } 2885 /* Adding an initialisation in order to avoid to hndle NULL pointer later */ 2886 mr_free(bkpinfo->restore_path); 2887 mr_asprintf(bkpinfo->restore_path, "%s", "/tmp"); 2888 2906 2889 log_msg(2, "Calling restore_to_live_filesystem()"); 2907 2890 retval = restore_to_live_filesystem(); … … 2921 2904 2922 2905 log_it("About to call load_mountlist and load_raidtab"); 2923 strcpy(bkpinfo->restore_path, MNT_RESTORING); 2906 mr_free(bkpinfo->restore_path); 2907 mr_asprintf(bkpinfo->restore_path, "%s", MNT_RESTORING); 2924 2908 read_cfg_file_into_bkpinfo(g_mondo_cfg_file); 2925 2909 retval = load_mountlist(mountlist, g_mountlist_fname);
Note:
See TracChangeset
for help on using the changeset viewer.