Changeset 2296 in MondoRescue
- Timestamp:
- Jul 23, 2009, 2:53:30 PM (15 years ago)
- Location:
- branches/2.2.10
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-archive.c
r2291 r2296 350 350 paranoid_free(command); 351 351 352 mr_asprintf(&command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s", 353 TAPE_BLOCK_SIZE, zipparams, fname, filelist, MONDO_LOGFILE); 352 mr_asprintf(&command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s", TAPE_BLOCK_SIZE, zipparams, fname, filelist, MONDO_LOGFILE); 354 353 paranoid_free(zipparams); 355 354 … … 867 866 log_msg(1, "lines_in_filelist = %ld", lines_in_filelist); 868 867 869 mr_asprintf(&command, 870 /* "mindi --custom 2=%s 3=%s/images 4=\"%s\" 5=\"%s\" \ 868 /* "mindi 1=%s --custom 2=%s 3=%s/images 4=\"%s\" 5=\"%s\" \ 871 869 6=\"%s\" 7=%ld 8=\"%s\" 9=\"%s\" 10=\"%s\" \ 872 870 11=\"%s\" 12=%s 13=%ld 14=\"%s\" 15=\"%s\" 16=\"%s\" 17=\"%s\" 18=%ld 19=%d",*/ 873 871 mr_asprintf(&command, "mindi %s --custom %s %s/images '%s' '%s' \ 874 872 '%s' %ld '%s' '%s' '%s' \ 875 873 '%s' %s %ld '%s' '%s' '%s' '%s' %ld %d '%s'", tmp2, bkpinfo->tmpdir, // parameter #2 … … 1076 1074 this_thread_no, archiving_set_no); 1077 1075 if (g_getfattr) { 1078 mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, 1079 bkpinfo->tmpdir, archiving_set_no); 1076 mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no); 1080 1077 get_fattr_list(archiving_filelist_fname, curr_xattr_list_fname); 1081 1078 mr_free(curr_xattr_list_fname); 1082 1079 } 1083 1080 if (g_getfacl) { 1084 mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, 1085 bkpinfo->tmpdir, archiving_set_no); 1081 mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no); 1086 1082 get_acl_list(archiving_filelist_fname, curr_acl_list_fname); 1087 1083 mr_free(curr_acl_list_fname); … … 1097 1093 1098 1094 if (res) { 1099 mr_asprintf(&tmp, 1100 "Errors occurred while archiving set %ld. Please review logs.", 1101 archiving_set_no); 1095 mr_asprintf(&tmp, "Errors occurred while archiving set %ld. Please review logs.", archiving_set_no); 1102 1096 log_to_screen(tmp); 1103 1097 mr_free(tmp); … … 1427 1421 } else { 1428 1422 // store set N 1429 mr_asprintf(&storing_filelist_fname, FILELIST_FNAME_RAW_SZ, 1430 bkpinfo->tmpdir, storing_set_no); 1431 mr_asprintf(&storing_afioball_fname, AFIOBALL_FNAME_RAW_SZ, 1432 bkpinfo->tmpdir, storing_set_no, bkpinfo->zip_suffix); 1423 mr_asprintf(&storing_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, storing_set_no); 1424 mr_asprintf(&storing_afioball_fname, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir, storing_set_no, bkpinfo->zip_suffix); 1433 1425 if (g_getfattr) { 1434 mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, 1435 bkpinfo->tmpdir, storing_set_no); 1426 mr_asprintf(&curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, storing_set_no); 1436 1427 } 1437 1428 if (g_getfacl) { 1438 mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, 1439 bkpinfo->tmpdir, storing_set_no); 1429 mr_asprintf(&curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, storing_set_no); 1440 1430 } 1441 1431 … … 1491 1481 mr_free(media_usage_comment); 1492 1482 if (res) { 1493 mr_asprintf(&tmp, "Failed to add archive %ld's files to CD dir\n", 1494 storing_set_no); 1483 mr_asprintf(&tmp, "Failed to add archive %ld's files to CD dir\n", storing_set_no); 1495 1484 log_to_screen(tmp); 1496 1485 paranoid_free(tmp); … … 1717 1706 1718 1707 if (bkpinfo->call_before_iso[0] != '\0') { 1719 mr_asprintf(&message_to_screen, "Running pre-ISO call for CD#%d", 1720 g_current_media_number); 1708 mr_asprintf(&message_to_screen, "Running pre-ISO call for CD#%d", g_current_media_number); 1721 1709 res = 1722 1710 eval_call_to_make_ISO(bkpinfo->call_before_iso, … … 1763 1751 retval += res; 1764 1752 #ifdef DVDRWFORMAT 1765 mr_asprintf(&tmp, 1766 "tail -n8 %s | grep 'blank=full.*dvd-compat.*DAO'", 1767 MONDO_LOGFILE); 1753 mr_asprintf(&tmp, "tail -n8 %s | grep 'blank=full.*dvd-compat.*DAO'", MONDO_LOGFILE); 1768 1754 if (g_backup_media_type == dvd 1769 1755 && (res || !run_program_and_log_output(tmp, 1))) { … … 2089 2075 "Calling ntfsclone in background because %s is an NTFS partition", 2090 2076 bigfile_fname); 2091 mr_asprintf(&sz_devfile, "%s/%d.%d.000", bkpinfo->tmpdir, 2092 (int) (random() % 32768), 2093 (int) (random() % 32768)); 2077 mr_asprintf(&sz_devfile, "%s/%d.%d.000", bkpinfo->tmpdir, (int) (random() % 32768), (int) (random() % 32768)); 2094 2078 mkfifo(sz_devfile, 0x770); 2095 2079 ntfsprog_fifo = sz_devfile; … … 2774 2758 mr_asprintf(&tmp, "cat %s 2> /dev/null", szserfname); 2775 2759 mr_free(our_serial_str); 2776 mr_asprintf(&our_serial_str, "%s", 2777 call_program_and_get_last_line_of_output(tmp)); 2760 mr_asprintf(&our_serial_str, "%s", call_program_and_get_last_line_of_output(tmp)); 2778 2761 mr_free(tmp); 2779 2762 // FIXME - should be able to use last_line_of_file(), surely? … … 2812 2795 eject_device(cdrom_dev); 2813 2796 mds = media_descriptor_string(g_backup_media_type); 2814 mr_asprintf(&tmp, "I am about to burn %s #%d of the backup set. Please insert %s and press Enter.", 2815 mds, g_current_media_number, mds); 2797 mr_asprintf(&tmp, "I am about to burn %s #%d of the backup set. Please insert %s and press Enter.", mds, g_current_media_number, mds); 2816 2798 mr_free(mds); 2817 2799 … … 3114 3096 mr_asprintf(&tmp, "Problem with slice # %ld", slice_num); 3115 3097 } else { 3116 mr_asprintf(&tmp, "%s - Bigfile #%ld, slice #%ld compressed OK ", biggie_filename, biggie_file_number + 1, 3117 slice_num); 3098 mr_asprintf(&tmp, "%s - Bigfile #%ld, slice #%ld compressed OK ", biggie_filename, biggie_file_number + 1, slice_num); 3118 3099 } 3119 3100 #ifndef _XWIN … … 3351 3332 if (space_occupied_by_cd(bkpinfo->scratchdir) / 1024 > 3352 3333 bkpinfo->media_size[g_current_media_number]) { 3353 mr_asprintf(&tmp1, 3354 "Warning! CD is too big. It occupies %ld KB, which is more than the %ld KB allowed.", 3355 (long) space_occupied_by_cd(bkpinfo->scratchdir), 3334 mr_asprintf(&tmp1, "Warning! CD is too big. It occupies %ld KB, which is more than the %ld KB allowed.", (long) space_occupied_by_cd(bkpinfo->scratchdir), 3356 3335 (long) bkpinfo->media_size[g_current_media_number]); 3357 3336 log_to_screen(tmp1); 3358 3337 mr_free(tmp1); 3359 3338 } 3360 mr_asprintf(&isofile, "%s/%s/%s-%d.iso", bkpinfo->isodir, 3361 bkpinfo->nfs_remote_dir, bkpinfo->prefix, 3362 g_current_media_number); 3339 mr_asprintf(&isofile, "%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, g_current_media_number); 3363 3340 for (that_one_was_ok = FALSE; !that_one_was_ok;) { 3364 3341 if (bkpinfo->backup_media_type != usb) { … … 3421 3398 } 3422 3399 wipe_archives(bkpinfo->scratchdir); 3423 mr_asprintf(&tmp1, "rm -Rf %s/images/*gz %s/images/*data*img", 3424 bkpinfo->scratchdir, bkpinfo->scratchdir); 3400 mr_asprintf(&tmp1, "rm -Rf %s/images/*gz %s/images/*data*img", bkpinfo->scratchdir, bkpinfo->scratchdir); 3425 3401 if (system(tmp1)) { 3426 3402 log_msg -
branches/2.2.10/mondo/src/common/libmondo-cli.c
r2291 r2296 901 901 } 902 902 flag_set['d'] = TRUE; 903 mr_asprintf(&tmp1, 904 "You didn't specify a tape streamer device. I'm assuming %s", 905 flag_val['d']); 903 mr_asprintf(&tmp1, "You didn't specify a tape streamer device. I'm assuming %s", flag_val['d']); 906 904 log_to_screen(tmp1); 907 905 mr_free(tmp1); … … 1184 1182 1185 1183 if (flag_set['b']) { 1186 mr_asprintf(&psz, flag_val['b']);1184 mr_asprintf(&psz, "%s", flag_val['b']); 1187 1185 log_msg(1, "psz = '%s'", psz); 1188 1186 if (psz[strlen(psz) - 1] == 'k') { … … 1230 1228 && !does_file_exist(bkpinfo->kernel_path)) { 1231 1229 retval++; 1232 mr_asprintf(&tmp1, 1233 "You specified kernel '%s', which does not exist\n", 1234 bkpinfo->kernel_path); 1230 mr_asprintf(&tmp1, "You specified kernel '%s', which does not exist\n", bkpinfo->kernel_path); 1235 1231 log_to_screen(tmp1); 1236 1232 mr_free(tmp1); … … 1272 1268 if (i) { 1273 1269 retval++; 1274 mr_asprintf(&tmp2, 1275 "Are you sure directory '%s' exists in remote dir '%s'?\nIf so, do you have rights to write to it?\n", 1276 bkpinfo->nfs_remote_dir, bkpinfo->nfs_mount); 1270 mr_asprintf(&tmp2, "Are you sure directory '%s' exists in remote dir '%s'?\nIf so, do you have rights to write to it?\n", bkpinfo->nfs_remote_dir, bkpinfo->nfs_mount); 1277 1271 log_to_screen(tmp2); 1278 1272 mr_free(tmp2); … … 1593 1587 case SIGKILL: 1594 1588 mr_asprintf(&tmp, "SIGKILL"); 1595 mr_asprintf(&tmp2, 1596 "I seriously have no clue how this signal even got to me. Something's wrong with your system."); 1589 mr_asprintf(&tmp2, "I seriously have no clue how this signal even got to me. Something's wrong with your system."); 1597 1590 break; 1598 1591 case SIGTERM: … … 1606 1599 case SIGSEGV: 1607 1600 mr_asprintf(&tmp, "SIGSEGV"); 1608 mr_asprintf(&tmp2, 1609 "Internal programming error. Please send a backtrace as well as your log."); 1601 mr_asprintf(&tmp2, "Internal programming error. Please send a backtrace as well as your log."); 1610 1602 break; 1611 1603 case SIGPIPE: -
branches/2.2.10/mondo/src/common/libmondo-devices.c
r2291 r2296 257 257 mr_asprintf(&command, "cdcontrol -f %s close", dev); 258 258 } else { 259 mr_asprintf(&command, "camcontrol load `echo %s | sed 's|/dev/||'`", 260 dev); 259 mr_asprintf(&command, "camcontrol load `echo %s | sed 's|/dev/||'`", dev); 261 260 } 262 261 #else … … 343 342 #ifdef __FreeBSD__ 344 343 // We assume here that this is running from mondorestore. (It is.) 345 mr_asprintf(&program, "ls %s %s >/dev/null 2>&1", drive, 346 build_partition_name(tmp, drive, partno)); 344 mr_asprintf(&program, "ls %s %s >/dev/null 2>&1", drive, build_partition_name(tmp, drive, partno)); 347 345 res = system(program); 348 346 mr_free(program); … … 399 397 assert_string_is_neither_NULL_nor_zerolength(str); 400 398 401 mr_asprintf(&command, 402 "dd if=%s bs=446 count=1 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null", 403 dev, str); 399 mr_asprintf(&command, "dd if=%s bs=446 count=1 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null", dev, str); 404 400 i = system(command); 405 401 mr_free(command); … … 425 421 int i; 426 422 427 mr_asprintf(&command, 428 "dd if=%s bs=512 count=%i 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null", 429 dev, n, str); 423 mr_asprintf(&command, "dd if=%s bs=512 count=%i 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null", dev, n, str); 430 424 i = system(command); 431 425 mr_free(command); … … 530 524 } 531 525 if (find_home_of_exe(cdr_exe)) { 532 mr_asprintf(&command, 533 "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep CD | cut -d' ' -f2 | head -n1", 534 cdr_exe); 526 mr_asprintf(&command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep CD | cut -d' ' -f2 | head -n1", cdr_exe); 535 527 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 536 528 mr_free(command); … … 848 840 } 849 841 850 mr_asprintf(&command, 851 "%s -scanbus | grep \"[0-9],[0-9],[0-9]\" | grep \"[D|C][V|D]\" | grep -n \"\" | grep \"%s\" | cut -d':' -f2", 852 cdr_exe, g_cdrw_drive_is_here); 842 mr_asprintf(&command, "%s -scanbus | grep \"[0-9],[0-9],[0-9]\" | grep \"[D|C][V|D]\" | grep -n \"\" | grep \"%s\" | cut -d':' -f2", cdr_exe, g_cdrw_drive_is_here); 853 843 log_msg(1, "command=%s", command); 854 844 mr_asprintf(&tmp1, "%s", call_program_and_get_last_line_of_output(command)); … … 1042 1032 1043 1033 #ifdef __FreeBSD__ 1044 mr_asprintf(&command, 1045 "lsvfs | tr -s '\t' ' ' | grep -v Filesys | grep -v -- -- | cut -d' ' -f1 | tr -s '\n' ' '"); 1034 mr_asprintf(&command, "lsvfs | tr -s '\t' ' ' | grep -v Filesys | grep -v -- -- | cut -d' ' -f1 | tr -s '\n' ' '"); 1046 1035 #else 1047 mr_asprintf(&command, 1048 "grep -v nodev /proc/filesystems | tr -s '\t' ' ' | cut -d' ' -f2 | tr -s '\n' ' '"); 1036 mr_asprintf(&command, "grep -v nodev /proc/filesystems | tr -s '\t' ' ' | cut -d' ' -f2 | tr -s '\n' ' '"); 1049 1037 #endif 1050 1038 … … 1243 1231 1244 1232 #ifdef __FreeBSD__ 1245 mr_asprintf(&command, "mount_vfat %s %s 2>> %s", 1246 device, mountpoint, MONDO_LOGFILE); 1233 mr_asprintf(&command, "mount_vfat %s %s 2>> %s", device, mountpoint, MONDO_LOGFILE); 1247 1234 1248 1235 #else 1249 mr_asprintf(&command, "mount %s -t vfat %s 2>> %s", 1250 device, mountpoint, MONDO_LOGFILE); 1236 mr_asprintf(&command, "mount %s -t vfat %s 2>> %s", device, mountpoint, MONDO_LOGFILE); 1251 1237 #endif 1252 1238 … … 1382 1368 mr_free(tmp); 1383 1369 1384 mr_asprintf(&tmp, "%s/%s/%s-%d.iso", bkpinfo->isodir, 1385 bkpinfo->nfs_remote_dir, bkpinfo->prefix, 1386 cd_number_i_want); 1370 mr_asprintf(&tmp, "%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, cd_number_i_want); 1387 1371 if (!does_file_exist(tmp)) { 1388 1372 mr_free(tmp); 1389 mr_asprintf(&tmp, "%s/isodir/%s/%s-%d.iso", bkpinfo->tmpdir, 1390 bkpinfo->nfs_remote_dir, bkpinfo->prefix, 1391 cd_number_i_want); 1373 mr_asprintf(&tmp, "%s/isodir/%s/%s-%d.iso", bkpinfo->tmpdir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, cd_number_i_want); 1392 1374 if (does_file_exist(tmp)) { 1393 1375 log_msg(1, … … 1550 1532 mr_free(tmp); 1551 1533 1552 mr_asprintf(&comment, 1553 "How much data (in Megabytes) will each %s store?", mds); 1534 mr_asprintf(&comment, "How much data (in Megabytes) will each %s store?", mds); 1554 1535 mr_free(mds); 1555 1536 if (!popup_and_get_string("Size", comment, sz_size, 5)) { … … 1588 1569 log_msg(1, "bkpinfo->media_device = %s", 1589 1570 bkpinfo->media_device); 1590 mr_asprintf(&comment, 1591 "Please specify your %s drive's /dev entry", mds); 1571 mr_asprintf(&comment, "Please specify your %s drive's /dev entry", mds); 1592 1572 if (!popup_and_get_string 1593 1573 ("Device?", comment, bkpinfo->media_device, … … 1761 1741 1762 1742 if (!bkpinfo->restore_data) { 1763 mr_asprintf(&comment, 1764 "How much data (in Megabytes) will each media store?"); 1743 mr_asprintf(&comment, "How much data (in Megabytes) will each media store?"); 1765 1744 if (!popup_and_get_string("Size", comment, sz_size, 5)) { 1766 1745 mr_free(comment); -
branches/2.2.10/mondo/src/common/libmondo-fifo.c
r2291 r2296 88 88 for (bufsize = wise_upper_limit, res = -1; 89 89 res != 0 && bufsize >= wise_lower_limit; bufsize--) { 90 mr_asprintf(&tmp, 91 "dd if=/dev/zero bs=1024 count=16k 2> /dev/null | buffer -o /dev/null -s %ld -m %d%c", 92 internal_tape_block_size, bufsize, 'm'); 90 mr_asprintf(&tmp, "dd if=/dev/zero bs=1024 count=16k 2> /dev/null | buffer -o /dev/null -s %ld -m %d%c", internal_tape_block_size, bufsize, 'm'); 93 91 res = run_program_and_log_output(tmp, 2); 94 92 mr_free(tmp); -
branches/2.2.10/mondo/src/common/libmondo-filelist.c
r2291 r2296 500 500 mr_free(command); 501 501 502 mr_asprintf(&command, 503 "getfacl --all-effective -P %s 2>> %s | gzip -c1 > %s 2>> %s", 504 filelist, MONDO_LOGFILE, facl_fname, MONDO_LOGFILE); 502 mr_asprintf(&command, "getfacl --all-effective -P %s 2>> %s | gzip -c1 > %s 2>> %s", filelist, MONDO_LOGFILE, facl_fname, MONDO_LOGFILE); 505 503 log_it("%s",command); 506 504 retval = system(command); -
branches/2.2.10/mondo/src/common/libmondo-files.c
r2289 r2296 71 71 mr_free(command); 72 72 } else { 73 mr_asprintf(&tmp, "File '%s' not found; cannot calc checksum", 74 filename); 73 mr_asprintf(&tmp, "File '%s' not found; cannot calc checksum", filename); 75 74 log_it(tmp); 76 75 mr_free(tmp); … … 143 142 assert_string_is_neither_NULL_nor_zerolength(filename); 144 143 if (!does_file_exist(filename)) { 145 mr_asprintf(&tmp, 146 "%s does not exist, so I cannot found the number of lines in it", 147 filename); 144 mr_asprintf(&tmp, "%s does not exist, so I cannot found the number of lines in it", filename); 148 145 log_it(tmp); 149 146 mr_free(tmp); … … 358 355 return (NULL); // forget it :) 359 356 } 360 mr_asprintf(&command, 361 "file %s 2> /dev/null | cut -d':' -f1 2> /dev/null", 362 incoming); 357 mr_asprintf(&command, "file %s 2> /dev/null | cut -d':' -f1 2> /dev/null", incoming); 363 358 strcpy(incoming, 364 359 call_program_and_get_last_line_of_output(command)); … … 459 454 && !strstr(err_log_lines[i], "% done"); i--); 460 455 if (i < 0) { 461 mr_asprintf(&command, 462 "tail -n3 %s | grep -Fi \"%c\" | tail -n1 | awk '{print $0;}'", 463 filename, '%'); 456 mr_asprintf(&command, "tail -n3 %s | grep -Fi \"%c\" | tail -n1 | awk '{print $0;}'", filename, '%'); 464 457 strcpy(lastline, 465 458 call_program_and_get_last_line_of_output(command)); … … 512 505 513 506 if (!does_file_exist(filename)) { 514 mr_asprintf(&tmp, "Tring to get last line of nonexistent file (%s)", 515 filename); 507 mr_asprintf(&tmp, "Tring to get last line of nonexistent file (%s)", filename); 516 508 log_it(tmp); 517 509 mr_free(tmp); … … 630 622 time_remaining = 631 623 time_taken * 100 / (long) (percentage) - time_taken; 632 mr_asprintf(&tmp, 633 "%02d%% done %02d:%02d taken %02d:%02d remaining %-37s\r", 634 percentage, (int) (time_taken / 60), 635 (int) (time_taken % 60), 636 (int) (time_remaining / 60), 637 (int) (time_remaining % 60), curr_fname); 624 mr_asprintf(&tmp, "%02d%% done %02d:%02d taken %02d:%02d remaining %-37s\r", percentage, (int) (time_taken / 60), (int) (time_taken % 60), (int) (time_remaining / 60), (int) (time_remaining % 60), curr_fname); 638 625 log_to_screen(tmp); 639 626 mr_free(tmp); … … 758 745 759 746 mr_asprintf(&mountlist, "%s/mountlist.txt", tmpdir); 760 mr_asprintf(&command, 761 "grep \"%s \" %s/mountlist.txt | head -n1 | awk '{print $4}'", 762 dev, tmpdir); 747 mr_asprintf(&command, "grep \"%s \" %s/mountlist.txt | head -n1 | awk '{print $4}'", dev, tmpdir); 763 748 mr_free(mountlist); 764 749 … … 837 822 log_msg(4, "%s --> %ld K", fname, file_len_K); 838 823 } 839 mr_asprintf(&comment, 840 "After adding %s, scratchL+%ld now equals %ld", fname, 841 file_len_K, scratchL); 824 mr_asprintf(&comment, "After adding %s, scratchL+%ld now equals %ld", fname, file_len_K, scratchL); 842 825 log_msg(4, comment); 843 826 mr_free(comment); … … 1060 1043 find_and_store_mondoarchives_home(g_mondo_home); 1061 1044 } 1062 mr_asprintf(&command, CP_BIN " --parents -pRdf %s %s", g_mondo_home, 1063 bkpinfo->scratchdir); 1045 mr_asprintf(&command, CP_BIN " --parents -pRdf %s %s", g_mondo_home, bkpinfo->scratchdir); 1064 1046 1065 1047 log_msg(4, "command = %s", command); … … 1071 1053 } 1072 1054 1073 mr_asprintf(&command, "cp -f %s/LAST-FILELIST-NUMBER %s", bkpinfo->tmpdir, 1074 bkpinfo->scratchdir); 1055 mr_asprintf(&command, "cp -f %s/LAST-FILELIST-NUMBER %s", bkpinfo->tmpdir, bkpinfo->scratchdir); 1075 1056 res = run_program_and_log_output(command, FALSE); 1076 1057 mr_free(command); … … 1099 1080 1100 1081 if (bkpinfo->postnuke_tarball[0]) { 1101 mr_asprintf(&command, "cp -f %s %s/post-nuke.tgz", 1102 bkpinfo->postnuke_tarball, bkpinfo->tmpdir); 1082 mr_asprintf(&command, "cp -f %s %s/post-nuke.tgz", bkpinfo->postnuke_tarball, bkpinfo->tmpdir); 1103 1083 res = run_program_and_log_output(command, FALSE); 1104 1084 mr_free(command); … … 1150 1130 } 1151 1131 *(p++) = '\0'; 1152 mr_asprintf(&nfs_server_ipaddr, tmp);1153 mr_asprintf(&nfs_mount, p);1132 mr_asprintf(&nfs_server_ipaddr, "%s", tmp); 1133 mr_asprintf(&nfs_mount, "%s", p); 1154 1134 mr_free(tmp); 1155 1135 1156 1136 /* BERLIOS : there is a bug #67 here as it only considers the first NIC */ 1157 mr_asprintf(&command, 1158 "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\n' | head -n1 | cut -d' ' -f1"); 1137 mr_asprintf(&command, "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\n' | head -n1 | cut -d' ' -f1"); 1159 1138 mr_asprintf(&nfs_dev, "%s", call_program_and_get_last_line_of_output(command)); 1160 1139 mr_free(command); 1161 1140 1162 mr_asprintf(&command, 1163 "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f7 | cut -d':' -f2"); 1141 mr_asprintf(&command, "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f7 | cut -d':' -f2"); 1164 1142 mr_asprintf(&nfs_client_ipaddr, "%s", call_program_and_get_last_line_of_output(command)); 1165 1143 mr_free(command); 1166 1144 1167 mr_asprintf(&command, 1168 "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f9 | cut -d':' -f2"); 1145 mr_asprintf(&command, "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f9 | cut -d':' -f2"); 1169 1146 mr_asprintf(&nfs_client_netmask, "%s", call_program_and_get_last_line_of_output(command)); 1170 1147 mr_free(command); 1171 1148 1172 mr_asprintf(&command, 1173 "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f8 | cut -d':' -f2"); 1149 mr_asprintf(&command, "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f8 | cut -d':' -f2"); 1174 1150 mr_asprintf(&nfs_client_broadcast, "%s", call_program_and_get_last_line_of_output(command)); 1175 1151 mr_free(command); 1176 1152 1177 mr_asprintf(&command, 1178 "%s", "route -n | grep '^0.0.0.0' | awk '{print $2}'"); 1153 mr_asprintf(&command, "%s", "route -n | grep '^0.0.0.0' | awk '{print $2}'"); 1179 1154 mr_asprintf(&nfs_client_defgw, "%s", call_program_and_get_last_line_of_output(command)); 1180 1155 mr_free(command); … … 1195 1170 if (!strncmp(nfs_dev, "bond", 4) || !strncmp(nfs_dev, "alb", 3) || !strncmp(nfs_dev, "aft", 3)) { 1196 1171 log_to_screen("Found bonding device %s; looking for corresponding ethN slave device\n", nfs_dev); 1197 mr_asprintf(&command, 1198 "%s", "ifconfig %s | awk '{print $5}' | head -n1", nfs_dev); 1172 mr_asprintf(&command, "%s", "ifconfig %s | awk '{print $5}' | head -n1", nfs_dev); 1199 1173 mr_asprintf(&mac_addr, "%s", call_program_and_get_last_line_of_output(command)); 1200 1174 mr_free(command); … … 1204 1178 mr_free(nfs_dev); 1205 1179 1206 mr_asprintf(&nfs_dev, call_program_and_get_last_line_of_output(command));1180 mr_asprintf(&nfs_dev, "%s", call_program_and_get_last_line_of_output(command)); 1207 1181 mr_free(command); 1208 1182 … … 1313 1287 mr_free(mds); 1314 1288 } else if (scratchLL > 4) { 1315 mr_asprintf(&tmp, 1316 "Your backup will occupy one meeeeellion media! (maybe %s)", 1317 number_to_text((int) (scratchLL + 1))); 1289 mr_asprintf(&tmp, "Your backup will occupy one meeeeellion media! (maybe %s)", number_to_text((int) (scratchLL + 1))); 1318 1290 } else { 1319 mr_asprintf(&tmp, "Your backup will occupy approximately %s media.", 1320 number_to_text((int) (scratchLL + 1))); 1291 mr_asprintf(&tmp, "Your backup will occupy approximately %s media.", number_to_text((int) (scratchLL + 1))); 1321 1292 } 1322 1293 if (!bkpinfo->image_devs[0] && (scratchLL < 50)) { -
branches/2.2.10/mondo/src/common/libmondo-fork.c
r2275 r2296 283 283 log_if_failure = TRUE; 284 284 } 285 mr_asprintf(&callstr, "%s > %s/mondo-run-prog-thing.tmp 2> %s/mondo-run-prog-thing.err", 286 program, bkpinfo->tmpdir, bkpinfo->tmpdir); 285 mr_asprintf(&callstr, "%s > %s/mondo-run-prog-thing.tmp 2> %s/mondo-run-prog-thing.err", program, bkpinfo->tmpdir, bkpinfo->tmpdir); 287 286 while ((p = strchr(callstr, '\r'))) { 288 287 *p = ' '; … … 390 389 mr_asprintf(&lockfile, "%s/mojo-jojo.bla.bla", bkpinfo->tmpdir); 391 390 392 mr_asprintf(&command, 393 "echo hi > %s ; %s >> %s 2>> %s; res=$?; sleep 1; rm -f %s; exit $res", 394 lockfile, basic_call, MONDO_LOGFILE, MONDO_LOGFILE, lockfile); 391 mr_asprintf(&command, "echo hi > %s ; %s >> %s 2>> %s; res=$?; sleep 1; rm -f %s; exit $res", lockfile, basic_call, MONDO_LOGFILE, MONDO_LOGFILE, lockfile); 395 392 open_evalcall_form(what_i_am_doing); 396 393 mr_asprintf(&tmp, "Executing %s", basic_call); -
branches/2.2.10/mondo/src/common/libmondo-stream.c
r2266 r2296 273 273 strcpy(cdr_exe, "dvdrecord"); 274 274 } 275 mr_asprintf(&command, "%s -scanbus 2> /dev/null | grep -i tape | wc -l", 276 cdr_exe); 275 mr_asprintf(&command, "%s -scanbus 2> /dev/null | grep -i tape | wc -l", cdr_exe); 277 276 strcpy(tmp, call_program_and_get_last_line_of_output(command)); 278 277 mr_free(command); … … 284 283 return 1; 285 284 } 286 mr_asprintf(&command, 287 "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f2 | head -n1", 288 cdr_exe); 285 mr_asprintf(&command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f2 | head -n1", cdr_exe); 289 286 strcpy(tmp, call_program_and_get_last_line_of_output(command)); 290 287 mr_free(command); … … 294 291 return 1; 295 292 } 296 mr_asprintf(&command, 297 "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f3 | cut -d')' -f1 | head -n1", 298 cdr_exe); 293 mr_asprintf(&command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | cut -d' ' -f3 | cut -d')' -f1 | head -n1", cdr_exe); 299 294 strcpy(tmp, call_program_and_get_last_line_of_output(command)); 300 295 mr_free(command); … … 475 470 log_it("Insisting on tape #%d", tapeno); 476 471 if (g_current_media_number != tapeno) { 477 mr_asprintf(&tmp, 478 "When the tape drive goes quiet, please insert volume %d in this series.", 479 tapeno); 472 mr_asprintf(&tmp, "When the tape drive goes quiet, please insert volume %d in this series.", tapeno); 480 473 popup_and_OK(tmp); 481 474 mr_free(tmp); … … 869 862 (void) getcwd(old_cwd, MAX_STR_LEN); 870 863 chdir(bkpinfo->tmpdir); 871 mr_asprintf(&tmp, "tar -zxf %s ./tmp/mondo-restore.cfg 2> /dev/null", 872 outfname); 864 mr_asprintf(&tmp, "tar -zxf %s ./tmp/mondo-restore.cfg 2> /dev/null", outfname); 873 865 paranoid_system(tmp); 874 866 mr_free(tmp); … … 1143 1135 } 1144 1136 if (strcmp(temp_cksum, actual_cksum)) { 1145 mr_asprintf(&tmp, "actual cksum=%s; recorded cksum=%s", actual_cksum, 1146 temp_cksum); 1137 mr_asprintf(&tmp, "actual cksum=%s; recorded cksum=%s", actual_cksum, temp_cksum); 1147 1138 log_to_screen(tmp); 1148 1139 mr_free(tmp); 1149 1140 1150 mr_asprintf(&tmp, "%s (%ld K) is corrupt on tape", temp_fname, 1151 (long) orig_size >> 10); 1141 mr_asprintf(&tmp, "%s (%ld K) is corrupt on tape", temp_fname, (long) orig_size >> 10); 1152 1142 log_to_screen(tmp); 1153 1143 mr_free(tmp); … … 1500 1490 } 1501 1491 if (bkpinfo->backup_media_type == cdstream) { 1502 mr_asprintf(&command, 1503 "cdrecord -eject dev=%s speed=%d fs=24m -waiti - >> %s 2>> %s", 1504 bkpinfo->media_device, bkpinfo->cdrw_speed, MONDO_LOGFILE, 1505 MONDO_LOGFILE); 1492 mr_asprintf(&command, "cdrecord -eject dev=%s speed=%d fs=24m -waiti - >> %s 2>> %s", bkpinfo->media_device, bkpinfo->cdrw_speed, MONDO_LOGFILE, MONDO_LOGFILE); 1506 1493 log_it("Opening OUT to next CD with the command"); 1507 1494 log_it(command); … … 1706 1693 p++; 1707 1694 } 1708 mr_asprintf(&tmp, "Writing file '%s' to tape (%ld KB)", p, 1709 (long) filesize >> 10); 1695 mr_asprintf(&tmp, "Writing file '%s' to tape (%ld KB)", p, (long) filesize >> 10); 1710 1696 log_it(tmp); 1711 1697 mr_free(tmp); … … 1812 1798 fwrite(tempblock, 1, (size_t) TAPE_BLOCK_SIZE, 1813 1799 g_tape_stream) / 1024; 1814 mr_asprintf(&tmp, "%s (fname=%s, size=%ld K)", 1815 marker_to_string(control_char), p, 1816 (long) length_of_incoming_file >> 10); 1800 mr_asprintf(&tmp, "%s (fname=%s, size=%ld K)", marker_to_string(control_char), p, (long) length_of_incoming_file >> 10); 1817 1801 log_msg(6, tmp); 1818 1802 mr_free(tmp); -
branches/2.2.10/mondo/src/common/libmondo-tools.c
r2291 r2296 610 610 611 611 log_it("isodir = %s", bkpinfo->isodir); 612 mr_asprintf(&command, "df -P %s | tail -n1 | cut -d' ' -f1", 613 bkpinfo->isodir); 612 mr_asprintf(&command, "df -P %s | tail -n1 | cut -d' ' -f1", bkpinfo->isodir); 614 613 log_it("command = %s", command); 615 614 log_it("res of it = %s", call_program_and_get_last_line_of_output(command)); … … 911 910 ("ln -sf `which mkfs.msdos` /sbin/mkfs.vfat", FALSE); 912 911 } 913 mr_asprintf(&tmp, "%s", 914 call_program_and_get_last_line_of_output 915 ("free | grep Mem | head -n1 | tr -s ' ' '\t' | cut -f2")); 912 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output("free | grep Mem | head -n1 | tr -s ' ' '\t' | cut -f2")); 916 913 if (atol(tmp) < 35000) { 917 914 retval++; … … 984 981 run_program_and_log_output 985 982 ("umount `mount | grep cdr | cut -d' ' -f3 | tr '\n' ' '`", 5); 986 mr_asprintf(&tmp, "%s", 987 call_program_and_get_last_line_of_output 988 ("mount | grep -E \"cdr(om|w)\"")); 983 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output("mount | grep -E \"cdr(om|w)\"")); 989 984 if (strcmp("", tmp)) { 990 985 if (strstr(tmp, "autofs")) { … … 1067 1062 assert_string_is_neither_NULL_nor_zerolength(label); 1068 1063 if (!does_file_exist(config_file)) { 1069 mr_asprintf(&tmp, "(read_cfg_var) Cannot find %s config file", 1070 config_file); 1064 mr_asprintf(&tmp, "(read_cfg_var) Cannot find %s config file", config_file); 1071 1065 log_to_screen(tmp); 1072 1066 mr_free(tmp); … … 1078 1072 return (0); 1079 1073 } else { 1080 mr_asprintf(&command, "grep '%s .*' %s| cut -d' ' -f2,3,4,5", 1081 label, config_file); 1074 mr_asprintf(&command, "grep '%s .*' %s| cut -d' ' -f2,3,4,5", label, config_file); 1082 1075 strcpy(value, call_program_and_get_last_line_of_output(command)); 1083 1076 mr_free(command); … … 1207 1200 g_boot_mountpt[0] = '\0'; 1208 1201 log_msg(4, "Done. Great. Seeting command to something"); 1209 mr_asprintf(&command, "%s", 1210 "grep -v \":\" /etc/fstab | grep -vE '^#.*$' | grep -E \"[ ]/boot[ ]\" | tr -s ' ' '\t' | cut -f1 | head -n1"); 1202 mr_asprintf(&command, "grep -v \":\" /etc/fstab | grep -vE '^#.*$' | grep -E \"[ ]/boot[ ]\" | tr -s ' ' '\t' | cut -f1 | head -n1"); 1211 1203 log_msg(4, "Cool. Command = '%s'", command); 1212 1204 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); … … 1218 1210 mr_asprintf(&command, "mount | grep -Ew '/boot'"); 1219 1211 mr_free(tmp); 1220 mr_asprintf(&tmp, call_program_and_get_last_line_of_output(command));1212 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 1221 1213 mr_free(command); 1222 1214 … … 1235 1227 strcpy(g_boot_mountpt, tmp); 1236 1228 mr_free(tmp); 1237 mr_asprintf(&tmp, 1238 "%s (your /boot partition) is not mounted. I'll mount it before backing up", 1239 g_boot_mountpt); 1229 mr_asprintf(&tmp, "%s (your /boot partition) is not mounted. I'll mount it before backing up", g_boot_mountpt); 1240 1230 log_it(tmp); 1241 1231 mr_free(tmp); … … 1304 1294 assert(value != NULL); 1305 1295 if (!does_file_exist(config_file)) { 1306 mr_asprintf(&tmp, "(write_cfg_file) Cannot find %s config file", 1307 config_file); 1296 mr_asprintf(&tmp, "(write_cfg_file) Cannot find %s config file", config_file); 1308 1297 log_to_screen(tmp); 1309 1298 mr_free(tmp); … … 1312 1301 mr_asprintf(&tempfile, "%s/mojo-jojo.blah", bkpinfo->tmpdir); 1313 1302 if (does_file_exist(config_file)) { 1314 mr_asprintf(&command, "grep -vE '^%s .*$' %s > %s", 1315 label, config_file, tempfile); 1303 mr_asprintf(&command, "grep -vE '^%s .*$' %s > %s", label, config_file, tempfile); 1316 1304 paranoid_system(command); 1317 1305 mr_free(command); -
branches/2.2.10/mondo/src/common/libmondo-verify.c
r2276 r2296 107 107 108 108 log_msg(1, "Now scanning log file for 'star: ' stuff"); 109 mr_asprintf(&command, 110 "grep \"star: \" %s | sed 's/star: //' | grep -vE '^/dev/.*$' >> %s", 111 stderr_fname, afio_found_changes); 109 mr_asprintf(&command, "grep \"star: \" %s | sed 's/star: //' | grep -vE '^/dev/.*$' >> %s", stderr_fname, afio_found_changes); 112 110 log_msg(2, command); 113 111 res = system(command); … … 118 116 } 119 117 afio_diffs = count_lines_in_file(afio_found_changes); 120 mr_asprintf(&command, 121 "sort %s %s %s | uniq -c | awk '{ if ($1==\"2\") {print $2;};}' | grep -v \"incheckentry xwait()\" > %s", 122 ignorefiles_fname, afio_found_changes, afio_found_changes, 123 changedfiles_fname); 118 mr_asprintf(&command, "sort %s %s %s | uniq -c | awk '{ if ($1==\"2\") {print $2;};}' | grep -v \"incheckentry xwait()\" > %s", ignorefiles_fname, afio_found_changes, afio_found_changes, changedfiles_fname); 124 119 mr_free(afio_found_changes); 125 120 log_msg(2, command); … … 172 167 } else { 173 168 retval++; 174 mr_asprintf(&tmp, "Warning - missing set(s) between %d and %d\n", 175 g_last_afioball_number, set_number - 1); 169 mr_asprintf(&tmp, "Warning - missing set(s) between %d and %d\n", g_last_afioball_number, set_number - 1); 176 170 log_to_screen(tmp); 177 171 mr_free(tmp); … … 342 336 g_current_media_number, bigfile_num, slice_num); 343 337 if (!does_file_exist(slice_fname(bigfile_num, slice_num, mountpoint, ""))) { 344 mr_asprintf(&command, "%s -dc %s 2>> %s", 345 sz_exe, 346 slice_fname(bigfile_num, slice_num, mountpoint, bkpinfo->zip_suffix), 347 MONDO_LOGFILE); 338 mr_asprintf(&command, "%s -dc %s 2>> %s", sz_exe, slice_fname(bigfile_num, slice_num, mountpoint, bkpinfo->zip_suffix), MONDO_LOGFILE); 348 339 } else { 349 340 mr_asprintf(&command, "cat %s 2>> %s", slice_fname(bigfile_num, slice_num, mountpoint, ""), MONDO_LOGFILE); … … 474 465 bkpinfo->use_star = TRUE; 475 466 if (strstr(tarball_fname, ".bz2")) 476 mr_asprintf(&command, 477 "star -diff diffopts=mode,size,data file=%s %s >> %s 2>> %s", 478 tarball_fname, 479 (strstr(tarball_fname, ".bz2")) ? "-bz" : " ", outlog, 480 outlog); 467 mr_asprintf(&command, "star -diff diffopts=mode,size,data file=%s -bz >> %s 2>> %s", tarball_fname, outlog, outlog); 481 468 } else { 482 469 bkpinfo->use_star = FALSE; 483 mr_asprintf(&command, "afio -r -P %s -Z %s >> %s 2>> %s", 484 bkpinfo->zip_exe, tarball_fname, outlog, outlog); 470 mr_asprintf(&command, "afio -r -P %s -Z %s >> %s 2>> %s", bkpinfo->zip_exe, tarball_fname, outlog, outlog); 485 471 } 486 472 log_msg(6, "command=%s", command); … … 491 477 mr_asprintf(&command, "cat %s >> %s", outlog, MONDO_LOGFILE); 492 478 } else { 493 mr_asprintf(&command, "cut -d: -f%d %s | sort -u", 494 (bkpinfo->use_star) ? 1 : 2, outlog); 479 mr_asprintf(&command, "cut -d: -f%d %s | sort -u", (bkpinfo->use_star) ? 1 : 2, outlog); 495 480 pin = popen(command, "r"); 496 481 if (pin) { … … 794 779 res = verify_an_afioball_from_stream(fname, size); 795 780 if (res) { 796 mr_asprintf(&tmp, "Afioball %ld differs from live filesystem", 797 current_afioball_number); 781 mr_asprintf(&tmp, "Afioball %ld differs from live filesystem", current_afioball_number); 798 782 log_to_screen(tmp); 799 783 mr_free(tmp); … … 897 881 p++; 898 882 } 899 mr_asprintf(&comment, "Verifying bigfile #%ld (%ld K)", 900 current_biggiefile_number, (long) size >> 10); 883 mr_asprintf(&comment, "Verifying bigfile #%ld (%ld K)", current_biggiefile_number, (long) size >> 10); 901 884 update_progress_form(comment); 902 885 mr_free(comment); … … 1208 1191 diffs = count_lines_in_file(changed_files_fname); 1209 1192 if (diffs > 0) { 1210 mr_asprintf(&tmp, "cp -f %s %s/changed.files", changed_files_fname, 1211 MONDO_CACHE); 1193 mr_asprintf(&tmp, "cp -f %s %s/changed.files", changed_files_fname, MONDO_CACHE); 1212 1194 run_program_and_log_output(tmp, FALSE); 1213 1195 mr_free(tmp); -
branches/2.2.10/mondo/src/common/newt-specific.c
r2291 r2296 1026 1026 || percentage > g_isoform_old_progress) { 1027 1027 g_isoform_old_progress = percentage; 1028 mr_asprintf(&timeline_str, "%2ld:%02ld taken %2ld:%02ld remaining", (long) time_taken / 60, (long) time_taken % 60, 1029 (long) time_remaining / 60, (long) time_remaining % 60); 1028 mr_asprintf(&timeline_str, "%2ld:%02ld taken %2ld:%02ld remaining", (long) time_taken / 60, (long) time_taken % 60, (long) time_remaining / 60, (long) time_remaining % 60); 1030 1029 if (percentage < 3) { 1031 1030 mr_asprintf(&pcline_str, " Working"); … … 1038 1037 mr_strcat(pcline_str, " %c", special_dot_char(g_mysterious_dot_counter)); 1039 1038 } else { 1040 mr_asprintf(&pcline_str, " %3d%% done %3d%% to go", 1041 percentage, 100 - percentage); 1039 mr_asprintf(&pcline_str, " %3d%% done %3d%% to go", percentage, 100 - percentage); 1042 1040 } 1043 1041 if (g_text_mode) { … … 1143 1141 } else { 1144 1142 if (g_current_progress > g_maximum_progress) { 1145 mr_asprintf(&tmp, 1146 "update_progress_form_full(%s,%s,%s) --- g_current_progress=%ld; g_maximum_progress=%ld", 1147 blurb1, blurb2, blurb3, g_current_progress, 1148 g_maximum_progress); 1149 log_msg(0, tmp); 1150 mr_free(tmp); 1143 log_msg(0, "update_progress_form_full(%s,%s,%s) --- g_current_progress=%ld; g_maximum_progress=%ld", blurb1, blurb2, blurb3, g_current_progress, g_maximum_progress); 1151 1144 g_current_progress = g_maximum_progress; 1152 1145 } … … 1185 1178 paranoid_free(taskprogress); 1186 1179 } else { 1187 mr_asprintf(&timeline_str, "%2ld:%02ld taken %2ld:%02ld remaining ", 1188 (long) time_taken / 60, (long) time_taken % 60, (long) time_remaining / 60, (long) time_remaining % 60); 1180 mr_asprintf(&timeline_str, "%2ld:%02ld taken %2ld:%02ld remaining ", (long) time_taken / 60, (long) time_taken % 60, (long) time_remaining / 60, (long) time_remaining % 60); 1189 1181 mr_asprintf(percentline_str, " %3d%% done %3d%% to go", percentage, 100 - percentage); 1190 1182 … … 1608 1600 keylist[i]); 1609 1601 } 1610 mr_asprintf(&differ_sz, 1611 " %ld files differ. Hit 'Select' to pick a file. Hit 'Close' to quit the list.", 1612 i); 1602 mr_asprintf(&differ_sz, " %ld files differ. Hit 'Select' to pick a file. Hit 'Close' to quit the list.", i); 1613 1603 newtPushHelpLine(differ_sz); 1614 1604 mr_free(differ_sz); -
branches/2.2.10/mondo/src/mondorestore/mondo-prep.c
r2291 r2296 79 79 make_list_of_drives_in_mountlist(mountlist, drivelist); 80 80 for (lino = 0; lino < drivelist->entries; lino++) { 81 mr_asprintf(&command, 82 "dd if=%s bs=512 count=1 2> /dev/null | grep \"%s\"", 83 drivelist->el[lino].device, MONDO_WAS_HERE); 81 mr_asprintf(&command, "dd if=%s bs=512 count=1 2> /dev/null | grep \"%s\"", drivelist->el[lino].device, MONDO_WAS_HERE); 84 82 res = run_program_and_log_output(command, 1); 85 83 mr_free(command); … … 260 258 strcpy(vgremove_sz, "vgremove"); 261 259 } 262 mr_asprintf(&tmp1, 263 "for i in `%s | cut -d\"'\" -f2 | sort -r` ; do echo \"Shutting down lv $i\" >> %s ; %s -f $i; done", lvscan_sz, MONDO_LOGFILE, lvremove_sz); 260 mr_asprintf(&tmp1, "for i in `%s | cut -d\"'\" -f2 | sort -r` ; do echo \"Shutting down lv $i\" >> %s ; %s -f $i; done", lvscan_sz, MONDO_LOGFILE, lvremove_sz); 264 261 run_program_and_log_output(tmp1, 5); 265 262 mr_free(tmp1); … … 521 518 new_mountlist->entries++; 522 519 } else { 523 mr_asprintf(&tmp, 524 "Not adding %s to mountlist: it's already there", 525 p); 520 mr_asprintf(&tmp, "Not adding %s to mountlist: it's already there", p); 526 521 log_it(tmp); 527 522 mr_free(tmp); … … 647 642 mr_asprintf(&strtmp, "%s", program); 648 643 paranoid_free(program); 649 mr_asprintf(&program, "%s --spare-devices=%d", strtmp, 650 raidlist->el[i].spare_disks.entries); 644 mr_asprintf(&program, "%s --spare-devices=%d", strtmp, raidlist->el[i].spare_disks.entries); 651 645 paranoid_free(strtmp); 652 646 } … … 747 741 748 742 /* format raid partition */ 749 mr_asprintf(&program, 750 "for plex in `vinum lv -r %s | grep '^P' | tr '\t' ' ' | tr -s ' ' | cut -d' ' -f2`; do echo $plex; done > /tmp/plexes", basename(device)); 743 mr_asprintf(&program, "for plex in `vinum lv -r %s | grep '^P' | tr '\t' ' ' | tr -s ' ' | cut -d' ' -f2`; do echo $plex; done > /tmp/plexes", basename(device)); 751 744 system(program); 752 745 if (g_fprep) { … … 914 907 915 908 assert(mountlist != NULL); 916 mr_asprintf(&tmp, "format_everything (mountlist, interactively = %s", 917 (interactively) ? "true" : "false"); 909 mr_asprintf(&tmp, "format_everything (mountlist, interactively = %s", (interactively) ? "true" : "false"); 918 910 log_it(tmp); 919 911 mr_free(tmp); … … 943 935 if (interactively) { 944 936 // ask user if we should format the current device 945 mr_asprintf(&tmp, "Shall I format %s (%s) ?", me->device, 946 me->mountpoint); 937 mr_asprintf(&tmp, "Shall I format %s (%s) ?", me->device, me->mountpoint); 947 938 do_it = ask_me_yes_or_no(tmp); 948 939 mr_free(tmp); … … 1425 1416 mr_free(command); 1426 1417 1427 mr_asprintf(&command, "disklabel -R %s /tmp/disklabel", 1428 canonical_name(drivename)); 1418 mr_asprintf(&command, "disklabel -R %s /tmp/disklabel", canonical_name(drivename)); 1429 1419 retval += run_program_and_log_output(command, TRUE); 1430 1420 mr_free(command); … … 1571 1561 file = open(drivename, O_WRONLY); 1572 1562 if (file != -1) { 1573 mr_asprintf(&tmp, 1574 "Warning - unable to open %s for wiping it's partition table", 1575 drivename); 1563 mr_asprintf(&tmp, "Warning - unable to open %s for wiping it's partition table", drivename); 1576 1564 log_to_screen(tmp); 1577 1565 mr_free(tmp); … … 1580 1568 for (i = 0; i < 512; i++) { 1581 1569 if (!write(file, "\0", 1)) { 1582 mr_asprintf(&tmp, "Warning - unable to write to %s", 1583 drivename); 1570 mr_asprintf(&tmp, "Warning - unable to write to %s", drivename); 1584 1571 log_to_screen(tmp); 1585 1572 mr_free(tmp); … … 1642 1629 if (pout_to_fdisk) { 1643 1630 // mark relevant partition as bootable 1644 mr_asprintf(&tmp, "a\n%s\n", 1645 call_program_and_get_last_line_of_output 1646 ("make-me-bootable /tmp/mountlist.txt dummy")); 1631 mr_asprintf(&tmp, "a\n%s\n", call_program_and_get_last_line_of_output("make-me-bootable /tmp/mountlist.txt dummy")); 1647 1632 fput_string_one_char_at_a_time(pout_to_fdisk, tmp); 1648 1633 mr_free(tmp); … … 1739 1724 1740 1725 if (is_this_device_mounted(partition_name)) { 1741 mr_asprintf(&tmp, "%s is mounted, and should not be partitioned", 1742 partition_name); 1726 mr_asprintf(&tmp, "%s is mounted, and should not be partitioned", partition_name); 1743 1727 log_to_screen(tmp); 1744 1728 mr_free(tmp); … … 2050 2034 } else { 2051 2035 /* probably an image */ 2052 mr_asprintf(&tmp, 2053 "Unknown format ('%s') - using supplied string anyway", 2054 format); 2036 mr_asprintf(&tmp, "Unknown format ('%s') - using supplied string anyway", format); 2055 2037 mvaddstr_and_log_it(g_currentY++, 0, tmp); 2056 2038 mr_free(tmp); -
branches/2.2.10/mondo/src/mondorestore/mondo-rstr-compare.c
r2291 r2296 47 47 char *bigfile_fname_ptr; 48 48 char *tmp_ptr = NULL; 49 char *command_ptr ;49 char *command_ptr = NULL; 50 50 51 51 char *checksum, *original_cksum, *bigfile_fname, *tmp, *command; … … 65 65 malloc_string(original_cksum_ptr); 66 66 malloc_string(bigfile_fname_ptr); 67 malloc_string(command_ptr);68 67 69 68 /********************************************************************* … … 74 73 memset(original_cksum_ptr, '\0', sizeof(original_cksum)); 75 74 memset(bigfile_fname_ptr, '\0', sizeof(bigfile_fname)); 76 memset(command_ptr, '\0', sizeof(command));77 75 /** end **/ 78 76 … … 113 111 if (!strncmp(bigfile_fname_ptr, "/dev/", 5)) { 114 112 strcpy(original_cksum_ptr, "IGNORE"); 115 } else {116 sprintf(command_ptr,117 "md5sum \"%s%s\" > /tmp/md5sum.txt 2> /tmp/errors",118 MNT_RESTORING, bigfile_fname_ptr); 119 }113 log_msg(2, "IGNORING %s as begining with /dev", bigfile_fname_ptr); 114 return (1); 115 } 116 117 mr_asprintf(&command_ptr, "md5sum \"%s%s\" > /tmp/md5sum.txt 2> /tmp/errors", MNT_RESTORING, bigfile_fname_ptr); 120 118 log_msg(2, command_ptr); 119 i = system(command_ptr); 120 mr_free(command_ptr); 121 121 122 mr_asprintf(&tmp_ptr, "cat /tmp/errors >> %s 2> /dev/null", MONDO_LOGFILE); 122 123 paranoid_system(tmp_ptr); 123 124 paranoid_free(tmp_ptr); 124 125 125 if ( system(command_ptr)) {126 if (i) { 126 127 log_OS_error("Warning - command failed"); 127 128 original_cksum[0] = '\0'; … … 169 170 paranoid_free(checksum_ptr); 170 171 paranoid_free(checksum); 171 paranoid_free(command_ptr);172 172 paranoid_free(command); 173 173 paranoid_free(tmp); … … 190 190 int res; 191 191 long noof_biggiefiles, bigfileno = 0; 192 char tmp[MAX_STR_LEN];192 char *tmp = NULL; 193 193 194 194 log_msg(1, "Comparing biggiefiles"); … … 211 211 noof_biggiefiles); 212 212 for (bigfileno = 0; bigfileno < noof_biggiefiles; bigfileno++) { 213 sprintf(tmp, "Comparing big file #%ld", bigfileno + 1);213 mr_asprintf(&tmp, "Comparing big file #%ld", bigfileno + 1); 214 214 log_msg(1, tmp); 215 215 update_progress_form(tmp); 216 mr_free(tmp); 217 216 218 res = compare_a_biggiefile(bigfileno); 217 219 retval += res; … … 250 252 251 253 /*** needs malloc *********/ 252 char *command , *tmp, *filelist_name, *logfile,253 *compressor_exe;254 char *command = NULL; 255 char *tmp = NULL; 254 256 char *archiver_exe = NULL; 255 256 malloc_string(command); 257 malloc_string(tmp); 258 malloc_string(filelist_name); 259 malloc_string(logfile); 260 malloc_string(compressor_exe); 257 char *filelist_name = NULL; 258 char *logfile = NULL; 259 char *compressor_exe = NULL; 261 260 262 261 use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE; 263 262 assert_string_is_neither_NULL_nor_zerolength(tarball_fname); 264 sprintf(logfile, "/tmp/afio.log.%d", current_tarball_number); 265 sprintf(filelist_name, MNT_CDROM "/archives/filelist.%d", 266 current_tarball_number); 267 263 mr_asprintf(&filelist_name, MNT_CDROM "/archives/filelist.%d", current_tarball_number); 268 264 noof_lines = count_lines_in_file(filelist_name); 265 mr_free(filelist_name); 269 266 270 267 if (strstr(tarball_fname, ".bz2")) { 271 strcpy(compressor_exe, "bzip2");268 mr_asprintf(&compressor_exe, "bzip2"); 272 269 } else if (strstr(tarball_fname, ".gz")) { 273 strcpy(compressor_exe, "gzip");270 mr_asprintf(&compressor_exe, "gzip"); 274 271 } else if (strstr(tarball_fname, ".lzo")) { 275 strcpy(compressor_exe, "lzop"); 276 } else { 277 compressor_exe[0] = '\0'; 272 mr_asprintf(&compressor_exe, "lzop"); 278 273 } 279 274 … … 284 279 } 285 280 286 if (compressor_exe[0]) { 287 strcpy(tmp, compressor_exe); 288 if (!find_home_of_exe(tmp)) { 281 if (compressor_exe) { 282 if (!find_home_of_exe(compressor_exe)) { 283 mr_free(compressor_exe); 284 mr_free(archiver_exe); 289 285 fatal_error("(compare_a_tarball) Compression program missing"); 290 286 } 291 if (use_star) // star 292 { 287 if (use_star) { 293 288 if (!strcmp(compressor_exe, "bzip2")) { 294 289 mr_strcat(archiver_exe, " -bz"); 295 290 } else { 296 fatal_error 297 ("(compare_a_tarball) Please use only bzip2 with star"); 291 mr_free(compressor_exe); 292 mr_free(archiver_exe); 293 fatal_error("(compare_a_tarball) Please use only bzip2 with star"); 298 294 } 299 } else // afio 300 { 301 sprintf(compressor_exe, "-P %s -Z", tmp); 302 } 303 } 304 // star -diff H=star -bz file=.... 295 } else { 296 // afio 297 mr_free(compressor_exe); 298 mr_asprintf(&tmp, "%s", compressor_exe); 299 mr_asprintf(&compressor_exe, "-P %s -Z", tmp); 300 mr_free(tmp); 301 } 302 } 305 303 306 304 #ifdef __FreeBSD__ … … 309 307 #define BUFSIZE (1024L*1024L)/TAPE_BLOCK_SIZE 310 308 #endif 311 if (use_star) // doesn't use compressor_exe 312 { 313 sprintf(command, 314 "%s -diff H=star file=%s >> %s 2>> %s", 315 archiver_exe, tarball_fname, logfile, logfile); 316 } else { 317 sprintf(command, 318 "%s -r -b %ld -M 16m -c %ld %s %s >> %s 2>> %s", 319 archiver_exe, 320 TAPE_BLOCK_SIZE, 321 BUFSIZE, compressor_exe, tarball_fname, logfile, logfile); 322 } 309 mr_asprintf(&logfile, "/tmp/afio.log.%d", current_tarball_number); 310 311 if (use_star) { 312 // doesn't use compressor_exe 313 mr_asprintf(&command, "%s -diff H=star file=%s >> %s 2>> %s", archiver_exe, tarball_fname, logfile, logfile); 314 } else { 315 mr_asprintf(&command, "%s -r -b %ld -M 16m -c %ld %s %s >> %s 2>> %s", archiver_exe, TAPE_BLOCK_SIZE, BUFSIZE, compressor_exe, tarball_fname, logfile, logfile); 316 } 317 mr_free(compressor_exe); 323 318 paranoid_free(archiver_exe); 324 319 … … 329 324 if (res) { 330 325 log_OS_error(command); 331 sprintf(tmp, "Warning - afio returned error = %d", res); 332 log_msg(2, tmp); 333 } 326 log_msg(2, "Warning - afio returned error = %d", res); 327 } 328 mr_free(command); 329 334 330 if (length_of_file(logfile) > 5) { 335 sprintf(command, 336 "sed s/': \\\"'/\\|/ %s | sed s/'\\\": '/\\|/ | cut -d'|' -f2 | sort -u | grep -vE \"^dev/.*\" >> "MONDO_CACHE"/changed.txt", 337 logfile); 331 mr_asprintf(&command, "sed s/': \\\"'/\\|/ %s | sed s/'\\\": '/\\|/ | cut -d'|' -f2 | sort -u | grep -vE \"^dev/.*\" >> "MONDO_CACHE"/changed.txt", logfile); 338 332 system(command); 333 mr_free(command); 334 339 335 archiver_errors = count_lines_in_file(logfile); 340 336 } else { 341 337 archiver_errors = 0; 342 338 } 343 sprintf(tmp, "%ld difference%c in fileset #%d ",344 archiver_errors, (archiver_errors != 1) ? 's' : ' ',345 current_tarball_number);346 339 if (archiver_errors) { 347 sprintf(tmp, 348 "Differences found while processing fileset #%d ", 349 current_tarball_number); 350 log_msg(1, tmp); 340 log_msg(1, "%ld difference%c in fileset #%d ", archiver_errors, (archiver_errors != 1) ? 's' : ' ', current_tarball_number); 351 341 } 352 342 unlink(logfile); 353 paranoid_free(command); 354 paranoid_free(tmp); 355 paranoid_free(filelist_name); 356 paranoid_free(logfile); 357 paranoid_free(compressor_exe); 343 mr_free(logfile); 344 358 345 return (retval); 359 346 } … … 377 364 /** needs malloc **********/ 378 365 379 char *tarball_fname, *progress_str, *tmp; 366 char *tarball_fname = NULL; 367 char *progress_str = NULL; 368 char *tmp = NULL; 380 369 char *mds = NULL; 381 370 long max_val; 382 371 383 malloc_string(tarball_fname);384 malloc_string(progress_str);385 malloc_string(tmp);386 372 387 373 assert(bkpinfo != NULL); 388 374 mvaddstr_and_log_it(g_currentY, 0, "Comparing archives"); 375 376 malloc_string(tmp); 389 377 read_cfg_var(g_mondo_cfg_file, "last-filelist-number", tmp); 390 391 378 max_val = atol(tmp); 379 paranoid_free(tmp); 380 392 381 mds = media_descriptor_string(bkpinfo->backup_media_type); 393 sprintf(progress_str, "Comparing with %s #%d ", mds, g_current_media_number);382 mr_asprintf(&progress_str, "Comparing with %s #%d ", mds, g_current_media_number); 394 383 395 384 open_progress_form("Comparing files", … … 403 392 insist_on_this_cd_number(g_current_media_number); 404 393 update_progress_form(progress_str); 405 sprintf(tarball_fname, 406 MNT_CDROM "/archives/%d.afio.bz2", current_tarball_number); 394 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.bz2", current_tarball_number); 407 395 408 396 if (!does_file_exist(tarball_fname)) { 409 sprintf(tarball_fname, MNT_CDROM "/archives/%d.afio.lzo",410 397 mr_free(tarball_fname); 398 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.lzo", current_tarball_number); 411 399 } 412 400 if (!does_file_exist(tarball_fname)) { 413 sprintf(tarball_fname, MNT_CDROM "/archives/%d.afio.gz",414 401 mr_free(tarball_fname); 402 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.gz", current_tarball_number); 415 403 } 416 404 if (!does_file_exist(tarball_fname)) { 417 sprintf(tarball_fname, MNT_CDROM "/archives/%d.afio.",418 405 mr_free(tarball_fname); 406 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.afio.", current_tarball_number); 419 407 } 420 408 if (!does_file_exist(tarball_fname)) { 421 sprintf(tarball_fname, MNT_CDROM "/archives/%d.star.bz2",422 409 mr_free(tarball_fname); 410 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.star.bz2", current_tarball_number); 423 411 } 424 412 if (!does_file_exist(tarball_fname)) { 425 sprintf(tarball_fname, MNT_CDROM "/archives/%d.star.",426 413 mr_free(tarball_fname); 414 mr_asprintf(&tarball_fname, MNT_CDROM "/archives/%d.star.", current_tarball_number); 427 415 } 428 416 if (!does_file_exist(tarball_fname)) { … … 432 420 == 0) { 433 421 log_msg(2, "OK, I think I'm done with tarballs..."); 422 mr_free(tarball_fname); 434 423 break; 435 424 } 436 425 log_msg(2, "OK, I think it's time for another CD..."); 437 426 g_current_media_number++; 438 sprintf(progress_str, "Comparing with %s #%d ", mds, g_current_media_number); 427 428 mr_free(progress_str); 429 mr_asprintf(&progress_str, "Comparing with %s #%d ", mds, g_current_media_number); 439 430 log_to_screen(progress_str); 440 431 } else { … … 444 435 current_tarball_number++; 445 436 } 446 } 437 mr_free(tarball_fname); 438 } 439 mr_free(progress_str); 447 440 mr_free(mds); 448 441 … … 453 446 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 454 447 } 455 paranoid_free(tarball_fname);456 paranoid_free(progress_str);457 paranoid_free(tmp);458 448 return (retval); 459 449 } … … 478 468 { 479 469 /** needs malloc *********/ 480 char *tmp, *cwd, *new, *command; 470 char *tmp = NULL; 471 char *cwd, *new; 472 char *command = NULL; 481 473 int resA = 0; 482 474 int resB = 0; 483 475 long noof_changed_files; 484 476 485 malloc_string(tmp);486 477 malloc_string(cwd); 487 478 malloc_string(new); 488 malloc_string(command);489 479 490 480 assert(bkpinfo != NULL); … … 501 491 noof_changed_files = count_lines_in_file(MONDO_CACHE"/changed.txt"); 502 492 if (noof_changed_files) { 503 sprintf(tmp, "%ld files do not match the backup ", 504 noof_changed_files); 505 // mvaddstr_and_log_it( g_currentY++, 0, tmp ); 493 mr_asprintf(&tmp, "%ld files do not match the backup ", noof_changed_files); 506 494 log_to_screen(tmp); 507 sprintf(command, "cat "MONDO_CACHE"/changed.txt >> %s", MONDO_LOGFILE); 495 mr_free(tmp); 496 497 mr_asprintf(&command, "cat "MONDO_CACHE"/changed.txt >> %s", MONDO_LOGFILE); 508 498 paranoid_system(command); 509 } else { 510 sprintf(tmp, "All files match the backup "); 499 mr_free(command); 500 } else { 501 mr_asprintf(&tmp, "All files match the backup "); 511 502 mvaddstr_and_log_it(g_currentY++, 0, tmp); 512 503 log_to_screen(tmp); 513 }514 515 paranoid_free(tmp); 504 mr_free(tmp); 505 } 506 516 507 paranoid_free(cwd); 517 508 paranoid_free(new); 518 paranoid_free(command);519 509 520 510 return (resA + resB); … … 544 534 int res = 0; 545 535 long q; 546 char *tmp ;536 char *tmp = NULL; 547 537 char *new; 548 538 char *cwd; 549 539 550 malloc_string(tmp);551 540 malloc_string(new); 552 541 malloc_string(cwd); … … 575 564 if (g_text_mode) { 576 565 save_mountlist_to_disk(mountlist, g_mountlist_fname); 577 sprintf(tmp, "%s %s", find_my_editor(), g_mountlist_fname);566 mr_asprintf(&tmp, "%s %s", find_my_editor(), g_mountlist_fname); 578 567 res = system(tmp); 568 mr_free(tmp); 569 579 570 load_mountlist(mountlist, g_mountlist_fname); 580 571 } else { … … 622 613 } else { 623 614 q = count_lines_in_file(MONDO_CACHE"/changed.files"); 624 sprintf(tmp, "%ld significant difference%s found.", q, 625 (q != 1) ? "s" : ""); 615 mr_asprintf(&tmp, "%ld significant difference%s found.", q, (q != 1) ? "s" : ""); 626 616 mvaddstr_and_log_it(g_currentY++, 0, tmp); 627 617 log_to_screen(tmp); 628 629 strcpy(tmp, 630 618 mr_free(tmp); 619 620 mr_asprintf(&tmp, "Type 'less /tmp/changed.files' for a list of non-matching files"); 631 621 mvaddstr_and_log_it(g_currentY++, 0, tmp); 632 622 log_to_screen(tmp); 623 mr_free(tmp); 633 624 634 625 log_msg(2, "calling popup_changelist_from_file()"); … … 647 638 648 639 kill_petris(); 649 paranoid_free(tmp);650 640 paranoid_free(new); 651 641 paranoid_free(cwd); … … 670 660 671 661 /** needs malloc **/ 672 char *dir, *command; 662 char *dir; 663 char *command = NULL; 673 664 674 665 assert(bkpinfo != NULL); 675 666 malloc_string(dir); 676 malloc_string(command);677 667 getcwd(dir, MAX_STR_LEN); 678 668 chdir(bkpinfo->restore_path); 679 669 680 sprintf(command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp", 681 bkpinfo->restore_path); 670 mr_asprintf(&command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp", bkpinfo->restore_path); 682 671 run_program_and_log_output(command, FALSE); 672 mr_free(command); 673 683 674 mvaddstr_and_log_it(g_currentY, 684 675 0, "Verifying archives against filesystem"); … … 704 695 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 705 696 paranoid_free(dir); 706 paranoid_free(command);707 697 return (res); 708 698 } … … 727 717 { 728 718 int res; 729 char *dir, *command; 719 char *dir; 720 char *command = NULL; 730 721 731 722 assert(bkpinfo != NULL); 732 723 malloc_string(dir); 733 malloc_string(command);734 724 735 725 getcwd(dir, MAX_STR_LEN); 736 726 chdir(bkpinfo->restore_path); 737 sprintf(command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp", 738 bkpinfo->restore_path); 727 mr_asprintf(&command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp", bkpinfo->restore_path); 739 728 run_program_and_log_output(command, FALSE); 729 mr_free(command); 730 740 731 mvaddstr_and_log_it(g_currentY, 741 732 0, "Verifying archives against filesystem"); … … 748 739 } 749 740 paranoid_free(dir); 750 paranoid_free(command);751 741 return (res); 752 742 } -
branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c
r2287 r2296 368 368 log_msg(3, "Mommm! SME is being a dildo!"); 369 369 } else { 370 mr_asprintf(&mountpoint, mpt);370 mr_asprintf(&mountpoint, "%s", mpt); 371 371 } 372 372 … … 408 408 mr_free(command); 409 409 410 mr_asprintf(&command, "mount -t %s %s %s %s 2>> %s", format, device, 411 additional_parameters, mountdir, MONDO_LOGFILE); 410 mr_asprintf(&command, "mount -t %s %s %s %s 2>> %s", format, device, additional_parameters, mountdir, MONDO_LOGFILE); 412 411 log_msg(2, "command='%s'", command); 413 412 } … … 418 417 log_msg(1, "Re-trying without the fancy extra parameters"); 419 418 mr_free(command); 420 mr_asprintf(&command, "mount -t %s %s %s 2>> %s", format, device, 421 mountdir, MONDO_LOGFILE); 419 mr_asprintf(&command, "mount -t %s %s %s 2>> %s", format, device, mountdir, MONDO_LOGFILE); 422 420 res = run_program_and_log_output(command, TRUE); 423 421 } … … 497 495 "Again with the /proc - why is this in your mountlist?"); 498 496 } else if (is_this_device_mounted(mountlist->el[lino].device)) { 499 mr_asprintf(&tmp, "%s is already mounted", 500 mountlist->el[lino].device); 497 mr_asprintf(&tmp, "%s is already mounted", mountlist->el[lino].device); 501 498 log_to_screen(tmp); 502 499 mr_free(tmp); … … 607 604 mr_asprintf(&mount_cmd, "mount_cd9660 -r %s " MNT_CDROM, mddev); 608 605 #else 609 mr_asprintf(&mount_cmd, "mount %s/%s/%s-%d.iso -t iso9660 -o loop,ro %s", bkpinfo->isodir, bkpinfo->nfs_remote_dir, 610 bkpinfo->prefix, g_current_media_number, MNT_CDROM); 606 mr_asprintf(&mount_cmd, "mount %s/%s/%s-%d.iso -t iso9660 -o loop,ro %s", bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, g_current_media_number, MNT_CDROM); 611 607 #endif 612 608 … … 619 615 mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", mddev, MNT_CDROM); 620 616 #else 621 mr_asprintf(&mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s", 622 bkpinfo->isodir, bkpinfo->prefix, g_current_media_number, MNT_CDROM); 617 mr_asprintf(&mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s", bkpinfo->isodir, bkpinfo->prefix, g_current_media_number, MNT_CDROM); 623 618 #endif 624 619 } else if (bkpinfo->backup_media_type == usb) { … … 1101 1096 unlink(FILELIST_FULL_STUB); 1102 1097 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 1103 mr_asprintf(&command, "tar -b %ld -zxf %s ./%s ./%s ./%s ./%s ./%s", 1104 bkpinfo->internal_tape_block_size, 1105 bkpinfo->media_device, 1106 MOUNTLIST_FNAME_STUB, 1107 BIGGIELIST_TXT_STUB, 1108 FILELIST_FULL_STUB, 1109 IWANTMYLVM_STUB, 1110 MONDO_CFG_FILE_STUB); 1098 mr_asprintf(&command, "tar -b %ld -zxf %s ./%s ./%s ./%s ./%s ./%s", bkpinfo->internal_tape_block_size, bkpinfo->media_device, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB); 1111 1099 log_msg(1, "tarcommand = %s", command); 1112 1100 run_program_and_log_output(command, 1); … … 1116 1104 /* Doing that allow us to remain compatible with pre-2.2.5 versions */ 1117 1105 log_msg(2, "pre-2.2.4 compatible mode on"); 1118 mr_asprintf(&command, 1119 "tar -b %ld -zxf %s %s %s %s %s %s", 1120 bkpinfo->internal_tape_block_size, 1121 bkpinfo->media_device, 1122 MOUNTLIST_FNAME_STUB, 1123 BIGGIELIST_TXT_STUB, 1124 FILELIST_FULL_STUB, 1125 IWANTMYLVM_STUB, 1126 MONDO_CFG_FILE_STUB); 1106 mr_asprintf(&command, "tar -b %ld -zxf %s %s %s %s %s %s", bkpinfo->internal_tape_block_size, bkpinfo->media_device, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB); 1127 1107 log_msg(1, "tarcommand = %s", command); 1128 1108 run_program_and_log_output(command, 1); … … 1136 1116 log_msg(2, "Back from iotcn"); 1137 1117 run_program_and_log_output("mount", 1); 1138 mr_asprintf(&command, 1139 "tar -zxf %s/images/all.tar.gz ./%s ./%s ./%s ./%s ./%s", 1140 MNT_CDROM, 1141 MOUNTLIST_FNAME_STUB, 1142 BIGGIELIST_TXT_STUB, 1143 FILELIST_FULL_STUB, 1144 IWANTMYLVM_STUB, 1145 MONDO_CFG_FILE_STUB); 1118 mr_asprintf(&command, "tar -zxf %s/images/all.tar.gz ./%s ./%s ./%s ./%s ./%s", MNT_CDROM, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB); 1146 1119 1147 1120 log_msg(1, "tarcommand = %s", command); … … 1152 1125 /* Doing that allow us to remain compatible with pre-2.2.5 versions */ 1153 1126 log_msg(2, "pre-2.2.4 compatible mode on"); 1154 mr_asprintf(&command, 1155 "tar -zxf %s/images/all.tar.gz %s %s %s %s %s", 1156 MNT_CDROM, 1157 MOUNTLIST_FNAME_STUB, 1158 BIGGIELIST_TXT_STUB, 1159 FILELIST_FULL_STUB, 1160 IWANTMYLVM_STUB, 1161 MONDO_CFG_FILE_STUB); 1127 mr_asprintf(&command, "tar -zxf %s/images/all.tar.gz %s %s %s %s %s", MNT_CDROM, MOUNTLIST_FNAME_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB, MONDO_CFG_FILE_STUB); 1162 1128 1163 1129 log_msg(1, "tarcommand = %s", command); … … 1195 1161 && 1196 1162 ask_me_yes_or_no("Do you want to retrieve the mountlist as well?")) { 1197 mr_asprintf(&command, "ln -sf %s/%s /tmp", MOUNTLIST_FNAME_STUB, 1198 bkpinfo->tmpdir); 1163 mr_asprintf(&command, "ln -sf %s/%s /tmp", MOUNTLIST_FNAME_STUB, bkpinfo->tmpdir); 1199 1164 paranoid_system(command); 1200 1165 mr_free(command); … … 1225 1190 mr_free(command); 1226 1191 } 1227 mr_asprintf(&command, "grep -E '^/dev/.*' %s > %s", 1228 g_biggielist_txt, g_filelist_imagedevs); 1192 mr_asprintf(&command, "grep -E '^/dev/.*' %s > %s", g_biggielist_txt, g_filelist_imagedevs); 1229 1193 paranoid_system(command); 1230 1194 mr_free(command); … … 2044 2008 "Well, I know a certain kitty-kitty who'll be sleeping with Mommy tonight..."); 2045 2009 } else { 2046 mr_asprintf(&command, "umount " MNT_RESTORING "%s", 2047 mountlist->el[lino].mountpoint); 2010 mr_asprintf(&command, "umount " MNT_RESTORING "%s", mountlist->el[lino].mountpoint); 2048 2011 2049 2012 /* To support latest Ubuntu where /var is a separate FS … … 2112 2075 } 2113 2076 2114 mr_asprintf(&command, 2115 "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx ./%s ./%s ./%s ./%s ./%s", 2116 dev, 2117 bkpinfo->internal_tape_block_size, 2118 1024L * 1024 * 32 / bkpinfo->internal_tape_block_size, 2119 MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, 2120 BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB); 2077 mr_asprintf(&command, "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx ./%s ./%s ./%s ./%s ./%s", dev, bkpinfo->internal_tape_block_size, 1024L * 1024 * 32 / bkpinfo->internal_tape_block_size, MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB); 2121 2078 log_msg(2, "command = '%s'", command); 2122 2079 res = run_program_and_log_output(command, -1); … … 2129 2086 /* Doing that allow us to remain compatible with pre-2.2.5 versions */ 2130 2087 log_msg(2, "pre-2.2.4 compatible mode on"); 2131 mr_asprintf(&command, 2132 "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx %s %s %s %s %s", 2133 dev, 2134 bkpinfo->internal_tape_block_size, 2135 1024L * 1024 * 32 / bkpinfo->internal_tape_block_size, 2136 MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, 2137 BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB); 2088 mr_asprintf(&command, "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx %s %s %s %s %s", dev, bkpinfo->internal_tape_block_size, 1024L * 1024 * 32 / bkpinfo->internal_tape_block_size, MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB); 2138 2089 log_msg(2, "command = '%s'", command); 2139 2090 res = run_program_and_log_output(command, -1); … … 2226 2177 log_msg(2, "media_device is blank; assuming %s"); 2227 2178 } 2228 mr_asprintf(&tmp, bkpinfo->media_device);2179 mr_asprintf(&tmp, "%s", bkpinfo->media_device); 2229 2180 if (extract_cfg_file_and_mountlist_from_tape_dev 2230 2181 (bkpinfo->media_device)) { … … 2335 2286 /* Is this code really useful ??? */ 2336 2287 if (extract_mountlist_stub) { 2337 mr_asprintf(&command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB, 2338 bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB); 2288 mr_asprintf(&command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB, bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB); 2339 2289 run_program_and_log_output(command, FALSE); 2340 2290 mr_free(command); -
branches/2.2.10/mondo/src/mondorestore/mondorestore.c
r2291 r2296 668 668 strcpy(fstab_fname, "/tmp/fstab"); 669 669 } 670 mr_asprintf(&tmp1, 671 "label-partitions-as-necessary %s < %s >> %s 2>> %s", 672 g_mountlist_fname, fstab_fname, MONDO_LOGFILE, 673 MONDO_LOGFILE); 670 mr_asprintf(&tmp1, "label-partitions-as-necessary %s < %s >> %s 2>> %s", g_mountlist_fname, fstab_fname, MONDO_LOGFILE, MONDO_LOGFILE); 674 671 res = system(tmp1); 675 672 mr_free(tmp1); … … 811 808 } 812 809 if (!evaluate_mountlist(mountlist, tmpA, tmpB, tmpC)) { 813 mr_asprintf(&tmp, 814 "Mountlist analyzed. Result: \"%s %s %s\" Switch to Interactive Mode?", 815 tmpA, tmpB, tmpC); 810 mr_asprintf(&tmp, "Mountlist analyzed. Result: \"%s %s %s\" Switch to Interactive Mode?", tmpA, tmpB, tmpC); 816 811 res = ask_me_yes_or_no(tmp); 817 812 mr_free(tmp); … … 1293 1288 } 1294 1289 mds = media_descriptor_string(bkpinfo->backup_media_type); 1295 mr_asprintf(&tmp, "Working on %s #%d, file #%ld, slice #%ld ", mds, 1296 g_current_media_number, bigfileno + 1, sliceno); 1290 mr_asprintf(&tmp, "Working on %s #%d, file #%ld, slice #%ld ", mds, g_current_media_number, bigfileno + 1, sliceno); 1297 1291 mr_free(mds); 1298 1292 log_msg(2, tmp); … … 1329 1323 if (use_ntfsprog_hack) { 1330 1324 log_msg(3, "Waiting for ntfsclone to finish"); 1331 mr_asprintf(&tmp, 1332 " ps | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null"); 1325 mr_asprintf(&tmp, " ps | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null"); 1333 1326 while (system(tmp) == 0) { 1334 1327 sleep(1); … … 1464 1457 use_ntfsprog_hack = TRUE; 1465 1458 log_msg(2, "Calling ntfsclone in background because %s is a /dev entry", outfile_fname); 1466 mr_asprintf(&sz_devfile, "%s/%d.%d.000", 1467 bkpinfo->tmpdir, 1468 (int) (random() % 32768), 1469 (int) (random() % 32768)); 1459 mr_asprintf(&sz_devfile, "%s/%d.%d.000", bkpinfo->tmpdir, (int) (random() % 32768), (int) (random() % 32768)); 1470 1460 mkfifo(sz_devfile, 0x770); 1471 1461 strcpy(ntfsprog_fifo, sz_devfile); … … 1684 1674 log_msg(3, "Saved fileset %ld's subset to %s", current_tarball_number, filelist_subset_fname); 1685 1675 } 1686 mr_asprintf(&screen_message, "Tarball #%ld --- %ld matches", 1687 current_tarball_number, matches); 1676 mr_asprintf(&screen_message, "Tarball #%ld --- %ld matches", current_tarball_number, matches); 1688 1677 log_to_screen(screen_message); 1689 1678 mr_free(screen_message); … … 2237 2226 } 2238 2227 g_current_media_number++; 2239 mr_asprintf(&progress_str, "Restoring from %s #%d", 2240 media_descriptor_string(bkpinfo->backup_media_type), 2241 g_current_media_number); 2228 mr_asprintf(&progress_str, "Restoring from %s #%d", media_descriptor_string(bkpinfo->backup_media_type), g_current_media_number); 2242 2229 log_to_screen(progress_str); 2243 2230 } else { 2244 mr_asprintf(&progress_str, "Restoring from fileset #%ld on %s #%d", 2245 current_tarball_number, mds, g_current_media_number); 2231 mr_asprintf(&progress_str, "Restoring from fileset #%ld on %s #%d", current_tarball_number, mds, g_current_media_number); 2246 2232 for (res = 999, attempts = 0; attempts < 3 && res != 0; 2247 2233 attempts++) { … … 2251 2237 filelist); 2252 2238 } 2253 mr_asprintf(&tmp1, "%s #%d, fileset #%ld - restore ", 2254 mds, g_current_media_number, current_tarball_number); 2239 mr_asprintf(&tmp1, "%s #%d, fileset #%ld - restore ", mds, g_current_media_number, current_tarball_number); 2255 2240 if (res) { 2256 2241 mr_strcat(tmp1, "reported errors"); … … 2381 2366 p++; 2382 2367 } 2383 mr_asprintf(&tmp1, "Restoring big file %ld (%lld K)", 2384 current_bigfile_number + 1, biggie_size / 1024); 2368 mr_asprintf(&tmp1, "Restoring big file %ld (%lld K)", current_bigfile_number + 1, biggie_size / 1024); 2385 2369 update_progress_form(tmp1); 2386 2370 mr_free(tmp1); … … 2519 2503 update_progress_form(progress_str); 2520 2504 if (g_getfattr) { 2521 mr_asprintf(&xattr_fname, "%s/xattr-subset-%ld.tmp", bkpinfo->tmpdir, 2522 current_afioball_number); 2505 mr_asprintf(&xattr_fname, "%s/xattr-subset-%ld.tmp", bkpinfo->tmpdir, current_afioball_number); 2523 2506 unlink(xattr_fname); 2524 2507 } -
branches/2.2.10/tools/quality
r2267 r2296 28 28 29 29 # How many sprintf/strcat/strcpy vs asprintf are they 30 for s in asprintf mr_asprintf sprintf snprintf strcat strcpy strncpy fgets malloc mr_malloc malloc_string getline mr_getline MAX_STR_LEN getcwd goto free mr_free paranoid_free ; do30 for s in asprintf mr_asprintf sprintf snprintf strcat strcpy strncpy fgets malloc mr_malloc malloc_string getline mr_getline MAX_STR_LEN getcwd goto free mr_free paranoid_free paranoid_system; do 31 31 echo "monodrescue $s usage : " 32 32 tot=0 … … 40 40 echo " " 41 41 echo "Qualimetry: " 42 find . -name '*.c' -o -name '*.h' | egrep -v '\.svn|/\*|monitas|/\*|mindi-busybox' | xargs grep -rw asprintf | egrep -v '/\*' | egrep -v 'asprintf\(&' > /tmp/mondo.quality42 pbg -w asprintf | grep -vE 'monitas|mindi-busybox|quality|/\*|asprintf\(&' > /tmp/mondo.quality 43 43 cat /tmp/mondo.quality 44 44 echo "monodrescue uses : `cat /tmp/mondo.quality | wc -l` asprintf without &" 45 find . -name '*.c' -o -name '*.h' | egrep -v '\.svn|/\*|monitas|/\*|mindi-busybox' | xargs grep -rw getline | egrep -v '/\*' | egrep -v 'getline\(&' > /tmp/mondo.quality45 pbg -w getline | grep -vE 'monitas|mindi-busybox|quality|/\*|getline\(&' > /tmp/mondo.quality 46 46 cat /tmp/mondo.quality 47 47 echo "monodrescue uses : `cat /tmp/mondo.quality | wc -l` getline without &" 48 48 pbg mr_asprintf | grep -vE '"|FNAME|ISOFS|syscall_sprintf|mr_mem|quality' > /tmp/mondo.quality 49 cat /tmp/mondo.quality 50 echo "monodrescue uses : `cat /tmp/mondo.quality | wc -l` mr_aspritnf without \"" 49 51 echo " " 50 52 echo "Splint: "
Note:
See TracChangeset
for help on using the changeset viewer.