Changeset 2211 in MondoRescue
- Timestamp:
- Jun 3, 2009, 7:10:19 PM (16 years ago)
- Location:
- branches/2.2.9/mondo
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mondo/src/common/libmondo-archive.c
r2202 r2211 12 12 13 13 #include "my-stuff.h" 14 #include "mr_mem.h" 14 15 #include "mondostructures.h" 15 16 #include "libmondo-string-EXT.h" … … 192 193 unsigned int res = 0; 193 194 int tries = 0; 194 char *command; 195 char *zipparams; 196 char *tmp; 195 char *command = NULL; 196 char *tmp = NULL; 197 197 char *p; 198 198 199 malloc_string(command);200 malloc_string(zipparams);201 malloc_string(tmp);202 199 203 200 if (!does_file_exist(filelist)) { 204 sprintf(tmp, "(archive_this_fileset) - filelist %s does not exist", 205 filelist); 201 mr_asprintf(&tmp, "(archive_this_fileset) - filelist %s does not exist", filelist); 206 202 log_to_screen(tmp); 203 paranoid_free(tmp); 207 204 return (1); 208 205 } 209 206 210 sprintf(tmp, "echo hi > %s 2> /dev/null", fname);207 mr_asprintf(&tmp, "echo hi > %s 2> /dev/null", fname); 211 208 if (system(tmp)) { 209 paranoid_free(tmp); 212 210 fatal_error("Unable to write tarball to scratchdir"); 213 211 } 214 215 sprintf(command, "star H=star list=%s -c " STAR_ACL_SZ " file=%s", 212 paranoid_free(tmp); 213 214 mr_asprintf(&command, "star H=star list=%s -c " STAR_ACL_SZ " file=%s", 216 215 filelist, fname); 217 216 if (bkpinfo->use_lzo) { … … 219 218 } 220 219 if (bkpinfo->compression_level > 0) { 221 strcat(command, " -bz");222 } 223 sprintf(command + strlen(command), " 2>> %s", MONDO_LOGFILE);220 mr_strcat(command, " -bz"); 221 } 222 mr_strcat(command, " 2>> %s", MONDO_LOGFILE); 224 223 log_msg(4, "command = '%s'", command); 225 224 … … 227 226 log_msg(5, "command='%s'", command); 228 227 res = system(command); 229 strcpy(tmp, last_line_of_file(MONDO_LOGFILE));228 mr_asprintf(&tmp, last_line_of_file(MONDO_LOGFILE)); 230 229 log_msg(1, "res=%d; tmp='%s'", res, tmp); 231 230 if (bkpinfo->use_star && (res == 254 || res == 65024) … … 235 234 res = 0; 236 235 } 236 paranoid_free(tmp); 237 237 238 if (res) { 238 239 log_OS_error(command); … … 249 250 } 250 251 } 252 paranoid_free(command); 253 251 254 retval += res; 252 255 if (retval) { … … 256 259 tries); 257 260 } 258 259 paranoid_free(command);260 paranoid_free(zipparams);261 paranoid_free(tmp);262 261 return (retval); 263 262 } … … 294 293 295 294 /*@ buffers ************************************************************ */ 296 char *command ;297 char *zipparams ;298 char *tmp ;295 char *command = NULL; 296 char *zipparams = NULL; 297 char *tmp = NULL; 299 298 300 299 assert(bkpinfo != NULL); … … 306 305 } 307 306 308 malloc_string(command);309 malloc_string(zipparams);310 malloc_string(tmp);311 312 307 if (!does_file_exist(filelist)) { 313 sprintf(tmp, "(archive_this_fileset) - filelist %s does not exist",308 mr_asprintf(&tmp, "(archive_this_fileset) - filelist %s does not exist", 314 309 filelist); 315 310 log_to_screen(tmp); 311 paranoid_free(tmp); 316 312 return (1); 317 313 } 318 sprintf(tmp, "echo hi > %s 2> /dev/null", fname);314 mr_asprintf(&tmp, "echo hi > %s 2> /dev/null", fname); 319 315 if (system(tmp)) { 316 paranoid_free(tmp); 320 317 fatal_error("Unable to write tarball to scratchdir"); 321 318 } 319 paranoid_free(tmp); 322 320 323 321 324 322 if (bkpinfo->compression_level > 0) { 325 sprintf(tmp, "%s/do-not-compress-these", g_mondo_home);323 mr_asprintf(&tmp, "%s/do-not-compress-these", g_mondo_home); 326 324 // -b %ld, TAPE_BLOCK_SIZE 327 sprintf(zipparams, "-Z -P %s -G %d -T 3k", bkpinfo->zip_exe,325 mr_asprintf(&zipparams, "-Z -P %s -G %d -T 3k", bkpinfo->zip_exe, 328 326 bkpinfo->compression_level); 329 327 if (does_file_exist(tmp)) { 330 strcat(zipparams, " -E "); 331 strcat(zipparams, tmp); 328 mr_strcat(zipparams, " -E %s",tmp); 332 329 } else { 333 330 log_msg(3, "%s not found. Cannot exclude zipfiles, etc.", tmp); 334 331 } 332 paranoid_free(tmp); 335 333 } else { 336 zipparams[0] = '\0';334 mr_asprintf(&zipparams, ""); 337 335 } 338 336 … … 347 345 fatal_error("scratchdir not found"); 348 346 } 349 sprintf(command, "rm -f %s %s. %s.gz %s.%s", fname, fname, fname,347 mr_asprintf(&command, "rm -f %s %s. %s.gz %s.%s", fname, fname, fname, 350 348 fname, bkpinfo->zip_suffix); 351 349 paranoid_system(command); 352 353 sprintf(command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s", 350 paranoid_free(command); 351 352 mr_asprintf(&command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s", 354 353 TAPE_BLOCK_SIZE, zipparams, fname, filelist, MONDO_LOGFILE); 355 356 sprintf(tmp, "echo hi > %s 2> /dev/null", fname); 354 paranoid_free(zipparams); 355 356 mr_asprintf(&tmp, "echo hi > %s 2> /dev/null", fname); 357 357 if (system(tmp)) { 358 paranoid_free(tmp); 358 359 fatal_error("Unable to write tarball to scratchdir"); 359 360 } 361 paranoid_free(tmp); 360 362 361 363 for (res = 99, tries = 0; tries < 3 && res != 0; tries++) { … … 370 372 } 371 373 } 374 paranoid_free(command); 375 372 376 retval += res; 373 377 if (retval) { … … 378 382 } 379 383 380 paranoid_free(command);381 paranoid_free(zipparams);382 paranoid_free(tmp);383 384 return (retval); 384 385 } … … 511 512 char *tmp2 = NULL; 512 513 char *scratchdir; 513 char *command ;514 char *command = NULL; 514 515 char *use_lzo_sz; 515 516 char *use_gzip_sz; … … 541 542 542 543 assert(bkpinfo != NULL); 543 command = malloc(1200);544 544 tmp = malloc(9*MAX_STR_LEN); 545 545 malloc_string(scratchdir); … … 803 803 } 804 804 if (bkpinfo->backup_media_type == usb) { 805 (void)asprintf(&tmp2, "--usb %s", bkpinfo->media_device);805 mr_asprintf(&tmp2, "--usb %s", bkpinfo->media_device); 806 806 } else { 807 (void)asprintf(&tmp2," ");807 mr_asprintf(&tmp2," "); 808 808 } 809 809 … … 828 828 829 829 if (g_getfattr) { 830 (void)asprintf(&tmp1, "%s/XATTR", bkpinfo->tmpdir);830 mr_asprintf(&tmp1, "%s/XATTR", bkpinfo->tmpdir); 831 831 if (write_one_liner_data_file(tmp1, "TRUE")) { 832 832 log_msg(1, "%ld: Unable to write one-liner XATTR", … … 836 836 } 837 837 if (g_getfacl) { 838 (void)asprintf(&tmp1, "%s/ACL", bkpinfo->tmpdir);838 mr_asprintf(&tmp1, "%s/ACL", bkpinfo->tmpdir); 839 839 if (write_one_liner_data_file(tmp1, "TRUE")) { 840 840 log_msg(1, "%ld: Unable to write one-liner ACL", … … 844 844 } 845 845 if (bkpinfo->use_obdr) { 846 (void)asprintf(&tmp1, "%s/OBDR", bkpinfo->tmpdir);846 mr_asprintf(&tmp1, "%s/OBDR", bkpinfo->tmpdir); 847 847 if (write_one_liner_data_file(tmp1, "TRUE")) { 848 848 log_msg(1, "%ld: Unable to write one-liner OBDR", … … 855 855 size_of_all_biggiefiles_K(bkpinfo) / bkpinfo->optimal_set_size + 1; 856 856 /* add nfs stuff here? */ 857 sprintf(command, "mkdir -p %s/images", bkpinfo->scratchdir);857 mr_asprintf(&command, "mkdir -p %s/images", bkpinfo->scratchdir); 858 858 if (system(command)) { 859 859 res++; 860 860 log_OS_error("Unable to make images directory"); 861 861 } 862 paranoid_free(command); 862 863 sprintf(tmp, "BTW, I'm telling Mindi your kernel is '%s'", 863 864 bkpinfo->kernel_path); … … 865 866 log_msg(1, "lines_in_filelist = %ld", lines_in_filelist); 866 867 867 sprintf(command,868 mr_asprintf(&command, 868 869 /* "mindi --custom 2=%s 3=%s/images 4=\"%s\" 5=\"%s\" \ 869 870 6=\"%s\" 7=%ld 8=\"%s\" 9=\"%s\" 10=\"%s\" \ … … 891 892 use_gzip_sz); // parameter #20 (STRING) 892 893 893 // Watch it! This next line adds a parameter...894 894 if (bkpinfo->nonbootable_backup) { 895 strcat(command, " NONBOOTABLE");895 mr_strcat(command, " NONBOOTABLE"); 896 896 } 897 897 log_msg(2, command); … … 899 899 // popup_and_OK("Pausing"); 900 900 901 res = 902 run_program_and_log_to_screen(command,903 "Generating boot+data disks"); 901 res = run_program_and_log_to_screen(command, "Generating boot+data disks"); 902 paranoid_free(command); 903 904 904 if (bkpinfo->nonbootable_backup) { 905 905 res = 0; … … 907 907 if (!res) { 908 908 log_to_screen("Boot+data disks were created OK"); 909 sprintf(command, "cp -f %s/images/mindi.iso %s/mondorescue.iso",909 mr_asprintf(&command, "cp -f %s/images/mindi.iso %s/mondorescue.iso", 910 910 bkpinfo->scratchdir, MINDI_CACHE); 911 911 log_msg(2, command); 912 912 run_program_and_log_output(command, FALSE); 913 paranoid_free(command); 914 913 915 if (bkpinfo->nonbootable_backup) { 914 sprintf(command, "cp -f %s/all.tar.gz %s/images",916 mr_asprintf(&command, "cp -f %s/all.tar.gz %s/images", 915 917 bkpinfo->tmpdir, bkpinfo->scratchdir); 916 918 if (system(command)) { 919 paranoid_free(command); 917 920 fatal_error("Unable to create temporary all tarball"); 918 921 } 922 paranoid_free(command); 919 923 } 920 924 /* For USB we already have everything on the key */ 921 925 if (bkpinfo->backup_media_type == usb) { 922 sprintf(command, "rm -rf %s/images", bkpinfo->scratchdir);926 mr_asprintf(&command, "rm -rf %s/images", bkpinfo->scratchdir); 923 927 run_program_and_log_output(command, FALSE); 928 paranoid_free(command); 924 929 } else { 925 930 sprintf(tmp, "cp -f %s/images/all.tar.gz %s", bkpinfo->scratchdir, … … 936 941 } else { 937 942 log_to_screen("Mindi failed to create your boot+data disks."); 938 strcpy(command, "grep 'Fatal error' /var/log/mindi.log");943 mr_asprintf(&command, "grep 'Fatal error' /var/log/mindi.log"); 939 944 strcpy(tmp, call_program_and_get_last_line_of_output(command)); 945 paranoid_free(command); 946 940 947 if (strlen(tmp) > 1) { 941 948 popup_and_OK(tmp); … … 957 964 paranoid_free(value); 958 965 paranoid_free(bootdev); 959 paranoid_free(command);960 966 paranoid_free(use_star_sz); 961 967 return (res); … … 1345 1351 char *storing_filelist_fname; 1346 1352 char *storing_afioball_fname; 1347 char *tmp ;1353 char *tmp = NULL; 1348 1354 char *media_usage_comment; 1349 1355 pthread_t archival_thread[ARCH_THREADS]; … … 1360 1366 log_msg(8, "here"); 1361 1367 assert(bkpinfo != NULL); 1362 tmp = malloc(MAX_STR_LEN * 2);1363 1368 malloc_string(result_str); 1364 1369 malloc_string(curr_xattr_list_fname); … … 1382 1387 *p_last_set_archived = -1; 1383 1388 *p_next_set_to_archive = 0; 1384 sprintf(tmp, "%s/archives/filelist.full", bkpinfo->scratchdir);1385 1389 log_to_screen("Archiving regular files"); 1386 1390 log_msg(5, "Go, Shorty. It's your birthday."); … … 1500 1504 update_progress_form(media_usage_comment); 1501 1505 if (res) { 1502 sprintf(tmp,1506 mr_asprintf(&tmp, 1503 1507 "Failed to add archive %ld's files to CD dir\n", 1504 1508 storing_set_no); 1505 1509 log_to_screen(tmp); 1510 paranoid_free(tmp); 1506 1511 fatal_error 1507 1512 ("Is your hard disk full? If not, please send the author the logfile."); … … 1513 1518 close_progress_form(); 1514 1519 1515 sprintf(tmp, "Your regular files have been archived ");1520 mr_asprintf(&tmp, "Your regular files have been archived "); 1516 1521 log_msg(2, "Joining background threads to foreground thread"); 1517 1522 for (i = 0; i < noof_threads; i++) { … … 1522 1527 log_msg(2, "Done."); 1523 1528 if (retval) { 1524 strcat(tmp, "(with errors).");1529 mr_strcat(tmp, "(with errors)."); 1525 1530 } else { 1526 strcat(tmp, "successfully.");1531 mr_strcat(tmp, "successfully."); 1527 1532 } 1528 1533 log_to_screen(tmp); 1534 paranoid_free(tmp); 1535 1529 1536 paranoid_free(transfer_block); 1530 1537 paranoid_free(result_str); … … 1581 1588 log_msg(2, "make_usb_fs --- scratchdir=%s", bkpinfo->scratchdir); 1582 1589 (void) getcwd(old_pwd, MAX_STR_LEN - 1); 1583 (void)asprintf(&tmp, "chmod 755 %s", bkpinfo->scratchdir);1590 mr_asprintf(&tmp, "chmod 755 %s", bkpinfo->scratchdir); 1584 1591 run_program_and_log_output(tmp, FALSE); 1585 1592 paranoid_free(tmp); 1586 1593 (void)chdir(bkpinfo->scratchdir); 1587 1594 1588 (void)asprintf(&message_to_screen, "Copying data to make %s #%d",1595 mr_asprintf(&message_to_screen, "Copying data to make %s #%d", 1589 1596 media_descriptor_string(bkpinfo->backup_media_type), 1590 1597 g_current_media_number); 1591 1598 log_msg(1, message_to_screen); 1592 1599 1593 (void)asprintf(&tmp1, "%s1", bkpinfo->media_device);1600 mr_asprintf(&tmp1, "%s1", bkpinfo->media_device); 1594 1601 if (is_this_device_mounted(tmp1)) { 1595 1602 log_msg(1, "USB device mounted. Remounting it at the right place"); 1596 (void)asprintf(&tmp, "umount %s", tmp1);1603 mr_asprintf(&tmp, "umount %s", tmp1); 1597 1604 run_program_and_log_output(tmp, FALSE); 1598 1605 paranoid_free(tmp); … … 1601 1608 1602 1609 log_msg(1, "Mounting USB device."); 1603 (void)asprintf(&tmp1, "%s/usb", bkpinfo->tmpdir);1604 (void)asprintf(&tmp, "mkdir -p %s", tmp1);1610 mr_asprintf(&tmp1, "%s/usb", bkpinfo->tmpdir); 1611 mr_asprintf(&tmp, "mkdir -p %s", tmp1); 1605 1612 run_program_and_log_output(tmp, FALSE); 1606 1613 paranoid_free(tmp); 1607 1614 /* Mindi always create one single parition on the USB dev */ 1608 (void)asprintf(&tmp, "mount %s1 %s", bkpinfo->media_device, tmp1);1615 mr_asprintf(&tmp, "mount %s1 %s", bkpinfo->media_device, tmp1); 1609 1616 run_program_and_log_output(tmp, FALSE); 1610 1617 paranoid_free(tmp); … … 1616 1623 1617 1624 /* Command to execute */ 1618 (void)asprintf(&tmp,"mv %s/* %s", bkpinfo->scratchdir, tmp1);1625 mr_asprintf(&tmp,"mv %s/* %s", bkpinfo->scratchdir, tmp1); 1619 1626 res = eval_call_to_make_USB(tmp, message_to_screen); 1620 1627 if (res) { 1621 (void)asprintf(&result_sz, "%s ...failed",tmp);1628 mr_asprintf(&result_sz, "%s ...failed",tmp); 1622 1629 } else { 1623 (void)asprintf(&result_sz, "%s ...OK",tmp);1630 mr_asprintf(&result_sz, "%s ...OK",tmp); 1624 1631 } 1625 1632 log_to_screen(result_sz); … … 1632 1639 1633 1640 if (is_this_device_mounted(bkpinfo->media_device)) { 1634 (void)asprintf(&tmp, "umount %s1", bkpinfo->media_device);1641 mr_asprintf(&tmp, "umount %s1", bkpinfo->media_device); 1635 1642 run_program_and_log_output(tmp, FALSE); 1636 1643 paranoid_free(tmp); … … 1672 1679 char *tmp; 1673 1680 char *old_pwd; 1674 char *result_sz ;1675 char *message_to_screen ;1681 char *result_sz = NULL; 1682 char *message_to_screen = NULL; 1676 1683 char *sz_blank_disk; 1677 1684 char *fnam; … … 1681 1688 1682 1689 malloc_string(old_pwd); 1683 malloc_string(result_sz);1684 malloc_string(message_to_screen);1685 1690 malloc_string(sz_blank_disk); 1686 1691 malloc_string(fnam); … … 1717 1722 1718 1723 if (bkpinfo->call_before_iso[0] != '\0') { 1719 sprintf(message_to_screen, "Running pre-ISO call for CD#%d",1724 mr_asprintf(&message_to_screen, "Running pre-ISO call for CD#%d", 1720 1725 g_current_media_number); 1721 1726 res = … … 1724 1729 MONDO_LOGFILE, message_to_screen); 1725 1730 if (res) { 1726 strcat(message_to_screen, "...failed");1731 mr_strcat(message_to_screen, "...failed"); 1727 1732 } else { 1728 strcat(message_to_screen, "...OK");1733 mr_strcat(message_to_screen, "...OK"); 1729 1734 } 1730 1735 log_to_screen(message_to_screen); 1736 paranoid_free(message_to_screen); 1737 1731 1738 retval += res; 1732 1739 } … … 1735 1742 log_msg(2, "bkpinfo->call_make_iso = %s", bkpinfo->call_make_iso); 1736 1743 sprintf(tmp, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir); 1737 sprintf(message_to_screen, "Making an ISO (%s #%d)",1744 mr_asprintf(&message_to_screen, "Making an ISO (%s #%d)", 1738 1745 media_descriptor_string(bkpinfo->backup_media_type), 1739 1746 g_current_media_number); … … 1830 1837 } 1831 1838 } 1839 paranoid_free(message_to_screen); 1832 1840 } else { 1833 sprintf(message_to_screen, "Running mkisofs to make %s #%d",1841 mr_asprintf(&message_to_screen, "Running mkisofs to make %s #%d", 1834 1842 media_descriptor_string(bkpinfo->backup_media_type), 1835 1843 g_current_media_number); 1836 1844 log_msg(1, message_to_screen); 1837 sprintf(result_sz, "Call to mkisofs to make ISO (%s #%d) ",1845 mr_asprintf(&result_sz, "Call to mkisofs to make ISO (%s #%d) ", 1838 1846 media_descriptor_string(bkpinfo->backup_media_type), 1839 1847 g_current_media_number); … … 1888 1896 } 1889 1897 } 1898 paranoid_free(message_to_screen); 1899 1890 1900 if (res) { 1891 strcat(result_sz, "...failed");1901 mr_strcat(result_sz, "...failed"); 1892 1902 } else { 1893 strcat(result_sz, "...OK");1903 mr_strcat(result_sz, "...OK"); 1894 1904 } 1895 1905 log_to_screen(result_sz); 1906 paranoid_free(result_sz); 1896 1907 retval += res; 1897 1908 } … … 1910 1921 if (bkpinfo->call_burn_iso[0] != '\0') { 1911 1922 log_msg(2, "bkpinfo->call_burn_iso = %s", bkpinfo->call_burn_iso); 1912 sprintf(message_to_screen, "Burning %s #%d",1923 mr_asprintf(&message_to_screen, "Burning %s #%d", 1913 1924 media_descriptor_string(bkpinfo->backup_media_type), 1914 1925 g_current_media_number); … … 1919 1930 MONDO_LOGFILE, message_to_screen); 1920 1931 if (res) { 1921 strcat(message_to_screen, "...failed");1932 mr_strcat(message_to_screen, "...failed"); 1922 1933 } else { 1923 strcat(message_to_screen, "...OK");1934 mr_strcat(message_to_screen, "...OK"); 1924 1935 } 1925 1936 log_to_screen(message_to_screen); 1937 paranoid_free(message_to_screen); 1938 1926 1939 retval += res; 1927 1940 } 1928 1941 1929 1942 if (bkpinfo->call_after_iso[0] != '\0') { 1930 sprintf(message_to_screen, "Running post-ISO call (%s #%d)",1943 mr_asprintf(&message_to_screen, "Running post-ISO call (%s #%d)", 1931 1944 media_descriptor_string(bkpinfo->backup_media_type), 1932 1945 g_current_media_number); … … 1936 1949 MONDO_LOGFILE, message_to_screen); 1937 1950 if (res) { 1938 strcat(message_to_screen, "...failed");1951 mr_strcat(message_to_screen, "...failed"); 1939 1952 } else { 1940 strcat(message_to_screen, "...OK");1953 mr_strcat(message_to_screen, "...OK"); 1941 1954 } 1942 1955 log_to_screen(message_to_screen); 1956 paranoid_free(message_to_screen); 1957 1943 1958 retval += res; 1944 1959 } … … 1949 1964 } 1950 1965 paranoid_free(old_pwd); 1951 paranoid_free(result_sz);1952 paranoid_free(message_to_screen);1953 1966 paranoid_free(sz_blank_disk); 1954 1967 paranoid_free(fnam); … … 2010 2023 2011 2024 /*@ buffers ******************************************** */ 2012 char *tmp ;2025 char *tmp = NULL; 2013 2026 char *bigfile_fname; 2014 2027 char *sz_devfile; … … 2031 2044 assert_string_is_neither_NULL_nor_zerolength(biggielist_fname); 2032 2045 2033 malloc_string(tmp);2034 2046 malloc_string(bigfile_fname); 2035 2047 malloc_string(sz_devfile); … … 2047 2059 return (0); 2048 2060 } 2049 sprintf(tmp, "I am now backing up all large files.");2061 mr_asprintf(&tmp, "I am now backing up all large files."); 2050 2062 log_to_screen(tmp); 2051 2063 noof_biggie_files = count_lines_in_file(biggielist_fname); … … 2053 2065 "Please wait. This may take some time.", "", 2054 2066 estimated_total_noof_slices); 2067 paranoid_free(tmp); 2068 2055 2069 if (!(fin = fopen(biggielist_fname, "r"))) { 2056 2070 log_OS_error("Unable to openin biggielist"); … … 2109 2123 } 2110 2124 } 2111 // Otherwise, use good old 'dd' and 'bzip2'2125 // Otherwise, use good old 'dd' and 'bzip2' 2112 2126 else { 2113 2127 sz_devfile[0] = '\0'; … … 2115 2129 } 2116 2130 2117 // Whether partition or biggiefile, just do your thang :-) 2118 sprintf(tmp, "Bigfile #%ld is '%s' (%ld KB)", 2119 biggie_file_number + 1, bigfile_fname, 2120 (long) biggie_fsize >> 10); 2131 // Whether partition or biggiefile, just do your thang :-) 2121 2132 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 2122 2133 write_header_block_to_stream(biggie_fsize, bigfile_fname, … … 2142 2153 p = bigfile_fname; 2143 2154 } 2144 sprintf(tmp, "Archiving %s ... ", bigfile_fname);2155 mr_asprintf(&tmp, "Archiving %s ... ", bigfile_fname); 2145 2156 if (res) { 2146 strcat(tmp, "Failed!");2157 mr_strcat(tmp, "Failed!"); 2147 2158 } else { 2148 strcat(tmp, "OK");2159 mr_strcat(tmp, "OK"); 2149 2160 } 2150 2161 if (delete_when_done) { … … 2159 2170 } 2160 2171 #endif 2172 paranoid_free(tmp); 2161 2173 } 2162 2174 log_msg(1, "Finished backing up bigfiles"); … … 2165 2177 close_progress_form(); 2166 2178 paranoid_fclose(fin); 2167 paranoid_free(tmp);2168 2179 paranoid_free(bigfile_fname); 2169 2180 paranoid_free(sz_devfile); … … 2191 2202 char *curr_xattr_list_fname; 2192 2203 char *curr_acl_list_fname; 2193 char *tmp ;2204 char *tmp = NULL; 2194 2205 char *media_usage_comment; 2195 2206 … … 2199 2210 malloc_string(curr_xattr_list_fname); 2200 2211 malloc_string(curr_acl_list_fname); 2201 2202 tmp = malloc(MAX_STR_LEN * 2);2203 2204 sprintf(tmp, "%s/archives/filelist.full", bkpinfo->scratchdir);2205 2212 2206 2213 log_to_screen("Archiving regular files"); … … 2242 2249 retval += res; 2243 2250 if (res) { 2244 sprintf(tmp,2251 mr_asprintf(&tmp, 2245 2252 "Errors occurred while archiving set %ld. Perhaps your live filesystem changed?", 2246 2253 curr_set_no); 2247 2254 log_to_screen(tmp); 2255 paranoid_free(tmp); 2248 2256 } 2249 2257 … … 2288 2296 2289 2297 if (res) { 2290 sprintf(tmp, "Failed to add archive %ld's files to CD dir\n",2298 mr_asprintf(&tmp, "Failed to add archive %ld's files to CD dir\n", 2291 2299 curr_set_no); 2292 2300 log_to_screen(tmp); 2301 paranoid_free(tmp); 2293 2302 fatal_error 2294 2303 ("Is your hard disk is full? If not, please send the author the logfile."); … … 2296 2305 } 2297 2306 close_progress_form(); 2298 sprintf(tmp, "Your regular files have been archived ");2307 mr_asprintf(&tmp, "Your regular files have been archived "); 2299 2308 if (retval) { 2300 strcat(tmp, "(with errors).");2309 mr_strcat(tmp, "(with errors)."); 2301 2310 } else { 2302 strcat(tmp, "successfully.");2311 mr_strcat(tmp, "successfully."); 2303 2312 } 2304 2313 log_to_screen(tmp); … … 2398 2407 } 2399 2408 2400 (void)asprintf(&command, "cp %s/biggielist.txt %s", bkpinfo->tmpdir,2409 mr_asprintf(&command, "cp %s/biggielist.txt %s", bkpinfo->tmpdir, 2401 2410 biggielist); 2402 2411 paranoid_system(command); 2403 2412 paranoid_free(command); 2404 2413 2405 (void)asprintf(&blah, "biggielist = %s", biggielist);2414 mr_asprintf(&blah, "biggielist = %s", biggielist); 2406 2415 log_msg(2, blah); 2407 2416 paranoid_free(blah); … … 2413 2422 if (g_getfattr) { 2414 2423 get_fattr_list(biggielist, xattr_fname); 2415 (void)asprintf(&command, "cp %s %s/archives/", xattr_fname,2424 mr_asprintf(&command, "cp %s %s/archives/", xattr_fname, 2416 2425 bkpinfo->scratchdir); 2417 2426 paranoid_system(command); … … 2420 2429 if (g_getfacl) { 2421 2430 get_acl_list(biggielist, acl_fname); 2422 (void)asprintf(&command, "cp %s %s/archives/", acl_fname,2431 mr_asprintf(&command, "cp %s %s/archives/", acl_fname, 2423 2432 bkpinfo->scratchdir); 2424 2433 paranoid_system(command); … … 2428 2437 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 2429 2438 res += write_EXAT_files_to_tape(xattr_fname, acl_fname); 2430 (void)asprintf(&blah, "%ld", count_lines_in_file(biggielist));2439 mr_asprintf(&blah, "%ld", count_lines_in_file(biggielist)); 2431 2440 write_header_block_to_stream((off_t)0, blah, BLK_START_BIGGIEFILES); 2432 2441 paranoid_free(blah); … … 2954 2963 2955 2964 /*@ buffers ************************************************** */ 2956 char *tmp, *checksum_line, *command; 2965 char *tmp = NULL; 2966 char *checksum_line, *command; 2957 2967 char *tempblock; 2958 2968 char *curr_slice_fname_uncompressed; … … 2990 3000 assert(bkpinfo != NULL); 2991 3001 assert_string_is_neither_NULL_nor_zerolength(biggie_filename); 2992 malloc_string(tmp);2993 3002 malloc_string(checksum_line); 2994 3003 malloc_string(curr_slice_fname_uncompressed); … … 3028 3037 sprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename); 3029 3038 log_it("command = %s", command); 3030 strcpy (tmp, call_program_and_get_last_line_of_output(command));3039 mr_asprintf(&tmp, call_program_and_get_last_line_of_output(command)); 3031 3040 log_it("res of it = %s", tmp); 3032 3041 totallength = (off_t)atoll(tmp); 3042 paranoid_free(tmp); 3033 3043 } else { 3034 3044 file_to_openin = biggie_filename; … … 3057 3067 strcpy(biggiestruct.checksum, checksum_line); 3058 3068 3059 strcpy(tmp, slice_fname(biggie_file_number, 0, bkpinfo->tmpdir, ""));3069 mr_asprintf(&tmp, slice_fname(biggie_file_number, 0, bkpinfo->tmpdir, "")); 3060 3070 fout = fopen(tmp, "w"); 3061 3071 if (fout == NULL) { … … 3065 3075 return (1); 3066 3076 } 3077 paranoid_free(tmp); 3067 3078 3068 3079 (void) fwrite((void *) &biggiestruct, 1, sizeof(biggiestruct), fout); … … 3075 3086 if (!(fin = fopen(file_to_openin, "r"))) { 3076 3087 log_OS_error("Unable to openin biggie_filename"); 3077 sprintf(tmp, "Cannot archive bigfile '%s': not found", 3078 biggie_filename); 3088 mr_asprintf(&tmp, "Cannot archive bigfile '%s': not found", biggie_filename); 3079 3089 log_to_screen(tmp); 3090 paranoid_free(tmp); 3091 3080 3092 paranoid_free(tempblock); 3081 paranoid_free(tmp);3082 3093 paranoid_free(checksum_line); 3083 3094 paranoid_free(command); … … 3102 3113 suffix)); 3103 3114 3104 strcpy(tmp, percent_media_full_comment());3115 mr_asprintf(&tmp, percent_media_full_comment()); 3105 3116 update_progress_form(tmp); 3117 paranoid_free(tmp); 3118 3106 3119 if (!(fout = fopen(curr_slice_fname_uncompressed, "w"))) { 3107 3120 log_OS_error(curr_slice_fname_uncompressed); … … 3156 3169 } 3157 3170 if (res) { 3158 sprintf(tmp, "Problem with slice # %ld", slice_num);3171 mr_asprintf(&tmp, "Problem with slice # %ld", slice_num); 3159 3172 } else { 3160 sprintf(tmp,3173 mr_asprintf(&tmp, 3161 3174 "%s - Bigfile #%ld, slice #%ld compressed OK ", 3162 3175 biggie_filename, biggie_file_number + 1, … … 3173 3186 log_msg(2, tmp); 3174 3187 #endif 3188 paranoid_free(tmp); 3189 3175 3190 strcpy(file_to_archive, curr_slice_fname_compressed); 3176 3191 g_current_progress++; … … 3195 3210 retval += res; 3196 3211 if (res) { 3197 sprintf(tmp,3212 mr_asprintf(&tmp, 3198 3213 "Failed to add slice %ld of bigfile %ld to scratchdir", 3199 3214 slice_num, biggie_file_number + 1); 3200 3215 log_to_screen(tmp); 3216 paranoid_free(tmp); 3201 3217 fatal_error 3202 3218 ("Hard disk full. You should have bought a bigger one."); … … 3204 3220 } 3205 3221 paranoid_fclose(fin); 3206 sprintf(tmp, "Sliced bigfile #%ld", biggie_file_number + 1);3222 mr_asprintf(&tmp, "Sliced bigfile #%ld", biggie_file_number + 1); 3207 3223 if (retval) { 3208 strcat(tmp, "...FAILED");3224 mr_strcat(tmp, "...FAILED"); 3209 3225 } else { 3210 strcat(tmp, "...OK!");3226 mr_strcat(tmp, "...OK!"); 3211 3227 } 3212 3228 log_msg(1, tmp); 3229 paranoid_free(tmp); 3230 3213 3231 paranoid_free(tempblock); 3214 paranoid_free(tmp);3215 3232 paranoid_free(checksum_line); 3216 3233 paranoid_free(command); -
branches/2.2.9/mondo/src/common/libmondo-cli.c
r2202 r2211 12 12 #include <pthread.h> 13 13 #include "my-stuff.h" 14 #include "mr_mem.h" 15 #include "mr_string.h" 14 16 #include "mondostructures.h" 15 17 #include "libmondo-cli-EXT.h" 16 18 #include "libmondo.h" 17 #include "mr_string.h"18 19 19 20 extern int g_loglevel; … … 278 279 ********/ 279 280 /* Get the number of mounted file systems ((those that start with "/dev/" */ 280 asprintf(&command, "mount 2>/dev/null | awk '{if($1 ~ \"^/dev/\"){print $0}}'|wc -l");281 mr_asprintf(&command, "mount 2>/dev/null | awk '{if($1 ~ \"^/dev/\"){print $0}}'|wc -l"); 281 282 log_msg(5, "Running: %s", command); 282 asprintf(&mounted_file_system, "%s", call_program_and_get_last_line_of_output(command));283 mr_asprintf(&mounted_file_system, "%s", call_program_and_get_last_line_of_output(command)); 283 284 paranoid_free(command); 284 285 … … 288 289 289 290 for (i=mount_cnt; i > 0; i--) { 290 asprintf(&command, "mount 2>/dev/null | awk '{if($1 ~ \"^/dev/\"){print $1,$3}}'|head -n %d", i);291 mr_asprintf(&command, "mount 2>/dev/null | awk '{if($1 ~ \"^/dev/\"){print $1,$3}}'|head -n %d", i); 291 292 log_msg(5, "Running: %s", command); 292 asprintf(&mounted_file_system, "%s", call_program_and_get_last_line_of_output(command));293 mr_asprintf(&mounted_file_system, "%s", call_program_and_get_last_line_of_output(command)); 293 294 paranoid_free(command); 294 295 … … 366 367 log_msg(5, " %s looks like a device special file", dsf); 367 368 /* Verify that the dsf exists */ 368 asprintf(&command, "ls -al %s 2>/dev/null | wc -l", dsf);369 mr_asprintf(&command, "ls -al %s 2>/dev/null | wc -l", dsf); 369 370 log_msg(5, " Executing: %s", command); 370 asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));371 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 371 372 paranoid_free(command); 372 373 … … 392 393 * Either way, it's an error. 393 394 ********/ 394 asprintf(&command,395 mr_asprintf(&command, 395 396 "fdisk -l %s 2>/dev/null|grep -E \"^/dev/\"|awk '{printf(\"%%s \", $1)}END{print \"\"}'", dsf); 396 397 log_msg(4, "Executing: %s", command); 397 asprintf(&partition_list, "%s", call_program_and_get_last_line_of_output(command));398 mr_asprintf(&partition_list, "%s", call_program_and_get_last_line_of_output(command)); 398 399 paranoid_free(command); 399 400 log_msg(4, "Partition list for %s: %s", dsf, partition_list); … … 445 446 log_msg(4, "Processing partition: %s", partitions[i]); 446 447 /* See if it's swap. If it is, ignore it. */ 447 asprintf(&command,448 mr_asprintf(&command, 448 449 "fdisk -l %s 2>/dev/null | awk '{if(($1==\"%s\")&&(toupper($0) ~ \"SWAP\")){print $1;exit}}'", 449 450 dsf, partitions[i]); 450 451 log_msg(4, " Running: %s", command); 451 asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));452 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 452 453 paranoid_free(command); 453 454 log_msg(4, " Return value: %s", tmp); … … 459 460 } 460 461 /* It's not swap. See if we can find the mount point from the mount command. */ 461 asprintf(&command, "mount 2>/dev/null | awk '{if((NF>0)&&($1==\"%s\")){print $3}}'", partitions[i]);462 asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));462 mr_asprintf(&command, "mount 2>/dev/null | awk '{if((NF>0)&&($1==\"%s\")){print $3}}'", partitions[i]); 463 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 463 464 paranoid_free(command); 464 465 if (strlen(tmp)) { … … 477 478 log_msg(4, " It's not mounted. Checking to see if it's LVM..."); 478 479 /* Get the partition ID; 8e for LVM */ 479 asprintf(&command, "fdisk -l %s |awk '{if($1 ~ \"^%s\"){print $5}}'", dsf, partitions[i]);480 mr_asprintf(&command, "fdisk -l %s |awk '{if($1 ~ \"^%s\"){print $5}}'", dsf, partitions[i]); 480 481 log_msg(4, " Running: %s", command); 481 asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));482 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 482 483 paranoid_free(command); 483 484 if (strlen(tmp)) { … … 486 487 /* It's LVM: Find the VG it's in */ 487 488 log_msg(4, " It's LVM: Find the VG it's in..."); 488 asprintf(&command, "pvdisplay -v %s 2>/dev/null|grep \"VG Name\"|awk '{print $NF}'", partitions[i]);489 mr_asprintf(&command, "pvdisplay -v %s 2>/dev/null|grep \"VG Name\"|awk '{print $NF}'", partitions[i]); 489 490 log_msg(4, " Running: %s", command); 490 491 strcpy(VG, call_program_and_get_last_line_of_output(command)); … … 494 495 /* Found the Volume Group. Now find all of the VG's mount points */ 495 496 log_msg(4, " Found the Volume Group. Now find all of the VG's mount points"); 496 asprintf(&command,497 mr_asprintf(&command, 497 498 "mount 2>/dev/null|grep -E \"/dev/mapper/%s-|/dev/%s/\"|awk '{printf(\"%%s \",$3)}END{print \"\"}'", 498 499 VG, VG); 499 500 log_msg(4, " Running: %s", command); 500 asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command));501 mr_asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command)); 501 502 paranoid_free(command); 502 503 log_msg(4, " VG %s mount_list: %s", VG, mount_list); … … 516 517 *******/ 517 518 paranoid_free(mount_list); 518 asprintf(&command, "%s",519 mr_asprintf(&command, "%s", 519 520 "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'"); 520 521 log_msg (5, "Running: %s", command); 521 asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command));522 mr_asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command)); 522 523 paranoid_free(command); 523 524 log_msg(4, " Software raid device list: %s", mount_list); 524 525 lastpos = 0; 525 526 while ((token = mr_strtok(mount_list, token_chars, &lastpos)) != NULL) { 526 asprintf(&command, "mdadm --detail %s 2>/dev/null | grep -c %s", token, VG);527 mr_asprintf(&command, "mdadm --detail %s 2>/dev/null | grep -c %s", token, VG); 527 528 log_msg (5, "Running: %s", command); 528 529 paranoid_free(tmp); 529 asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));530 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 530 531 paranoid_free(command); 531 532 log_msg(4, "Number of Software raid device: %s", tmp); … … 557 558 ********/ 558 559 log_msg (5, "It's not swap, mounted, or LVM. See if it's used in a software raid device."); 559 asprintf(&command, "mdadm --examine %s 2>/dev/null | awk '{if($1 == \"UUID\"){print $3}}'", partitions[i]);560 mr_asprintf(&command, "mdadm --examine %s 2>/dev/null | awk '{if($1 == \"UUID\"){print $3}}'", partitions[i]); 560 561 log_msg(4, " Running: %s", command); 561 asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));562 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 562 563 paranoid_free(command); 563 564 if (!strlen(tmp)) { … … 568 569 log_msg (5, " UUID: %s", tmp); 569 570 /* Get the Software raid device list */ 570 asprintf(&command, "%s",571 mr_asprintf(&command, "%s", 571 572 "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'"); 572 573 log_msg (5, " Running: %s", command); 573 asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command));574 mr_asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command)); 574 575 paranoid_free(command); 575 576 log_msg(4, " Software raid device list: %s", mount_list); … … 577 578 lastpos = 0; 578 579 while ((token = mr_strtok(mount_list, token_chars, &lastpos)) != NULL) { 579 asprintf(&command, "mdadm --detail %s 2>/dev/null | grep -c %s", token, tmp);580 mr_asprintf(&command, "mdadm --detail %s 2>/dev/null | grep -c %s", token, tmp); 580 581 log_msg(4, " Running: %s", command); 581 582 paranoid_free(tmp); 582 asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));583 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 583 584 paranoid_free(command); 584 585 if (!atoi(tmp)) { … … 756 757 } 757 758 758 asprintf(&tmp1, "%s", flag_val['I']);759 mr_asprintf(&tmp1, "%s", flag_val['I']); 759 760 p = tmp1; 760 761 q = tmp1; … … 1035 1036 if (flag_set['z']) { 1036 1037 if (find_home_of_exe("getfattr")) { 1037 asprintf(&g_getfattr,"getfattr");1038 mr_asprintf(&g_getfattr,"getfattr"); 1038 1039 } 1039 1040 if (find_home_of_exe("getfacl")) { 1040 asprintf(&g_getfacl,"getfacl");1041 mr_asprintf(&g_getfacl,"getfacl"); 1041 1042 } 1042 1043 } … … 1055 1056 strcat(bkpinfo->exclude_paths, " "); 1056 1057 } 1057 asprintf(&tmp1, "%s", flag_val['E']);1058 mr_asprintf(&tmp1, "%s", flag_val['E']); 1058 1059 1059 1060 p = tmp1; … … 1211 1212 1212 1213 if ((flag_set['n']) && (! bkpinfo->restore_data)) { 1213 asprintf(&tmp1,"%s/%s/.dummy.txt", bkpinfo->isodir,bkpinfo->nfs_remote_dir);1214 mr_asprintf(&tmp1,"%s/%s/.dummy.txt", bkpinfo->isodir,bkpinfo->nfs_remote_dir); 1214 1215 sprintf(tmp, "echo hi > %s", tmp1); 1215 1216 if (run_program_and_log_output(tmp, 2)) { … … 1467 1468 if (flag_set[optopt]) { 1468 1469 bad_switches = TRUE; 1469 (void)asprintf(&tmp, "Switch -%c previously defined as %s\n", opt,1470 mr_asprintf(&tmp, "Switch -%c previously defined as %s\n", opt, 1470 1471 flag_val[i]); 1471 1472 log_to_screen(tmp); … … 1484 1485 if (strchr(flag_val[opt], '/') 1485 1486 && flag_val[opt][0] != '/') { 1486 (void)asprintf(&tmp,1487 mr_asprintf(&tmp, 1487 1488 "-%c flag --- must be absolute path --- '%s' isn't absolute", 1488 1489 opt, flag_val[opt]); … … 1499 1500 for (i = optind; i < argc; i++) { 1500 1501 bad_switches = TRUE; 1501 (void)asprintf(&tmp, "Invalid arg -- %s\n", argv[i]);1502 mr_asprintf(&tmp, "Invalid arg -- %s\n", argv[i]); 1502 1503 log_to_screen(tmp); 1503 1504 paranoid_free(tmp); … … 1525 1526 void terminate_daemon(int sig) 1526 1527 { 1527 char tmp[64]; 1528 char tmp2[MAX_STR_LEN]; 1529 // char command[512]; 1530 // pid_t pid; 1528 char *tmp = NULL; 1529 char *tmp2 = NULL; 1531 1530 1532 1531 switch (sig) { 1533 1532 case SIGINT: 1534 sprintf(tmp, "SIGINT");1535 strcpy(tmp2, "You interrupted me :-)");1533 mr_asprintf(&tmp, "SIGINT"); 1534 mr_asprintf(&tmp2, "You interrupted me :-)"); 1536 1535 break; 1537 1536 case SIGKILL: 1538 sprintf(tmp, "SIGKILL");1539 strcpy(tmp2,1537 mr_asprintf(&tmp, "SIGKILL"); 1538 mr_asprintf(&tmp2, 1540 1539 "I seriously have no clue how this signal even got to me. Something's wrong with your system."); 1541 1540 break; 1542 1541 case SIGTERM: 1543 sprintf(tmp, "SIGTERM");1544 strcpy(tmp2, "Got terminate signal");1542 mr_asprintf(&tmp, "SIGTERM"); 1543 mr_asprintf(&tmp2, "Got terminate signal"); 1545 1544 break; 1546 1545 case SIGHUP: 1547 sprintf(tmp, "SIGHUP");1548 strcpy(tmp2, "Hangup on line");1546 mr_asprintf(&tmp, "SIGHUP"); 1547 mr_asprintf(&tmp2, "Hangup on line"); 1549 1548 break; 1550 1549 case SIGSEGV: 1551 sprintf(tmp, "SIGSEGV");1552 strcpy(tmp2,1550 mr_asprintf(&tmp, "SIGSEGV"); 1551 mr_asprintf(&tmp2, 1553 1552 "Internal programming error. Please send a backtrace as well as your log."); 1554 1553 break; 1555 1554 case SIGPIPE: 1556 sprintf(tmp, "SIGPIPE");1557 strcpy(tmp2, "Pipe was broken");1555 mr_asprintf(&tmp, "SIGPIPE"); 1556 mr_asprintf(&tmp2, "Pipe was broken"); 1558 1557 break; 1559 1558 case SIGABRT: 1560 sprintf(tmp, "SIGABRT");1561 sprintf(tmp2,1559 mr_asprintf(&tmp, "SIGABRT"); 1560 mr_asprintf(&tmp2, 1562 1561 "Abort - probably failed assertion. I'm sleeping for a few seconds so you can read the message."); 1563 1562 break; 1564 1563 default: 1565 sprintf(tmp, "(Unknown)"); 1566 } 1567 1568 strcat(tmp, " signal received from OS"); 1564 mr_asprintf(&tmp, "(Unknown)"); 1565 mr_asprintf(&tmp2, "(Unknown)"); 1566 } 1567 1568 mr_strcat(tmp, " signal received from OS"); 1569 1569 log_to_screen(tmp); 1570 paranoid_free(tmp); 1571 1570 1572 log_to_screen(tmp2); 1573 paranoid_free(tmp2); 1571 1574 if (sig == SIGABRT) { 1572 1575 sleep(10); -
branches/2.2.9/mondo/src/common/libmondo-devices.c
r2205 r2211 9 9 10 10 #include "my-stuff.h" 11 #include "mr_mem.h" 11 12 #include "mondostructures.h" 12 13 #include "libmondo-files-EXT.h" … … 327 328 char *program; 328 329 char *incoming; 329 char *searchstr ;330 char *searchstr = NULL; 330 331 char *tmp; 331 332 … … 1040 1041 bool is_this_a_valid_disk_format(char *format) 1041 1042 { 1042 char *good_formats ;1043 char *good_formats = NULL; 1043 1044 char *command; 1044 1045 char *format_sz; … … 1288 1289 { 1289 1290 /*@ buffer ****************************************************** */ 1290 char *command; 1291 char *dev; 1292 char *options; 1291 char *command = NULL; 1293 1292 int retval; 1294 1293 1295 malloc_string(command);1296 malloc_string(dev);1297 malloc_string(options);1298 1294 assert_string_is_neither_NULL_nor_zerolength(device); 1299 1295 assert_string_is_neither_NULL_nor_zerolength(mountpoint); 1300 1296 1301 1297 make_hole_for_dir(mountpoint); 1302 strcpy(options, "ro"); 1298 1299 #ifndef __FreeBSD__ 1300 char *dev = NULL; 1301 char *options = NULL; 1302 mr_asprintf(&options, "ro"); 1303 #endif 1304 1303 1305 if (isdigit(device[0])) { 1304 1306 find_cdrom_device(device, FALSE); 1305 } else {1306 strcpy(dev, device);1307 1307 } 1308 1308 if (g_ISO_restore_mode) { 1309 1309 1310 1310 #ifdef __FreeBSD__ 1311 strcpy(dev, make_vn(device));1311 mr_asprintf(&dev, make_vn(device)); 1312 1312 if (!dev) { 1313 sprintf(command, "Unable to mount ISO (make_vn(%s) failed)", 1314 device); 1313 mr_asprintf(&command, "Unable to mount ISO (make_vn(%s) failed)", device); 1315 1314 fatal_error(command); 1316 1315 } 1317 1316 strcpy(device, dev); 1317 paranoid_free(dev); 1318 1318 #else 1319 strcat(options, ",loop");1319 mr_strcat(options, ",loop"); 1320 1320 #endif 1321 1321 … … 1326 1326 1327 1327 #ifdef __FreeBSD__ 1328 sprintf(command, "mount_cd9660 -r %s %s 2>> %s",1328 mr_asprintf(&command, "mount_cd9660 -r %s %s 2>> %s", 1329 1329 device, mountpoint, MONDO_LOGFILE); 1330 1330 1331 1331 #else 1332 sprintf(command, "mount %s -o %s -t iso9660 %s 2>> %s",1332 mr_asprintf(&command, "mount %s -o %s -t iso9660 %s 2>> %s", 1333 1333 device, options, mountpoint, MONDO_LOGFILE); 1334 paranoid_free(options); 1334 1335 #endif 1335 1336 … … 1340 1341 retval = system(command); 1341 1342 log_msg(1, "system(%s) returned %d", command, retval); 1342 1343 1343 paranoid_free(command); 1344 paranoid_free(dev); 1345 paranoid_free(options); 1344 1346 1345 return (retval); 1347 1346 } … … 2183 2182 void sensibly_set_tmpdir_and_scratchdir() 2184 2183 { 2185 char *tmp , *command, *sz;2186 2187 malloc_string(tmp); 2184 char *tmp = NULL; 2185 char *command, *sz; 2186 2188 2187 malloc_string(command); 2189 2188 malloc_string(sz); … … 2191 2190 2192 2191 #ifdef __FreeBSD__ 2193 strcpy(tmp,2192 mr_asprintf(&tmp, 2194 2193 call_program_and_get_last_line_of_output 2195 2194 ("LANGUAGE=C df -m -P -t nonfs,msdosfs,ntfs,ntfs-3g,smbfs,smb,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | tr -s '\t' ' ' | grep -vE \"none|Filesystem\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'")); 2196 2195 #else 2197 strcpy(tmp,2196 mr_asprintf(&tmp, 2198 2197 call_program_and_get_last_line_of_output 2199 2198 ("LANGUAGE=C df -m -P -x nfs -x nfs4 -x vfat -x ntfs -x ntfs-3g -x smbfs -x smb -x cifs -x afs -x gfs -x ocfs -x ocfs2 -x mvfs -x nsspool -x nssvol -x iso9660| sed 's/ /devdev/' | tr -s '\t' ' ' | grep -vE \"none|Filesystem|/dev/shm\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'")); … … 2202 2201 if (tmp[0] != '/') { 2203 2202 strcpy(sz, tmp); 2204 strcpy(tmp, "/");2205 strcat(tmp, sz);2203 paranoid_free(tmp); 2204 mr_asprintf(&tmp, "/%s", sz); 2206 2205 } 2207 2206 if (!tmp[0]) { … … 2216 2215 2217 2216 sprintf(command, "rm -Rf %s/tmp.mondo.* %s/mondo.scratch.*", tmp, tmp); 2217 paranoid_free(tmp); 2218 2218 2219 paranoid_system(command); 2219 paranoid_free(tmp);2220 2220 paranoid_free(command); 2221 2221 paranoid_free(sz); … … 2282 2282 { 2283 2283 int cd_number = -1; 2284 char *mountdev; 2285 char *tmp; 2286 2287 malloc_string(mountdev); 2288 malloc_string(tmp); 2284 char *mountdev = NULL; 2285 char *tmp = NULL; 2286 2289 2287 assert(bkpinfo != NULL); 2290 2288 // log_it("Asking what_number_cd_is_this"); 2291 2289 if (g_ISO_restore_mode) { 2292 sprintf(tmp, "mount | grep iso9660 | awk '{print $3;}'"); 2293 // log_it("tmp = %s", tmp); 2294 2295 strcpy(mountdev, call_program_and_get_last_line_of_output(tmp)); 2296 strcat(mountdev, "/archives/THIS-CD-NUMBER"); 2297 // log_it("mountdev = %s", mountdev); 2290 mr_asprintf(&tmp, "mount | grep iso9660 | awk '{print $3;}'"); 2291 2292 mr_asprintf(&mountdev, "%s%s", call_program_and_get_last_line_of_output(tmp), "/archives/THIS-CD-NUMBER"); 2298 2293 cd_number = atoi(last_line_of_file(mountdev)); 2299 // log_it("cd_number = %d", cd_number);2300 2294 paranoid_free(mountdev); 2301 2295 paranoid_free(tmp); 2296 2302 2297 return (cd_number); 2303 2298 } 2304 2299 2305 strcpy(mountdev, bkpinfo->media_device);2300 mr_asprintf(&mountdev, bkpinfo->media_device); 2306 2301 if (!mountdev[0]) { 2307 2302 log_it … … 2316 2311 } 2317 2312 } 2318 cd_number =2319 atoi(last_line_of_file(MNT_CDROM "/archives/THIS-CD-NUMBER"));2320 // log_it("cd_number..later.. = %d", cd_number);2321 2313 paranoid_free(mountdev); 2322 paranoid_free(tmp); 2314 2315 cd_number = atoi(last_line_of_file(MNT_CDROM "/archives/THIS-CD-NUMBER")); 2323 2316 return (cd_number); 2324 2317 } -
branches/2.2.9/mondo/src/common/libmondo-filelist.c
r2206 r2211 18 18 #include "libmondo-tools-EXT.h" 19 19 #include "mr_string.h" 20 #include "mr_mem.h" 20 21 21 22 #include <time.h> … … 484 485 log_msg(8, "Analyzing %s", file_to_analyze); 485 486 tmp = mr_stresc(file_to_analyze, "`$\\\"(){}[]'*?&|!#~", '\\'); 486 (void)asprintf(&strtmp, syscall_sprintf, tmp);487 mr_asprintf(&strtmp, syscall_sprintf, tmp); 487 488 paranoid_free(tmp); 488 (void)asprintf(&syscall, "%s 2>> /dev/null", strtmp); // " MONDO_LOGFILE);489 mr_asprintf(&syscall, "%s 2>> /dev/null", strtmp); // " MONDO_LOGFILE); 489 490 paranoid_free(strtmp); 490 491 call_exe_and_pipe_output_to_fd(syscall, pout); … … 1389 1390 malloc_string(name_of_evalcall_form); 1390 1391 malloc_string(find_skeleton_marker); 1391 (void)asprintf(&find_excludes, " ");1392 mr_asprintf(&find_excludes, " "); 1392 1393 while((token = mr_strtok (sth, delims, &lastpos))) { 1393 (void)asprintf(&strtmp,"%s", find_excludes);1394 mr_asprintf(&strtmp,"%s", find_excludes); 1394 1395 paranoid_free(find_excludes); 1395 (void)asprintf(&find_excludes,"%s -path %s -prune -o", strtmp, token);1396 mr_asprintf(&find_excludes,"%s -path %s -prune -o", strtmp, token); 1396 1397 paranoid_free(strtmp); 1397 1398 paranoid_free(token); … … 1399 1400 #if linux 1400 1401 // 2.6 has /sys as a proc-type thing -- must be excluded 1401 (void)asprintf(&strtmp,1402 mr_asprintf(&strtmp, 1402 1403 "find '%s' -fstype mvfs -prune -o -fstype devpts -prune -o -fstype tmpfs -prune -o -fstype proc -prune -o -fstype sysfs -prune -o %s -type d -print > %s 2> /dev/null", 1403 1404 dir, find_excludes, g_skeleton_filelist); 1404 1405 #else 1405 1406 // On BSD, for example, /sys is the kernel sources -- don't exclude 1406 (void)asprintf(&strtmp,1407 mr_asprintf(&strtmp, 1407 1408 "find '%s' -fstype mvfs -prune -o -path /proc -prune -o %s -type d -print > %s 2> /dev/null", 1408 1409 dir, find_excludes, g_skeleton_filelist); … … 1412 1413 (void)system(strtmp); 1413 1414 paranoid_free(strtmp); 1414 (void)asprintf(&tmp, "wc -l %s | awk '{print $1;}'", g_skeleton_filelist);1415 mr_asprintf(&tmp, "wc -l %s | awk '{print $1;}'", g_skeleton_filelist); 1415 1416 g_skeleton_entries = 1416 1417 1 + atol(call_program_and_get_last_line_of_output(tmp)); … … 1442 1443 #ifndef _XWIN 1443 1444 if (!g_text_mode) { 1444 (void)asprintf(&tmp, "Reading %-68s", dir);1445 mr_asprintf(&tmp, "Reading %-68s", dir); 1445 1446 newtDrawRootText(0, g_noof_rows - 3, tmp); 1446 1447 paranoid_free(tmp); … … 1456 1457 // log_msg(0, "Cataloguing %s", dir); 1457 1458 if (sth[0] == ' ') { 1458 (void)asprintf(&skip_these, "%s", sth);1459 mr_asprintf(&skip_these, "%s", sth); 1459 1460 } else { 1460 (void)asprintf(&skip_these, " %s ", sth);1461 } 1462 (void)asprintf(&new_with_spaces, " %s ", dir);1461 mr_asprintf(&skip_these, " %s ", sth); 1462 } 1463 mr_asprintf(&new_with_spaces, " %s ", dir); 1463 1464 if ((dip = opendir(dir)) == NULL) { 1464 (void)asprintf(&tmp,"opendir %s", dir);1465 mr_asprintf(&tmp,"opendir %s", dir); 1465 1466 log_OS_error(tmp); 1466 1467 paranoid_free(tmp); … … 1472 1473 i++; 1473 1474 if (strcmp(dir, "/")) { 1474 (void)asprintf(&new,"%s/%s",dir,dit->d_name);1475 mr_asprintf(&new,"%s/%s",dir,dit->d_name); 1475 1476 } else { 1476 (void)asprintf(&new,"%s%s",dir,dit->d_name);1477 mr_asprintf(&new,"%s%s",dir,dit->d_name); 1477 1478 } 1478 1479 paranoid_free(new_with_spaces); 1479 (void)asprintf(&new_with_spaces, " %s ", new);1480 mr_asprintf(&new_with_spaces, " %s ", new); 1480 1481 if (strstr(skip_these, new_with_spaces)) { 1481 1482 fprintf(fout, "%s\n", new); … … 1496 1497 counter = 0; 1497 1498 uberctr++; 1498 (void)asprintf(&tmp, " %c ",1499 mr_asprintf(&tmp, " %c ", 1499 1500 special_dot_char(uberctr)); 1500 1501 #ifndef _XWIN … … 1550 1551 bool in_quotes = FALSE; 1551 1552 1552 (void)asprintf(&sz_res, "%s", incoming);1553 mr_asprintf(&sz_res, "%s", incoming); 1553 1554 p = sz_res; 1554 1555 while ((*p != ' ' || in_quotes) && *p != '\0') { … … 1598 1599 fatal_error("Cannot malloc exclude_paths"); 1599 1600 } 1600 (void)asprintf(&sz_datefile,MONDO_CACHE"/difflevel.%d" , 0);1601 mr_asprintf(&sz_datefile,MONDO_CACHE"/difflevel.%d" , 0); 1601 1602 if (!include_paths && !userdef_filelist) { 1602 1603 fatal_error … … 1606 1607 sprintf(command, "mkdir -p %s/archives", scratchdir); 1607 1608 paranoid_system(command); 1608 (void)asprintf(&sz_filelist, "%s/tmpfs/filelist.full", tmpdir);1609 mr_asprintf(&sz_filelist, "%s/tmpfs/filelist.full", tmpdir); 1609 1610 make_hole_for_file(sz_filelist); 1610 1611 … … 1646 1647 log_msg(2, "include_paths = '%s'", include_paths); 1647 1648 log_msg(1, "Calculating filelist"); 1648 (void)asprintf(&tmp2, "%s", call_program_and_get_last_line_of_output("mount | grep -Ew 'ntfs|ntfs-3g|fat|vfat|dos' | awk '{print $3}'"));1649 mr_asprintf(&tmp2, "%s", call_program_and_get_last_line_of_output("mount | grep -Ew 'ntfs|ntfs-3g|fat|vfat|dos' | awk '{print $3}'")); 1649 1650 if (strlen(tmp2) < 1) { 1650 (void)asprintf(&tmp1," ");1651 mr_asprintf(&tmp1," "); 1651 1652 } else { 1652 1653 log_msg(2, "Found windows FS: %s",tmp2); 1653 (void)asprintf(&tmp1, "find %s -name '/win386.swp' -o -name '/hiberfil.sys' -o -name '/pagefile.sys' 2> /dev/null\n",tmp2);1654 mr_asprintf(&tmp1, "find %s -name '/win386.swp' -o -name '/hiberfil.sys' -o -name '/pagefile.sys' 2> /dev/null\n",tmp2); 1654 1655 paranoid_free(tmp2); 1655 (void)asprintf(&tmp2, "%s", call_program_and_get_last_line_of_output(tmp1));1656 mr_asprintf(&tmp2, "%s", call_program_and_get_last_line_of_output(tmp1)); 1656 1657 log_msg(2, "Found windows files: %s",tmp2); 1657 1658 } -
branches/2.2.9/mondo/src/common/libmondo-mountlist.c
r2209 r2211 74 74 prev_part_no = 0; 75 75 tmp[0] = '\0'; 76 asprintf(&flaws_str, "%s", "");76 mr_asprintf(&flaws_str, "%s", ""); 77 77 78 78 … … 363 363 assert_string_is_neither_NULL_nor_zerolength(drive); 364 364 assert(mountlist != NULL); 365 asprintf(&flaws_str, "%s", "");365 mr_asprintf(&flaws_str, "%s", ""); 366 366 367 367 malloc_string(tmp); … … 522 522 assert(flaws_str_C != NULL); 523 523 524 asprintf(&flaws_str, "%s", "");524 mr_asprintf(&flaws_str, "%s", ""); 525 525 526 526 make_list_of_drives_in_mountlist(mountlist, drivelist); … … 532 532 (drivelist->el[i].device, 533 533 DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE)) { 534 asprintf(&tmp, " Not evaluating %s (I don't know how yet)",534 mr_asprintf(&tmp, " Not evaluating %s (I don't know how yet)", 535 535 drivelist->el[i].device); 536 536 log_it(tmp); … … 606 606 607 607 for (currline = 0; currline < mountlist->entries; currline++) { 608 asprintf(&curr_mountpoint, "%s", mountlist->el[currline].mountpoint);608 mr_asprintf(&curr_mountpoint, "%s", mountlist->el[currline].mountpoint); 609 609 for (i = 0, copies = 0, last_copy = -1; i < mountlist->entries; 610 610 i++) { … … 618 618 if (copies > 1 && last_copy == currline 619 619 && strcmp(curr_mountpoint, "raid")) { 620 asprintf(&tmp, " %s %s's.", number_to_text(copies),620 mr_asprintf(&tmp, " %s %s's.", number_to_text(copies), 621 621 curr_mountpoint); 622 622 mr_strcat(flaws_str, "%s", tmp); … … 657 657 for (lino = 0, noof_drives = 0; lino < mountlist->entries; lino++) { 658 658 659 asprintf(&drive, "%s", mountlist->el[lino].device);659 mr_asprintf(&drive, "%s", mountlist->el[lino].device); 660 660 if (!strncmp(drive, RAID_DEVICE_STUB, strlen(RAID_DEVICE_STUB))) { 661 661 log_msg(8, "Not putting %s in list of drives: it's a virtual drive", drive); … … 733 733 (void *) &mountlist->el[i], 734 734 sizeof(struct mountlist_line)); 735 asprintf(&tmp,735 mr_asprintf(&tmp, 736 736 "%s is available; user may choose to add it to raid device", 737 737 output_list->el[items - 1].device); … … 853 853 if (j < items) { 854 854 strcat(mountlist->el[items].device, "_dup"); 855 asprintf(&tmp,855 mr_asprintf(&tmp, 856 856 "Duplicate entry in mountlist - renaming to %s", 857 857 mountlist->el[items].device); … … 859 859 paranoid_free(tmp); 860 860 } 861 asprintf(&tmp, "%s", mountlist->el[items].device);861 mr_asprintf(&tmp, "%s", mountlist->el[items].device); 862 862 if (strstr(tmp, "/dev/md/")) { 863 863 log_it("format_device() --- Contracting %s", tmp); … … 1008 1008 assert(b >= 0); 1009 1009 1010 asprintf(&device, "%s", mountlist->el[a].device);1011 asprintf(&mountpoint, "%s", mountlist->el[a].mountpoint);1012 asprintf(&format, "%s", mountlist->el[a].format);1010 mr_asprintf(&device, "%s", mountlist->el[a].device); 1011 mr_asprintf(&mountpoint, "%s", mountlist->el[a].mountpoint); 1012 mr_asprintf(&format, "%s", mountlist->el[a].format); 1013 1013 1014 1014 size = mountlist->el[a].size; -
branches/2.2.9/mondo/src/common/libmondo-raid.c
r2190 r2211 1 1 /* libmondo-raid.c subroutines for handling RAID 2 2 $Id$ 3 .4 5 6 06/297 - added create_raidtab_from_mdstat()8 - changed char[MAX_STR_LEN] to char*9 10 10/21/200311 - get_next_raidtab_line() --- correctly handle multiple spaces12 between label and value13 14 07/0315 - line 447 - changed assert()16 17 05/0818 - cleaned up some FreeBSd-specific stuff19 20 05/0521 - added Joshua Oreman's FreeBSD patches22 23 04/2524 - added a bunch of RAID utilities from mondorestore/mondo-restore.c25 26 04/24/200327 - added some assert()'s and log_OS_error()'s28 29 10/19/200230 - added some comments31 32 07/2433 - created34 3 */ 35 4 … … 49 18 #include "libmondo-raid.h" 50 19 #include "mr_string.h" 20 #include "mr_mem.h" 51 21 52 22 #ifdef __FreeBSD__ … … 77 47 #else 78 48 /*@ buffer ********************************************************** */ 79 char *command ;49 char *command = NULL; 80 50 int res; 81 51 82 command = malloc(MAX_STR_LEN * 2); 83 strcpy(command, "grep \""); 52 mr_asprintf(&command, "grep \""); 84 53 if (raidno == -1) { 85 strcat(command, "linear");54 mr_strcat(command, "linear"); 86 55 } else { 87 sprintf(command + strlen(command), "raid%d", raidno);88 } 89 strcat(command, "\" /proc/mdstat > /dev/null 2> /dev/null");56 mr_strcat(command, "raid%d", raidno); 57 } 58 mr_strcat(command, "\" /proc/mdstat > /dev/null 2> /dev/null"); 90 59 log_it("Is raid %d registered? Command = '%s'", raidno, command); 91 60 res = system(command); 92 61 paranoid_free(command); 62 93 63 if (res) { 94 64 return (FALSE); … … 1043 1013 pos = string; 1044 1014 while (*pos == ' ') pos += 1; 1045 asprintf(&strtmp, "%s", pos);1015 mr_asprintf(&strtmp, "%s", pos); 1046 1016 strcpy(string, strtmp); 1047 1017 paranoid_free(strtmp); … … 1064 1034 token = mr_strtok (string, delims, &lastpos); 1065 1035 // get RAID device name 1066 asprintf(&strtmp,"%s%s", device_prefix, token);1036 mr_asprintf(&strtmp,"%s%s", device_prefix, token); 1067 1037 strcpy(raidlist->el[raidlist->entries].raid_device, strtmp); 1068 1038 paranoid_free(strtmp); … … 1123 1093 case ' ': // normal data disks 1124 1094 raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].index = atoi(pos + 1); 1125 asprintf(&strtmp,"%s%s", device_prefix, token);1095 mr_asprintf(&strtmp,"%s%s", device_prefix, token); 1126 1096 strcpy(raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].device, strtmp); 1127 1097 paranoid_free(strtmp); … … 1130 1100 case 'S': // spare disks 1131 1101 raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].index = atoi(pos + 1); 1132 asprintf(&strtmp,"%s%s", device_prefix, token);1102 mr_asprintf(&strtmp,"%s%s", device_prefix, token); 1133 1103 strcpy(raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].device, strtmp); 1134 1104 paranoid_free(strtmp); … … 1137 1107 case 'F': // failed disks 1138 1108 raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].index = atoi(pos + 1); 1139 asprintf(&strtmp,"%s%s", device_prefix, token);1109 mr_asprintf(&strtmp,"%s%s", device_prefix, token); 1140 1110 strcpy(raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].device, strtmp); 1141 1111 paranoid_free(strtmp); -
branches/2.2.9/mondo/src/common/libmondo-stream.c
r2176 r2211 13 13 14 14 #include "my-stuff.h" 15 #include "mr_mem.h" 15 16 #include "mondostructures.h" 16 17 #include "libmondo-devices.h" … … 369 370 } 370 371 if (strstr(fname, "xattr") == NULL) { 371 asprintf(&tmp,"Wrong order expected xattr, got %s, sunshine.", fname);372 mr_asprintf(&tmp,"Wrong order expected xattr, got %s, sunshine.", fname); 372 373 fatal_error(tmp); 373 374 } … … 399 400 } 400 401 if (strstr(fname, "acl") == NULL) { 401 asprintf(&tmp,"Wrong order expected acl, got %s, sunshine.", fname);402 mr_asprintf(&tmp,"Wrong order expected acl, got %s, sunshine.", fname); 402 403 fatal_error(tmp); 403 404 } … … 682 683 683 684 log_it("Skipping OBDR headers"); 684 asprintf(&command, "mt -f %s rewind",bkpinfo->media_device);685 mr_asprintf(&command, "mt -f %s rewind",bkpinfo->media_device); 685 686 res = run_program_and_log_output(command, 1); 686 687 paranoid_free(command); 687 688 688 asprintf(&command, "mt -f %s fsf 2",bkpinfo->media_device);689 mr_asprintf(&command, "mt -f %s fsf 2",bkpinfo->media_device); 689 690 res = run_program_and_log_output(command, 1); 690 691 paranoid_free(command); … … 709 710 log_it("Creating OBDR headers"); 710 711 /* OBDR: First block 10 kB of zero bs = 512 */ 711 asprintf(&command, "mt -f %s compression off",bkpinfo->media_device);712 mr_asprintf(&command, "mt -f %s compression off",bkpinfo->media_device); 712 713 res = run_program_and_log_output(command, 1); 713 714 paranoid_free(command); 714 715 715 asprintf(&command, "mt -f %s rewind",bkpinfo->media_device);716 mr_asprintf(&command, "mt -f %s rewind",bkpinfo->media_device); 716 717 res += run_program_and_log_output(command, 1); 717 718 paranoid_free(command); … … 719 720 set_tape_block_size_with_mt(512); 720 721 721 asprintf(&command, "dd if=/dev/zero of=%s bs=512 count=20",bkpinfo->media_device);722 mr_asprintf(&command, "dd if=/dev/zero of=%s bs=512 count=20",bkpinfo->media_device); 722 723 res += run_program_and_log_output(command, 1); 723 724 paranoid_free(command); … … 726 727 set_tape_block_size_with_mt(2048); 727 728 728 asprintf(&command, "dd if=%s of=%s bs=2048",MINDI_CACHE"/mondorescue.iso",bkpinfo->media_device);729 mr_asprintf(&command, "dd if=%s of=%s bs=2048",MINDI_CACHE"/mondorescue.iso",bkpinfo->media_device); 729 730 res += run_program_and_log_output(command, 1); 730 731 paranoid_free(command); -
branches/2.2.9/mondo/src/common/libmondo-string.c
r2209 r2211 8 8 9 9 #include "my-stuff.h" 10 #include "mr_mem.h" 10 11 #include "mondostructures.h" 11 12 #include "libmondo-string.h" … … 630 631 if (strlen(flaws_str) > 0) { 631 632 paranoid_free(flaws_str_A); 632 asprintf(&flaws_str_A, "%s", flaws_str + 1);633 mr_asprintf(&flaws_str_A, "%s", flaws_str + 1); 633 634 } 634 635 if (strlen(flaws_str_A) >= 74) { 635 636 for (i = 74; flaws_str_A[i] != ' '; i--); 636 637 paranoid_free(flaws_str_B); 637 asprintf(&flaws_str_B, "%s", flaws_str_A + i + 1);638 mr_asprintf(&flaws_str_B, "%s", flaws_str_A + i + 1); 638 639 flaws_str_A[i] = '\0'; 639 640 } … … 641 642 for (i = 74; flaws_str_B[i] != ' '; i--); 642 643 paranoid_free(flaws_str_C); 643 asprintf(&flaws_str_C, "%s", flaws_str_B + i + 1);644 mr_asprintf(&flaws_str_C, "%s", flaws_str_B + i + 1); 644 645 flaws_str_B[i] = '\0'; 645 646 } -
branches/2.2.9/mondo/src/common/libmondo-tools.c
r2205 r2211 10 10 11 11 #include "my-stuff.h" 12 #include "mr_mem.h" 12 13 #include "mondostructures.h" 13 14 #include "lib-common-externs.h" … … 232 233 233 234 uname(&utsn); 234 asprintf(&tmp, "%s", utsn.machine);235 mr_asprintf(&tmp, "%s", utsn.machine); 235 236 return (tmp); 236 237 } … … 420 421 int post_param_configuration() 421 422 { 422 char *extra_cdrom_params ;423 char *mondo_mkisofs_sz ;423 char *extra_cdrom_params = NULL; 424 char *mondo_mkisofs_sz = NULL; 424 425 char *command; 425 426 char *mtpt; 426 char *hostname, *ip_address; 427 char *hostname; 428 char *ip_address = NULL; 427 429 int retval = 0; 428 430 char *colon; … … 440 442 441 443 assert(bkpinfo != NULL); 442 malloc_string(extra_cdrom_params);443 malloc_string(mondo_mkisofs_sz);444 444 malloc_string(command); 445 445 malloc_string(mtpt); 446 446 malloc_string(hostname); 447 malloc_string(ip_address);448 447 malloc_string(cdr_exe); 449 448 malloc_string(tmp); … … 497 496 498 497 if (bkpinfo->backup_media_type == dvd) { 499 extra_cdrom_params[0] = '\0';500 mondo_mkisofs_sz[0] = '\0';501 498 if (find_home_of_exe("growisofs")) { 502 499 strcpy(cdr_exe, "growisofs"); … … 506 503 } 507 504 if (bkpinfo->nonbootable_backup) { 508 strcat(mondo_mkisofs_sz, MONDO_GROWISOFS_NONBOOT);505 mr_asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_NONBOOT); 509 506 } else if 510 507 #ifdef __FreeBSD__ … … 515 512 #ifdef __IA64__ 516 513 { 517 strcat(mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_ELILO);514 mr_asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_ELILO); 518 515 } 519 516 #else 520 517 { 521 strcat(mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_LILO);518 mr_asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_LILO); 522 519 } 523 520 #endif 524 521 else 525 522 { 526 strcat(mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_SYSLINUX);523 mr_asprintf(&mondo_mkisofs_sz, MONDO_GROWISOFS_REGULAR_SYSLINUX); 527 524 } 528 525 if (bkpinfo->manual_cd_tray) { 526 paranoid_free(mondo_mkisofs_sz); 529 527 fatal_error("Manual CD tray + DVD not supported yet."); 530 528 // -m isn't supported by growisofs, BTW... … … 533 531 "%s %s -Z %s . 2>> _ERR_", 534 532 mondo_mkisofs_sz, 535 extra_cdrom_params, bkpinfo->media_device); 533 "", bkpinfo->media_device); 534 paranoid_free(mondo_mkisofs_sz); 536 535 } 537 536 if (getenv ("SUDO_COMMAND")) { … … 549 548 if (bkpinfo->backup_media_type == cdrw 550 549 || bkpinfo->backup_media_type == cdr) { 551 extra_cdrom_params[0] = '\0';552 550 if (!bkpinfo->manual_cd_tray) { 553 strcat(extra_cdrom_params, "-waiti ");551 mr_asprintf(&extra_cdrom_params, "-waiti "); 554 552 } 555 553 if (bkpinfo->backup_media_type == cdrw) { 556 strcat(extra_cdrom_params, "blank=fast ");554 mr_asprintf(&extra_cdrom_params, "blank=fast "); 557 555 } 558 556 if (find_home_of_exe("cdrecord")) { … … 564 562 } 565 563 if (bkpinfo->nonbootable_backup) { 566 strcpy(mondo_mkisofs_sz, MONDO_MKISOFS_NONBOOT);564 mr_asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_NONBOOT); 567 565 } else if 568 566 #ifdef __FreeBSD__ … … 573 571 #ifdef __IA64__ 574 572 { 575 strcat(mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_ELILO);573 mr_asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_ELILO); 576 574 } 577 575 #else 578 576 { 579 strcpy(mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_LILO);577 mr_asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_LILO); 580 578 } 581 579 #endif 582 580 else 583 581 { 584 strcpy(mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_SYSLINUX);582 mr_asprintf(&mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_SYSLINUX); 585 583 } 586 584 if (bkpinfo->manual_cd_tray) { … … 609 607 bkpinfo->cdrw_speed); 610 608 } 609 paranoid_free(mondo_mkisofs_sz); 610 paranoid_free(extra_cdrom_params); 611 611 } // end of CD code 612 612 … … 693 693 retval++; 694 694 } else { 695 strcpy(ip_address, inet_ntoa695 mr_asprintf(&ip_address, inet_ntoa 696 696 ((struct in_addr) 697 697 *((struct in_addr *) hent->h_addr))); 698 strcat(ip_address, strchr(bkpinfo->nfs_mount, ':'));698 mr_strcat(ip_address, strchr(bkpinfo->nfs_mount, ':')); 699 699 strcpy(bkpinfo->nfs_mount, ip_address); 700 paranoid_free(ip_address); 700 701 } 701 702 } … … 718 719 g_backup_media_type = bkpinfo->backup_media_type; 719 720 paranoid_free(mtpt); 720 paranoid_free(extra_cdrom_params);721 paranoid_free(mondo_mkisofs_sz);722 721 paranoid_free(command); 723 722 paranoid_free(hostname); 724 paranoid_free(ip_address);725 723 paranoid_free(cdr_exe); 726 724 paranoid_free(tmp); … … 758 756 759 757 unlink(MONDO_TRACEFILE); 760 asprintf(&tmp,"rm -Rf %s/changed.files*",MONDO_CACHE);758 mr_asprintf(&tmp,"rm -Rf %s/changed.files*",MONDO_CACHE); 761 759 run_program_and_log_output(tmp, FALSE); 762 760 paranoid_free(tmp); … … 783 781 if ((bkpinfo->tmpdir != NULL) && (strstr(bkpinfo->tmpdir,"mondo.tmp.") != NULL)) { 784 782 /* purging a potential old tmpdir */ 785 asprintf(&tmp,"rm -Rf %s",bkpinfo->tmpdir);783 mr_asprintf(&tmp,"rm -Rf %s",bkpinfo->tmpdir); 786 784 system(tmp); 787 785 paranoid_free(tmp); … … 789 787 790 788 if (path != NULL) { 791 asprintf(&tmp, "%s/mondo.tmp.XXXXXX", path);789 mr_asprintf(&tmp, "%s/mondo.tmp.XXXXXX", path); 792 790 } else if (getenv("TMPDIR")) { 793 asprintf(&tmp, "%s/mondo.tmp.XXXXXX", getenv("TMPDIR"));791 mr_asprintf(&tmp, "%s/mondo.tmp.XXXXXX", getenv("TMPDIR")); 794 792 } else if (getenv("TMP")) { 795 asprintf(&tmp, "%s/mondo.tmp.XXXXXX", getenv("TMP"));793 mr_asprintf(&tmp, "%s/mondo.tmp.XXXXXX", getenv("TMP")); 796 794 } else { 797 asprintf(&tmp, "/tmp/mondo.tmp.XXXXXX");795 mr_asprintf(&tmp, "/tmp/mondo.tmp.XXXXXX"); 798 796 } 799 797 p = mkdtemp(tmp); -
branches/2.2.9/mondo/src/common/libmondo-verify.c
r1747 r2211 1 1 /*************************************************************************** 2 libmondo-verify.c - description 3 ----------------- 4 5 begin: Fri Apr 19 16:40:35 EDT 2002 6 copyright : (C) 2002 Mondo Hugo Rabson 7 email : Hugo Rabson <hugorabson@msn.com> 8 edited by : by Stan Benoit 4/2002 9 email : troff@nakedsoul.org 10 cvsid : $Id$ 2 $Id$ 11 3 ***************************************************************************/ 12 13 /***************************************************************************14 * *15 * This program is free software; you can redistribute it and/or modify *16 * it under the terms of the GNU General Public License as published by *17 * the Free Software Foundation; either version 2 of the License, or *18 * (at your option) any later version. *19 * *20 ***************************************************************************/21 /* mondo-verify22 23 24 07/0725 - added star verify support26 27 04/04/200428 - added star support29 30 10/23/200331 - changed "ISO #n" to "<media descriptor> #n"32 33 10/0134 - working on biggiefile verification (CDs)35 36 09/1637 - fixed bug in CD biggie verif'n38 39 09/1540 - state explicitly that we do not verify disk images41 42 09/1343 - working on verify_all_slices_on_CD()44 45 09/0146 - write list of changed biggiefiles (streaming only) to changed.files47 48 05/0549 - exclude /dev/ * from list of changed files50 - add Joshua Oreman's FreeBSD patches51 52 04/24/200353 - added lots of assert()'s and log_OS_error()'s54 55 09/01 - 09/30/200256 - run_program_and_log_output() now takes boolean operator to specify57 whether it will log its activities in the event of _success_58 - eject_device() added59 - cleaned up 'changed file' feedback a little bit60 61 08/01 - 08/3162 - make sure to prefix bkpinfo->restore_path to local biggiefile fname when63 comparing it to the archived copy of biggiefile; otherwise, biggiefile64 not found & checksum missing & so on65 - exclude "incheckentry xwait()" from changed.files66 - cleaned up some log_it() calls67 68 07/01 - 07/3169 - renamed libmondo-verify.c70 - say 'bigfile' not 'biggiefile'71 - exclude /dev/ * from changed.files72 73 01/01 - 06/3074 - remove /tmp/changed.files.* dead files75 - don't pclose() tape after calling closein_tape(): the latter does it already76 - fixed bug in verify_cd_image()'s CD-mounting code77 - don't write to screen "old cksum.. curr cksum.."78 - changed the gawks to awks for the benefit of Debian79 - handles files >2GB in size80 - fixed bug in /tmp/changed.files-generator81 - re-enabled a lot of CD-verification code82 - afioballs are saved in %s/tmpfs/ now (%s=tmpdir)83 - changed some labels to make them more user-friendly84 - don't chdir() anywhere before verifying stuff85 - changed files are now detected by verify_tape_backup() and listed in86 /tmp/changed.files87 - replaced &> with > .. 2>88 - still implementing improved tape support89 90 91 Started late Dec, 200192 93 -----------------------------------------------------------------------------94 */95 4 96 5 … … 101 10 102 11 #include "my-stuff.h" 12 #include "mr_mem.h" 103 13 #include "mondostructures.h" 104 14 #include "libmondo-verify.h" … … 419 329 bkpinfo->restore_path, 420 330 biggiestruct.filename); 421 asprintf(&tmp, "echo \"%s/%s not found\" >> %s/biggies.changed",331 mr_asprintf(&tmp, "echo \"%s/%s not found\" >> %s/biggies.changed", 422 332 bkpinfo->restore_path, 423 333 biggiestruct.filename, … … 1070 980 assert(bkpinfo != NULL); 1071 981 1072 asprintf(&fname, "%s1", bkpinfo->media_device);982 mr_asprintf(&fname, "%s1", bkpinfo->media_device); 1073 983 if (is_this_device_mounted(fname)) { 1074 984 log_msg(1, "USB device mounted. Remounting it at the right place"); 1075 asprintf(&tmp, "umount %s", fname);985 mr_asprintf(&tmp, "umount %s", fname); 1076 986 run_program_and_log_output(tmp, FALSE); 1077 987 paranoid_free(tmp); … … 1080 990 1081 991 log_msg(1, "Mounting USB device."); 1082 asprintf(&mountpoint, "%s/usb", bkpinfo->tmpdir);1083 asprintf(&tmp, "mkdir -p %s", mountpoint);992 mr_asprintf(&mountpoint, "%s/usb", bkpinfo->tmpdir); 993 mr_asprintf(&tmp, "mkdir -p %s", mountpoint); 1084 994 run_program_and_log_output(tmp, FALSE); 1085 995 paranoid_free(tmp); 1086 996 /* Mindi always create one single parition on the USB dev */ 1087 asprintf(&tmp, "mount %s1 %s", bkpinfo->media_device, mountpoint);997 mr_asprintf(&tmp, "mount %s1 %s", bkpinfo->media_device, mountpoint); 1088 998 ret = run_program_and_log_output(tmp, FALSE); 1089 999 paranoid_free(tmp); … … 1095 1005 sync(); 1096 1006 log_msg(2, "OK, I've mounted the USB Disk/Key\n"); 1097 asprintf(&tmp, "%s/archives/NOT-THE-LAST", mountpoint);1007 mr_asprintf(&tmp, "%s/archives/NOT-THE-LAST", mountpoint); 1098 1008 if (!does_file_exist(tmp)) { 1099 1009 log_msg … … 1112 1022 verify_all_slices_on_CD(mountpoint); 1113 1023 1114 asprintf(&tmp1, "umount %s", mountpoint);1024 mr_asprintf(&tmp1, "umount %s", mountpoint); 1115 1025 #ifdef __FreeBSD__ 1116 1026 ret += system(tmp1); … … 1121 1031 #endif 1122 1032 { 1123 asprintf(&tmp, "%s failed; unable to unmount USB device\n", tmp1);1033 mr_asprintf(&tmp, "%s failed; unable to unmount USB device\n", tmp1); 1124 1034 log_to_screen(tmp); 1125 1035 paranoid_free(tmp); -
branches/2.2.9/mondo/src/common/newt-specific.c
r2136 r2211 19 19 20 20 #include "my-stuff.h" 21 #include "mr_mem.h" 21 22 #include "mondostructures.h" 22 23 #include "newt-specific.h" … … 263 264 char *tmp1 = NULL; 264 265 265 asprintf(&tmp,"ps %s | grep \" %s \" | awk '{print %s;}' | grep -v \"grep\"", ps_options, str , ps_proc_id);266 mr_asprintf(&tmp,"ps %s | grep \" %s \" | awk '{print %s;}' | grep -v \"grep\"", ps_options, str , ps_proc_id); 266 267 run_program_and_log_output(tmp, TRUE); 267 268 if (strlen(tmp) > 0) { 268 asprintf(&tmp1,"kill `%s`", tmp);269 mr_asprintf(&tmp1,"kill `%s`", tmp); 269 270 run_program_and_log_output(tmp1, TRUE); 270 271 paranoid_free(tmp1); … … 386 387 run_program_and_log_output("umount " MNT_CDROM, FALSE); 387 388 if (g_selfmounted_isodir) { 388 asprintf(&command, "umount %s", g_selfmounted_isodir);389 mr_asprintf(&command, "umount %s", g_selfmounted_isodir); 389 390 run_program_and_log_output(command, 1); 390 391 paranoid_free(command); 391 asprintf(&command, "rmdir %s", g_selfmounted_isodir);392 mr_asprintf(&command, "rmdir %s", g_selfmounted_isodir); 392 393 run_program_and_log_output(command, 1); 393 394 paranoid_free(command); … … 405 406 printf("Type 'less %s' to see the output log\n", MONDO_LOGFILE); 406 407 if (strstr(bkpinfo->tmpdir ,"mondo.tmp.") != NULL) { 407 asprintf(&command, "rm -Rf %s %s", bkpinfo->tmpdir, bkpinfo->scratchdir);408 mr_asprintf(&command, "rm -Rf %s %s", bkpinfo->tmpdir, bkpinfo->scratchdir); 408 409 system(command); 409 410 paranoid_free(command); … … 956 957 /*@ buffers ********************************************************** */ 957 958 char *timeline_str; 958 char *pcline_str ;959 char *taskprogress ;959 char *pcline_str = NULL; 960 char *taskprogress = NULL; 960 961 961 962 /*@ int ************************************************************** */ … … 965 966 966 967 malloc_string(timeline_str); 967 malloc_string(pcline_str);968 malloc_string(taskprogress);969 968 timeline_str[0] = '\0'; 970 969 // log_it("update_eval_call_form called"); … … 997 996 time_remaining % 60); 998 997 if (percentage < 3) { 999 sprintf(pcline_str, " Working");998 mr_asprintf(&pcline_str, " Working"); 1000 999 for (j = 0; j < g_mysterious_dot_counter; j++) { 1001 strcat(pcline_str, ".");1000 mr_strcat(pcline_str, "."); 1002 1001 } 1003 1002 for (; j < 27; j++) { 1004 strcat(pcline_str, " ");1003 mr_strcat(pcline_str, " "); 1005 1004 } 1006 sprintf(pcline_str + strlen(pcline_str), " %c", 1007 special_dot_char(g_mysterious_dot_counter)); 1005 mr_strcat(pcline_str, " %c", special_dot_char(g_mysterious_dot_counter)); 1008 1006 } else { 1009 sprintf(pcline_str, " %3d%% done %3d%% to go",1007 mr_asprintf(&pcline_str, " %3d%% done %3d%% to go", 1010 1008 percentage, 100 - percentage); 1011 1009 } 1012 1010 if (g_text_mode) { 1013 sprintf(taskprogress, "TASK: [");1011 mr_asprintf(&taskprogress, "TASK: ["); 1014 1012 for (i = 0; i < percentage; i += 5) { 1015 strcat(taskprogress, "*");1013 mr_strcat(taskprogress, "*"); 1016 1014 } 1017 1015 for (; i < 100; i += 5) { 1018 strcat(taskprogress, ".");1016 mr_strcat(taskprogress, "."); 1019 1017 } 1020 1018 if (percentage >= 3) { 1021 sprintf(taskprogress + strlen(taskprogress), 1022 "] %3d%% done; %2ld:%02ld to go", percentage, 1019 mr_strcat(taskprogress, "] %3d%% done; %2ld:%02ld to go", percentage, 1023 1020 time_remaining / 60, time_remaining % 60); 1024 1021 printf("---evalcall---1--- %s\n", … … 1027 1024 printf("---evalcall---E---\n"); 1028 1025 } 1026 paranoid_free(taskprogress); 1029 1027 } else { 1030 1028 newtScaleSet(g_isoform_scale, … … 1037 1035 } 1038 1036 } 1037 paranoid_free(pcline_str); 1039 1038 } 1040 1039 if (!g_text_mode) { … … 1043 1042 } 1044 1043 paranoid_free(timeline_str); 1045 paranoid_free(pcline_str);1046 paranoid_free(taskprogress);1047 1044 } 1048 1045 … … 1099 1096 char *percentline_str; 1100 1097 char *timeline_str; 1101 char *taskprogress ;1098 char *taskprogress = NULL; 1102 1099 char *tmp; 1103 1100 … … 1105 1102 percentline_str = malloc(MAX_NEWT_COMMENT_LEN); 1106 1103 timeline_str = malloc(MAX_NEWT_COMMENT_LEN); 1107 taskprogress = malloc(MAX_NEWT_COMMENT_LEN);1108 1104 malloc_string(tmp); 1109 1105 if (!g_text_mode) { … … 1159 1155 printf("---progress-form---3--- %s\n", blurb3); 1160 1156 printf("---progress-form---E---\n"); 1161 sprintf(taskprogress, "TASK: [");1157 mr_asprintf(&taskprogress, "TASK: ["); 1162 1158 for (i = 0; i < percentage; i += 5) { 1163 strcat(taskprogress, "*");1159 mr_strcat(taskprogress, "*"); 1164 1160 } 1165 1161 for (; i < 100; i += 5) { 1166 strcat(taskprogress, ".");1162 mr_strcat(taskprogress, "."); 1167 1163 } 1168 1164 if (percentage > 100) { 1169 1165 log_msg(2, "percentage = %d", percentage); 1170 1166 } 1171 sprintf(taskprogress + strlen(taskprogress), 1172 "] %3d%c", percentage, '%'); 1173 sprintf(taskprogress + strlen(taskprogress), 1174 " done; %2ld:%02ld to go", 1167 mr_strcat(taskprogress, "] %3d%c", percentage, '%'); 1168 mr_strcat(taskprogress, " done; %2ld:%02ld to go", 1175 1169 time_remaining / 60, time_remaining % 60); 1176 1170 printf("---progress-form---4--- %s\n", taskprogress); 1171 paranoid_free(taskprogress); 1177 1172 } else { 1178 1173 center_string(blurb1, 54); … … 1199 1194 paranoid_free(percentline_str); 1200 1195 paranoid_free(timeline_str); 1201 paranoid_free(taskprogress);1202 1196 paranoid_free(tmp); 1203 1197 } … … 1414 1408 } 1415 1409 1416 asprintf(&tmp1,"%s/icantfindthesefiles.txt",bkpinfo->tmpdir);1410 mr_asprintf(&tmp1,"%s/icantfindthesefiles.txt",bkpinfo->tmpdir); 1417 1411 if (!(fout = fopen(tmp1, "a"))) { 1418 1412 log_msg(2, "Can't write to %s", tmp1); … … 1503 1497 char *filelist_entry_to_string(struct s_filelist_entry *flentry) { 1504 1498 static char comment[100]; 1505 char *tmp ;1499 char *tmp = NULL; 1506 1500 1507 1501 iamhere("entering"); 1508 malloc_string(tmp);1509 1502 assert(flentry != NULL); 1510 1503 if (flentry->severity == 0) { 1511 strcpy(tmp, "0 ");1504 mr_asprintf(&tmp, "0 "); 1512 1505 } else if (flentry->severity == 1) { 1513 strcpy(tmp, "low ");1506 mr_asprintf(&tmp, "low "); 1514 1507 } else if (flentry->severity == 2) { 1515 strcpy(tmp, "med "); 1516 } else { 1517 strcpy(tmp, "high"); 1518 } 1519 strcat(tmp, " "); 1520 strncat(tmp, flentry->filename, 100); 1521 tmp[98] = '\0'; 1522 strcpy(comment, tmp); 1508 mr_asprintf(&tmp, "med "); 1509 } else { 1510 mr_asprintf(&tmp, "high"); 1511 } 1512 mr_strcat(tmp, " "); 1513 mr_strcat(tmp, flentry->filename); 1514 strncpy(comment, tmp, 99); 1523 1515 paranoid_free(tmp); 1516 1524 1517 iamhere("leaving"); 1525 1518 return (comment); -
branches/2.2.9/mondo/src/mondoarchive/Makefile.am
r1930 r2211 11 11 sbin_PROGRAMS = mondoarchive 12 12 mondoarchive_SOURCES = mondoarchive.c 13 mondoarchive_LDADD = ${top_builddir}/src/common/libmondo.a 13 mondoarchive_LDADD = ${top_builddir}/src/common/libmondo.a ${top_builddir}/src/lib/libmr.a -
branches/2.2.9/mondo/src/mondoarchive/mondoarchive.c
r2113 r2211 1 1 /*************************************************************************** 2 main.c - description 3 ------------------- 4 begin : Fri Apr 19 16:40:35 EDT 2002 5 copyright : (C) 2002 by Stan Benoit 6 email : troff@nakedsoul.org 7 cvsid : $Id$ 8 ***************************************************************************/ 9 10 /*************************************************************************** 11 * * 12 * This program is free software; you can redistribute it and/or modify * 13 * it under the terms of the GNU General Public License as published by * 14 * the Free Software Foundation; either version 2 of the License, or * 15 * (at your option) any later version. * 16 * * 17 ***************************************************************************/ 18 19 /** 20 * @file 21 * The main file for mondoarchive. 22 */ 2 $Id$ 3 * The main file for mondoarchive. 4 */ 23 5 24 6 /************************* #include statements *************************/ … … 27 9 #include <stdlib.h> 28 10 #include "my-stuff.h" 11 #include "mr_mem.h" 29 12 #include "../common/mondostructures.h" 30 13 #include "../common/libmondo.h" … … 70 53 /* Reference to global bkpinfo */ 71 54 struct s_bkpinfo *bkpinfo; 55 56 /* No cleanup for the moment */ 57 void (*mr_cleanup)(void) = NULL; 72 58 73 59 /* To be coded */ … … 183 169 char *tmp1 = NULL; 184 170 int res, retval; 185 char *say_at_end ;171 char *say_at_end = NULL; 186 172 187 173 /* Make sure I'm root; abort if not */ … … 211 197 diffs = 0; 212 198 malloc_string(tmp); 213 malloc_string(say_at_end);214 say_at_end[0] = '\0';215 199 malloc_libmondo_global_strings(); 216 200 … … 220 204 221 205 /* make sure PATH environmental variable allows access to mkfs, fdisk, etc. */ 222 asprintf(&tmp1,"%s:/sbin:/usr/sbin:/usr/local/sbin",getenv("PATH"));206 mr_asprintf(&tmp1,"%s:/sbin:/usr/sbin:/usr/local/sbin",getenv("PATH")); 223 207 setenv("PATH", tmp1, 1); 224 208 paranoid_free(tmp1); 225 209 226 210 /* Add the ARCH environment variable for ia64 purposes */ 227 asprintf(&tmp1,"%s",get_architecture());211 mr_asprintf(&tmp1,"%s",get_architecture()); 228 212 setenv("ARCH", tmp1, 1); 229 213 paranoid_free(tmp1); … … 378 362 retval += res; 379 363 if (res) { 380 strcat(say_at_end,364 mr_asprintf(&say_at_end, 381 365 "Data archived. Please check the logs, just as a precaution. "); 382 366 } else { 383 strcat(say_at_end, "Data archived OK. ");367 mr_asprintf(&say_at_end, "Data archived OK. "); 384 368 } 385 369 } … … 391 375 sprintf(tmp, "%d difference%c found.", -res, 392 376 (-res != 1) ? 's' : ' '); 393 strcat(say_at_end, tmp);377 mr_asprintf(&say_at_end, tmp); 394 378 log_to_screen(tmp); 395 379 res = 0; … … 424 408 unlink(MONDO_CACHE"/changed.files"); 425 409 } 426 log_to_screen(say_at_end); 410 if (say_at_end != NULL) { 411 log_to_screen(say_at_end); 412 paranoid_free(say_at_end); 413 } 427 414 sprintf(tmp, "umount %s/tmpfs", bkpinfo->tmpdir); 428 415 run_program_and_log_output(tmp, TRUE); … … 445 432 446 433 free_libmondo_global_strings(); 447 paranoid_free(say_at_end);448 434 449 435 -
branches/2.2.9/mondo/src/mondorestore/mondo-prep.c
r2205 r2211 1 1 /*************************************************************************** 2 2 $Id$ 3 ***************************************************************************/ 4 5 /*************************************************************************** 6 * * 7 * This program is free software; you can redistribute it and/or modify * 8 * it under the terms of the GNU General Public License as published by * 9 * the Free Software Foundation; either version 2 of the License, or * 10 * (at your option) any later version. * 11 * * 12 ***************************************************************************/ 13 14 /** 15 * @file 16 * Functions for prepping hard drives: partitioning, formatting, etc. 17 */ 3 * Functions for prepping hard drives: partitioning, formatting, etc. 4 */ 18 5 19 6 20 7 #include "my-stuff.h" 8 #include "mr_mem.h" 21 9 #include "../common/mondostructures.h" 22 10 #include "mondoprep.h" … … 349 337 log_it("%s... so I'll get creative.", tmp); 350 338 if (lvmversion == 2) { 351 asprintf(&tmp1, "tail -n5 %s | grep Insufficient | tail -n1", MONDO_LOGFILE);339 mr_asprintf(&tmp1, "tail -n5 %s | grep Insufficient | tail -n1", MONDO_LOGFILE); 352 340 strcpy(tmp, call_program_and_get_last_line_of_output(tmp1)); 353 341 free(tmp1); 354 342 } else { 355 asprintf(&tmp1, "tail -n5 %s | grep lvcreate | tail -n1", MONDO_LOGFILE);343 mr_asprintf(&tmp1, "tail -n5 %s | grep lvcreate | tail -n1", MONDO_LOGFILE); 356 344 strcpy(tmp, call_program_and_get_last_line_of_output(tmp1)); 357 345 free(tmp1); … … 596 584 } 597 585 // create device list from normal disks followed by spare ones 598 asprintf(&devices, "%s", raidlist->el[i].data_disks.el[0].device);586 mr_asprintf(&devices, "%s", raidlist->el[i].data_disks.el[0].device); 599 587 for (j = 1; j < raidlist->el[i].data_disks.entries; j++) { 600 asprintf(&strtmp, "%s", devices);588 mr_asprintf(&strtmp, "%s", devices); 601 589 paranoid_free(devices); 602 asprintf(&devices, "%s %s", strtmp,590 mr_asprintf(&devices, "%s %s", strtmp, 603 591 raidlist->el[i].data_disks.el[j].device); 604 592 paranoid_free(strtmp); 605 593 } 606 594 for (j = 0; j < raidlist->el[i].spare_disks.entries; j++) { 607 asprintf(&strtmp, "%s", devices);595 mr_asprintf(&strtmp, "%s", devices); 608 596 paranoid_free(devices); 609 asprintf(&devices, "%s %s", strtmp,597 mr_asprintf(&devices, "%s %s", strtmp, 610 598 raidlist->el[i].spare_disks.el[j].device); 611 599 paranoid_free(strtmp); … … 613 601 // translate RAID level 614 602 if (raidlist->el[i].raid_level == -2) { 615 asprintf(&level, "multipath");603 mr_asprintf(&level, "multipath"); 616 604 } else if (raidlist->el[i].raid_level == -1) { 617 asprintf(&level, "linear");605 mr_asprintf(&level, "linear"); 618 606 } else { 619 asprintf(&level, "raid%d", raidlist->el[i].raid_level);607 mr_asprintf(&level, "raid%d", raidlist->el[i].raid_level); 620 608 } 621 609 // create RAID device: … … 624 612 // - faulty devices ignored 625 613 // - persistent superblock always used as this is recommended 626 asprintf(&program,614 mr_asprintf(&program, 627 615 "mdadm --create --force --run --auto=yes %s --level=%s --raid-devices=%d", 628 616 raidlist->el[i].raid_device, level, 629 617 raidlist->el[i].data_disks.entries); 630 618 if (raidlist->el[i].parity != -1) { 631 asprintf(&strtmp, "%s", program);619 mr_asprintf(&strtmp, "%s", program); 632 620 paranoid_free(program); 633 621 switch(raidlist->el[i].parity) { 634 622 case 0: 635 asprintf(&program, "%s --parity=%s", strtmp, "la");623 mr_asprintf(&program, "%s --parity=%s", strtmp, "la"); 636 624 break; 637 625 case 1: 638 asprintf(&program, "%s --parity=%s", strtmp, "ra");626 mr_asprintf(&program, "%s --parity=%s", strtmp, "ra"); 639 627 break; 640 628 case 2: 641 asprintf(&program, "%s --parity=%s", strtmp, "ls");629 mr_asprintf(&program, "%s --parity=%s", strtmp, "ls"); 642 630 break; 643 631 case 3: 644 asprintf(&program, "%s --parity=%s", strtmp, "rs");632 mr_asprintf(&program, "%s --parity=%s", strtmp, "rs"); 645 633 break; 646 634 default: … … 651 639 } 652 640 if (raidlist->el[i].chunk_size != -1) { 653 asprintf(&strtmp, "%s", program);641 mr_asprintf(&strtmp, "%s", program); 654 642 paranoid_free(program); 655 asprintf(&program, "%s --chunk=%d", strtmp, raidlist->el[i].chunk_size);643 mr_asprintf(&program, "%s --chunk=%d", strtmp, raidlist->el[i].chunk_size); 656 644 paranoid_free(strtmp); 657 645 } 658 646 if (raidlist->el[i].spare_disks.entries > 0) { 659 asprintf(&strtmp, "%s", program);647 mr_asprintf(&strtmp, "%s", program); 660 648 paranoid_free(program); 661 asprintf(&program, "%s --spare-devices=%d", strtmp,649 mr_asprintf(&program, "%s --spare-devices=%d", strtmp, 662 650 raidlist->el[i].spare_disks.entries); 663 651 paranoid_free(strtmp); 664 652 } 665 asprintf(&strtmp, "%s", program);653 mr_asprintf(&strtmp, "%s", program); 666 654 paranoid_free(program); 667 asprintf(&program, "%s %s", strtmp, devices);655 mr_asprintf(&program, "%s %s", strtmp, devices); 668 656 paranoid_free(strtmp); 669 657 res = run_program_and_log_output(program, 1); … … 690 678 { 691 679 /** int **************************************************************/ 692 int res;693 int retval = 0;694 680 #ifdef __FreeBSD__ 695 681 static bool vinum_started_yet = FALSE; … … 698 684 /** buffers ***********************************************************/ 699 685 char *program; 700 char *tmp; 686 char *tmp = NULL; 687 int res = 0; 688 int retval = 0; 701 689 702 690 /** end ****************************************************************/ 703 691 704 692 malloc_string(program); 705 malloc_string(tmp);706 693 assert_string_is_neither_NULL_nor_zerolength(device); 707 694 assert(format != NULL); 708 695 709 696 if (strstr(format, "raid")) { // do not form RAID disks; do it to /dev/md* instead 710 sprintf(tmp, "Not formatting %s (it is a RAID disk)", device);697 mr_asprintf(&tmp, "Not formatting %s (it is a RAID disk)", device); 711 698 log_it(tmp); 699 paranoid_free(tmp); 712 700 paranoid_free(program); 713 paranoid_free(tmp);714 701 return (0); 715 702 } … … 723 710 #endif 724 711 if (strlen(format) <= 2) { 725 sprintf(tmp,712 mr_asprintf(&tmp, 726 713 "%s has a really small format type ('%s') - this is probably a hexadecimal string, which would suggest the partition is an image --- I shouldn't format it", 727 714 device, format); 728 715 log_it(tmp); 716 paranoid_free(tmp); 729 717 paranoid_free(program); 718 return (0); 719 } 720 if (is_this_device_mounted(device)) { 721 mr_asprintf(&tmp, "%s is mounted - cannot format it ", device); 722 log_to_screen(tmp); 730 723 paranoid_free(tmp); 731 return (0);732 }733 if (is_this_device_mounted(device)) {734 sprintf(tmp, "%s is mounted - cannot format it ", device);735 log_to_screen(tmp);736 724 paranoid_free(program); 737 paranoid_free(tmp);738 725 return (1); 739 726 } … … 762 749 FILE *fin; 763 750 char line[MAX_STR_LEN]; 764 sprintf(tmp, 765 "Initializing Vinum device %s (this may take a *long* time)", 766 device); 751 752 mr_asprintf(&tmp, "Initializing Vinum device %s (this may take a *long* time)", device); 767 753 log_to_screen(tmp); 754 paranoid_free(tmp); 755 768 756 /* format raid partition */ 769 757 // sprintf (program, "mkraid --really-force %s", device); --- disabled -- BB, 02/12/2003 … … 780 768 *(strchr(line, '\n')) = '\0'; // get rid of the \n on the end 781 769 782 sprintf(tmp, "Initializing plex: %s", line);770 mr_asprintf(&tmp, "Initializing plex: %s", line); 783 771 open_evalcall_form(tmp); 784 sprintf(tmp, "vinum init %s", line); 772 paranoid_free(tmp); 773 774 mr_asprintf(&tmp, "vinum init %s", line); 785 775 system(tmp); 776 paranoid_free(tmp); 777 786 778 while (1) { 787 sprintf(tmp,779 mr_asprintf(&tmp, 788 780 "vinum lp -r %s | grep '^S' | head -1 | tr -s ' ' | cut -d: -f2 | cut -f1 | sed 's/^ //' | sed 's/I //' | sed 's/%%//'", 789 781 line); 790 782 FILE *pin = popen(tmp, "r"); 783 paranoid_free(tmp); 784 791 785 char status[MAX_STR_LEN / 4]; 792 786 fgets(status, MAX_STR_LEN / 4 - 1, pin); … … 806 800 } 807 801 #else 808 sprintf(tmp, "Initializing RAID device %s", device);802 mr_asprintf(&tmp, "Initializing RAID device %s", device); 809 803 log_to_screen(tmp); 804 paranoid_free(tmp); 810 805 811 806 // Shouldn't be necessary. … … 856 851 } 857 852 res = which_format_command_do_i_need(format, program); 858 sprintf(tmp, "%s %s", program, device);853 mr_asprintf(&tmp, "%s %s", program, device); 859 854 if (strstr(program, "kludge")) { 860 strcat(tmp, " /");855 mr_strcat(tmp, " /"); 861 856 } 862 857 sprintf(program, "sh -c 'echo -en \"y\\ny\\ny\\n\" | %s'", tmp); 863 sprintf(tmp, "Formatting %s as %s", device, format); 858 paranoid_free(tmp); 859 860 mr_asprintf(&tmp, "Formatting %s as %s", device, format); 864 861 update_progress_form(tmp); 862 paranoid_free(tmp); 863 865 864 res = run_program_and_log_output(program, FALSE); 865 mr_asprintf(&tmp, ""); 866 866 if (res && strstr(program, "kludge")) { 867 sprintf(tmp, "Kludge failed; using regular mkfs.%s to format %s",867 mr_strcat(tmp, "Kludge failed; using regular mkfs.%s to format %s", 868 868 format, device); 869 869 #ifdef __FreeBSD__ … … 885 885 retval += res; 886 886 if (retval) { 887 strcat(tmp, "...failed");887 mr_strcat(tmp, "...failed"); 888 888 } else { 889 strcat(tmp, "...OK");889 mr_strcat(tmp, "...OK"); 890 890 } 891 891 892 892 log_to_screen(tmp); 893 paranoid_free(tmp); 894 893 895 paranoid_free(program); 894 paranoid_free(tmp);895 896 system("sync"); 896 897 sleep(1); … … 1717 1718 char *tmp; 1718 1719 char *logfile; 1719 char *output ;1720 char *output = NULL; 1720 1721 1721 1722 /** pointers **********************************************************/ … … 1730 1731 malloc_string(tmp); 1731 1732 malloc_string(logfile); 1732 malloc_string(output);1733 1733 1734 1734 assert_string_is_neither_NULL_nor_zerolength(drive); … … 1745 1745 paranoid_free(tmp); 1746 1746 paranoid_free(logfile); 1747 paranoid_free(output);1748 1747 return (0); 1749 1748 } … … 1766 1765 paranoid_free(tmp); 1767 1766 paranoid_free(logfile); 1768 paranoid_free(output);1769 1767 return (1); 1770 1768 /* … … 1786 1784 /* BERLIOS: should not be called each time */ 1787 1785 part_table_fmt = which_partition_format(drive); 1788 output[0] = '\0';1786 mr_asprintf(&output, ""); 1789 1787 /* make it a primary/extended/logical */ 1790 1788 if (partno <= 4) { 1791 sprintf(output + strlen(output), "n\np\n%d\n", partno);1789 mr_strcat(output, "n\np\n%d\n", partno); 1792 1790 } else { 1793 1791 /* MBR needs an extended partition if more than 4 partitions */ … … 1804 1802 return (1); 1805 1803 } else { 1806 sprintf(output + strlen(output), "n\ne\n%d\n\n\n", 1807 prev_partno + 1); 1804 mr_strcat(output, "n\ne\n%d\n\n\n", prev_partno + 1); 1808 1805 } 1809 1806 } 1810 strcat(output + strlen(output), "n\nl\n");1807 mr_strcat(output, "n\nl\n"); 1811 1808 } else { 1812 1809 /* GPT allows more than 4 primary partitions */ 1813 sprintf(output + strlen(output), "n\np\n%d\n", partno);1814 } 1815 } 1816 strcat(output + strlen(output), "\n"); /*start block (ENTER for next free blk */1810 mr_strcat(output, "n\np\n%d\n", partno); 1811 } 1812 } 1813 mr_strcat(output, "\n"); /*start block (ENTER for next free blk */ 1817 1814 if (partsize > 0) { 1818 1815 if (!strcmp(format, "7")) { … … 1820 1817 partsize += 512; 1821 1818 } 1822 sprintf(output + strlen(output), "+%lldK", (long long) (partsize));1823 } 1824 strcat(output + strlen(output), "\n");1819 mr_strcat(output, "+%lldK", (long long) (partsize)); 1820 } 1821 mr_strcat(output, "\n"); 1825 1822 #if 0 1826 1823 /* … … 1864 1861 } 1865 1862 } else { 1866 strcat(output, "w\n\n");1863 mr_strcat(output, "w\n\n"); 1867 1864 if (g_fprep) { 1868 1865 fprintf(g_fprep, "echo \"%s\" | %s\n", output, program); … … 1916 1913 } 1917 1914 } 1915 paranoid_free(output); 1916 1918 1917 g_current_progress++; 1919 1918 log_it("partition_device() --- leaving"); … … 1922 1921 paranoid_free(tmp); 1923 1922 paranoid_free(logfile); 1924 paranoid_free(output);1925 1923 return (retval); 1926 1924 } … … 2032 2030 char *partition; 2033 2031 char *command; 2034 char *output ;2032 char *output = NULL; 2035 2033 char *tmp; 2036 2034 char *partcode; … … 2051 2049 malloc_string(partition); 2052 2050 malloc_string(command); 2053 malloc_string(output);2054 2051 malloc_string(tmp); 2055 2052 malloc_string(partcode); … … 2138 2135 fput_string_one_char_at_a_time(pout_to_fdisk, "p\n"); 2139 2136 } else { 2140 sprintf(output, "t\n%d\n%s\n", partno, partcode); 2141 strcat(output, "w\n"); 2137 mr_asprintf(&output, "t\n%d\n%s\nw\n", partno, partcode); 2142 2138 sprintf(command, "parted2fdisk %s >> %s 2>> %s", drive, 2143 2139 MONDO_LOGFILE, MONDO_LOGFILE); … … 2154 2150 paranoid_pclose(fout); 2155 2151 } 2152 paranoid_free(output); 2156 2153 } 2157 2154 if (res) { … … 2162 2159 paranoid_free(partition); 2163 2160 paranoid_free(command); 2164 paranoid_free(output);2165 2161 paranoid_free(tmp); 2166 2162 paranoid_free(partcode); -
branches/2.2.9/mondo/src/mondorestore/mondo-rstr-compare.c
r1930 r2211 1 1 /*************************************************************************** 2 mondo-compare.c - compares mondoarchive data3 -------------------4 begin : Fri Apr 25 20035 copyright : (C) 2000 by Hugo Rabson6 email : Hugo Rabson <hugorabson@msn.com>7 2 cvsid : $Id$ 8 3 ***************************************************************************/ 9 4 10 /***************************************************************************11 * *12 * This program is free software; you can redistribute it and/or modify *13 * it under the terms of the GNU General Public License as published by *14 * the Free Software Foundation; either version 2 of the License, or *15 * (at your option) any later version. *16 * *17 ***************************************************************************/18 19 /***************************************************************************20 * Change Log *21 ***************************************************************************22 .23 24 25 26 10/21/200327 - changed "/mnt/cdrom" to MNT_CDROM28 29 10/1830 - don't say unknown compressor if no compressor at all31 32 09/1733 - cleaned up logging & conversion-to-changed.txt34 - cleaned up compare_mode()35 36 09/1637 - fixed bad malloc(),free() pairs in compare_a_biggiefile()38 39 09/1440 - compare_mode() --- a couple of strings were the wrong way round,41 e.g. changed.txt and changed.files42 43 05/0544 - exclude /dev/ * from list of changed files45 46 04/3047 - added textonly mode48 49 04/2750 - improved compare_mode() to allow for ISO/cd/crazy people51 52 04/2553 - first incarnation54 */55 56 57 5 #include <pthread.h> 58 6 #include "my-stuff.h" 7 #include "mr_mem.h" 59 8 #include "../common/mondostructures.h" 60 9 #include "../common/libmondo.h" … … 97 46 char *original_cksum_ptr; 98 47 char *bigfile_fname_ptr; 99 char *tmp_ptr ;48 char *tmp_ptr = NULL; 100 49 char *command_ptr; 101 50 … … 117 66 malloc_string(bigfile_fname_ptr); 118 67 malloc_string(command_ptr); 119 malloc_string(tmp_ptr);120 68 121 69 /********************************************************************* … … 126 74 memset(original_cksum_ptr, '\0', sizeof(original_cksum)); 127 75 memset(bigfile_fname_ptr, '\0', sizeof(bigfile_fname)); 128 memset(tmp_ptr, '\0', sizeof(tmp));129 76 memset(command_ptr, '\0', sizeof(command)); 130 77 /** end **/ … … 134 81 insist_on_this_cd_number((++g_current_media_number)); 135 82 } else { 136 sprintf(tmp_ptr,83 mr_asprintf(&tmp_ptr, 137 84 "No CD's left. No biggiefiles left. No prob, Bob."); 138 85 log_msg(2, tmp_ptr); 86 paranoid_free(tmp_ptr); 139 87 return (0); 140 88 } 141 89 } 142 90 if (!(fin = fopen(slice_fname(bigfileno, 0, ARCHIVES_PATH, ""), "r"))) { 143 sprintf(tmp_ptr,91 mr_asprintf(&tmp_ptr, 144 92 "Cannot open bigfile %ld (%s)'s info file", 145 93 bigfileno + 1, bigfile_fname_ptr); 146 94 log_to_screen(tmp_ptr); 95 paranoid_free(tmp_ptr); 147 96 return (1); 148 97 } … … 156 105 log_msg(2, "biggiestruct.checksum = %s", biggiestruct.checksum); 157 106 158 sprintf(tmp_ptr, "Comparing %s", bigfile_fname_ptr);159 160 107 if (!g_text_mode) { 108 mr_asprintf(&tmp_ptr, "Comparing %s", bigfile_fname_ptr); 161 109 newtDrawRootText(0, 22, tmp_ptr); 110 paranoid_free(tmp_ptr); 162 111 newtRefresh(); 163 112 } … … 173 122 } 174 123 log_msg(2, command_ptr); 175 sprintf(tmp_ptr, "cat /tmp/errors >> %s 2> /dev/null", MONDO_LOGFILE);124 mr_asprintf(&tmp_ptr, "cat /tmp/errors >> %s 2> /dev/null", MONDO_LOGFILE); 176 125 paranoid_system(tmp_ptr); 126 paranoid_free(tmp_ptr); 127 177 128 if (system(command_ptr)) { 178 129 log_OS_error("Warning - command failed"); … … 197 148 } 198 149 } 199 sprintf(tmp_ptr, "bigfile #%ld ('%s') ", bigfileno + 1,150 mr_asprintf(&tmp_ptr, "bigfile #%ld ('%s') ", bigfileno + 1, 200 151 bigfile_fname_ptr); 201 152 if (!strcmp(checksum_ptr, original_cksum_ptr) != 0) { 202 strcat(tmp_ptr, " ... OK");203 } else { 204 strcat(tmp_ptr, "... changed");153 mr_strcat(tmp_ptr, " ... OK"); 154 } else { 155 mr_strcat(tmp_ptr, "... changed"); 205 156 retval++; 206 157 } 207 158 log_msg(1, tmp_ptr); 159 paranoid_free(tmp_ptr); 160 208 161 if (retval) { 209 162 if (!(fout = fopen(MONDO_CACHE"/changed.txt", "a"))) { … … 222 175 paranoid_free(command_ptr); 223 176 paranoid_free(command); 224 paranoid_free(tmp_ptr);225 177 paranoid_free(tmp); 226 178 … … 302 254 303 255 /*** needs malloc *********/ 304 char *command, *tmp, *filelist_name, *logfile, *archiver_exe,256 char *command, *tmp, *filelist_name, *logfile, 305 257 *compressor_exe; 258 char *archiver_exe = NULL; 306 259 307 260 malloc_string(command); … … 309 262 malloc_string(filelist_name); 310 263 malloc_string(logfile); 311 malloc_string(archiver_exe);312 264 malloc_string(compressor_exe); 313 265 … … 331 283 332 284 if (use_star) { 333 strcpy(archiver_exe, "star");334 } else { 335 strcpy(archiver_exe, "afio");285 mr_asprintf(&archiver_exe, "star"); 286 } else { 287 mr_asprintf(&archiver_exe, "afio"); 336 288 } 337 289 … … 344 296 { 345 297 if (!strcmp(compressor_exe, "bzip2")) { 346 strcat(archiver_exe, " -bz");298 mr_strcat(archiver_exe, " -bz"); 347 299 } else { 348 300 fatal_error … … 373 325 BUFSIZE, compressor_exe, tarball_fname, logfile, logfile); 374 326 } 327 paranoid_free(archiver_exe); 328 375 329 #undef BUFSIZE 376 330 … … 405 359 paranoid_free(filelist_name); 406 360 paranoid_free(logfile); 407 paranoid_free(archiver_exe);408 361 paranoid_free(compressor_exe); 409 362 return (retval); -
branches/2.2.9/mondo/src/mondorestore/mondo-rstr-newt.c
r2209 r2211 1 1 /*************************************************************************** 2 2 * $Id$ 3 */4 5 6 /**7 * @file8 3 * Functions for handling GUI interfaces in the restore. 9 4 */ … … 11 6 #ifdef __FreeBSD__ 12 7 #define OSSWAP(linux,fbsd) fbsd 13 //#include <libgen.h>14 8 #else 15 9 #define OSSWAP(linux,fbsd) linux … … 17 11 18 12 #include "mondo-rstr-newt.h" 13 #include "mr_mem.h" 19 14 20 15 //static char cvsid[] = "$Id$"; … … 1950 1945 assert(raidlist != NULL); 1951 1946 1952 asprintf(&flaws_str_A, "%s", "xxxxxxxxx");1953 asprintf(&flaws_str_B, "%s", "xxxxxxxxx");1954 asprintf(&flaws_str_C, "%s", "xxxxxxxxx");1947 mr_asprintf(&flaws_str_A, "%s", " "); 1948 mr_asprintf(&flaws_str_B, "%s", " "); 1949 mr_asprintf(&flaws_str_C, "%s", " "); 1955 1950 if (mountlist->entries > ARBITRARY_MAXIMUM) { 1956 1951 log_to_screen("Arbitrary limits suck, man!"); -
branches/2.2.9/mondo/src/mondorestore/mondo-rstr-tools.c
r2206 r2211 1 1 /*************************************************************************** 2 2 $Id$ 3 4 ***************************************************************************5 * *6 * This program is free software; you can redistribute it and/or modify *7 * it under the terms of the GNU General Public License as published by *8 * the Free Software Foundation; either version 2 of the License, or *9 * (at your option) any later version. *10 * *11 3 ***************************************************************************/ 12 4 … … 14 6 #include <linux/fd.h> 15 7 #include "my-stuff.h" 8 #include "mr_mem.h" 16 9 #include "../common/mondostructures.h" 17 10 #include "../common/libmondo.h" … … 284 277 int iso_fiddly_bits(bool nuke_me_please) 285 278 { 286 char *mount_isodir_command, *tmp, *command; 279 char *mount_isodir_command = NULL; 280 char *tmp, *command; 287 281 int retval = 0, i; 288 282 bool already_mounted = FALSE; 289 283 290 284 assert(bkpinfo != NULL); 291 malloc_string(mount_isodir_command);292 285 malloc_string(tmp); 293 286 malloc_string(command); … … 295 288 read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device); 296 289 if (bkpinfo->disaster_recovery) { 297 /* Patch Conor Daly 26-june-2004 298 * Don't let this clobber an existing bkpinfo->isodir */ 299 if (!bkpinfo->isodir[0]) { 300 strcpy(bkpinfo->isodir, "/tmp/isodir"); 301 } 302 /* End patch */ 303 sprintf(command, "mkdir -p %s", bkpinfo->isodir); 304 run_program_and_log_output(command, 5); 305 log_msg(2, "Setting isodir to %s", bkpinfo->isodir); 306 } 307 308 if (!get_isodir_info 309 (g_isodir_device, g_isodir_format, bkpinfo->isodir, 310 nuke_me_please)) { 311 return (1); 290 /* Patch Conor Daly 26-june-2004 291 * Don't let this clobber an existing bkpinfo->isodir */ 292 if (!bkpinfo->isodir[0]) { 293 strcpy(bkpinfo->isodir, "/tmp/isodir"); 294 } 295 /* End patch */ 296 sprintf(command, "mkdir -p %s", bkpinfo->isodir); 297 run_program_and_log_output(command, 5); 298 log_msg(2, "Setting isodir to %s", bkpinfo->isodir); 299 } 300 301 if (!get_isodir_info(g_isodir_device, g_isodir_format, bkpinfo->isodir, nuke_me_please)) { 302 return (1); 312 303 } 313 304 paranoid_system("umount " MNT_CDROM " 2> /dev/null"); /* just in case */ 314 305 315 306 if (is_this_device_mounted(g_isodir_device)) { 316 log_to_screen("WARNING - isodir is already mounted");317 already_mounted = TRUE;307 log_to_screen("WARNING - isodir is already mounted"); 308 already_mounted = TRUE; 318 309 } else { 319 sprintf(mount_isodir_command, "mount %s", g_isodir_device); 320 if (strlen(g_isodir_format) > 1) { 321 sprintf(mount_isodir_command + strlen(mount_isodir_command), 322 " -t %s", g_isodir_format); 323 } 324 strcat(mount_isodir_command, " -o ro "); 325 strcat(mount_isodir_command, bkpinfo->isodir); 326 run_program_and_log_output("df -m", FALSE); 327 sprintf(tmp, 310 mr_asprintf(&mount_isodir_command, "mount %s", g_isodir_device); 311 if (strlen(g_isodir_format) > 1) { 312 mr_strcat(mount_isodir_command, " -t %s", g_isodir_format); 313 } 314 mr_strcat(mount_isodir_command, " -o ro %s", bkpinfo->isodir); 315 run_program_and_log_output("df -m", FALSE); 316 sprintf(tmp, 328 317 "The 'mount' command is '%s'. PLEASE report this command to be if you have problems, ok?", 329 318 mount_isodir_command); 330 log_msg(1, tmp); 331 if (run_program_and_log_output(mount_isodir_command, FALSE)) { 332 popup_and_OK 333 ("Cannot mount the device where the ISO files are stored."); 334 return (1); 335 } 336 log_to_screen 319 log_msg(1, tmp); 320 if (run_program_and_log_output(mount_isodir_command, FALSE)) { 321 popup_and_OK 322 ("Cannot mount the device where the ISO files are stored."); 323 return (1); 324 } 325 paranoid_free(mount_isodir_command); 326 log_to_screen 337 327 ("I have mounted the device where the ISO files are stored."); 338 328 } … … 351 341 log_msg(2, "%ld: bkpinfo->isodir is now %s", __LINE__, 352 342 bkpinfo->isodir); 353 paranoid_free(mount_isodir_command);354 343 paranoid_free(tmp); 355 344 paranoid_free(command); … … 385 374 386 375 /** malloc **/ 387 char *tmp, *command, *mountdir, *mountpoint, *additional_parameters; 376 char *tmp, *command, *mountdir, *mountpoint; 377 char *additional_parameters = NULL; 388 378 389 379 assert_string_is_neither_NULL_nor_zerolength(device); … … 394 384 malloc_string(mountdir); 395 385 malloc_string(mountpoint); 396 malloc_string(additional_parameters);397 386 398 387 if (!strcmp(mpt, "/1")) { … … 412 401 log_msg(1, tmp); 413 402 /* Deal with additional params only if not /proc or /sys */ 403 mr_asprintf(&additional_parameters, ""); 414 404 if (strcmp(format, "proc") && strcmp(format, "sys")) { 415 405 if (writeable) { 416 strcpy(additional_parameters, "-o rw");406 mr_strcat(additional_parameters, "-o rw"); 417 407 } else { 418 strcpy(additional_parameters, "-o ro");408 mr_strcat(additional_parameters, "-o ro"); 419 409 } 420 410 if (find_home_of_exe("setfattr")) { 421 strcat(additional_parameters, ",user_xattr");411 mr_strcat(additional_parameters, ",user_xattr"); 422 412 } 423 413 if (find_home_of_exe("setfacl")) { 424 strcat(additional_parameters, ",acl");414 mr_strcat(additional_parameters, ",acl"); 425 415 } 426 416 } … … 440 430 log_msg(2, "command='%s'", command); 441 431 } 432 paranoid_free(additional_parameters); 442 433 443 434 res = run_program_and_log_output(command, TRUE); … … 479 470 paranoid_free(mountdir); 480 471 paranoid_free(mountpoint); 481 paranoid_free(additional_parameters);482 472 483 473 return (res); … … 498 488 { 499 489 int retval = 0, lino, res; 500 char *tmp, *these_failed, *format; 501 struct mountlist_itself *mountlist = NULL; 490 char *tmp; 491 char *these_failed = NULL; 492 char *format; 493 struct mountlist_itself *mountlist = NULL; 502 494 503 495 malloc_string(tmp); 504 496 malloc_string(format); 505 malloc_string(these_failed);506 /** menset **/507 these_failed[0] = '\0';508 497 509 498 assert(p_external_copy_of_mountlist != NULL); … … 520 509 "", mountlist->entries); 521 510 511 mr_asprintf(&these_failed, ""); 522 512 for (lino = 0; lino < mountlist->entries; lino++) { 523 513 if (!strcmp(mountlist->el[lino].device, "/proc")) { … … 540 530 retval += res; 541 531 if (res) { 542 strcat(these_failed, mountlist->el[lino].device); 543 strcat(these_failed, " "); 532 mr_strcat(these_failed, "%s ",mountlist->el[lino].device); 544 533 } 545 534 } … … 556 545 ("format and restore *without* partitioning first. Sorry for the inconvenience."); 557 546 } 558 sprintf(tmp, "Could not mount device(s) %s- shall I abort?", 559 these_failed); 547 sprintf(tmp, "Could not mount device(s) %s- shall I abort?", these_failed); 560 548 561 549 if (!ask_me_yes_or_no(tmp)) { … … 573 561 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 574 562 } 563 paranoid_free(these_failed); 564 575 565 /* Also mounting under MNT_RESTORING special FS */ 576 566 (void)mount_device("/proc","/proc","proc",TRUE); … … 580 570 paranoid_free(tmp); 581 571 paranoid_free(format); 582 paranoid_free(these_failed);583 572 return (retval); 584 573 } … … 896 885 read_cfg_var(cfg_file, "acl", value); 897 886 if (strstr(value, "TRUE")) { 898 asprintf(&g_getfacl,"setfacl");887 mr_asprintf(&g_getfacl,"setfacl"); 899 888 log_msg(1, "We will restore ACLs"); 900 889 if (! find_home_of_exe("setfacl")) { … … 904 893 read_cfg_var(cfg_file, "xattr", value); 905 894 if (strstr(value, "TRUE")) { 906 asprintf(&g_getfattr,"setfattr");895 mr_asprintf(&g_getfattr,"setfattr"); 907 896 log_msg(1, "We will restore XATTRs"); 908 897 if (! find_home_of_exe("setfattr")) { … … 1398 1387 * the current /dev location 1399 1388 */ 1400 asprintf(&cmd,"tar cf - /dev | ( cd %s ; tar xf - )",MNT_RESTORING);1389 mr_asprintf(&cmd,"tar cf - /dev | ( cd %s ; tar xf - )",MNT_RESTORING); 1401 1390 run_program_and_log_output(cmd, 3); 1402 1391 paranoid_free(cmd); … … 1410 1399 read_cfg_var(g_mondo_cfg_file, "bootloader.device", device); 1411 1400 read_cfg_var(g_mondo_cfg_file, "bootloader.name", name); 1412 asprintf(&tmp, "run_boot_loader: device='%s', name='%s'", device, name);1401 mr_asprintf(&tmp, "run_boot_loader: device='%s', name='%s'", device, name); 1413 1402 log_msg(2, tmp); 1414 1403 paranoid_free(tmp); … … 1427 1416 #ifdef __FreeBSD__ 1428 1417 else if (!strcmp(name, "BOOT0")) { 1429 asprintf(&tmp, "boot0cfg -B %s", device);1418 mr_asprintf(&tmp, "boot0cfg -B %s", device); 1430 1419 res = run_program_and_log_output(tmp, FALSE); 1431 1420 paranoid_free(tmp); 1432 1421 } else { 1433 asprintf(&tmp, "ls /dev | grep -Eq '^%ss[1-4].*'", device);1422 mr_asprintf(&tmp, "ls /dev | grep -Eq '^%ss[1-4].*'", device); 1434 1423 if (!system(tmp)) { 1435 1424 paranoid_free(tmp); 1436 asprintf(&tmp, MNT_RESTORING "/sbin/fdisk -B %s", device);1425 mr_asprintf(&tmp, MNT_RESTORING "/sbin/fdisk -B %s", device); 1437 1426 res = run_program_and_log_output(tmp, 3); 1438 1427 } else { … … 2019 2008 int retval = 0, lino, res = 0, i; 2020 2009 char *command; 2021 char *tmp ;2010 char *tmp = NULL; 2022 2011 2023 2012 malloc_string(command); 2024 malloc_string(tmp);2025 2013 assert(p_external_copy_of_mountlist != NULL); 2026 2014 … … 2049 2037 paranoid_system("sync"); 2050 2038 2051 sprintf(tmp, "cp -f %s " MNT_RESTORING "/var/log", MONDO_LOGFILE);2039 mr_asprintf(&tmp, "cp -f %s " MNT_RESTORING "/var/log", MONDO_LOGFILE); 2052 2040 if (run_program_and_log_output(tmp, FALSE)) { 2053 2041 log_msg(1, 2054 2042 "Error. Failed to copy log to PC's /var/log dir. (Mounted read-only?)"); 2055 2043 } 2044 paranoid_free(tmp); 2056 2045 if (does_file_exist("/tmp/DUMBASS-GENTOO")) { 2057 2046 run_program_and_log_output("mkdir -p " MNT_RESTORING … … 2067 2056 continue; 2068 2057 } 2069 sprintf(tmp, "Unmounting device %s ", mountlist->el[lino].device);2058 mr_asprintf(&tmp, "Unmounting device %s ", mountlist->el[lino].device); 2070 2059 2071 2060 update_progress_form(tmp); 2061 2072 2062 if (is_this_device_mounted(mountlist->el[lino].device)) { 2073 2063 if (!strcmp(mountlist->el[lino].mountpoint, "swap")) { … … 2094 2084 res = run_program_and_log_output(command, 3); 2095 2085 } else { 2096 strcat(tmp, "...not mounted anyway :-) OK");2086 mr_strcat(tmp, "...not mounted anyway :-) OK"); 2097 2087 res = 0; 2098 2088 } 2099 2089 g_current_progress++; 2100 2090 if (res) { 2101 strcat(tmp, "...Failed");2091 mr_strcat(tmp, "...Failed"); 2102 2092 retval++; 2103 2093 log_to_screen(tmp); … … 2105 2095 log_msg(2, tmp); 2106 2096 } 2097 paranoid_free(tmp); 2107 2098 } 2108 2099 close_progress_form(); … … 2119 2110 free(mountlist); 2120 2111 paranoid_free(command); 2121 paranoid_free(tmp);2122 2112 return (retval); 2123 2113 } -
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); -
branches/2.2.9/mondo/test/test-mountlist.c
r2209 r2211 1 /* 2 * $Id$ 3 * 4 * Test program for mountlist management at restore time 5 * Cn be used on host system with valgrind easier than with mondorestore 6 */ 1 7 #include <stdio.h> 2 8 #include "my-stuff.h" 9 #include "mr_mem.h" 3 10 #include "../common/mondostructures.h" 4 11 #include "../common/libmondo.h" … … 44 51 struct raidlist_itself *raidlist; 45 52 46 asprintf(&MONDO_LOGFILE,"/tmp/mrtest-mountlist.log");53 mr_asprintf(&MONDO_LOGFILE,"/tmp/mrtest-mountlist.log"); 47 54 48 55 /* Globals */ … … 60 67 61 68 setup_newt_stuff(); 62 asprintf(&g_mountlist_fname, "/tmp/mountlist.txt");69 mr_asprintf(&g_mountlist_fname, "/tmp/mountlist.txt"); 63 70 log_it("before mountlist"); 64 71 load_mountlist(mountlist, g_mountlist_fname);
Note:
See TracChangeset
for help on using the changeset viewer.