Changeset 783 in MondoRescue for trunk/mondo/mondo/mondorestore
- Timestamp:
- Aug 31, 2006, 5:09:20 PM (18 years ago)
- Location:
- trunk/mondo/mondo/mondorestore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/mondo/mondorestore/Makefile.am
r426 r783 2 2 ## Process with Automake to generate Makefile.in 3 3 ## 4 5 AM_CPPFLAGS = -DMONDO_CONF_DIR=\"$(sysconfdir)\" -I${top_builddir}/mondo/include 4 6 5 7 ## Headers … … 12 14 mondorestore_SOURCES = mondo-prep.c mondo-restore.c mondo-rstr-newt.c \ 13 15 mondo-rstr-compare.c mondo-rstr-tools.c 14 mondorestore_LDADD = ${top_builddir}/mondo/common/libmondo.a @MONDORESTORE_STATIC@ 16 mondorestore_LDADD = ${top_builddir}/mondo/common/libmondo.a ${top_builddir}/mondo/lib/libmr.a @MONDORESTORE_STATIC@ 17 18 -
trunk/mondo/mondo/mondorestore/mondo-prep.c
r764 r783 9 9 10 10 11 #include " ../common/my-stuff.h"11 #include "my-stuff.h" 12 12 #include "../common/mondostructures.h" 13 13 #include "mondoprep.h" … … 53 53 char *command; 54 54 int lino; 55 int i;56 55 FILE *fout; 57 56 char *buf; 58 const int blocksize = 512;59 57 struct list_of_disks *drivelist = NULL; 60 58 // If LVMs are present and a zero-and-reboot wasn't recently undertaken 61 59 // then zero & insist on reboot. 62 buf = malloc(blocksize);63 60 if (does_file_exist("/tmp/i-want-my-lvm")) // FIXME - cheating :) 64 61 { … … 89 86 log_to_screen("Please hit 'Enter' to reboot."); 90 87 for (lino = 0; lino < drivelist->entries; lino++) { 91 for (i = 0; i < blocksize; i++) { 92 buf[i] = 0; 93 } 94 sprintf(buf, "%s\n", MONDO_WAS_HERE); 88 asprintf(&buf, "%s\n", MONDO_WAS_HERE); 95 89 fout = fopen(drivelist->el[lino].device, "w+"); 96 90 if (!fout) { … … 98 92 drivelist->el[lino].device); 99 93 } else { 100 if (1 != fwrite(buf, blocksize, 1, fout)) {94 if (1 != fwrite(buf, strlen(buf)+1, 1, fout)) { 101 95 log_msg(1, "Failed to wipe %s", 102 96 drivelist->el[lino].device); … … 107 101 fclose(fout); 108 102 } 103 paranoid_free(buf); 109 104 } 110 105 sync(); … … 257 252 for (getline(&incoming, &n1, fin); !feof(fin); getline(&incoming, &n1, fin)) { 258 253 fgetpos(fin, &orig_pos); 259 /* BERLIOS : Strange no ?*/254 /* we want to execute lines begining with a # */ 260 255 if (incoming[0] != '#') { 261 256 continue; … … 268 263 } 269 264 if ((p = strstr(incoming, "vgcreate"))) { 270 // include next line(s) if they end in /dev (cos we've got a broken i-want-my-lvm)265 // include next line(s) if they end in /dev (cos we've got a broken i-want-my-lvm) 271 266 for (getline(&tmp, &n, fin); !feof(fin); getline(&tmp, &n, fin)) { 272 267 if (tmp[0] == '#') { … … 287 282 } 288 283 } 289 malloc_string(tmp1); 290 strcpy(tmp1, p + strlen("vgcreate") + 1); 284 asprintf(&tmp1, p + strlen("vgcreate") + 1); 291 285 for (q = tmp1; *q > 32; q++); 292 286 *q = '\0'; … … 294 288 asprintf(&tmp, "rm -Rf /dev/%s", tmp1); 295 289 paranoid_free(tmp1); 290 296 291 run_program_and_log_output(tmp, 1); 297 292 paranoid_free(tmp); … … 304 299 } 305 300 for (p = incoming + 1; *p == ' '; p++); 306 paranoid_free(command); 307 asprintf(&command, p); 301 paranoid_alloc(command,p); 308 302 for (p = command; *p != '\0'; p++); 309 303 for (; *(p - 1) < 32; p--); 310 304 *p = '\0'; 305 306 /* BERLIOS: we should rather define LVMv1 or v2 and use it */ 311 307 res = run_program_and_log_output(command, 5); 312 308 if (res > 0 && (p = strstr(command, "lvm "))) { … … 338 334 log_msg(5, "p='%s' --> extents=%ld", p, extents); 339 335 paranoid_free(tmp); 336 340 337 p = strstr(command, "-L"); 341 338 if (!p) { … … 349 346 *q = ' '; 350 347 } 348 /* BERLIOS: Dangerous: no size control !! */ 351 349 sprintf(p, "%ld", extents); 352 350 i = strlen(p); … … 359 357 *(q - 1) = ' '; 360 358 } 359 /* BERLIOS: Dangerous: no size control !! */ 361 360 sprintf(p, "%ld%c", extents, 'm'); 362 361 i = strlen(p); … … 673 672 char *tmp = NULL; 674 673 char *tmp1 = NULL; 674 #ifdef __FreeBSD__ 675 675 char *line = NULL; 676 676 char *status = NULL; … … 679 679 size_t n = 0; 680 680 size_t n1 = 0; 681 #endif 681 682 682 683 /** end ****************************************************************/ … … 1525 1526 // If so, then we just call label_drive_or_slice() and return. 1526 1527 char c; 1528 char *command; 1529 1527 1530 if (current_devno == 1) { 1528 1531 // try DangerouslyDedicated mode … … 1538 1541 drivename, 1539 1542 0); 1540 char command[MAX_STR_LEN]; 1541 sprintf(command, "disklabel -B %s", 1543 asprintf(&command, "disklabel -B %s", 1542 1544 basename(drivename)); 1543 1545 if (system(command)) { … … 1546 1548 ("Warning! Unable to make the drive bootable.")); 1547 1549 } 1550 paranoid_free(command); 1548 1551 paranoid_free(device_str); 1549 1552 … … 2077 2080 asprintf(&partcode, "8e"); 2078 2081 } else if (format[0] == '\0') { /* LVM physical partition */ 2079 asprintf(&partcode, " ");2082 asprintf(&partcode, "%s", ""); 2080 2083 } else if (strlen(format) >= 1 && strlen(format) <= 2) { 2081 2084 asprintf(&partcode, format); … … 2375 2378 2376 2379 assert_string_is_neither_NULL_nor_zerolength(format); 2377 assert(program != NULL);2378 2380 2379 2381 if (strcmp(format, "swap") == 0) { 2380 2382 #ifdef __FreeBSD__ 2381 strcpy(program, "true");2383 asprintf(&program, "true"); 2382 2384 #else 2383 strcpy(program, "mkswap");2385 asprintf(&program, "mkswap"); 2384 2386 #endif 2385 2387 } else if (strcmp(format, "vfat") == 0) { 2386 strcpy(program, "format-and-kludge-vfat");2388 asprintf(&program, "format-and-kludge-vfat"); 2387 2389 #ifndef __FreeBSD__ 2388 2390 } else if (strcmp(format, "reiserfs") == 0) { 2389 strcpy(program, "mkreiserfs -ff");2391 asprintf(&program, "mkreiserfs -ff"); 2390 2392 } else if (strcmp(format, "xfs") == 0) { 2391 strcpy(program, "mkfs.xfs -f -q");2393 asprintf(&program, "mkfs.xfs -f -q"); 2392 2394 } else if (strcmp(format, "jfs") == 0) { 2393 strcpy(program, "mkfs.jfs");2395 asprintf(&program, "mkfs.jfs"); 2394 2396 } else if (strcmp(format, "ext3") == 0) { 2395 strcpy(program, "mkfs -t ext2 -F -j -q");2397 asprintf(&program, "mkfs -t ext2 -F -j -q"); 2396 2398 } else if (strcmp(format, "minix") == 0) { 2397 strcpy(program, "mkfs.minix");2399 asprintf(&program, "mkfs.minix"); 2398 2400 #endif 2399 2401 } else if (strcmp(format, "ext2") == 0) { 2400 strcpy(program, "mke2fs -F -q");2402 asprintf(&program, "mke2fs -F -q"); 2401 2403 } else { 2402 2404 #ifdef __FreeBSD__ 2403 sprintf(program, "newfs_%s", format);2405 asprintf(&program, "newfs_%s", format); 2404 2406 #else 2405 sprintf(program, "mkfs -t %s -c", format); // -c checks for bad blocks2407 asprintf(&program, "mkfs -t %s -c", format); // -c checks for bad blocks 2406 2408 #endif 2407 2409 asprintf(&tmp, "Unknown format (%s) - assuming '%s' will do", format, … … 2504 2506 } 2505 2507 2506 /*2507 sprintf (tmp, "cp -f %s %s.pre-resize", g_mountlist_fname, g_mountlist_fname);2508 run_program_and_log_output (tmp, FALSE);2509 */2510 2511 2508 current_size_of_drive = get_phys_size_of_drive(drive_name); 2512 2509 … … 2600 2597 assert(mountlist != NULL); 2601 2598 2602 if (g_mountlist_fname [0] == '\0') {2599 if (g_mountlist_fname == NULL) { 2603 2600 log_it 2604 2601 ("resize_mountlist_prop...() - warning - mountlist fname is blank"); … … 2648 2645 if (c && strncmp(c, "/disc", 5) == 0) { 2649 2646 /* yup its devfs, change the "disc" to "part" so the existing code works */ 2650 str cpy(c + 1, "part");2647 strncpy(c + 1, "part", (size_t)5); 2651 2648 } 2652 2649 drivemntlist->entries = 0; -
trunk/mondo/mondo/mondorestore/mondo-restore-EXT.h
r688 r783 10 10 extern bool g_ISO_restore_mode; /* are we in Iso Mode? */ 11 11 extern bool g_I_have_just_nuked; 12 extern char *g_tmpfs_mountpt;13 12 extern char *g_isodir_device; 14 13 extern char *g_isodir_format; … … 32 31 struct raidlist_itself *); 33 32 extern void sort_mountlist_by_device(struct mountlist_itself *); 34 extern void find_pathname_of_executable_preferably_in_RESTORING(char *,35 char *,36 char *);37 33 extern int interactive_mode(struct s_bkpinfo *, struct mountlist_itself *, 38 34 struct raidlist_itself *); … … 53 49 extern int restore_a_biggiefile_from_CD(struct s_bkpinfo *, long, 54 50 struct s_node *); 55 extern int restore_a_biggiefile_from_stream(struct s_bkpinfo *, char *, 56 long, char *, long long, 57 struct s_node *); 51 extern char *restore_a_biggiefile_from_stream(struct s_bkpinfo *, char *, 52 long, struct s_node *, int); 58 53 extern int restore_a_tarball_from_CD(char *, int, struct s_node *); 59 54 extern int restore_a_tarball_from_stream(struct s_bkpinfo *, char *, int, -
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); -
trunk/mondo/mondo/mondorestore/mondo-restore.h
r688 r783 10 10 int catchall_mode(struct s_bkpinfo *, struct mountlist_itself *, 11 11 struct raidlist_itself *); 12 void find_pathname_of_executable_preferably_in_RESTORING(char *, char *,13 char *);14 12 int interactive_mode(struct s_bkpinfo *, struct mountlist_itself *, 15 13 struct raidlist_itself *); … … 22 20 int restore_mode(struct s_bkpinfo *, struct mountlist_itself *, 23 21 struct raidlist_itself *); 24 int restore_a_biggiefile_from_stream(struct s_bkpinfo *, char *, long, 25 char *, long long, struct s_node *, 26 int, char *); 22 char *restore_a_biggiefile_from_stream(struct s_bkpinfo *, char *, long, 23 struct s_node *, int); 27 24 int restore_a_tarball_from_CD(char *, long, struct s_node *); 28 25 int restore_a_tarball_from_stream(struct s_bkpinfo *, char *, long, -
trunk/mondo/mondo/mondorestore/mondo-rstr-compare.c
r689 r783 4 4 5 5 6 #include " ../common/my-stuff.h"6 #include "my-stuff.h" 7 7 #include "../common/mondostructures.h" 8 8 #include "../common/libmondo.h" … … 44 44 char *p = NULL; 45 45 int i = 0; 46 int n = 0;46 size_t n = 0; 47 47 int retval = 0; 48 48 … … 258 258 } 259 259 paranoid_free(tmp); 260 260 261 if (use_star) { 261 262 if (strcmp(compressor_exe, "bzip2")) { … … 264 265 } 265 266 } else { 266 asprintf(&tmp, compressor_exe);267 sprintf(compressor_exe, "-P %s -Z", tmp);267 tmp = compressor_exe; 268 asprintf(&compressor_exe, "-P %s -Z", tmp); 268 269 paranoid_free(tmp); 269 270 } … … 299 300 log_OS_error(command); 300 301 } 302 paranoid_free(command); 303 301 304 if (length_of_file(logfile) > 5) { 302 sprintf(command,305 asprintf(&command, 303 306 "sed s/': \\\"'/\\|/ %s | sed s/'\\\": '/\\|/ | cut -d'|' -f2 | sort -u | grep -vx \"dev/.*\" >> /tmp/changed.txt", 304 307 logfile); 305 308 system(command); 309 paranoid_free(command); 306 310 archiver_errors = count_lines_in_file(logfile); 307 311 } else { 308 312 archiver_errors = 0; 309 313 } 310 paranoid_free(command);311 314 312 315 if (archiver_errors) { … … 353 356 354 357 asprintf(&progress_str, _("Comparing with %s #%d "), 355 media_descriptor_string(bkpinfo->backup_media_type),358 bkpinfo->backup_media_string, 356 359 g_current_media_number); 357 360 … … 402 405 paranoid_free(progress_str); 403 406 asprintf(&progress_str, _("Comparing with %s #%d "), 404 media_descriptor_string(bkpinfo->backup_media_type),407 bkpinfo->backup_media_string, 405 408 g_current_media_number); 406 409 log_to_screen(progress_str); -
trunk/mondo/mondo/mondorestore/mondo-rstr-newt.c
r764 r783 537 537 char *personalities = NULL; 538 538 char *prompt = NULL; 539 char *sz = NULL;540 539 int out = 0, res = 0; 541 540 … … 544 543 system 545 544 ("grep Pers /proc/mdstat > /tmp/raid-personalities.txt 2> /dev/null"); 546 personalities = last_line_of_file("/tmp/raid-personalities.txt") );545 personalities = last_line_of_file("/tmp/raid-personalities.txt"); 547 546 asprintf(&prompt, _("Please enter the RAID level you want. %s"), 548 547 personalities); … … 616 615 int i = 0; 617 616 int pos = 0; 618 619 /** buffers ***********************************************************/620 char *tmp = NULL;621 617 622 618 assert(mountlist != NULL); … … 858 854 popup_and_OK(tmp); 859 855 } else { 856 paranoid_free(av->el[lino].label); 857 paranoid_free(av->el[lino].value); 860 858 memcpy((void *) &av->el[lino], (void *) &av->el[av->entries--], 861 859 sizeof(struct raid_var_line)); 860 /* BERLIOS: New way of doing should be replaced by line below. Hope it's ok. 861 * Will be when memory for struct is also dynamically allocated 862 av->el[lino] = av->el[av->entries--]; 863 */ 862 864 } 863 865 } … … 1323 1325 device); 1324 1326 if (j < 0) { 1325 sprintf(tmp,1327 asprintf(&tmp, 1326 1328 _ 1327 1329 ("/etc/raidtab does not have an entry for %s; please delete it and add it again"), 1328 1330 mountlist->el[currline].device); 1329 1331 popup_and_OK(tmp); 1332 paranoid_free(tmp); 1330 1333 } else { 1331 1334 log_it(_("edit_raidlist_entry - calling")); … … 1499 1502 1500 1503 void *keylist[10]; 1501 void *curr_choice ;1504 void *curr_choice = NULL; 1502 1505 1503 1506 int currline2 = 0; … … 1971 1974 raidrec->additional_vars.el[lino].label, sz_out); 1972 1975 if (popup_and_get_string(header, comment, sz_out)) { 1973 strcpy(raidrec->additional_vars.el[lino].value, sz_out); 1976 paranoid_free(raidrec->additional_vars.el[lino].value); 1977 raidrec->additional_vars.el[lino].value = sz_out; 1974 1978 } 1975 1979 paranoid_free(header); 1976 1980 paranoid_free(comment); 1977 paranoid_free(sz_out);1978 1981 } 1979 1982 #endif … … 2015 2018 int currline = 0; 2016 2019 int finished = FALSE; 2020 int res = 0; 2017 2021 2018 2022 /** buffers **********************************************************/ … … 2025 2029 assert(raidlist != NULL); 2026 2030 2027 asprintf(&flaws_str_A, "xxxxxxxxx");2028 asprintf(&flaws_str_B, "xxxxxxxxx");2029 asprintf(&flaws_str_C, "xxxxxxxxx");2030 2031 if (mountlist->entries > ARBITRARY_MAXIMUM) { 2031 2032 log_to_screen(_("Arbitrary limits suck, man!")); … … 2045 2046 _("Format"), _("Size (MB)")); 2046 2047 headerMsg = newtLabel(2, 1, tmp); 2047 flawsLabelA = newtLabel(2, 13, flaws_str_A);2048 flawsLabelB = newtLabel(2, 14, flaws_str_B);2049 flawsLabelC = newtLabel(2, 15, flaws_str_C);2048 flawsLabelA = newtLabel(2, 13, "x"); 2049 flawsLabelB = newtLabel(2, 14, "x"); 2050 flawsLabelC = newtLabel(2, 15, "x"); 2050 2051 partitionsListbox = 2051 2052 newtListbox(2, 2, 10, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT); … … 2057 2058 bEdit, bDelete, bReload, bCancel, bOK, NULL); 2058 2059 while (!finished) { 2059 evaluate_mountlist(mountlist, flaws_str_A, flaws_str_B,2060 res = evaluate_mountlist(mountlist, flaws_str_A, flaws_str_B, 2060 2061 flaws_str_C); 2061 2062 newtLabelSetText(flawsLabelA, flaws_str_A); 2062 2063 newtLabelSetText(flawsLabelB, flaws_str_B); 2063 2064 newtLabelSetText(flawsLabelC, flaws_str_C); 2065 2066 paranoid_free(flaws_str_A); 2067 paranoid_free(flaws_str_B); 2068 paranoid_free(flaws_str_C); 2069 2064 2070 b_res = newtRunForm(myForm); 2065 2071 /* BERLIOS: This needs to be re-written */ 2066 2072 if (b_res == bOK) { 2067 if (!evaluate_mountlist 2068 (mountlist, flaws_str_A, flaws_str_B, flaws_str_C)) { 2073 if (!res) { 2069 2074 finished = 2070 2075 ask_me_yes_or_no … … 2113 2118 } 2114 2119 } 2115 paranoid_free(flaws_str_A);2116 paranoid_free(flaws_str_B);2117 paranoid_free(flaws_str_C);2118 2120 } 2119 2121 newtFormDestroy(myForm); … … 2413 2415 raidrec = &raidlist->el[pos_in_raidlist]; 2414 2416 initialize_raidrec(raidrec); 2415 strcpy(raidrec->OSSWAP(raid_device, volname),2417 asprintf(&raidrec->OSSWAP(raid_device, volname), 2416 2418 OSSWAP(device, basename(device))); 2417 2419 #ifndef __FreeBSD__ … … 2647 2649 (void *) &raidrec->additional_vars.el[i], 2648 2650 sizeof(struct raid_var_line)); 2651 /* BERLIOS : To be changed */ 2649 2652 } 2650 2653 raidrec->additional_vars.entries--; -
trunk/mondo/mondo/mondorestore/mondo-rstr-newt.h
r688 r783 3 3 **/ 4 4 5 #include " ../common/my-stuff.h"5 #include "my-stuff.h" 6 6 #include "../common/mondostructures.h" 7 7 #include "../common/libmondo.h" -
trunk/mondo/mondo/mondorestore/mondo-rstr-tools.c
r764 r783 5 5 #include <unistd.h> 6 6 7 #include " ../common/my-stuff.h"7 #include "my-stuff.h" 8 8 #include "../common/mondostructures.h" 9 9 #include "../common/libmondo.h" … … 39 39 40 40 extern t_bkptype g_backup_media_type; 41 extern char *g_backup_media_string; 41 42 42 43 extern int g_partition_table_locked_up; … … 290 291 assert(bkpinfo != NULL); 291 292 g_ISO_restore_mode = TRUE; 293 294 paranoid_free(g_isodir_device); 292 295 read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device); 293 296 if (bkpinfo->disaster_recovery) { 294 297 /* Patch Conor Daly 26-june-2004 295 298 * Don't let this clobber an existing bkpinfo->isodir */ 296 if (!bkpinfo->isodir [0]) {297 strcpy(bkpinfo->isodir, "/tmp/isodir");299 if (!bkpinfo->isodir) { 300 paranoid_alloc(bkpinfo->isodir, "/tmp/isodir"); 298 301 } 299 302 /* End patch */ … … 344 347 i = what_number_cd_is_this(bkpinfo); /* has the side-effect of calling mount_cdrom() */ 345 348 asprintf(&tmp, "%s #%d has been mounted via loopback mount", 346 media_descriptor_string(bkpinfo->backup_media_type), i);349 bkpinfo->backup_media_string, i); 347 350 log_msg(1, tmp); 348 351 paranoid_free(tmp); … … 497 500 { 498 501 char *mount_cmd = NULL; 499 char *tmp = NULL;500 502 int i, res; 501 503 #ifdef __FreeBSD__ … … 519 521 log_msg(2, "Mounting for NFS thingy"); 520 522 log_msg(2, "isodir = %s", bkpinfo->isodir); 521 if ((!bkpinfo->isodir [0]|| !strcmp(bkpinfo->isodir, "/"))523 if ((!bkpinfo->isodir || !strcmp(bkpinfo->isodir, "/")) 522 524 && am_I_in_disaster_recovery_mode()) { 523 strcpy(bkpinfo->isodir, "/tmp/isodir");525 paranoid_alloc(bkpinfo->isodir, "/tmp/isodir"); 524 526 log_msg(1, "isodir is being set to %s", bkpinfo->isodir); 525 527 } … … 663 665 asprintf(&p2, ",user_xattr"); 664 666 } else { 665 asprintf(&p2, " ");667 asprintf(&p2, "%s", ""); 666 668 } 667 669 paranoid_free(tmp); … … 671 673 asprintf(&p3, ",acl"); 672 674 } else { 673 asprintf(&p3, " ");675 asprintf(&p3, "%s", ""); 674 676 } 675 677 paranoid_free(tmp); … … 789 791 char *value = NULL; 790 792 char *tmp = NULL; 793 char *tmp1 = NULL; 791 794 char *command = NULL; 792 795 char *iso_mnt = NULL; … … 836 839 837 840 if (read_cfg_var(cfg_file, "iso-prefix", value) == 0) { 838 paranoid_free(bkpinfo->prefix); 839 bkpinfo->prefix = value; 841 paranoid_alloc(bkpinfo->prefix,value); 840 842 } else { 841 843 paranoid_alloc(bkpinfo->prefix, STD_PREFIX); … … 845 847 paranoid_free(value); 846 848 if (read_cfg_var(cfg_file, "iso-prefix", value) == 0) { 847 paranoid_free(bkpinfo->prefix); 848 bkpinfo->prefix = value; 849 paranoid_alloc(bkpinfo->prefix,value); 849 850 } else { 850 851 paranoid_alloc(bkpinfo->prefix, STD_PREFIX); … … 869 870 } else if (bkpinfo->backup_media_type == tape 870 871 || bkpinfo->backup_media_type == udev) { 872 paranoid_free(bkpinfo->media_device); 871 873 if (read_cfg_var(cfg_file, "media-dev", bkpinfo->media_device)) { 872 874 fatal_error("Cannot get tape device name from cfg file"); … … 964 966 "...cos it wouldn't make sense to abandon the values that GOT ME to this config file in the first place"); 965 967 } else { 968 paranoid_free(bkpinfo->nfs_mount); 969 paranoid_free(bkpinfo->nfs_remote_dir); 966 970 read_cfg_var(g_mondo_cfg_file, "nfs-server-mount", 967 971 bkpinfo->nfs_mount); … … 976 980 * isodir in disaster recovery mode 977 981 */ 978 old_isodir = bkpinfo->isodir;982 paranoid_alloc(old_isodir,bkpinfo->isodir); 979 983 read_cfg_var(g_mondo_cfg_file, "iso-mnt", iso_mnt); 980 984 read_cfg_var(g_mondo_cfg_file, "isodir", iso_path); 981 985 if (iso_mnt && iso_path) { 986 paranoid_free(bkpinfo->isodir); 982 987 asprintf(&bkpinfo->isodir, "%s%s", iso_mnt, iso_path); 983 } else {984 bkpinfo->isodir = old_isodir;985 988 } 986 989 paranoid_free(iso_mnt); … … 992 995 ("user nominated isodir differs from archive, keeping user's choice: %s %s\n", 993 996 old_isodir, bkpinfo->isodir); 994 if (bkpinfo->isodir != old_isodir) { 995 paranoid_free(old_isodir); 996 } 997 } else { 998 paranoid_free(old_isodir); 999 } 1000 } 1001 997 } 998 } 999 paranoid_free(old_isodir); 1000 1001 paranoid_free(g_isodir_device); 1002 1002 read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device); 1003 1003 log_msg(2, "isodir=%s; iso-dev=%s", bkpinfo->isodir, g_isodir_device); … … 1029 1029 paranoid_free(iso_mnt); 1030 1030 paranoid_free(iso_path); 1031 asprintf(&iso_mnt, " ");1032 asprintf(&iso_path, " ");1031 asprintf(&iso_mnt, "%s", ""); 1032 asprintf(&iso_path, "%s", ""); 1033 1033 1034 1034 if (mount_cdrom(bkpinfo)) { … … 1069 1069 } 1070 1070 g_backup_media_type = bkpinfo->backup_media_type; 1071 bkpinfo->backup_media_string = bkptype_to_string(bkpinfo->backup_media_type); 1072 g_backup_media_string = bkpinfo->backup_media_string; 1071 1073 return (0); 1072 1074 } … … 1823 1825 assert(bkpinfo != NULL); 1824 1826 1825 malloc_string(g_tmpfs_mountpt);1826 1827 1827 asprintf(&g_biggielist_txt, "%s/%s",bkpinfo->tmpdir , BIGGIELIST_TXT_STUB); 1828 1828 asprintf(&g_filelist_full, "%s/%s", bkpinfo->tmpdir, FILELIST_FULL_STUB); … … 1830 1830 asprintf(&g_imagedevs_restthese, "%s/tmp/imagedevs.restore-these", 1831 1831 bkpinfo->tmpdir); 1832 paranoid_free(g_mondo_cfg_file); 1833 paranoid_free(g_mountlist_fname); 1832 1834 if (bkpinfo->disaster_recovery) { 1833 1835 asprintf(&g_mondo_cfg_file, "/%s", MONDO_CFG_FILE_STUB); … … 2110 2112 { 2111 2113 int retval = 0; 2112 char *device = NULL;2113 2114 char *command = NULL; 2114 2115 char *cfg_file = NULL; … … 2364 2365 2365 2366 g_backup_media_type = bkpinfo->backup_media_type; 2367 bkpinfo->backup_media_string = bkptype_to_string(bkpinfo->backup_media_type); 2368 g_backup_media_string = bkpinfo->backup_media_string; 2366 2369 return (retval); 2367 2370 }
Note:
See TracChangeset
for help on using the changeset viewer.