Changeset 2211 in MondoRescue for branches/2.2.9/mondo/src/common
- Timestamp:
- Jun 3, 2009, 7:10:19 PM (16 years ago)
- Location:
- branches/2.2.9/mondo/src/common
- Files:
-
- 11 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);
Note:
See TracChangeset
for help on using the changeset viewer.