Changeset 783 in MondoRescue for trunk/mondo/mondo/mondorestore/mondo-restore.c
- Timestamp:
- Aug 31, 2006, 5:09:20 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/mondo/mondorestore/mondo-restore.c
r689 r783 13 13 #include <unistd.h> 14 14 15 #include " ../common/my-stuff.h"15 #include "my-stuff.h" 16 16 #include "../common/mondostructures.h" 17 17 #include "../common/libmondo.h" … … 158 158 assert(raidlist != NULL); 159 159 if (!bkpinfo->disaster_recovery) { 160 strcpy(g_mountlist_fname, "/tmp/mountlist.txt");160 paranoid_alloc(g_mountlist_fname, "/tmp/mountlist.txt"); 161 161 log_msg(2, "I guess you're testing edit_mountlist()"); 162 162 } … … 310 310 /************************************************************************** 311 311 *END_ EXTRACT_CONFIG_FILE_FROM_RAMDISK * 312 **************************************************************************/313 314 315 /**316 * Locate an executable in the directory structure rooted at @p restg.317 * @param out_path Where to put the executable.318 * @param fname The basename of the executable.319 * @param restg The directory structure to look in.320 * @note If it could not be found in @p restg then @p fname is put in @p out_path.321 * @ingroup restoreUtilityGroup322 */323 void324 find_pathname_of_executable_preferably_in_RESTORING(char *out_path,325 char *fname,326 char *restg)327 {328 assert(out_path != NULL);329 assert_string_is_neither_NULL_nor_zerolength(fname);330 331 sprintf(out_path, "%s/sbin/%s", restg, fname);332 if (does_file_exist(out_path)) {333 sprintf(out_path, "%s/usr/sbin/%s", restg, fname);334 if (does_file_exist(out_path)) {335 sprintf(out_path, "%s/bin/%s", restg, fname);336 if (does_file_exist(out_path)) {337 sprintf(out_path, "%s/usr/bin/%s", restg, fname);338 if (does_file_exist(out_path)) {339 strcpy(out_path, fname);340 }341 }342 }343 }344 }345 346 /**************************************************************************347 *END_FIND_PATHNAME_OF_EXECUTABLE_PREFERABLY_IN_RESTORING *348 312 **************************************************************************/ 349 313 … … 534 498 ask_me_yes_or_no 535 499 (_("Do you want me to restore _some_ of your data?")))) { 536 old_restpath = bkpinfo->restore_path;500 asprintf(&old_restpath,bkpinfo->restore_path); 537 501 for (done = FALSE; !done;) { 538 502 unlink("/tmp/filelist.full"); … … 548 512 if (!strcmp(bkpinfo->restore_path, "/")) { 549 513 if (!ask_me_yes_or_no(_("Are you sure?"))) { 550 paranoid_free(bkpinfo->restore_path); 551 bkpinfo->restore_path = old_restpath; 514 paranoid_alloc(bkpinfo->restore_path, old_restpath); 552 515 goto gotos_suck; 553 516 } … … 558 521 free_filelist(filelist); 559 522 } else { 560 bkpinfo->restore_path = old_restpath;523 paranoid_alloc(bkpinfo->restore_path,old_restpath); 561 524 free_filelist(filelist); 562 525 } … … 569 532 } 570 533 } 534 paranoid_free(old_restpath); 571 535 } else { 572 536 mvaddstr_and_log_it(g_currentY++, … … 630 594 ("Warning - errors occurred during the restore phase.")); 631 595 } 596 return(retval); 632 597 } 633 598 … … 750 715 bool boot_loader_installed = FALSE; 751 716 char *tmp = NULL; 752 char tmpA[MAX_STR_LEN];753 char tmpB[MAX_STR_LEN];754 char tmpC[MAX_STR_LEN];717 char *tmpA = NULL; 718 char *tmpB = NULL; 719 char *tmpC = NULL; 755 720 756 721 assert(bkpinfo != NULL); … … 807 772 tmp = call_program_and_get_last_line_of_output("cat /proc/cmdline"); 808 773 #endif 809 if (strstr(tmp, ,"nopart")) {774 if (strstr(tmp,"nopart")) { 810 775 log_msg(2, 811 776 "Not partitioning drives due to 'nopart' option."); … … 949 914 if (filelist) { 950 915 save_filelist(filelist, "/tmp/selected-files.txt"); 951 old_restpath = bkpinfo->restore_path;916 asprintf(&old_restpath,bkpinfo->restore_path); 952 917 if (popup_and_get_string(_("Restore path"), 953 918 _("Restore files to where? )"), … … 957 922 } 958 923 free_filelist(filelist); 959 bkpinfo->restore_path = old_restpath;924 paranoid_alloc(bkpinfo->restore_path,old_restpath); 960 925 } 961 926 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { … … 1012 977 char *bigblk = NULL; 1013 978 char *pathname_of_last_file_restored = NULL; 1014 int retval = 0;1015 979 int finished = FALSE; 1016 980 long sliceno; … … 1172 1136 asprintf(&tmp3, 1173 1137 "Asking for %s #%d so that I may read slice #%ld\n", 1174 media_descriptor_string(bkpinfo->backup_media_type),1138 bkpinfo->backup_media_string, 1175 1139 g_current_media_number, sliceno); 1176 1140 log_msg(2, tmp3); … … 1178 1142 1179 1143 asprintf(&tmp3, _("Restoring from %s #%d"), 1180 media_descriptor_string(bkpinfo->backup_media_type),1144 bkpinfo->backup_media_string, 1181 1145 g_current_media_number); 1182 1146 log_to_screen(tmp3); … … 1198 1162 asprintf(&bzip2_command, "bzip2 -dc %s 2>> %s",tmp2, MONDO_LOGFILE); 1199 1163 } else if (does_file_exist(tmp)) { 1200 asprintf(&bzip2_command, " ");1164 asprintf(&bzip2_command, "%s", ""); 1201 1165 } else { 1202 1166 log_to_screen(_("OK, that's pretty fsck0red...")); … … 1209 1173 } 1210 1174 asprintf(&tmp3, "Working on %s #%d, file #%ld, slice #%ld ", 1211 media_descriptor_string(bkpinfo->backup_media_type),1175 bkpinfo->backup_media_string, 1212 1176 g_current_media_number, bigfileno + 1, sliceno); 1213 1177 log_msg(2, tmp3); … … 1300 1264 char *command = NULL; 1301 1265 char *outfile_fname = NULL; 1302 char *ntfsprog_command = NULL;1303 1266 char *ntfsprog_fifo = NULL; 1304 1267 char *file_to_openout = NULL; … … 1418 1381 } 1419 1382 1420 if ( !bkpinfo->zip_exe[0]) {1383 if (bkpinfo->zip_exe == NULL) { 1421 1384 asprintf(&command, "cat > \"%s\"", file_to_openout); 1422 1385 } else { … … 1649 1612 asprintf(&tmp, " -bz"); 1650 1613 } else { 1651 asprintf(&tmp, " ");1614 asprintf(&tmp, "%s", ""); 1652 1615 } 1653 1616 asprintf(&command, … … 1792 1755 "Restoring from fileset #%ld (%ld KB) on %s #%d", 1793 1756 current_tarball_number, (long) size >> 10, 1794 media_descriptor_string(bkpinfo->backup_media_type),1757 bkpinfo->backup_media_string, 1795 1758 g_current_media_number); 1796 1759 log_msg(2, tmp); … … 1869 1832 // star 1870 1833 if (filelist) { 1871 asprintf(&command, "star -x file=%s %s list=%s 2>> %s", afio_fname, executable 1834 asprintf(&command, "star -x file=%s %s list=%s 2>> %s", afio_fname, executable, 1872 1835 filelist_subset_fname,MONDO_LOGFILE); 1873 1836 } else { … … 1946 1909 long noof_biggiefiles = 0L, bigfileno = 0L, total_slices = 0L; 1947 1910 char *tmp = NULL; 1911 char *tmp1 = NULL; 1948 1912 bool just_changed_cds = FALSE, finished = FALSE; 1949 1913 char *xattr_fname = NULL; … … 1997 1961 log_msg(3, "Cannot find bigfile #%ld 's first slice on %s #%d", 1998 1962 bigfileno + 1, 1999 media_descriptor_string(bkpinfo->backup_media_type),1963 bkpinfo->backup_media_string, 2000 1964 g_current_media_number); 2001 1965 tmp1 = slice_fname(bigfileno + 1, 0, ARCHIVES_PATH, ""); … … 2012 1976 ++g_current_media_number); 2013 1977 asprintf(&tmp, _("Restoring from %s #%d"), 2014 media_descriptor_string(bkpinfo-> 2015 backup_media_type), 1978 bkpinfo->backup_media_string, 2016 1979 g_current_media_number); 2017 1980 log_to_screen(tmp); … … 2124 2087 2125 2088 asprintf(&progress_str, _("Restoring from %s #%d"), 2126 media_descriptor_string(bkpinfo->backup_media_type),2089 bkpinfo->backup_media_string, 2127 2090 g_current_media_number); 2128 2091 log_to_screen(progress_str); … … 2174 2137 paranoid_free(progress_str); 2175 2138 asprintf(&progress_str, _("Restoring from %s #%d"), 2176 media_descriptor_string(bkpinfo->backup_media_type),2139 bkpinfo->backup_media_string, 2177 2140 g_current_media_number); 2178 2141 log_to_screen(progress_str); … … 2182 2145 _("Restoring from fileset #%ld on %s #%d"), 2183 2146 current_tarball_number, 2184 media_descriptor_string(bkpinfo->backup_media_type),2147 bkpinfo->backup_media_string, 2185 2148 g_current_media_number); 2186 2149 // log_msg(3, "progress_str = %s", progress_str); … … 2198 2161 } 2199 2162 asprintf(&tmp, _("%s #%d, fileset #%ld - restore %s"), 2200 media_descriptor_string(bkpinfo->backup_media_type),2163 bkpinfo->backup_media_string, 2201 2164 g_current_media_number, current_tarball_number,tmp1); 2202 2165 paranoid_free(tmp1); … … 2260 2223 char *xattr_fname = NULL; 2261 2224 char *acl_fname = NULL; 2262 char *p = NULL;2263 2225 char *pathname_of_last_biggie_restored = NULL; 2264 2226 char *biggies_whose_EXATs_we_should_set = NULL; // EXtended ATtributes 2265 long long biggie_size = NULL;2266 FILE *fbw = NULL;2227 long long biggie_size = (long long)0; 2228 FILE *fbw; 2267 2229 2268 2230 assert(bkpinfo != NULL); … … 2506 2468 asprintf(&progress_str, _("Restoring from fileset #%ld on %s #%d"), 2507 2469 current_afioball_number, 2508 media_descriptor_string(bkpinfo->backup_media_type),2470 bkpinfo->backup_media_string, 2509 2471 g_current_media_number); 2510 2472 res = … … 2735 2697 malloc_libmondo_global_strings(); 2736 2698 2737 g_mondo_home = call_program_and_get_last_line_of_output("which mondorestore") );2738 sprintf(g_tmpfs_mountpt, "/tmp/tmpfs");2699 g_mondo_home = call_program_and_get_last_line_of_output("which mondorestore"); 2700 paranoid_alloc(g_tmpfs_mountpt, "/tmp/tmpfs"); 2739 2701 make_hole_for_dir(g_tmpfs_mountpt); 2740 2702 g_current_media_number = 1; // precaution … … 2746 2708 reset_bkpinfo(bkpinfo); 2747 2709 bkpinfo->backup_media_type = none; // in case boot disk was made for one backup type but user wants to restore from another backup type 2710 bkpinfo->backup_media_string = NULL; 2748 2711 bkpinfo->restore_data = TRUE; // Well, yeah :-) 2749 2712 if (am_I_in_disaster_recovery_mode()) { … … 2757 2720 2758 2721 log_msg(1, "FYI - g_mountlist_fname = %s", g_mountlist_fname); 2759 if (strlen(g_mountlist_fname) < 3) {2760 fatal_error2761 ("Serious error in malloc()'ing. Could be a bug in your glibc.");2762 }2763 2722 mkdir(MNT_CDROM, 0x770); 2764 2723 … … 2812 2771 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME); 2813 2772 if (!does_file_exist(g_mountlist_fname)) { 2814 strcpy(g_mountlist_fname, "/tmp/mountlist.txt");2773 paranoid_alloc(g_mountlist_fname, "/tmp/mountlist.txt"); 2815 2774 } 2816 2775 res = let_user_edit_the_mountlist(bkpinfo, mountlist, raidlist); … … 2839 2798 bkpinfo->compression_level = 1; 2840 2799 g_current_media_number = 2; 2841 strcpy(bkpinfo->restore_path, "/tmp/TESTING");2800 paranoid_alloc(bkpinfo->restore_path, "/tmp/TESTING"); 2842 2801 bkpinfo->backup_media_type = dvd; 2802 paranoid_free(bkpinfo->backup_media_string); 2803 bkpinfo->backup_media_string = bkptype_to_string(bkpinfo->backup_media_type); 2843 2804 open_progress_form(_("Reassembling /dev/hda1"), 2844 2805 _("Shark is a bit of a silly person."), … … 2965 2926 2966 2927 iamhere("About to call load_mountlist and load_raidtab"); 2967 strcpy(bkpinfo->restore_path, MNT_RESTORING);2928 paranoid_alloc(bkpinfo->restore_path, MNT_RESTORING); 2968 2929 read_cfg_file_into_bkpinfo(g_mondo_cfg_file, bkpinfo); 2969 2930 retval = load_mountlist(mountlist, g_mountlist_fname); … … 2978 2939 && !is_this_device_mounted(bkpinfo->nfs_mount)) { 2979 2940 log_msg(1, "Mounting nfs dir"); 2980 sprintf(bkpinfo->isodir, "/tmp/isodir");2941 paranoid_alloc(bkpinfo->isodir, "/tmp/isodir"); 2981 2942 run_program_and_log_output("mkdir -p /tmp/isodir", 5); 2982 2943 asprintf(&tmp, "mount %s -t nfs -o nolock /tmp/isodir", … … 3000 2961 log_msg(0, "Partitioning only."); 3001 2962 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME); 3002 strcpy(g_mountlist_fname, "/tmp/mountlist.txt");2963 paranoid_alloc(g_mountlist_fname, "/tmp/mountlist.txt"); 3003 2964 load_mountlist(mountlist, g_mountlist_fname); 3004 2965 res = partition_everything(mountlist); … … 3009 2970 log_msg(0, "Formatting only."); 3010 2971 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME); 3011 strcpy(g_mountlist_fname, "/tmp/mountlist.txt");2972 paranoid_alloc(g_mountlist_fname, "/tmp/mountlist.txt"); 3012 2973 load_mountlist(mountlist, g_mountlist_fname); 3013 2974 res = format_everything(mountlist, FALSE, raidlist); … … 3018 2979 log_msg(0, "Stopping LVM and RAID"); 3019 2980 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME); 3020 strcpy(g_mountlist_fname, "/tmp/mountlist.txt");2981 paranoid_alloc(g_mountlist_fname, "/tmp/mountlist.txt"); 3021 2982 load_mountlist(mountlist, g_mountlist_fname); 3022 2983 res = do_my_funky_lvm_stuff(TRUE, FALSE);
Note:
See TracChangeset
for help on using the changeset viewer.