Changeset 2211 in MondoRescue for branches/2.2.9/mondo/src/mondorestore/mondorestore.c
- Timestamp:
- Jun 3, 2009, 7:10:19 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mondo/src/mondorestore/mondorestore.c
r2209 r2211 2 2 $Id$ 3 3 restores mondoarchive data 4 The main file for mondorestore. 4 5 ***************************************************************************/ 5 6 /**7 * @file8 * The main file for mondorestore.9 */10 6 11 7 /************************************************************************** … … 14 10 #include <pthread.h> 15 11 #include "my-stuff.h" 12 #include "mr_mem.h" 16 13 #include "../common/mondostructures.h" 17 14 #include "../common/libmondo.h" … … 364 361 365 362 /* Clean up blkid cache file if they exist */ 366 asprintf(&tmp1,"%s/etc/blkid.tab",bkpinfo->restore_path);363 mr_asprintf(&tmp1,"%s/etc/blkid.tab",bkpinfo->restore_path); 367 364 (void)unlink(tmp1); 368 365 paranoid_free(tmp1); 369 asprintf(&tmp1,"%s/etc/blkid.tab.old",bkpinfo->restore_path);366 mr_asprintf(&tmp1,"%s/etc/blkid.tab.old",bkpinfo->restore_path); 370 367 (void)unlink(tmp1); 371 368 paranoid_free(tmp1); … … 379 376 380 377 /* Clean up multiconf cache file if they exist */ 381 asprintf(&tmp1,"%s/var/lib/multipath/bindings",bkpinfo->restore_path);378 mr_asprintf(&tmp1,"%s/var/lib/multipath/bindings",bkpinfo->restore_path); 382 379 (void)unlink(tmp1); 383 380 paranoid_free(tmp1); 384 381 385 382 /* Edit multipath.conf if needed to adapt wwid */ 386 asprintf(&tmp1,"%s/etc/multipath.conf", MNT_RESTORING);383 mr_asprintf(&tmp1,"%s/etc/multipath.conf", MNT_RESTORING); 387 384 if (does_file_exist(tmp1)) { 388 385 log_msg(2, "We may need to clean /etc/multipath.conf"); … … 394 391 395 392 if (bkpinfo->restore_mode != nuke) { 396 asprintf(&editor, "%s", find_my_editor());397 asprintf(&tmp1,"chroot %s %s /etc/multipath.conf", MNT_RESTORING, editor);393 mr_asprintf(&editor, "%s", find_my_editor()); 394 mr_asprintf(&tmp1,"chroot %s %s /etc/multipath.conf", MNT_RESTORING, editor); 398 395 popup_and_OK("You will now edit multipath.conf"); 399 396 if (!g_text_mode) { … … 788 785 assert(raidlist != NULL); 789 786 790 asprintf(&tmpA, "%s", "xxxxxxxxx");791 asprintf(&tmpB, "%s", "xxxxxxxxx");792 asprintf(&tmpC, "%s", "xxxxxxxxx");787 mr_asprintf(&tmpA, "%s", " "); 788 mr_asprintf(&tmpB, "%s", " "); 789 mr_asprintf(&tmpC, "%s", " "); 793 790 794 791 log_msg(2, "nuke_mode --- starting"); … … 1671 1668 1672 1669 /** malloc **/ 1673 char *command ;1670 char *command = NULL; 1674 1671 char *tmp; 1675 1672 char *filelist_name; … … 1685 1682 1686 1683 assert_string_is_neither_NULL_nor_zerolength(tarball_fname); 1687 malloc_string(command);1688 1684 malloc_string(tmp); 1689 1685 malloc_string(filelist_name); … … 1698 1694 use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE; 1699 1695 // sprintf(files_to_restore_this_time_fname, "/tmp/ftrttf.%d.%d", (int)getpid(), (int)random()); 1700 sprintf(command, "mkdir -p %s/tmp", MNT_RESTORING);1696 mr_asprintf(&command, "mkdir -p %s/tmp", MNT_RESTORING); 1701 1697 run_program_and_log_output(command, 9); 1698 paranoid_free(command); 1699 1702 1700 sprintf(temp_log, "/tmp/%d.%d", (int) (random() % 32768), 1703 1701 (int) (random() % 32768)); … … 1783 1781 // if (strstr(tarball_fname, ".star.")) 1784 1782 if (use_star) { 1785 sprintf(command,1783 mr_asprintf(&command, 1786 1784 "star -x -force-remove -U " STAR_ACL_SZ 1787 1785 " errctl= file=%s", tarball_fname); 1788 1786 if (strstr(tarball_fname, ".bz2")) { 1789 strcat(command, " -bz");1787 mr_strcat(command, " -bz"); 1790 1788 } 1791 1789 } else { 1792 1790 if (filelist_subset_fname[0] != '\0') { 1793 sprintf(command,1791 mr_asprintf(&command, 1794 1792 "afio -i -M 8m -b %ld -c %ld %s -w '%s' %s", 1795 1793 TAPE_BLOCK_SIZE, … … 1798 1796 tarball_fname); 1799 1797 } else { 1800 sprintf(command,1798 mr_asprintf(&command, 1801 1799 "afio -i -b %ld -c %ld -M 8m %s %s", 1802 1800 TAPE_BLOCK_SIZE, … … 1804 1802 } 1805 1803 } 1804 1806 1805 #undef BUFSIZE 1807 sprintf(command + strlen(command), " 2>> %s >> %s", temp_log, 1808 temp_log); 1806 mr_strcat(command, " 2>> %s >> %s", temp_log, temp_log); 1809 1807 log_msg(1, "command = '%s'", command); 1810 1808 unlink(temp_log); … … 1818 1816 } 1819 1817 } 1818 paranoid_free(command); 1819 1820 1820 if (res && length_of_file(temp_log) < 5) { 1821 1821 res = 0; … … 1849 1849 } 1850 1850 if (retval) { 1851 sprintf(command, "cat %s >> %s", temp_log, MONDO_LOGFILE);1851 mr_asprintf(&command, "cat %s >> %s", temp_log, MONDO_LOGFILE); 1852 1852 system(command); 1853 paranoid_free(command); 1854 1853 1855 log_msg(2, "Errors occurred while processing fileset #%d", 1854 1856 current_tarball_number); … … 1867 1869 1868 1870 leave_sub: 1869 paranoid_free(command);1870 1871 paranoid_free(tmp); 1871 1872 paranoid_free(filelist_name); … … 2249 2250 long max_val; 2250 2251 /**malloc ***/ 2251 char *tmp; 2252 char *tmp = NULL; 2253 char *tmp1 = NULL; 2252 2254 char *tarball_fname; 2253 2255 char *progress_str; … … 2271 2273 read_cfg_var(g_mondo_cfg_file, "last-filelist-number", tmp); 2272 2274 max_val = atol(tmp) + 1; 2275 paranoid_free(tmp); 2276 2273 2277 sprintf(progress_str, "Restoring from %s #%d", 2274 2278 media_descriptor_string(bkpinfo->backup_media_type), … … 2334 2338 filelist); 2335 2339 } 2336 sprintf(tmp, "%s #%d, fileset #%ld - restore ",2340 mr_asprintf(&tmp1, "%s #%d, fileset #%ld - restore ", 2337 2341 media_descriptor_string(bkpinfo->backup_media_type), 2338 2342 g_current_media_number, current_tarball_number); 2339 2343 if (res) { 2340 strcat(tmp, "reported errors");2344 mr_strcat(tmp1, "reported errors"); 2341 2345 } else if (attempts > 1) { 2342 strcat(tmp, "succeeded");2346 mr_strcat(tmp1, "succeeded"); 2343 2347 } else { 2344 strcat(tmp, "succeeded");2348 mr_strcat(tmp1, "succeeded"); 2345 2349 } 2346 2350 if (attempts > 1) { 2347 sprintf(tmp + strlen(tmp), " (%d attempts) - review logs",2348 attempts);2349 }2350 strcpy(comment, tmp);2351 mr_strcat(tmp1, " (%d attempts) - review logs", attempts); 2352 } 2353 strcpy(comment, tmp1); 2354 paranoid_free(tmp1); 2351 2355 if (attempts > 1) { 2352 2356 log_to_screen(comment); … … 2364 2368 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 2365 2369 } 2366 paranoid_free(tmp);2367 2370 paranoid_free(tarball_fname); 2368 2371 paranoid_free(progress_str);
Note:
See TracChangeset
for help on using the changeset viewer.