Changeset 2211 in MondoRescue for branches/2.2.9/mondo/src/common/libmondo-archive.c
- Timestamp:
- Jun 3, 2009, 7:10:19 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mondo/src/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);
Note:
See TracChangeset
for help on using the changeset viewer.