Changeset 688 in MondoRescue for trunk/mondo/mondo/common
- Timestamp:
- Jul 17, 2006, 3:44:46 PM (18 years ago)
- Location:
- trunk/mondo/mondo/common
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/mondo/common/libmondo-archive.c
r687 r688 27 27 #include <sys/ipc.h> 28 28 #include <stdarg.h> 29 #include <unistd.h> 29 30 #define DVDRWFORMAT 1 30 31 … … 230 231 log_msg(5, "command='%s'", command); 231 232 res = system(command); 232 asprintf(&tmp, "%s",last_line_of_file(MONDO_LOGFILE));233 tmp = last_line_of_file(MONDO_LOGFILE)); 233 234 log_msg(1, "res=%d; tmp='%s'", res, tmp); 234 235 if (bkpinfo->use_star && (res == 254 || res == 65024) … … 296 297 297 298 /*@ buffers ******************************************************** */ 298 char *command ;299 char *command = NULL; 299 300 char *zipparams = NULL; 300 char *tmp, *tmp1; 301 char *tmp = NULL; 302 char *tmp1 = NULL; 301 303 302 304 assert(bkpinfo != NULL); … … 389 391 390 392 if (g_tmpfs_mountpt[0] != '\0') { 391 i = atoi(call_program_and_get_last_line_of_output 392 ("df -m -P | grep dev/shm | grep -v none | tr -s ' ' '\t' | cut -f4")); 393 tmp = call_program_and_get_last_line_of_output 394 ("df -m -P | grep dev/shm | grep -v none | tr -s ' ' '\t' | cut -f4"); 395 i = atoi(tmp); 396 paranoid_free(tmp); 397 393 398 if (i > 0) { 394 399 if (free_ramdisk_space > i) { … … 466 471 copy_mondo_and_mindi_stuff_to_scratchdir(bkpinfo); // payload, too, if it exists 467 472 #if __FreeBSD__ == 5 468 strcpy(bkpinfo->kernel_path, "/boot/kernel/kernel");473 paranoid_alloc(bkpinfo->kernel_path, "/boot/kernel/kernel"); 469 474 #elif __FreeBSD__ == 4 470 strcpy(bkpinfo->kernel_path, "/kernel");475 paranoid_alloc(bkpinfo->kernel_path, "/kernel"); 471 476 #elif linux 472 477 if (figure_out_kernel_path_interactively_if_necessary … … 523 528 { 524 529 /*@ buffer ************************************************************ */ 525 char *tmp ;526 char *command ;527 char *use_lzo_sz ;528 char *use_comp_sz ;529 char *use_star_sz ;530 char *bootldr_str ;531 char *tape_device ;532 char *last_filelist_number ;533 char *broken_bios_sz ;534 char *cd_recovery_sz ;535 char *tape_size_sz ;536 char *devs_to_exclude ;537 char *use_lilo_sz ;538 char *value ;539 char *bootdev ;530 char *tmp = NULL; 531 char *command = NULL; 532 char *use_lzo_sz = NULL; 533 char *use_comp_sz = NULL; 534 char *use_star_sz = NULL; 535 char *bootldr_str = NULL; 536 char *tape_device = NULL; 537 char *last_filelist_number = NULL; 538 char *broken_bios_sz = NULL; 539 char *cd_recovery_sz = NULL; 540 char *tape_size_sz = NULL; 541 char *devs_to_exclude = NULL; 542 char *use_lilo_sz = NULL; 543 char *value = NULL; 544 char *bootdev = NULL; 540 545 541 546 … … 556 561 "echo '%s' | tr -s ' ' '\n' | grep -x '/dev/.*' | tr -s '\n' ' ' | awk '{print $0\"\\n\";}'", 557 562 bkpinfo->exclude_paths); 558 asprintf(&devs_to_exclude, 559 call_program_and_get_last_line_of_output(tmp)); 563 devs_to_exclude = call_program_and_get_last_line_of_output(tmp); 560 564 paranoid_free(tmp); 561 565 asprintf(&tmp, "devs_to_exclude = '%s'", devs_to_exclude); … … 576 580 paranoid_free(tmp); 577 581 asprintf(&tmp, "%s/LAST-FILELIST-NUMBER", bkpinfo->tmpdir); 578 asprintf(&last_filelist_number, last_line_of_file(tmp));582 last_filelist_number = last_line_of_file(tmp); 579 583 paranoid_free(tmp); 580 584 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { … … 617 621 if (!bkpinfo->nonbootable_backup 618 622 && (bkpinfo->boot_loader == '\0' 619 || bkpinfo->boot_device [0] == '\0')) {623 || bkpinfo->boot_device == NULL)) { 620 624 621 625 #ifdef __FreeBSD__ 622 asprintf(&bootdev, call_program_and_get_last_line_of_output 623 ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'")); 624 if (!bootdev[0]) { 626 bootdev = call_program_and_get_last_line_of_output 627 ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'"); 628 if (!bootdev) { 629 bootdev = call_program_and_get_last_line_of_output 630 ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'"); 631 } 632 #else 633 bootdev = call_program_and_get_last_line_of_output 634 ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"); 635 if (!bootdev) { 636 bootdev = call_program_and_get_last_line_of_output 637 ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"); 638 } 639 if ((bootdev) && (strstr(bootdev, "/dev/cciss/"))) { 625 640 paranoid_free(bootdev); 626 asprintf(&bootdev, call_program_and_get_last_line_of_output 627 ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'")); 628 } 629 #else 630 asprintf(&bootdev, call_program_and_get_last_line_of_output 631 ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'")); 632 if (strstr(bootdev, "/dev/cciss/")) { 633 paranoid_free(bootdev); 634 asprintf(&bootdev, call_program_and_get_last_line_of_output 635 ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | cut -dp -f1")); 636 } 637 if (!bootdev[0]) { 638 paranoid_free(bootdev); 639 asprintf(&bootdev, call_program_and_get_last_line_of_output 640 ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'")); 641 if (strstr(bootdev, "/dev/cciss/")) { 642 paranoid_free(bootdev); 643 asprintf(&bootdev, call_program_and_get_last_line_of_output 644 ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | cut -dp -f1")); 645 } 641 bootdev = call_program_and_get_last_line_of_output 642 ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | cut -dp -f1"); 646 643 } 647 644 #endif 648 if (bootdev [0])645 if (bootdev) 649 646 ch = which_boot_loader(bootdev); 650 647 else … … 658 655 bkpinfo->boot_loader = ch; 659 656 } 660 if (bkpinfo->boot_device [0] != '\0') {657 if (bkpinfo->boot_device != NULL) { 661 658 asprintf(&tmp, "User specified boot device. It is '%s'.", 662 659 bkpinfo->boot_device); 663 660 log_msg(2, tmp); 664 661 paranoid_free(tmp); 662 paranoid_free(bootdev); 665 663 } else { 666 strcpy(bkpinfo->boot_device, bootdev); 667 } 668 } 669 paranoid_free(bootdev); 664 bkpinfo->boot_device = bootdev; 665 } 666 } 670 667 671 668 if ( … … 797 794 estimated_total_noof_slices = 798 795 size_of_all_biggiefiles_K(bkpinfo) / bkpinfo->optimal_set_size + 1; 799 /* add nfs stuff here? */800 796 asprintf(&command, "mkdir -p %s/images", bkpinfo->scratchdir); 801 797 if (system(command)) { … … 916 912 log_to_screen("Mindi failed to create your boot+data disks."); 917 913 asprintf(&command, "grep 'Fatal error' /var/log/mindi.log"); 918 asprintf(&tmp, call_program_and_get_last_line_of_output(command));914 tmp = call_program_and_get_last_line_of_output(command); 919 915 paranoid_free(command); 920 916 if (strlen(tmp) > 1) { … … 1176 1172 asprintf(&data_disks_file, "%s/all.tar.gz", bkpinfo->tmpdir); 1177 1173 1178 asprintf(&g_serial_string, 1179 call_program_and_get_last_line_of_output("dd \ 1174 g_serial_string = call_program_and_get_last_line_of_output("dd \ 1180 1175 if=/dev/urandom bs=16 count=1 2> /dev/null | \ 1181 1176 hexdump | tr -s ' ' '0' | head -n1")); 1182 strip_spaces(g_serial_string);1183 1177 asprintf(&tmp, "%s...word.", g_serial_string); 1184 1178 paranoid_free(g_serial_string); … … 1271 1265 } 1272 1266 /* if not Debian then go ahead & use fdformat */ 1273 asprintf(&tempfile, "%s", 1274 call_program_and_get_last_line_of_output 1275 ("mktemp -q /tmp/mondo.XXXXXXXX")); 1267 tempfile = call_program_and_get_last_line_of_output("mktemp -q /tmp/mondo.XXXXXXXX")); 1276 1268 asprintf(&command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile, 1277 1269 tempfile, tempfile); … … 1729 1721 ("Failed to write to disk. I shall blank it and then try again."); 1730 1722 sleep(5); 1731 sy stem("sync");1723 sync(); 1732 1724 pause_for_N_seconds(5, "Letting DVD drive settle"); 1733 1725 … … 1921 1913 char *tmp; 1922 1914 char *command; 1915 bool ret = TRUE; 1923 1916 asprintf(&command, 1924 1917 "dd if=%s bs=512 count=1 2> /dev/null | strings | head -n1", 1925 1918 bigfile_fname); 1926 1919 log_msg(1, "command = '%s'", command); 1927 asprintf(&tmp, "%s", 1928 call_program_and_get_last_line_of_output(command)); 1920 tmp = call_program_and_get_last_line_of_output(command)); 1929 1921 log_msg(1, "--> tmp = '%s'", tmp); 1930 1922 paranoid_free(command); 1931 1923 if (strstr(tmp, "NTFS")) { 1932 1924 iamhere("TRUE"); 1933 paranoid_free(tmp);1934 return (TRUE);1935 1925 } else { 1936 1926 iamhere("FALSE"); 1937 paranoid_free(tmp); 1938 return (FALSE); 1939 } 1927 ret = FALSE; 1928 } 1929 paranoid_free(tmp); 1930 return(ret); 1940 1931 } 1941 1932 … … 2870 2861 log_to_screen("%s found in drive. It's a Mondo disk.", 2871 2862 media_descriptor_string(g_backup_media_type)); 2872 cd_number = atoi(last_line_of_file(szcdno)); 2863 tmp1 = last_line_of_file(szcdno); 2864 cd_number = atoi(tmp1); 2865 paranoid_free(tmp1); 2873 2866 asprintf(&tmp1, "cat %s 2> /dev/null", szserfname); 2874 asprintf(&our_serial_str, "%s", 2875 call_program_and_get_last_line_of_output(tmp1)); 2867 our_serial_str = call_program_and_get_last_line_of_output(tmp1); 2876 2868 paranoid_free(tmp1); 2877 2869 // FIXME - should be able to use last_line_of_file(), surely? … … 2916 2908 } 2917 2909 paranoid_free(mtpt); 2918 2919 /*2920 if (g_current_media_number > ask_for_one_if_more_than_this)2921 {2922 ok_go_ahead_burn_it = FALSE;2923 log_it("paafcd: %d > %d, so I'll definitely pause.", g_current_media_number > ask_for_one_if_more_than_this);2924 }2925 */2926 2910 2927 2911 if (!ok_go_ahead_burn_it) { … … 3077 3061 sprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename); 3078 3062 log_it("command = %s", command); 3079 strcpy (tmp, call_program_and_get_last_line_of_output(command));3063 tmp = call_program_and_get_last_line_of_output(command); 3080 3064 log_it("res of it = %s", tmp); 3081 3065 totallength = (off_t)atoll(tmp); 3066 paranoid_free(tmp); 3082 3067 } else { 3083 3068 file_to_openin = biggie_filename; … … 3105 3090 paranoid_free(checksum_line); 3106 3091 3107 asprintf(&tmp, "%s", 3108 slice_fname(biggie_file_number, 0, bkpinfo->tmpdir, "")); 3092 tmp = slice_fname(biggie_file_number, 0, bkpinfo->tmpdir, ""); 3109 3093 fout = fopen(tmp, "w"); 3110 3094 paranoid_free(tmp); … … 3124 3108 return (1); 3125 3109 } 3110 tmp = slice_fname(biggie_file_number, 0,bkpinfo->tmpdir, ""); 3126 3111 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 3127 res = move_files_to_stream(bkpinfo, 3128 slice_fname(biggie_file_number, 0, 3129 bkpinfo->tmpdir, ""), NULL); 3112 res = move_files_to_stream(bkpinfo,tmp,NULL); 3130 3113 } else { 3131 res = 3132 move_files_to_cd(bkpinfo, mrconf, 3133 slice_fname(biggie_file_number, 0, 3134 bkpinfo->tmpdir, ""), NULL); 3135 } 3114 res = move_files_to_cd(bkpinfo, mrconf, tmp, NULL); 3115 } 3116 paranoid_free(tmp); 3136 3117 i = bkpinfo->optimal_set_size / 256; 3137 3118 for (slice_num = 1; !finished; slice_num++) { 3138 asprintf(&curr_slice_fname_uncompressed, "%s", 3139 slice_fname(biggie_file_number, slice_num, 3140 bkpinfo->tmpdir, "")); 3141 asprintf(&curr_slice_fname_compressed, "%s", 3142 slice_fname(biggie_file_number, slice_num, 3143 bkpinfo->tmpdir, suffix)); 3119 curr_slice_fname_uncompressed = slice_fname(biggie_file_number, slice_num, bkpinfo->tmpdir, ""); 3120 curr_slice_fname_compressed = slice_fname(biggie_file_number, slice_num, bkpinfo->tmpdir, suffix)); 3144 3121 3145 3122 tmp = percent_media_full_comment(bkpinfo); … … 3573 3550 "Verifying archives against live filesystem"); 3574 3551 if (bkpinfo->backup_media_type == cdstream) { 3575 paranoid_alloc(bkpinfo->media_device, 3576 "/dev/cdrom"); 3552 paranoid_alloc(bkpinfo->media_device,"/dev/cdrom"); 3577 3553 } 3578 3554 verify_tape_backups(bkpinfo); … … 3588 3564 g_current_media_number = cdno; 3589 3565 if (bkpinfo->backup_media_type != iso) { 3590 paranoid_free(bkpinfo->media_device); 3591 bkpinfo->media_device = find_cdrom_device(FALSE); 3566 bkpinfo->media_device = find_cdrom_device(FALSE)); 3592 3567 } 3593 3568 chdir("/"); … … 3717 3692 } 3718 3693 if (((blockno + 1) % 128) == 0) { 3719 paranoid_system("sync"); /* fflush doesn't work; dunno why */3694 sync(); /* fflush doesn't work; dunno why */ 3720 3695 update_evalcall_form(percentage); 3721 3696 } -
trunk/mondo/mondo/common/libmondo-devices.c
r687 r688 1 /* $Id$ 1 /* 2 * $Id$ 2 3 * Subroutines for handling devices 3 4 */ … … 19 20 #include <sys/ioctl.h> 20 21 #include <sys/types.h> 22 #include <unistd.h> 21 23 #ifdef __FreeBSD__ 22 24 #define DKTYPENAMES … … 60 62 { 61 63 if (bkpinfo->media_device != NULL) { 62 paranoid_free(g_cdrom_drive_is_here); 63 asprintf(&g_cdrom_drive_is_here, bkpinfo->media_device); // just in case 64 paranoid_alloc(g_cdrom_drive_is_here, bkpinfo->media_device); // just in case 64 65 } 65 66 if (bkpinfo->media_device != NULL) { 66 paranoid_free(g_dvd_drive_is_here); 67 asprintf(&g_dvd_drive_is_here, bkpinfo->media_device); // just in case 67 paranoid_alloc(g_dvd_drive_is_here, bkpinfo->media_device); // just in case 68 68 } 69 69 } … … 320 320 char *incoming = NULL; 321 321 char *searchstr; 322 char *tmp; 322 323 323 324 /*@ ints ******************************************************* */ … … 332 333 assert_string_is_neither_NULL_nor_zerolength(drive); 333 334 assert(partno >= 0 && partno < 999); 334 335 malloc_string(searchstr);336 335 337 336 #ifdef __FreeBSD__ … … 353 352 paranoid_free(program); 354 353 355 (void) build_partition_name(searchstr, drive, partno); 356 strcat(searchstr, " "); 354 searchstr = build_partition_name(drive, partno); 355 asprintf(&tmp, "%s ", searchstr); 356 paranoid_free(searchstr); 357 357 358 for (res = 0; !res && getline(&incoming, &n, fin);) { 358 if (strstr(incoming, searchstr)) {359 if (strstr(incoming, tmp)) { 359 360 res = 1; 360 361 } … … 365 366 log_OS_error("Cannot pclose fin"); 366 367 } 367 paranoid_free( searchstr);368 paranoid_free(tmp); 368 369 return (res); 369 370 } … … 459 460 asprintf(&dev, g_cdrom_drive_is_here); 460 461 } else { 462 // find_cdrom_device allocates the string 461 463 dev = find_cdrom_device(FALSE); 462 464 } … … 468 470 469 471 if ((dev == NULL) || (! mount_CDROM_here(dev, mountpoint))) { 472 paranoid_free(dev); 470 473 if (!popup_and_get_string 471 (_("CD-ROM device"), _("Please enter your CD-ROM's /dev device"), 472 dev, MAX_STR_LEN / 4)) { 474 (_("CD-ROM device"), _("Please enter your CD-ROM's /dev device"), dev)) { 473 475 res = FALSE; 474 476 } else { … … 556 558 { 557 559 /*@ pointers **************************************************** */ 558 FILE *fin ;559 char *p ;560 char *q ;561 char *r ;560 FILE *fin = NULL; 561 char *p = NULL; 562 char *q = NULL; 563 char *r = NULL; 562 564 char *output = NULL; 563 565 size_t n = 0; … … 568 570 /*@ buffers ***************************************************** */ 569 571 char *tmp = NULL; 570 char *cdr_exe ;572 char *cdr_exe = NULL; 571 573 #ifndef __FreeBSD__ 572 574 char *phrase_two = NULL; 573 575 char *dvd_last_resort = NULL; 574 576 #endif 575 char *command ;576 char *mountpoint ;577 static char the_last_place_i_found_it[MAX_STR_LEN] = "";577 char *command = NULL; 578 char *mountpoint = NULL; 579 static char *the_last_place_i_found_it = NULL; 578 580 579 581 /*@ end vars **************************************************** */ … … 584 586 return(output); 585 587 } 586 if ( the_last_place_i_found_it[0] != '\0'&& !try_to_mount) {588 if ((the_last_place_i_found_it != NULL) && !try_to_mount) { 587 589 asprintf(&output, the_last_place_i_found_it); 588 590 log_msg(3, … … 834 836 } 835 837 log_msg(3, "(find_cdrom_device) --> '%s'", output); 836 strcpy(the_last_place_i_found_it, output);838 asprintf(&the_last_place_i_found_it, output); 837 839 paranoid_free(g_cdrom_drive_is_here); 838 840 asprintf(&g_cdrom_drive_is_here, output); … … 863 865 char *find_dvd_device() 864 866 { 865 char *tmp ;867 char *tmp = NULL; 866 868 int retval = 0, devno = -1; 867 869 char *output = NULL; … … 1008 1010 bool is_this_a_valid_disk_format(char *format) 1009 1011 { 1010 char *good_formats; 1011 char *command; 1012 char *format_sz; 1013 1014 FILE *pin; 1012 char *good_formats = NULL; 1013 char *command = NULL; 1014 char *tmp = NULL; 1015 char *format_sz = NULL; 1016 1017 FILE *pin = NULL; 1015 1018 bool retval; 1016 malloc_string(good_formats);1019 size_t n = 0; 1017 1020 assert_string_is_neither_NULL_nor_zerolength(format); 1018 1021 … … 1034 1037 retval = FALSE; 1035 1038 } else { 1036 strcpy(good_formats, " "); 1037 (void) fgets(good_formats + 1, MAX_STR_LEN, pin); 1039 getline(&good_formats, &n , pin); 1038 1040 if (pclose(pin)) { 1039 1041 log_OS_error("Cannot pclose good formats"); 1040 1042 } 1041 1043 strip_spaces(good_formats); 1042 strcat(good_formats, " swap lvm raid ntfs 7 "); // " ntfs 7 " -- um, cheating much? :) 1044 // " ntfs 7 " -- um, cheating much? :) 1045 asprintf(&tmp, " %s swap lvm raid ntfs 7 ",good_formats); 1046 paranoid_free(good_formats); 1047 good_formats = tmp; 1048 1043 1049 if (strstr(good_formats, format_sz)) { 1044 1050 retval = TRUE; … … 1046 1052 retval = FALSE; 1047 1053 } 1048 }1049 paranoid_free(good_formats);1054 paranoid_free(good_formats); 1055 } 1050 1056 paranoid_free(format_sz); 1051 1057 return (retval); … … 1141 1147 char *make_vn(char *fname) 1142 1148 { 1143 char *device ;1149 char *device = NULL; 1144 1150 char *mddevice = NULL; 1145 1151 char *command = NULL; … … 1224 1230 { 1225 1231 /*@ buffer ****************************************************** */ 1226 char *command ;1227 int retval ;1232 char *command = NULL; 1233 int retval = 0; 1228 1234 1229 1235 assert_string_is_neither_NULL_nor_zerolength(device); … … 1238 1244 1239 1245 #ifdef __FreeBSD__ 1240 char *dev ;1246 char *dev = NULL; 1241 1247 1242 1248 dev = make_vn(device)); … … 1361 1367 1362 1368 while (what_number_cd_is_this(bkpinfo) != cd_number_i_want) { 1363 paranoid_system("sync");1369 sync(); 1364 1370 if (is_this_device_mounted(MNT_CDROM)) { 1365 1371 res = … … 1383 1389 inject_device(bkpinfo->media_device); 1384 1390 } 1385 paranoid_system("sync");1391 sync(); 1386 1392 } 1387 1393 paranoid_free(request); … … 1410 1416 // archiving_to_media is FALSE if I'm being called by mondorestore 1411 1417 { 1412 char *tmp; 1418 char *tmp = NULL; 1419 char *tmp1 = NULL; 1420 char *tmp2 = NULL; 1413 1421 char *sz_size = NULL; 1414 char *command ;1415 char *comment ;1422 char *command = NULL; 1423 char *comment = NULL; 1416 1424 char *prompt = NULL; 1417 int i ;1418 FILE *fin ;1425 int i = 0; 1426 FILE *fin = NULL; 1419 1427 1420 1428 assert(bkpinfo != NULL); … … 1480 1488 media_descriptor_string(bkpinfo->backup_media_type)); 1481 1489 if (bkpinfo->backup_media_type == dvd) { 1482 paranoid_free(bkpinfo->media_device);1483 1490 bkpinfo->media_device = find_dvd_device(); 1484 1491 asprintf(&tmp, "1"); … … 1492 1499 } 1493 1500 if (bkpinfo->backup_media_type != dvd) { 1494 if (!popup_and_get_string(_("Speed"), comment, tmp , 4)) {1501 if (!popup_and_get_string(_("Speed"), comment, tmp)) { 1495 1502 log_to_screen(_("User has chosen not to backup the PC")); 1496 1503 finish(1); … … 1506 1513 media_descriptor_string(bkpinfo->backup_media_type)); 1507 1514 1508 if (!popup_and_get_string("Size", comment, sz_size , 5)) {1515 if (!popup_and_get_string("Size", comment, sz_size)) { 1509 1516 log_to_screen(_("User has chosen not to backup the PC")); 1510 1517 finish(1); … … 1515 1522 bkpinfo->media_size[i] = atoi(sz_size); 1516 1523 } 1524 paranoid_free(sz_size); 1525 1517 1526 if (bkpinfo->media_size[0] <= 0) { 1518 1527 log_to_screen(_("User has chosen not to backup the PC")); 1519 1528 finish(1); 1520 1529 } 1521 paranoid_free(sz_size);1522 1530 } 1523 1531 case cdstream: … … 1529 1537 || bkpinfo->backup_media_type == dvd) { 1530 1538 if (bkpinfo->media_device == NULL) { 1531 paranoid_alloc(bkpinfo->media_device, "/dev/cdrom");1539 asprintf(&bkpinfo->media_device, "/dev/cdrom"); 1532 1540 } // just for the heck of it :) 1533 1541 log_msg(1, "bkpinfo->media_device = %s", … … 1544 1552 backup_media_type)); 1545 1553 if (!popup_and_get_string 1546 (_("Device?"), comment, bkpinfo->media_device, 1547 MAX_STR_LEN / 4)) { 1554 (_("Device?"), comment, bkpinfo->media_device)) { 1548 1555 log_to_screen(_("User has chosen not to backup the PC")); 1549 1556 finish(1); … … 1555 1562 bkpinfo->media_device); 1556 1563 } else { 1557 paranoid_free(bkpinfo->media_device);1558 1564 bkpinfo->media_device = find_cdrw_device(); 1559 1565 if (bkpinfo->media_device != NULL) { … … 1571 1577 i = popup_and_get_string(_("Device node?"), 1572 1578 _("What is the SCSI node of your CD (re)writer, please?"), 1573 bkpinfo->media_device, 1574 MAX_STR_LEN / 4); 1579 bkpinfo->media_device); 1575 1580 } else { 1576 1581 i = popup_and_get_string(_("/dev entry?"), 1577 1582 _("What is the /dev entry of your CD (re)writer, please?"), 1578 bkpinfo->media_device, 1579 MAX_STR_LEN / 4); 1583 bkpinfo->media_device); 1580 1584 } 1581 1585 if (!i) { … … 1602 1606 if (find_tape_device_and_size(bkpinfo->media_device, sz_size)) { 1603 1607 log_msg(3, _("Ok, using vanilla scsi tape.")); 1604 paranoid_alloc(bkpinfo->media_device,VANILLA_SCSI_TAPE );1608 paranoid_alloc(bkpinfo->media_device,VANILLA_SCSI_TAPE"0" ); 1605 1609 if ((fin = fopen(bkpinfo->media_device, "r"))) { 1606 1610 paranoid_fclose(fin); … … 1630 1634 (_("Device name?"), 1631 1635 _("What is the /dev entry of your tape streamer?"), 1632 bkpinfo->media_device , MAX_STR_LEN / 4)) {1636 bkpinfo->media_device)) { 1633 1637 log_to_screen(_("User has chosen not to backup the PC")); 1634 1638 finish(1); … … 1642 1646 paranoid_free(tmp); 1643 1647 log_msg(4, "sz_size = %s", sz_size); 1644 sz_size[0] = '\0';1648 paranoid_free(sz_size); 1645 1649 bkpinfo->media_size[0] = 0; 1646 1650 log_msg(4, "media_size[0] = %ld", bkpinfo->media_size[0]); … … 1677 1681 (_("NFS dir."), 1678 1682 _("Please enter path and directory where archives are stored remotely. (Mondo has taken a guess at the correct value. If it is incorrect, delete it and type the correct one.)"), 1679 bkpinfo->nfs_mount , MAX_STR_LEN / 4)) {1683 bkpinfo->nfs_mount)) { 1680 1684 log_to_screen(_("User has chosen not to backup the PC")); 1681 1685 finish(1); … … 1701 1705 asprintf(&comment, 1702 1706 _("How much data (in Megabytes) will each media store?")); 1703 if (!popup_and_get_string(_("Size"), comment, sz_size , 5)) {1707 if (!popup_and_get_string(_("Size"), comment, sz_size)) { 1704 1708 log_to_screen(_("User has chosen not to backup the PC")); 1705 1709 finish(1); … … 1718 1722 if (!popup_and_get_string 1719 1723 (_("NFS share"), _("Which remote NFS share should I mount?"), 1720 bkpinfo->nfs_mount , MAX_STR_LEN)) {1724 bkpinfo->nfs_mount)) { 1721 1725 log_to_screen(_("User has chosen not to backup the PC")); 1722 1726 finish(1); … … 1742 1746 finish(1); 1743 1747 } 1744 asprintf(&tmp, bkpinfo->nfs_remote_dir);1745 1748 if (!popup_and_get_string 1746 (_("Directory"), _("Which directory within that mountpoint?"), tmp, 1747 MAX_STR_LEN)) { 1749 (_("Directory"), _("Which directory within that mountpoint?"),bkpinfo->nfs_remote_dir)) { 1748 1750 log_to_screen(_("User has chosen not to backup the PC")); 1749 1751 finish(1); 1750 1752 } 1751 strcpy(bkpinfo->nfs_remote_dir, tmp); 1752 paranoid_free(tmp); 1753 1754 // check whether writable - we better remove surrounding spaces for this 1755 strip_spaces(bkpinfo->nfs_remote_dir); 1756 asprintf(&command, "echo hi > %s/%s/.dummy.txt", bkpinfo->isodir, 1753 1754 asprintf(&command, "echo hi > '%s/%s/.dummy.txt'", bkpinfo->isodir, 1757 1755 bkpinfo->nfs_remote_dir); 1758 1756 while (run_program_and_log_output(command, FALSE)) { 1759 paranoid_free(tmp);1760 paranoid_free(prompt);1761 asprintf(&tmp, bkpinfo->nfs_remote_dir);1762 1757 asprintf(&prompt, 1763 1758 _("Directory '%s' under mountpoint '%s' does not exist or is not writable. You can fix this or change the directory and retry or cancel the backup."), 1764 1759 bkpinfo->nfs_remote_dir, bkpinfo->isodir); 1765 1760 if (!popup_and_get_string 1766 (_("Directory"), prompt, tmp, MAX_STR_LEN)) {1761 (_("Directory"), prompt, bkpinfo->nfs_remote_dir)) { 1767 1762 log_to_screen(_("User has chosen not to backup the PC")); 1768 1763 finish(1); 1769 1764 } 1770 strcpy(bkpinfo->nfs_remote_dir, tmp);1771 // check whether writable - we better remove surrounding spaces for this */ 1772 strip_spaces(bkpinfo->nfs_remote_dir);1765 paranoid_free(prompt); 1766 1767 paranoid_free(command); 1773 1768 asprintf(&command, "echo hi > %s/%s/.dummy.txt", 1774 1769 bkpinfo->isodir, bkpinfo->nfs_remote_dir); 1775 1770 } 1776 1771 paranoid_free(command); 1777 paranoid_free(tmp);1778 paranoid_free(prompt);1779 1772 1780 1773 if (!popup_and_get_string 1781 1774 (_("Prefix."), 1782 1775 _("Please enter the prefix that will be prepended to your ISO filename. Example: machine1 to obtain machine1-[1-9]*.iso files"), 1783 bkpinfo->prefix , MAX_STR_LEN / 4)) {1776 bkpinfo->prefix)) { 1784 1777 log_to_screen(_("User has chosen not to backup the PC")); 1785 1778 finish(1); … … 1800 1793 (_("Storage dir."), 1801 1794 _("Please enter the full path that contains your ISO images. Example: /mnt/raid0_0"), 1802 bkpinfo->isodir , MAX_STR_LEN / 4)) {1795 bkpinfo->isodir)) { 1803 1796 log_to_screen(_("User has chosen not to backup the PC")); 1804 1797 finish(1); … … 1812 1805 if (!popup_and_get_string 1813 1806 (_("ISO size."), 1814 _("Please enter how big you want each ISO image to be (in megabytes). This should be less than or equal to the size of the CD-R[W]'s or DVD's you plan to backup to."), 1815 sz_size, 16)) { 1807 _("Please enter how big you want each ISO image to be (in megabytes). This should be less than or equal to the size of the CD-R[W]'s or DVD's you plan to backup to."), sz_size)) { 1816 1808 log_to_screen(_("User has chosen not to backup the PC")); 1817 1809 finish(1); … … 1825 1817 (_("Prefix."), 1826 1818 _("Please enter the prefix that will be prepended to your ISO filename. Example: machine1 to obtain machine1-[1-9]*.iso files"), 1827 bkpinfo->prefix , MAX_STR_LEN / 4)) {1819 bkpinfo->prefix)) { 1828 1820 log_to_screen("User has chosen not to backup the PC"); 1829 1821 finish(1); … … 1844 1836 1845 1837 #ifdef __FreeBSD__ 1846 strcpy(bkpinfo->boot_device, 1847 call_program_and_get_last_line_of_output 1838 bkpinfo->boot_device = call_program_and_get_last_line_of_output 1848 1839 ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'")); 1849 1840 #else 1850 strcpy(bkpinfo->boot_device, 1851 call_program_and_get_last_line_of_output 1841 bkpinfo->boot_device = call_program_and_get_last_line_of_output 1852 1842 ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'")); 1853 1843 #endif … … 1860 1850 (_("Boot device"), 1861 1851 _("What is your boot device? (e.g. /dev/ad0)"), 1862 bkpinfo->boot_device , MAX_STR_LEN / 4)) {1852 bkpinfo->boot_device)) { 1863 1853 log_to_screen(_("User has chosen not to backup the PC")); 1864 1854 finish(1); … … 1869 1859 (_("Boot device"), 1870 1860 _("What is your boot device? (e.g. /dev/hda)"), 1871 bkpinfo->boot_device , MAX_STR_LEN / 4)) {1861 bkpinfo->boot_device)) { 1872 1862 log_to_screen(_("User has chosen not to backup the PC")); 1873 1863 finish(1); … … 1901 1891 } 1902 1892 bkpinfo->boot_loader = i; 1903 strcpy(bkpinfo->include_paths, "/");1893 asprintf(&bkpinfo->include_paths, "/"); 1904 1894 if (!popup_and_get_string 1905 1895 (_("Backup paths"), 1906 1896 _("Please enter paths which you want me to backup. The default is '/' (i.e. everything)."), 1907 bkpinfo->include_paths , MAX_STR_LEN)) {1897 bkpinfo->include_paths)) { 1908 1898 log_to_screen(_("User has chosen not to backup the PC")); 1909 1899 finish(1); 1910 1900 } 1901 1911 1902 tmp = list_of_NFS_mounts_only(); 1912 1903 if (strlen(tmp) > 2) { 1913 if (bkpinfo->exclude_paths[0]) { 1914 strcat(bkpinfo->exclude_paths, " "); 1915 } 1916 strncpy(bkpinfo->exclude_paths, tmp, MAX_STR_LEN); 1904 if (bkpinfo->exclude_paths != NULL) { 1905 tmp1 = bkpinfo->exclude_paths; 1906 asprintf(&bkpinfo->exclude_paths, "%s %s", tmp1, tmp); 1907 paranoid_free(tmp1); 1908 } else { 1909 bkpinfo->exclude_paths = tmp; 1910 } 1917 1911 } 1918 1912 paranoid_free(tmp); 1919 1913 // NTFS 1920 asprintf(&tmp, 1921 call_program_and_get_last_line_of_output 1922 ("parted2fdisk -l | grep -i ntfs | awk '{ print $1};' | tr -s '\\n' ' ' | awk '{ print $0};'")); 1914 tmp = call_program_and_get_last_line_of_output 1915 ("parted2fdisk -l | grep -i ntfs | awk '{ print $1};' | tr -s '\\n' ' ' | awk '{ print $0};'"); 1923 1916 if (strlen(tmp) > 2) { 1924 1917 if (!popup_and_get_string 1925 1918 (_("NTFS partitions"), 1926 1919 _("Please enter/confirm the NTFS partitions you wish to backup as well."), 1927 tmp , MAX_STR_LEN / 4)) {1920 tmp1)) { 1928 1921 log_to_screen(_("User has chosen not to backup the PC")); 1929 1922 finish(1); 1930 1923 } 1931 strncpy(bkpinfo->image_devs, tmp, MAX_STR_LEN / 4); 1924 if (bkpinfo->image_devs != NULL) { 1925 tmp2 = bkpinfo->image_devs; 1926 asprintf(&bkpinfo->image_devs, "%s %s", tmp2, tmp1); 1927 paranoid_free(tmp2); 1928 } else { 1929 bkpinfo->image_devs = tmp1; 1930 } 1931 paranoid_free(tmp1); 1932 1932 } 1933 1933 paranoid_free(tmp); … … 1936 1936 (_("Exclude paths"), 1937 1937 _("Please enter paths which you do NOT want to backup. Separate them with spaces. NB: /tmp and /proc are always excluded. :-) Just hit 'Enter' if you want to do a full system backup."), 1938 bkpinfo->exclude_paths , MAX_STR_LEN)) {1938 bkpinfo->exclude_paths)) { 1939 1939 log_to_screen(_("User has chosen not to backup the PC")); 1940 1940 finish(1); … … 2005 2005 * Get a space-separated list of NFS mounts. 2006 2006 * @return The list created. 2007 * @note The return value points to static data that will be overwritten with each call.2007 * @note The return value should be freed by caller 2008 2008 * @bug Even though we only want the mounts, the devices are still checked. 2009 2009 */ 2010 2010 char *list_of_NFS_mounts_only(void) 2011 2011 { 2012 char *exclude_these_devices; 2013 char *exclude_these_directories; 2014 char *result_sz; 2015 2016 asprintf(&exclude_these_directories, 2017 call_program_and_get_last_line_of_output 2012 return(call_program_and_get_last_line_of_output 2018 2013 ("mount -t coda,ncpfs,nfs,smbfs,cifs | tr -s '\t' ' ' | cut -d' ' -f3 | tr -s '\n' ' ' | awk '{print $0;}'")); 2014 /* BERLIOS : Useless 2019 2015 asprintf(&exclude_these_devices, 2020 2016 call_program_and_get_last_line_of_output 2021 2017 ("tr -s '\t' ' ' < /etc/fstab | grep -E '( (coda|ncpfs|nfs|smbfs|cifs) )' | cut -d' ' -f1 | tr -s '\n' ' ' | awk '{print $0;}'")); 2022 asprintf(&result_sz, "%s", exclude_these_directories); 2023 paranoid_free(exclude_these_devices); 2024 paranoid_free(exclude_these_directories); 2025 return (result_sz); 2018 */ 2026 2019 } 2027 2020 … … 2060 2053 void sensibly_set_tmpdir_and_scratchdir(struct s_bkpinfo *bkpinfo) 2061 2054 { 2062 char *tmp, *command, *sz; 2055 char *tmp = NULL; 2056 char *command = NULL; 2057 char *sz = NULL; 2058 int i = 0; 2063 2059 2064 2060 assert(bkpinfo != NULL); 2065 2061 2066 2062 #ifdef __FreeBSD__ 2067 asprintf(&tmp, 2068 call_program_and_get_last_line_of_output 2069 ("df -m -P -t nonfs,msdosfs,ntfs,smbfs,smb,cifs | tr -s '\t' ' ' | grep -vE \"none|Filesystem\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'")); 2063 tmp = call_program_and_get_last_line_of_output 2064 ("df -m -P -t nonfs,msdosfs,ntfs,smbfs,smb,cifs | tr -s '\t' ' ' | grep -vE \"none|Filesystem\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'"); 2070 2065 #else 2071 asprintf(&tmp, 2072 call_program_and_get_last_line_of_output 2073 ("df -m -P -x nfs -x vfat -x ntfs -x smbfs -x smb -x cifs | 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;}'")); 2066 tmp = call_program_and_get_last_line_of_output 2067 ("df -m -P -x nfs -x vfat -x ntfs -x smbfs -x smb -x cifs | 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;}'"); 2074 2068 #endif 2075 2069 … … 2082 2076 fatal_error("I couldn't figure out the tempdir!"); 2083 2077 } 2084 sprintf(bkpinfo->tmpdir, "%s/tmp.mondo.%d", tmp,2085 (int) (random() % 32768));2078 i = (int) (random() % 32768); 2079 asprintf(&bkpinfo->tmpdir, "%s/mondo.tmp.%d", tmp, i); 2086 2080 log_it("bkpinfo->tmpdir is being set to %s", bkpinfo->tmpdir); 2087 2081 2088 sprintf(bkpinfo->scratchdir, "%s/mondo.scratch.%d", tmp, 2089 (int) (random() % 32768)); 2082 asprintf(&bkpinfo->scratchdir, "%s/mondo.scratch.%d", tmp, i); 2090 2083 log_it("bkpinfo->scratchdir is being set to %s", bkpinfo->scratchdir); 2091 2084 2092 sprintf(g_erase_tmpdir_and_scratchdir, "rm -Rf %s %s", bkpinfo->tmpdir,2085 asprintf(&g_erase_tmpdir_and_scratchdir, "rm -Rf %s %s", bkpinfo->tmpdir, 2093 2086 bkpinfo->scratchdir); 2094 2087 2095 asprintf(&command, "rm -Rf %s/ tmp.mondo.* %s/mondo.scratch.*", tmp, tmp);2088 asprintf(&command, "rm -Rf %s/mondo.tmp.* %s/mondo.scratch.*", tmp, tmp); 2096 2089 paranoid_free(tmp); 2097 2090 … … 2152 2145 { 2153 2146 int cd_number = -1; 2154 char *mountdev; 2155 char *tmp; 2147 char *mountdev = NULL; 2148 char *tmp = NULL; 2149 char *tmp1 = NULL; 2156 2150 2157 2151 assert(bkpinfo != NULL); … … 2159 2153 asprintf(&tmp, "mount | grep iso9660 | awk '{print $3;}'"); 2160 2154 2161 asprintf(&mountdev, "%s/archives/THIS-CD-NUMBER", call_program_and_get_last_line_of_output(tmp));2155 tmp1 = call_program_and_get_last_line_of_output(tmp); 2162 2156 paranoid_free(tmp); 2163 2157 2164 cd_number = atoi(last_line_of_file(mountdev)); 2158 asprintf(&mountdev, "%s/archives/THIS-CD-NUMBER", tmp1); 2159 paranoid_free(tmp1); 2160 2161 tmp = last_line_of_file(mountdev); 2162 cd_number = atoi(tmp); 2165 2163 paranoid_free(mountdev); 2164 paranoid_free(tmp); 2166 2165 2167 2166 return (cd_number); … … 2176 2175 (void)mount_CDROM_here(bkpinfo->media_device, MNT_CDROM); 2177 2176 } 2178 cd_number = 2179 atoi(last_line_of_file(MNT_CDROM "/archives/THIS-CD-NUMBER")); 2177 tmp = last_line_of_file(MNT_CDROM "/archives/THIS-CD-NUMBER"); 2178 cd_number = atoi(tmp); 2179 paranoid_free(tmp); 2180 2180 return (cd_number); 2181 2181 } … … 2191 2191 char *where_is_root_mounted() 2192 2192 { 2193 /*@ buffers **************** */2194 2193 char *tmp; 2195 2194 2196 2197 2195 #ifdef __FreeBSD__ 2198 asprintf(&tmp,call_program_and_get_last_line_of_output2199 ("mount | grep \" on / \" | cut -d' ' -f1") );2196 tmp = call_program_and_get_last_line_of_output 2197 ("mount | grep \" on / \" | cut -d' ' -f1"); 2200 2198 #else 2201 asprintf(&tmp,call_program_and_get_last_line_of_output2202 ("mount | grep \" on / \" | cut -d' ' -f1 | sed s/[0-9]// | sed s/[0-9]//") );2199 tmp = call_program_and_get_last_line_of_output 2200 ("mount | grep \" on / \" | cut -d' ' -f1 | sed s/[0-9]// | sed s/[0-9]//"); 2203 2201 if (strstr(tmp, "/dev/cciss/")) { 2204 2202 paranoid_free(tmp); 2205 asprintf(&tmp,call_program_and_get_last_line_of_output2206 ("mount | grep \" on / \" | cut -d' ' -f1 | cut -dp -f1") );2203 tmp = call_program_and_get_last_line_of_output 2204 ("mount | grep \" on / \" | cut -d' ' -f1 | cut -dp -f1"); 2207 2205 } 2208 2206 if (strstr(tmp, "/dev/md")) { 2209 2207 paranoid_free(tmp); 2210 asprintf(&tmp, 2211 call_program_and_get_last_line_of_output 2212 ("mount | grep \" on / \" | cut -d' ' -f1")); 2208 tmp = call_program_and_get_last_line_of_output 2209 ("mount | grep \" on / \" | cut -d' ' -f1"); 2213 2210 } 2214 2211 #endif … … 2373 2370 char *resolve_softlinks_to_get_to_actual_device_file(char *incoming) 2374 2371 { 2375 char *output ;2376 char *command ;2377 char *curr_fname ;2378 char *scratch ;2379 char *tmp ;2380 char *p ;2372 char *output = NULL; 2373 char *command = NULL; 2374 char *curr_fname = NULL; 2375 char *scratch = NULL; 2376 char *tmp = NULL; 2377 char *p = NULL; 2381 2378 2382 2379 struct stat statbuf; … … 2391 2388 log_msg(1, "curr_fname = %s", curr_fname); 2392 2389 asprintf(&command, "file %s", curr_fname); 2393 asprintf(&tmp, call_program_and_get_last_line_of_output(command));2390 tmp = call_program_and_get_last_line_of_output(command); 2394 2391 paranoid_free(command); 2395 2392 … … 2400 2397 for (p = scratch; *p != '\0' && *p != '\''; p++); 2401 2398 *p = '\0'; 2402 log_msg(0, "curr_fname %s --> '%s' --> %s", curr_fname, tmp, 2403 scratch); 2399 log_msg(0, "curr_fname %s --> '%s' --> %s", curr_fname, tmp, scratch); 2404 2400 paranoid_free(tmp); 2405 2401 … … 2439 2435 char *which_partition_format(const char *drive) 2440 2436 { 2441 char *output ;2442 char *tmp ;2443 char *command ;2444 char *fdisk ;2437 char *output = NULL; 2438 char *tmp = NULL; 2439 char *command = NULL; 2440 char *fdisk = NULL; 2445 2441 2446 2442 log_msg(0, "Looking for partition table format type"); … … 2450 2446 paranoid_free(fdisk); 2451 2447 2452 asprintf(&tmp, call_program_and_get_last_line_of_output(command));2448 tmp = call_program_and_get_last_line_of_output(command); 2453 2449 paranoid_free(command); 2454 2450 -
trunk/mondo/mondo/common/libmondo-fifo.c
r687 r688 13 13 #endif 14 14 #include <fcntl.h> 15 #include <stdio.h>16 15 17 16 #include <errno.h> … … 85 84 wise_upper_limit = (am_I_in_disaster_recovery_mode()? 8 : 32); 86 85 wise_lower_limit = 1; // wise_upper_limit/2 + 1; 87 paranoid_system("sync");86 sync(); 88 87 for (bufsize = wise_upper_limit, res = -1; 89 88 res != 0 && bufsize >= wise_lower_limit; bufsize--) { … … 96 95 if (!res) { 97 96 bufsize++; 98 asprintf(&tmp, _("Negotiated max buffer of %d MB " , bufsize));97 asprintf(&tmp, _("Negotiated max buffer of %d MB "), bufsize); 99 98 log_to_screen(tmp); 100 99 paranoid_free(tmp); … … 160 159 char *command; 161 160 162 paranoid_system("sync");161 sync(); 163 162 asprintf(&command, 164 163 "ps wwax | grep -F \"%s\" | grep -Fv grep | awk '{print $1;}' | grep -v PID | tr -s '\n' ' ' | awk '{ print $1; }'", … … 167 166 log_msg(2, "kill_buffer() --- command = %s", command); 168 167 169 asprintf(&tmp, "%s", 170 call_program_and_get_last_line_of_output(command)); 168 tmp = call_program_and_get_last_line_of_output(command); 171 169 paranoid_free(command); 172 170 … … 177 175 run_program_and_log_output(command, TRUE); 178 176 } 177 paranoid_free(tmp); 179 178 paranoid_free(command); 180 paranoid_free(tmp);181 179 } 182 180 -
trunk/mondo/mondo/common/libmondo-filelist.c
r687 r688 847 847 { 848 848 849 /*@ structures ************************************************* */ 850 struct s_node *filelist; 851 852 /*@ pointers *************************************************** */ 853 FILE *pin; 854 855 /*@ buffers **************************************************** */ 856 char *command_to_open_fname; 849 struct s_node *filelist = NULL; 850 FILE *pin = NULL; 851 char *command_to_open_fname = NULL; 857 852 char *fname = NULL; 858 char *tmp; 859 int pos_in_fname; 853 char *tmp = NULL; 854 char *tmp1 = NULL; 855 int pos_in_fname = 0; 860 856 size_t n = 0; 861 /*@ int ******************************************************** */ 862 int percentage; 863 864 /*@ long ******************************************************* */ 865 long lines_in_filelist; 866 long lino = 0; 867 /*@ end vars *************************************************** */ 857 int percentage = 0; 858 859 long lines_in_filelist = 0L; 860 long lino = 0L; 868 861 869 862 assert_string_is_neither_NULL_nor_zerolength(filelist_fname); … … 876 869 asprintf(&tmp, "zcat %s | wc -l", filelist_fname); 877 870 log_msg(6, "tmp = %s", tmp); 878 lines_in_filelist = 879 atol(call_program_and_get_last_line_of_output(tmp)); 871 tmp1 = call_program_and_get_last_line_of_output(tmp); 880 872 paranoid_free(tmp); 873 874 lines_in_filelist = atol(tmp1); 875 paranoid_free(tmp1); 881 876 882 877 if (lines_in_filelist < 3) { … … 1322 1317 char *skeleton_filelist) 1323 1318 { 1324 DIR *dip ;1325 struct dirent *dit ;1319 DIR *dip = NULL; 1320 struct dirent *dit = NULL; 1326 1321 struct stat statbuf; 1327 char *new; 1328 char *tmp; 1322 char *new = NULL; 1323 char *tmp = NULL; 1324 char *tmp1 = NULL; 1329 1325 static int percentage = 0; 1330 char *skip_these ;1331 char *new_with_spaces ;1332 static char *name_of_evalcall_form ;1333 int i ;1326 char *skip_these = NULL; 1327 char *new_with_spaces = NULL; 1328 static char *name_of_evalcall_form = NULL; 1329 int i = 0; 1334 1330 static int depth = 0; 1335 char *p ;1331 char *p = NULL; 1336 1332 static int counter = 0; 1337 1333 static int uberctr = 0; 1338 static char *find_skeleton_marker ;1334 static char *find_skeleton_marker = NULL; 1339 1335 static long skeleton_lino = 0; 1340 1336 static time_t last_time = 0; … … 1365 1361 1366 1362 asprintf(&tmp, "wc -l %s | awk '{print $1;}'", skeleton_filelist); 1367 g_skeleton_entries = 1368 1 + atol(call_program_and_get_last_line_of_output(tmp)); 1363 tmp1 = call_program_and_get_last_line_of_output(tmp); 1369 1364 paranoid_free(tmp); 1365 1366 g_skeleton_entries = 1 + atol(tmp1); 1367 paranoid_free(tmp1); 1370 1368 1371 1369 asprintf(&name_of_evalcall_form, "Making catalog of %s", dir); … … 1534 1532 { 1535 1533 char sz_datefile_wildcard[] = "/var/cache/mondo/difflevel.%d"; 1536 char *p, *q; 1534 char *p = NULL; 1535 char *q = NULL; 1536 char *tmp = NULL; 1537 char *tmp1 = NULL; 1538 char *tmp2 = NULL; 1537 1539 char *sz_datefile; 1538 char *sz_filelist, *exclude_paths; 1539 int i; 1540 FILE *fout; 1541 char *command; 1540 char *sz_filelist = NULL; 1541 char *exclude_paths = NULL; 1542 int i = 0; 1543 FILE *fout = NULL; 1544 char *command = NULL; 1542 1545 time_t time_of_last_full_backup = 0; 1543 1546 struct stat statbuf; 1544 char *skeleton_filelist; 1547 char *skeleton_filelist = NULL; 1548 1545 1549 // The pathname to the skeleton filelist, used to give better progress reporting for mondo_makefilelist(). 1546 1547 1550 asprintf(&sz_datefile, sz_datefile_wildcard, 0); 1548 1551 if (!include_paths && !userdef_filelist) { … … 1573 1576 } 1574 1577 make_hole_for_file(sz_datefile); 1575 write_one_liner_data_file(sz_datefile,1576 call_program_and_get_last_line_of_output1577 ("date +%s"));1578 tmp = call_program_and_get_last_line_of_output("date +%s"); 1579 write_one_liner_data_file(sz_datefile, tmp); 1580 paranoid_free(tmp); 1578 1581 } else if (lstat(sz_datefile, &statbuf)) { 1579 1582 log_msg(2, … … 1600 1603 log_msg(2, "include_paths = '%s'", include_paths); 1601 1604 log_msg(1, "Calculating filelist"); 1605 tmp = call_program_and_get_last_line_of_output("locate /win386.swp 2> /dev/null"); 1606 tmp1 = call_program_and_get_last_line_of_output("locate /hiberfil.sys 2> /dev/null"); 1607 tmp2 = call_program_and_get_last_line_of_output("locate /pagefile.sys 2> /dev/null"); 1602 1608 asprintf(&exclude_paths, " %s %s %s %s %s %s . .. \ 1603 1609 " MNT_CDROM " " MNT_FLOPPY " /media/cdrom /media/cdrecorder \ 1604 /proc /sys /tmp /var/cache/mondo /var/cache/mindi", excp, call_program_and_get_last_line_of_output("locate /win386.swp 2> /dev/null"), call_program_and_get_last_line_of_output("locate /hiberfil.sys 2> /dev/null"), call_program_and_get_last_line_of_output("locate /pagefile.sys 2> /dev/null"), (tmpdir[0] == '/' && tmpdir[1] == '/') ? (tmpdir + 1) : tmpdir, (scratchdir[0] == '/' && scratchdir[1] == '/') ? (scratchdir + 1) : scratchdir); 1610 /proc /sys /tmp /var/cache/mondo /var/cache/mindi", excp, tmp, tmp1, tmp2, (tmpdir[0] == '/' && tmpdir[1] == '/') ? (tmpdir + 1) : tmpdir, (scratchdir[0] == '/' && scratchdir[1] == '/') ? (scratchdir + 1) : scratchdir); 1611 paranoid_free(tmp); 1612 paranoid_free(tmp1); 1613 paranoid_free(tmp2); 1605 1614 1606 1615 log_msg(2, "Excluding paths = '%s'", exclude_paths); -
trunk/mondo/mondo/common/libmondo-files.c
r687 r688 22 22 //static char cvsid[] = "$Id$"; 23 23 24 extern char err_log_lines[NOOF_ERR_LINES][MAX_STR_LEN];24 extern char **err_log_lines; 25 25 26 26 extern int g_currentY; … … 270 270 int figure_out_kernel_path_interactively_if_necessary(char *kernel) 271 271 { 272 char *tmp; 273 char *command; 274 275 if (!kernel[0]) { 276 strcpy(kernel, 277 call_program_and_get_last_line_of_output 272 char *tmp = NULL; 273 char *command = NULL; 274 275 if (kernel == NULL) { 276 kernel = call_program_and_get_last_line_of_output 278 277 ("mindi --findkernel 2> /dev/null")); 279 278 } 280 279 // If we didn't get anything back, check whether mindi raised a fatal error 281 if ( !kernel[0]) {280 if (kernel == NULL) { 282 281 asprintf(&command, "grep 'Fatal error' /var/log/mindi.log"); 283 asprintf(&tmp, call_program_and_get_last_line_of_output(command));282 tmp = call_program_and_get_last_line_of_output(command); 284 283 if (strlen(tmp) > 1) { 285 284 popup_and_OK(tmp); … … 289 288 paranoid_free(tmp); 290 289 } 291 log_it("Calling Mindi with kernel path of '%s'", kernel); 292 while (!kernel[0]) { 290 291 if (kernel != NULL) { 292 log_it("Calling Mindi with kernel path of '%s'", kernel); 293 } else { 294 log_it("Calling Mindi without kernel, so asking one"); 295 } 296 297 while (kernel == NULL) { 293 298 if (!ask_me_yes_or_no 294 299 (_("Kernel not found or invalid. Choose another?"))) { … … 298 303 (_("Kernel path"), 299 304 _("What is the full path and filename of your kernel, please?"), 300 kernel , MAX_STR_LEN / 4)) {305 kernel)) { 301 306 fatal_error 302 307 ("Kernel not found. Please specify with the '-k' flag."); 303 308 } 304 asprintf(&tmp, "User says kernel is at %s", kernel); 305 log_it(tmp); 306 paranoid_free(tmp); 309 log_it("User says kernel is at %s", kernel); 307 310 } 308 311 return (0); … … 322 325 { 323 326 /*@ buffers ********************* */ 324 static char output[MAX_STR_LEN];325 char *incoming ;326 char *command ;327 char *output = NULL; 328 char *incoming = NULL; 329 char *command = NULL; 327 330 328 331 /*@******************************* */ 329 332 330 333 assert_string_is_neither_NULL_nor_zerolength(fname); 334 331 335 asprintf(&command, "which %s 2> /dev/null", fname); 332 asprintf(&incoming, call_program_and_get_last_line_of_output(command));333 paranoid_free(command); 334 335 if (incoming [0] == '\0') {336 incoming = call_program_and_get_last_line_of_output(command); 337 paranoid_free(command); 338 339 if (incoming == NULL) { 336 340 if (system("which file > /dev/null 2> /dev/null")) { 337 paranoid_free(incoming);338 341 return (NULL); // forget it :) 339 342 } … … 343 346 paranoid_free(incoming); 344 347 345 asprintf(&incoming, 346 call_program_and_get_last_line_of_output(command)); 348 incoming = call_program_and_get_last_line_of_output(command); 347 349 paranoid_free(command); 348 350 } 349 if (incoming [0] == '\0') // yes, it is == '\0' twice, not once :)351 if (incoming == NULL) // yes, it is == '\0' twice, not once :) 350 352 { 351 353 asprintf(&command, "dirname %s 2> /dev/null", incoming); 352 354 paranoid_free(incoming); 353 355 354 asprintf(&incoming, 355 call_program_and_get_last_line_of_output(command)); 356 incoming = call_program_and_get_last_line_of_output(command); 356 357 paranoid_free(command); 357 358 } 358 strcpy(output, incoming); 359 paranoid_free(incoming); 360 361 if (output[0] != '\0' && does_file_exist(output)) { 362 log_msg(4, "find_home_of_exe () --- Found %s at %s", fname, 363 output); 359 output = incoming; 360 361 if (output != NULL && does_file_exist(output)) { 362 log_msg(4, "find_home_of_exe () --- Found %s at %s", fname, output); 364 363 } else { 365 output[0] = '\0';364 paranoid_free(output); 366 365 log_msg(4, "find_home_of_exe() --- Could not find %s", fname); 367 366 } 368 if (!output[0]) { 369 return (NULL); 370 } else { 371 return (output); 372 } 367 return (output); 373 368 } 374 369 … … 421 416 { 422 417 423 /*@ buffers ***************************************************** */ 424 char *lastline; 425 char *command; 426 /*@ pointers **************************************************** */ 427 char *p; 428 429 /*@ int's ******************************************************* */ 418 char *lastline = NULL; 419 char *command = NULL; 420 char *p = NULL; 430 421 int i; 431 422 432 for (i = NOOF_ERR_LINES- 1;423 for (i = g_noof_log_lines - 1; 433 424 i >= 0 && !strstr(err_log_lines[i], "% Done") 434 425 && !strstr(err_log_lines[i], "% done"); i--); … … 437 428 "tail -n3 %s | grep -Fi \"%c\" | tail -n1 | awk '{print $0;}'", 438 429 filename, '%'); 439 asprintf(&lastline, 440 call_program_and_get_last_line_of_output(command)); 430 lastline = call_program_and_get_last_line_of_output(command); 441 431 paranoid_free(command); 442 if (!lastline[0]) { 443 paranoid_free(lastline); 432 if (!lastline) { 444 433 return (0); 445 434 } … … 477 466 { 478 467 /*@ buffers ***************************************************** */ 479 static char output[MAX_STR_LEN];480 static char *command;481 static char *tmp;468 char *output = NULL; 469 char *command = NULL; 470 char *tmp = NULL; 482 471 483 472 /*@ pointers **************************************************** */ 484 473 FILE *fin; 474 size_t n = 0; 485 475 486 476 /*@ end vars **************************************************** */ … … 491 481 log_it(tmp); 492 482 paranoid_free(tmp); 493 494 output[0] = '\0'; 483 asprintf(&output, ""); 484 495 485 return (output); 496 486 } … … 499 489 paranoid_free(command); 500 490 501 (void) fgets(output, MAX_STR_LEN, fin);491 getline(&output, &n, fin); 502 492 paranoid_pclose(fin); 503 493 while (strlen(output) > 0 && output[strlen(output) - 1] < 32) { … … 693 683 long size_of_partition_in_mountlist_K(char *tmpdir, char *dev) 694 684 { 695 char *command ;696 char *sz_res ;697 long file_len_K ;685 char *command = NULL; 686 char *sz_res = NULL; 687 long file_len_K = 0L; 698 688 699 689 asprintf(&command, … … 701 691 dev, tmpdir); 702 692 log_it(command); 703 asprintf(&sz_res, call_program_and_get_last_line_of_output(command));693 sz_res = call_program_and_get_last_line_of_output(command); 704 694 file_len_K = atol(sz_res); 705 695 log_msg(4, "%s --> %s --> %ld", command, sz_res, file_len_K); … … 717 707 long size_of_all_biggiefiles_K(struct s_bkpinfo *bkpinfo) 718 708 { 719 /*@ buffers ***************************************************** */ 720 char *fname; 721 char *biggielist; 722 char *comment; 723 char *tmp; 724 char *command; 709 char *fname = NULL; 710 char *biggielist = NULL; 711 char *comment = NULL; 712 char *tmp = NULL; 713 char *command = NULL; 725 714 726 715 /*@ long ******************************************************** */ 727 long scratchL = 0 ;728 long file_len_K ;716 long scratchL = 0L; 717 long file_len_K = 0L; 729 718 730 719 /*@ pointers *************************************************** */ … … 734 723 /*@ end vars *************************************************** */ 735 724 736 malloc_string(tmp);737 malloc_string(command);738 725 log_it("Calculating size of all biggiefiles (in total)"); 739 726 asprintf(&biggielist, "%s/biggielist.txt", bkpinfo->tmpdir); … … 754 741 fatal_error("ntfsresize not found"); 755 742 } 756 sprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", fname);743 asprintf(&command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", fname); 757 744 log_it("command = %s", command); 758 strcpy (tmp, call_program_and_get_last_line_of_output(command)); 745 tmp = call_program_and_get_last_line_of_output(command); 746 paranoid_free(command); 747 759 748 log_it("res of it = %s", tmp); 760 749 file_len_K = atoll(tmp) / 1024L; 750 paranoid_free(tmp); 761 751 } else { 762 752 file_len_K = get_phys_size_of_drive(fname) * 1024L; … … 787 777 paranoid_fclose(fin); 788 778 log_it("Finished calculating total size of all biggiefiles"); 789 paranoid_free(tmp);790 paranoid_free(command);791 779 return (scratchL); 792 780 } … … 803 791 /*@ buffer ****************************************************** */ 804 792 char *tmp = NULL; 805 char *command ;793 char *command = NULL; 806 794 long long llres; 807 795 size_t n = 0; 808 796 /*@ pointers **************************************************** */ 809 char *p ;810 FILE *fin ;797 char *p = NULL; 798 FILE *fin = NULL; 811 799 812 800 /*@ end vars *************************************************** */ … … 1025 1013 paranoid_free(command); 1026 1014 1027 asprintf(&tmp, 1028 call_program_and_get_last_line_of_output("which mondorestore")); 1029 if (!tmp[0]) { 1015 tmp = call_program_and_get_last_line_of_output("which mondorestore"); 1016 if (!tmp) { 1030 1017 fatal_error 1031 1018 ("'which mondorestore' returned null. Where's your mondorestore? `which` can't find it. That's odd. Did you install mondorestore?"); … … 1068 1055 1069 1056 /*@ buffers ******** */ 1070 char *outfile ;1071 char *nfs_dev ;1072 char *nfs_mount ;1073 char *nfs_client_ipaddr ;1074 char *nfs_client_netmask ;1075 char *nfs_client_broadcast ;;1076 char *nfs_client_defgw ;1077 char *nfs_server_ipaddr ;1078 char *tmp ;1079 char *command ;1057 char *outfile = NULL; 1058 char *nfs_dev = NULL; 1059 char *nfs_mount = NULL; 1060 char *nfs_client_ipaddr = NULL; 1061 char *nfs_client_netmask = NULL; 1062 char *nfs_client_broadcast = NULL; 1063 char *nfs_client_defgw = NULL; 1064 char *nfs_server_ipaddr = NULL; 1065 char *tmp = NULL; 1066 char *command = NULL; 1080 1067 1081 1068 /*@ pointers ***** */ … … 1099 1086 asprintf(&command, 1100 1087 "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\n' | head -n1 | cut -d' ' -f1"); 1101 asprintf(&nfs_dev, call_program_and_get_last_line_of_output(command));1088 nfs_dev = call_program_and_get_last_line_of_output(command); 1102 1089 paranoid_free(command); 1103 1090 1104 1091 asprintf(&command, 1105 1092 "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f7 | cut -d':' -f2"); 1106 asprintf(&nfs_client_ipaddr, 1107 call_program_and_get_last_line_of_output(command)); 1093 nfs_client_ipaddr = call_program_and_get_last_line_of_output(command); 1108 1094 paranoid_free(command); 1109 1095 1110 1096 asprintf(&command, 1111 1097 "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f9 | cut -d':' -f2"); 1112 asprintf(&nfs_client_netmask, 1113 call_program_and_get_last_line_of_output(command)); 1098 nfs_client_netmask = call_program_and_get_last_line_of_output(command); 1114 1099 paranoid_free(command); 1115 1100 1116 1101 asprintf(&command, 1117 1102 "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f8 | cut -d':' -f2"); 1118 strcpy(nfs_client_broadcast, 1119 call_program_and_get_last_line_of_output(command)); 1120 sprintf(command, 1103 nfs_client_broadcast = call_program_and_get_last_line_of_output(command); 1104 paranoid_free(command); 1105 1106 asprintf(&command, 1121 1107 "route -n | grep '^0.0.0.0' | awk '{print $2}'"); 1122 asprintf(&nfs_client_defgw, 1123 call_program_and_get_last_line_of_output(command)); 1108 nfs_client_defgw = call_program_and_get_last_line_of_output(command); 1124 1109 paranoid_free(command); 1125 1110 … … 1317 1302 paranoid_free(tmp); 1318 1303 1319 asprintf(&do_not_compress_these, last_line_of_file(tmp));1304 do_not_compress_these = last_line_of_file(tmp); 1320 1305 for (p = do_not_compress_these; p != NULL; p++) { 1321 1306 asprintf(&tmp, p); -
trunk/mondo/mondo/common/libmondo-fork.c
r687 r688 1 /* libmondo-fork.c 2 $Id$ 3 4 - subroutines for handling forking/pthreads/etc. 5 6 7 01/20/2006 8 - replaced partimagehack with ntfsclone 9 10 06/20/2004 11 - create fifo /var/log/partimagehack-debug.log and empty it 12 to keep ramdisk from filling up 13 14 04/13/2004 15 - >= should be <= g_loglevel 16 17 11/15/2003 18 - changed a few []s to char*s 19 20 10/12 21 - rewrote partimagehack handling (multiple fifos, chunks, etc.) 22 23 10/11 24 - partimagehack now has debug level of N (set in my-stuff.h) 25 26 10/08 27 - call to partimagehack when restoring will now log errors to /var/log/....log 28 29 10/06 30 - cleaned up logging a bit 31 32 09/30 33 - line 735 - missing char* cmd in sprintf() 34 35 09/28 36 - added run_external_binary_with_percentage_indicator() 37 - rewritten eval_call_to_make_ISO() 38 39 09/18 40 - call mkstemp instead of mktemp 41 42 09/13 43 - major NTFS hackage 44 45 09/12 46 - paranoid_system("rm -f /tmp/ *PARTIMAGE*") before calling partimagehack 47 48 09/11 49 - forward-ported unbroken feed_*_partimage() subroutines 50 from early August 2003 51 52 09/08 53 - detect & use partimagehack if it exists 54 55 09/05 56 - finally finished partimagehack hack :) 57 58 07/04 59 - added subroutines to wrap around partimagehack 60 61 04/27 62 - don't echo (...res=%d...) at end of log_it() 63 unnecessarily 64 - replace newtFinished() and newtInit() with 65 newtSuspend() and newtResume() 66 67 04/24 68 - added some assert()'s and log_OS_error()'s 69 70 04/09 71 - cleaned up run_program_and_log_output() 72 73 04/07 74 - cleaned up code a bit 75 - let run_program_and_log_output() accept -1 (only log if _no error_) 76 77 01/02/2003 78 - in eval_call_to_make_ISO(), append output to MONDO_LOGFILE 79 instead of a temporary stderr text file 80 81 12/10 82 - patch by Heiko Schlittermann to handle % chars in issue.net 83 84 11/18 85 - if mkisofs in eval_call_to_make_ISO() returns an error then return it, 86 whether ISO was created or not 87 88 10/30 89 - if mkisofs in eval_call_to_make_ISO() returns an error then find out if 90 the output (ISO) file has been created; if it has then return 0 anyway 91 92 08/01 - 09/30 93 - run_program_and_log_output() now takes boolean operator to specify 94 whether it will log its activities in the event of _success_ 95 - system() now includes 2>/dev/null 96 - enlarged some tmp[]'s 97 - added run_program_and_log_to_screen() and run_program_and_log_output() 98 99 07/24 100 - created 101 */ 102 1 /* libmondo-fork.c - subroutines for handling forking/pthreads/etc. 2 * $Id$ 3 */ 103 4 104 5 #include "my-stuff.h" … … 110 11 #include "libmondo-tools-EXT.h" 111 12 112 /*@unused@*/113 //static char cvsid[] = "$Id$";114 115 13 extern char *g_tmpfs_mountpt; 116 14 extern t_bkptype g_backup_media_type; … … 123 21 * @param call The program to run. 124 22 * @return The last line of its output. 125 * @note The returned value points to static storage that will be overwritten with each call.23 * @note The returned value should be freed by caller 126 24 */ 127 25 char *call_program_and_get_last_line_of_output(char *call) 128 26 { 129 /*@ buffers ***************************************************** */ 130 static char *result = NULL; 131 char *tmp = NULL; 132 133 /*@ pointers **************************************************** */ 134 FILE *fin; 135 27 char *result = NULL; 28 FILE *fin = NULL; 136 29 size_t n = 0; 137 30 138 /*@******************************************************************** */139 140 31 assert_string_is_neither_NULL_nor_zerolength(call); 32 141 33 if ((fin = popen(call, "r"))) { 142 for (getline(&tmp, &n, fin); !feof(fin); 143 getline(&tmp, &n, fin)) { 144 if (strlen(tmp) > 1) { 145 if (result != NULL) { 146 paranoid_free(result); 147 } 148 asprintf(&result, tmp); 149 } 150 } 34 for (getline(&result, &n, fin); !feof(fin); getline(&result, &n, fin)); 151 35 paranoid_pclose(fin); 152 36 } else { 153 37 log_OS_error("Unable to popen call"); 154 38 } 155 strip_spaces(result); 156 paranoid_free(tmp); 157 return (result); 39 return(result); 158 40 } 159 41 … … 425 307 if (!(fin = popen(command, "r"))) { 426 308 log_OS_error("Unable to popen-in command"); 427 asprintf(&tmp, _("Failed utterly to call '%s'" , command));309 asprintf(&tmp, _("Failed utterly to call '%s'"), command); 428 310 log_to_screen(tmp); 429 311 paranoid_free(tmp); … … 648 530 { 649 531 650 /*@ int *************************************************************** */651 532 int res = 0; 652 533 int percentage = 0; … … 655 536 int last_pcno = 0; 656 537 657 /*@ buffers *********************************************************** */ 658 char *command; 659 char *tempfile; 660 /*@ pointers ********************************************************** */ 661 FILE *pin; 538 char *command = NULL; 539 char *tempfile = NULL; 540 FILE *pin = NULL; 662 541 663 542 assert_string_is_neither_NULL_nor_zerolength(cmd); 664 543 665 asprintf(&tempfile, 666 call_program_and_get_last_line_of_output 667 ("mktemp -q /tmp/mondo.XXXXXXXX")); 544 tempfile = call_program_and_get_last_line_of_output("mktemp -q /tmp/mondo.XXXXXXXX"); 668 545 asprintf(&command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile, tempfile, 669 546 tempfile); -
trunk/mondo/mondo/common/libmondo-mountlist-EXT.h
r59 r688 1 1 /* libmondo-mountlist-EXT.h */ 2 2 3 extern int evaluate_drive_within_mountlist(struct mountlist_itself4 *mountlist, char *drive,5 char *flaws_str);6 3 extern int evaluate_mountlist(struct mountlist_itself *mountlist, 7 4 char *flaws_str_A, char *flaws_str_B, … … 11 8 extern int look_for_duplicate_mountpoints(struct mountlist_itself 12 9 *mountlist, char *flaws_str); 13 extern int look_for_weird_formats(struct mountlist_itself *mountlist,14 char *flaws_str);15 10 extern int make_list_of_drives_in_mountlist(struct mountlist_itself *, 16 11 struct list_of_disks *); -
trunk/mondo/mondo/common/libmondo-mountlist.c
r507 r688 60 60 61 61 /*@ buffers ******************************************************** */ 62 char *tmp; 63 char *device; 62 char *tmp = NULL; 63 char *tmp1 = NULL; 64 char *device = NULL; 64 65 // BERLIOS : useless ? char *mountpoint; 65 66 … … 69 70 70 71 /*@ pointers ******************************************************* */ 71 char *part_table_fmt ;72 char *part_table_fmt = NULL; 72 73 73 74 /*@ initialize ***************************************************** */ 74 flaws_str[0] = '\0';75 75 prev_part_no = 0; 76 76 // BERLIOS: tmp[0] = '\0'; … … 81 81 if (physical_drive_size < 0) { 82 82 asprintf(&tmp, " %s does not exist.", drive); 83 strcat(flaws_str, tmp);83 flaws_str = tmp; 84 84 } else { 85 85 asprintf(&tmp, "%s is %ld MB", drive, physical_drive_size); 86 flaws_str = NULL; 86 87 } 87 88 log_it(tmp); … … 108 109 asprintf(&tmp, " Can only have up to 'h' in disklabel."); 109 110 log_it(tmp); 110 strcat(flaws_str, tmp); 111 if (flaws_str) { 112 asprintf(&tmp1, "%s%s",flaws_str, tmp); 113 } else { 114 asprintf(&tmp1, "%s", tmp); 115 } 116 paranoid_free(flaws_str); 117 flaws_str = tmp1; 111 118 paranoid_free(tmp); 112 119 res++; … … 124 131 if (!strstr(flaws_str, tmp)) { 125 132 log_it(tmp); 126 strcat(flaws_str, tmp); 133 if (flaws_str) { 134 asprintf(&tmp1, "%s%s",flaws_str, tmp); 135 } else { 136 asprintf(&tmp1, "%s", tmp); 137 } 138 paranoid_free(flaws_str); 139 flaws_str = tmp1; 127 140 res++; 128 141 } … … 134 147 asprintf(&tmp, " %s is tiny!", device); 135 148 log_it(tmp); 136 strcat(flaws_str, tmp); 149 if (flaws_str) { 150 asprintf(&tmp1, "%s%s",flaws_str, tmp); 151 } else { 152 asprintf(&tmp1, "%s", tmp); 153 } 154 paranoid_free(flaws_str); 155 flaws_str = tmp1; 137 156 paranoid_free(tmp); 138 157 res++; … … 147 166 asprintf(&tmp, " %s has a weird mountpoint.", device); 148 167 log_it(tmp); 149 strcat(flaws_str, tmp); 168 if (flaws_str) { 169 asprintf(&tmp1, "%s%s",flaws_str, tmp); 170 } else { 171 asprintf(&tmp1, "%s", tmp); 172 } 173 paranoid_free(flaws_str); 174 flaws_str = tmp1; 150 175 paranoid_free(tmp); 151 176 res++; … … 155 180 asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format); 156 181 log_it(tmp); 157 strcat(flaws_str, tmp); 182 if (flaws_str) { 183 asprintf(&tmp1, "%s%s",flaws_str, tmp); 184 } else { 185 asprintf(&tmp1, "%s", tmp); 186 } 187 paranoid_free(flaws_str); 188 flaws_str = tmp1; 158 189 paranoid_free(tmp); 159 190 res++; … … 179 210 180 211 if (((pos >= 0) || npos) && foundsome) { 181 sprintf(flaws_str + strlen(flaws_str), 182 " %s has both DD and PC-style partitions.", drive); 212 asprintf(&tmp, " %s has both DD and PC-style partitions.", drive); 213 if (flaws_str) { 214 asprintf(&tmp1, "%s%s",flaws_str, tmp); 215 } else { 216 asprintf(&tmp1, "%s", tmp); 217 } 218 paranoid_free(flaws_str); 219 flaws_str = tmp1; 220 paranoid_free(tmp); 183 221 return ++res; // fatal error 184 222 } … … 191 229 asprintf(&tmp, " Gap prior to %s.", device); 192 230 log_it(tmp); 193 strcat(flaws_str, tmp); 231 if (flaws_str) { 232 asprintf(&tmp1, "%s%s",flaws_str, tmp); 233 } else { 234 asprintf(&tmp1, "%s", tmp); 235 } 236 paranoid_free(flaws_str); 237 flaws_str = tmp1; 194 238 paranoid_free(tmp); 195 239 res++; … … 199 243 prev_part_no, curr_part_no); 200 244 log_it(tmp); 201 strcat(flaws_str, tmp); 245 if (flaws_str) { 246 asprintf(&tmp1, "%s%s",flaws_str, tmp); 247 } else { 248 asprintf(&tmp1, "%s", tmp); 249 } 250 paranoid_free(flaws_str); 251 flaws_str = tmp1; 202 252 paranoid_free(tmp); 203 253 res++; … … 211 261 asprintf(&tmp, " Partition %ss4 is occupied.", drive); 212 262 log_it(tmp); 213 strcat(flaws_str, tmp); 263 if (flaws_str) { 264 asprintf(&tmp1, "%s%s",flaws_str, tmp); 265 } else { 266 asprintf(&tmp1, "%s", tmp); 267 } 268 paranoid_free(flaws_str); 269 flaws_str = tmp1; 214 270 paranoid_free(tmp); 215 271 res++; … … 227 283 if (!strstr(flaws_str, tmp)) { 228 284 log_it(tmp); 229 strcat(flaws_str, tmp); 285 if (flaws_str) { 286 asprintf(&tmp1, "%s%s",flaws_str, tmp); 287 } else { 288 asprintf(&tmp1, "%s", tmp); 289 } 290 paranoid_free(flaws_str); 291 flaws_str = tmp1; 230 292 res++; 231 293 } … … 237 299 asprintf(&tmp, " %s is tiny!", device); 238 300 log_it(tmp); 239 strcat(flaws_str, tmp); 301 if (flaws_str) { 302 asprintf(&tmp1, "%s%s",flaws_str, tmp); 303 } else { 304 asprintf(&tmp1, "%s", tmp); 305 } 306 paranoid_free(flaws_str); 307 flaws_str = tmp1; 240 308 paranoid_free(tmp); 241 309 res++; … … 250 318 asprintf(&tmp, " %s has a weird mountpoint.", device); 251 319 log_it(tmp); 252 strcat(flaws_str, tmp); 320 if (flaws_str) { 321 asprintf(&tmp1, "%s%s",flaws_str, tmp); 322 } else { 323 asprintf(&tmp1, "%s", tmp); 324 } 325 paranoid_free(flaws_str); 326 flaws_str = tmp1; 253 327 paranoid_free(tmp); 254 328 res++; … … 258 332 asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format); 259 333 log_it(tmp); 260 strcat(flaws_str, tmp); 334 if (flaws_str) { 335 asprintf(&tmp1, "%s%s",flaws_str, tmp); 336 } else { 337 asprintf(&tmp1, "%s", tmp); 338 } 339 paranoid_free(flaws_str); 340 flaws_str = tmp1; 261 341 paranoid_free(tmp); 262 342 res++; … … 278 358 " Can only have up to 'h' in disklabel."); 279 359 log_it(tmp); 280 strcat(flaws_str, tmp); 360 if (flaws_str) { 361 asprintf(&tmp1, "%s%s",flaws_str, tmp); 362 } else { 363 asprintf(&tmp1, "%s", tmp); 364 } 365 paranoid_free(flaws_str); 366 flaws_str = tmp1; 281 367 paranoid_free(tmp); 282 368 res++; … … 294 380 if (!strstr(flaws_str, tmp)) { 295 381 log_it(tmp); 296 strcat(flaws_str, tmp); 382 if (flaws_str) { 383 asprintf(&tmp1, "%s%s",flaws_str, tmp); 384 } else { 385 asprintf(&tmp1, "%s", tmp); 386 } 387 paranoid_free(flaws_str); 388 flaws_str = tmp1; 297 389 res++; 298 390 } … … 304 396 asprintf(&tmp, " %s is tiny!", device); 305 397 log_it(tmp); 306 strcat(flaws_str, tmp); 398 if (flaws_str) { 399 asprintf(&tmp1, "%s%s",flaws_str, tmp); 400 } else { 401 asprintf(&tmp1, "%s", tmp); 402 } 403 paranoid_free(flaws_str); 404 flaws_str = tmp1; 307 405 paranoid_free(tmp); 308 406 res++; … … 317 415 asprintf(&tmp, " %s has a weird mountpoint.", device); 318 416 log_it(tmp); 319 strcat(flaws_str, tmp); 417 if (flaws_str) { 418 asprintf(&tmp1, "%s%s",flaws_str, tmp); 419 } else { 420 asprintf(&tmp1, "%s", tmp); 421 } 422 paranoid_free(flaws_str); 423 flaws_str = tmp1; 320 424 paranoid_free(tmp); 321 425 res++; … … 326 430 asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format); 327 431 log_it(tmp); 328 strcat(flaws_str, tmp); 432 if (flaws_str) { 433 asprintf(&tmp1, "%s%s",flaws_str, tmp); 434 } else { 435 asprintf(&tmp1, "%s", tmp); 436 } 437 paranoid_free(flaws_str); 438 flaws_str = tmp1; 329 439 paranoid_free(tmp); 330 440 res++; … … 347 457 amount_allocated - physical_drive_size, drive); 348 458 log_it(tmp); 349 strcat(flaws_str, tmp); 459 if (flaws_str) { 460 asprintf(&tmp1, "%s%s",flaws_str, tmp); 461 } else { 462 asprintf(&tmp1, "%s", tmp); 463 } 464 paranoid_free(flaws_str); 465 flaws_str = tmp1; 350 466 paranoid_free(tmp); 351 467 res++; … … 354 470 physical_drive_size - amount_allocated, drive); 355 471 log_it(tmp); 356 strcat(flaws_str, tmp); 472 if (flaws_str) { 473 asprintf(&tmp1, "%s%s",flaws_str, tmp); 474 } else { 475 asprintf(&tmp1, "%s", tmp); 476 } 477 paranoid_free(flaws_str); 478 flaws_str = tmp1; 357 479 paranoid_free(tmp); 358 480 } … … 391 513 assert_string_is_neither_NULL_nor_zerolength(drive); 392 514 assert(mountlist != NULL); 393 assert(flaws_str != NULL); 394 395 flaws_str[0] = '\0'; 515 flaws_str = NULL; 516 396 517 prev_part_no = 0; 397 518 // BERLIOS : useless ? tmp[0] = '\0'; … … 402 523 if (physical_drive_size < 0) { 403 524 asprintf(&tmp, " %s does not exist.", drive); 404 strcat(flaws_str, tmp); 525 if (flaws_str) { 526 asprintf(&tmp1, "%s%s",flaws_str, tmp); 527 } else { 528 asprintf(&tmp1, "%s", tmp); 529 } 530 paranoid_free(flaws_str); 531 flaws_str = tmp1; 405 532 res++; 406 533 log_msg(1, tmp); … … 421 548 if (physical_drive_size < 0) { 422 549 asprintf(&tmp, " %s refers to non-existent hardware.", device); 423 strcat(flaws_str, tmp); 550 if (flaws_str) { 551 asprintf(&tmp1, "%s%s",flaws_str, tmp); 552 } else { 553 asprintf(&tmp1, "%s", tmp); 554 } 555 paranoid_free(flaws_str); 556 flaws_str = tmp1; 424 557 res++; 425 558 paranoid_free(tmp); … … 432 565 asprintf(&tmp, " Gap prior to %s.", device); 433 566 log_it(tmp); 434 strcat(flaws_str, tmp); 567 if (flaws_str) { 568 asprintf(&tmp1, "%s%s",flaws_str, tmp); 569 } else { 570 asprintf(&tmp1, "%s", tmp); 571 } 572 paranoid_free(flaws_str); 573 flaws_str = tmp1; 435 574 paranoid_free(tmp); 436 575 res++; … … 440 579 prev_part_no, curr_part_no); 441 580 log_it(tmp); 442 strcat(flaws_str, tmp); 581 if (flaws_str) { 582 asprintf(&tmp1, "%s%s",flaws_str, tmp); 583 } else { 584 asprintf(&tmp1, "%s", tmp); 585 } 586 paranoid_free(flaws_str); 587 flaws_str = tmp1; 443 588 paranoid_free(tmp); 444 589 res++; … … 452 597 asprintf(&tmp, " Partition %s4 is occupied.", drive); 453 598 log_it(tmp); 454 strcat(flaws_str, tmp); 599 if (flaws_str) { 600 asprintf(&tmp1, "%s%s",flaws_str, tmp); 601 } else { 602 asprintf(&tmp1, "%s", tmp); 603 } 604 paranoid_free(flaws_str); 605 flaws_str = tmp1; 455 606 paranoid_free(tmp); 456 607 res++; … … 470 621 if (!strstr(flaws_str, tmp)) { 471 622 log_it(tmp); 472 strcat(flaws_str, tmp); 623 if (flaws_str) { 624 asprintf(&tmp1, "%s%s",flaws_str, tmp); 625 } else { 626 asprintf(&tmp1, "%s", tmp); 627 } 628 paranoid_free(flaws_str); 629 flaws_str = tmp1; 473 630 res++; 474 631 } … … 480 637 asprintf(&tmp, " %s is tiny!", device); 481 638 log_it(tmp); 482 strcat(flaws_str, tmp); 639 if (flaws_str) { 640 asprintf(&tmp1, "%s%s",flaws_str, tmp); 641 } else { 642 asprintf(&tmp1, "%s", tmp); 643 } 644 paranoid_free(flaws_str); 645 flaws_str = tmp1; 483 646 paranoid_free(tmp); 484 647 res++; … … 492 655 asprintf(&tmp, " %s has a weird mountpoint.", device); 493 656 log_it(tmp); 494 strcat(flaws_str, tmp); 657 if (flaws_str) { 658 asprintf(&tmp1, "%s%s",flaws_str, tmp); 659 } else { 660 asprintf(&tmp1, "%s", tmp); 661 } 662 paranoid_free(flaws_str); 663 flaws_str = tmp1; 495 664 paranoid_free(tmp); 496 665 res++; … … 500 669 asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format); 501 670 log_it(tmp); 502 strcat(flaws_str, tmp); 671 if (flaws_str) { 672 asprintf(&tmp1, "%s%s",flaws_str, tmp); 673 } else { 674 asprintf(&tmp1, "%s", tmp); 675 } 676 paranoid_free(flaws_str); 677 flaws_str = tmp1; 503 678 paranoid_free(tmp); 504 679 res++; … … 515 690 amount_allocated - physical_drive_size, drive); 516 691 log_it(tmp); 517 strcat(flaws_str, tmp); 692 if (flaws_str) { 693 asprintf(&tmp1, "%s%s",flaws_str, tmp); 694 } else { 695 asprintf(&tmp1, "%s", tmp); 696 } 697 paranoid_free(flaws_str); 698 flaws_str = tmp1; 518 699 paranoid_free(tmp); 519 700 res++; … … 522 703 physical_drive_size - amount_allocated, drive); 523 704 log_it(tmp); 524 strcat(flaws_str, tmp); 705 if (flaws_str) { 706 asprintf(&tmp1, "%s%s",flaws_str, tmp); 707 } else { 708 asprintf(&tmp1, "%s", tmp); 709 } 710 paranoid_free(flaws_str); 711 flaws_str = tmp1; 525 712 paranoid_free(tmp); 526 713 } … … 582 769 log_it(tmp); 583 770 } else { 584 asprintf(&tmp, " "); 585 // BERLIOS : tmp was NOT initialized ??? 771 // This function allocates tmp 586 772 if (!evaluate_drive_within_mountlist 587 773 (mountlist, drivelist->el[i].device, tmp)) { … … 595 781 } 596 782 res += look_for_duplicate_mountpoints(mountlist, flaws_str); 597 /* res+=look_for_weird_formats(mountlist,flaws_str); .. not necessary, now that we can check to see598 which formarts are actually _supported_ by the kernel */599 /* log_it(flaws_str); */600 783 return (spread_flaws_across_three_lines 601 784 (flaws_str, flaws_str_A, flaws_str_B, flaws_str_C, res)); … … 650 833 651 834 /*@ buffetr ********************************************************* */ 652 char *curr_mountpoint; 653 char *tmp; 835 char *curr_mountpoint = NULL; 836 char *tmp = NULL; 837 char *tmp1 = NULL; 654 838 655 839 assert(mountlist != NULL); 656 840 assert(flaws_str != NULL); 841 657 842 for (currline = 0; currline < mountlist->entries; currline++) { 658 843 asprintf(&curr_mountpoint, mountlist->el[currline].mountpoint); … … 670 855 asprintf(&tmp, " %s %s's.", number_to_text(copies), 671 856 curr_mountpoint); 672 strcat(flaws_str, tmp);673 857 log_it(tmp); 858 asprintf(&tmp1, "%s%s",flaws_str, tmp); 859 paranoid_free(flaws_str); 860 flaws_str = tmp1; 674 861 paranoid_free(tmp); 675 862 res++; 676 863 } 677 864 paranoid_free(curr_mountpoint); 678 }679 return (res);680 }681 682 683 /**684 * Look for strange formats. Does not respect /proc/filesystems.685 * @param mountlist The mountlist to check.686 * @param flaws_str The flaws string to append the results to.687 * @return The number of weird formats found, or 0 for success.688 * @bug Seems orphaned; please remove.689 */690 int691 look_for_weird_formats(struct mountlist_itself *mountlist, char *flaws_str)692 {693 694 /*@ int ************************************************************* */695 int i = 0;696 int res = 0;697 698 /*@ buffers ********************************************************* */699 char *tmp;700 char *format_sz;701 702 assert(mountlist != NULL);703 assert(flaws_str != NULL);704 705 for (i = 0; i < mountlist->entries; i++) {706 asprintf(&format_sz, " %s ", mountlist->el[i].format);707 if (!strstr(SANE_FORMATS, format_sz)708 && strcmp(mountlist->el[i].mountpoint, "image") != 0) {709 asprintf(&tmp, " %s has unknown format.",710 mountlist->el[i].device);711 log_it(tmp);712 strcat(flaws_str, tmp);713 paranoid_free(tmp);714 res++;715 } else if ((!strcmp(mountlist->el[i].format, "swap")716 && strcmp(mountlist->el[i].mountpoint, "swap")717 && strcmp(mountlist->el[i].mountpoint, "none"))718 || (strcmp(mountlist->el[i].format, "swap")719 && !strcmp(mountlist->el[i].mountpoint, "swap")720 && !strcmp(mountlist->el[i].mountpoint, "none"))) {721 asprintf(&tmp, " %s is half-swap.", mountlist->el[i].device);722 log_it(tmp);723 strcat(flaws_str, tmp);724 paranoid_free(tmp);725 res++;726 }727 paranoid_free(format_sz);728 865 } 729 866 return (res); -
trunk/mondo/mondo/common/libmondo-mountlist.h
r59 r688 4 4 5 5 6 int evaluate_drive_within_mountlist(struct mountlist_itself *mountlist,7 char *drive, char *flaws_str);8 6 int evaluate_mountlist(struct mountlist_itself *mountlist, 9 7 char *flaws_str_A, char *flaws_str_B, … … 13 11 int look_for_duplicate_mountpoints(struct mountlist_itself *mountlist, 14 12 char *flaws_str); 15 int look_for_weird_formats(struct mountlist_itself *mountlist,16 char *flaws_str);17 13 int make_list_of_drives_in_mountlist(struct mountlist_itself *, 18 14 struct list_of_disks *); -
trunk/mondo/mondo/common/libmondo-raid.c
r672 r688 774 774 { 775 775 int cnt = 0; 776 staticchar *argv[64];776 char *argv[64]; 777 777 char **ap; 778 char *line = (char *) malloc(MAX_STR_LEN); 779 if (!line) 780 errx(1, 781 "unable to allocate %i bytes of memory for `char *line' at %s:%i", 782 MAX_STR_LEN, __FILE__, __LINE__); 783 (void) fgets(line, MAX_STR_LEN, f); 778 char *line = NULL; 779 size_t = 0; 780 int lastpos = 0; 781 782 getline(&line, &n, f); 784 783 if (feof(f)) { 785 784 log_it("[GNVCL] Uh... I reached the EOF."); 786 return 0;787 } 788 789 for (ap = argv; (*ap = strsep(&line, " \t")) != NULL;)785 return NULL; 786 } 787 788 for (ap = argv; (*ap = mr_strtok(line, " \t", &lastpos)) != NULL;) 790 789 if (**ap != '\0') { 791 790 if (++ap >= &argv[64]) -
trunk/mondo/mondo/common/libmondo-stream.c
r687 r688 9 9 * Functions for writing data to/reading data from streams (tape, CD stream, etc.) 10 10 */ 11 12 #include <unistd.h> 11 13 12 14 #include "my-stuff.h" … … 23 25 #define EXTRA_TAPE_CHECKSUMS 24 26 25 /*@unused@*/26 //static char cvsid[] = "$Id$";27 27 extern bool g_sigpipe; 28 28 extern int g_tape_buffer_size_MB; … … 119 119 } 120 120 sleep(1); 121 paranoid_system("sync");121 sync(); 122 122 sleep(1); 123 123 paranoid_pclose(g_tape_stream); … … 152 152 153 153 sleep(1); 154 paranoid_system("sync");154 sync(); 155 155 sleep(1); 156 156 log_it("closeout_tape() -- entering"); … … 213 213 int find_tape_device_and_size(char *dev, char *siz) 214 214 { 215 char *tmp; 216 char *command; 217 char *cdr_exe; 218 int res; 215 char *tmp = NULL; 216 char *tmp1 = NULL; 217 char *command = NULL; 218 char *cdr_exe = NULL; 219 int res = 0; 219 220 220 221 log_to_screen("I am looking for your tape streamer. Please wait."); 221 dev [0] = '\0';222 dev = NULL; 222 223 siz = NULL; 223 224 if (find_home_of_exe("cdrecord")) { … … 228 229 asprintf(&command, "%s -scanbus 2> /dev/null | grep -i tape | wc -l", 229 230 cdr_exe); 230 asprintf(&tmp, call_program_and_get_last_line_of_output(command));231 tmp = call_program_and_get_last_line_of_output(command); 231 232 paranoid_free(command); 232 233 … … 234 235 log_it 235 236 ("Either too few or too many tape streamers for me to detect..."); 236 strcpy(dev, VANILLA_SCSI_TAPE);237 asprintf(&dev, VANILLA_SCSI_TAPE"0"); 237 238 paranoid_free(tmp); 238 239 paranoid_free(cdr_exe); … … 244 245 "%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", 245 246 cdr_exe); 246 asprintf(&tmp, call_program_and_get_last_line_of_output(command));247 tmp = call_program_and_get_last_line_of_output(command); 247 248 paranoid_free(command); 248 249 if (strlen(tmp) < 2) { … … 259 260 paranoid_free(cdr_exe); 260 261 261 asprintf(&tmp, call_program_and_get_last_line_of_output(command));262 tmp = call_program_and_get_last_line_of_output(command); 262 263 paranoid_free(command); 263 strcpy(dev, VANILLA_SCSI_TAPE); 264 dev[strlen(dev) - 1] = '\0'; 265 strcat(dev, tmp); // e.g. '/dev/st0' becomes '/dev/stN' 264 265 asprintf(&dev, VANILLA_SCSI_TAPE"%s", tmp); 266 266 paranoid_free(tmp); 267 267 268 res = 0;269 268 if (!mt_says_tape_exists(dev)) { 270 strcpy(dev, ALT_TAPE); 269 paranoid_free(dev); 270 271 asprintf(&dev, ALT_TAPE"%s", tmp); 271 272 if (!mt_says_tape_exists(dev)) { 272 273 log_it("Cannot openin %s", dev); 273 strcpy(dev, "/dev/st0"); 274 paranoid_free(dev); 275 276 asprintf(&dev, VANILLA_SCSI_TAPE"0"); 274 277 if (!mt_says_tape_exists(dev)) { 275 278 log_it("Cannot openin %s", dev); 276 strcpy(dev, "/dev/osst0"); 279 paranoid_free(dev); 280 281 asprintf(&dev, "/dev/osst0"); 277 282 if (!mt_says_tape_exists(dev)) { 278 283 res++; … … 286 291 log_it("At this point, dev = %s and res = %d", dev, res); 287 292 288 asprintf(&tmp,call_program_and_get_last_line_of_output("\293 tmp = call_program_and_get_last_line_of_output("\ 289 294 cdrecord -scanbus 2> /dev/null | tr -s '\t' ' ' | \ 290 295 grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep -i TAPE | \ 291 awk '{for(i=1; i<NF; i++) { if (index($i, \"GB\")>0) { print $i;};};};'") );296 awk '{for(i=1; i<NF; i++) { if (index($i, \"GB\")>0) { print $i;};};};'"); 292 297 293 298 if (mt_says_tape_exists(dev)) { … … 296 301 log_it("Turning %s", dev); 297 302 paranoid_free(tmp); 298 asprintf(&tmp ,303 asprintf(&tmp1, 299 304 (strrchr(dev, '/') != NULL) ? strrchr(dev, '/') : dev); 300 sprintf(dev, "/dev/os%s", tmp); 305 paranoid_free(dev); 306 asprintf(&dev, "/dev/os%s", tmp1); 307 paranoid_free(tmp1); 308 301 309 log_it("...into %s", dev); 302 310 if (mt_says_tape_exists(dev)) { … … 1228 1236 1229 1237 paranoid_pclose(g_tape_stream); 1230 sy stem("sync");1231 sy stem("sync");1232 sy stem("sync");1238 sync(); 1239 sync(); 1240 sync(); 1233 1241 log_it("Next tape requested."); 1234 1242 insist_on_this_tape_number(g_current_media_number + 1); // will increment it, too … … 1269 1277 1270 1278 paranoid_pclose(g_tape_stream); 1271 sy stem("sync");1272 sy stem("sync");1273 sy stem("sync");1279 sync(); 1280 sync(); 1281 sync(); 1274 1282 log_it("New tape requested."); 1275 1283 insist_on_this_tape_number(g_current_media_number + 1); // will increment g_current_media, too -
trunk/mondo/mondo/common/libmondo-string.c
r672 r688 33 33 * @note If @p drive ends in a digit, then 'p' (on Linux) or 's' (on *BSD) is added before @p partno. 34 34 */ 35 char *build_partition_name(c har *partition, const char *drive, int partno)35 char *build_partition_name(const char *drive, int partno) 36 36 { 37 37 char *p, *c; 38 39 assert(partition != NULL); 38 char *partition; 39 40 40 assert_string_is_neither_NULL_nor_zerolength(drive); 41 41 assert(partno >= 0); … … 537 537 538 538 /*@ buffers **************************************************** */ 539 char *output ;540 char *suffix ;539 char *output = NULL; 540 char *suffix = NULL; 541 541 542 542 /*@ end vars *************************************************** */ 543 543 544 544 assert_string_is_neither_NULL_nor_zerolength(path); 545 if (s[0] != '\0') { 545 546 if (s != NULL) { 546 547 asprintf(&suffix, ".%s", s); 547 548 } else { 548 asprintf(&suffix, "%s", " 549 asprintf(&suffix, "%s", ""); 549 550 } 550 551 asprintf(&output, "%s/slice-%07ld.%05ld.dat%s", path, bigfileno, -
trunk/mondo/mondo/common/libmondo-tools.c
r687 r688 218 218 d = 5.2; // :-) 219 219 #else 220 asprintf(&tmp, call_program_and_get_last_line_of_output("uname -r"));220 tmp = call_program_and_get_last_line_of_output("uname -r"); 221 221 p = strchr(tmp, '.'); 222 222 if (p) { … … 390 390 rdsiz_MB = PPCFG_RAMDISK_SIZE + g_tape_buffer_size_MB; 391 391 #ifdef __FreeBSD__ 392 asprintf(&tmp, 393 call_program_and_get_last_line_of_output 394 ("vmstat | tail -1 | tr -s ' ' | cut -d' ' -f6")); 392 tmp = call_program_and_get_last_line_of_output 393 ("vmstat | tail -1 | tr -s ' ' | cut -d' ' -f6"); 395 394 avm += atol(tmp); 396 395 paranoid_free(tmp); 397 asprintf(&tmp, 398 call_program_and_get_last_line_of_output 399 ("swapinfo | grep -v Device | tr -s ' ' | cut -d' ' -f4 | tr '\n' '+' | sed 's/+$//' | bc")); 396 tmp = call_program_and_get_last_line_of_output 397 ("swapinfo | grep -v Device | tr -s ' ' | cut -d' ' -f4 | tr '\n' '+' | sed 's/+$//' | bc"); 400 398 avm += atol(tmp); 401 399 paranoid_free(tmp); … … 403 401 g_tmpfs_mountpt); 404 402 #else 405 asprintf(&tmp, 406 call_program_and_get_last_line_of_output 407 ("free | grep \":\" | tr -s ' ' '\t' | cut -f2 | head -n1")); 403 tmp = call_program_and_get_last_line_of_output 404 ("free | grep \":\" | tr -s ' ' '\t' | cut -f2 | head -n1"); 408 405 avm += atol(tmp); 409 406 paranoid_free(tmp); … … 478 475 if (getenv ("SUDO_COMMAND")) { 479 476 asprintf(&command, "strings `which growisofs` | grep -c SUDO_COMMAND"); 480 if (!strcmp(call_program_and_get_last_line_of_output(command), "1")) { 477 tmp = call_program_and_get_last_line_of_output(command); 478 if (!strcmp(tmp, "1")) { 481 479 popup_and_OK("Fatal Error: Can't write DVDs as sudo because growisofs doesn't support this - see the growisofs manpage for details."); 482 480 fatal_error("Can't write DVDs as sudo because growisofs doesn't support this - see the growisofs manpage for details."); 483 481 } 482 paranoid_free(tmp); 484 483 paranoid_free(command); 485 484 } … … 574 573 bkpinfo->isodir); 575 574 log_it("command = %s", command); 576 asprintf(&tmp, call_program_and_get_last_line_of_output(command));575 tmp = call_program_and_get_last_line_of_output(command); 577 576 paranoid_free(command); 578 577 log_it("res of it = %s", tmp); … … 585 584 paranoid_free(tmp); 586 585 log_it("command = %s", command); 587 asprintf(&tmp, call_program_and_get_last_line_of_output(command));586 tmp = call_program_and_get_last_line_of_output(command); 588 587 paranoid_free(command); 589 588 log_it("res of it = %s", tmp); … … 704 703 } 705 704 g_current_media_number = 1; 706 bkpinfo->postnuke_tarball[0] = bkpinfo->nfs_mount[0] = '\0'; 705 bkpinfo->postnuke_tarball = NULL; 706 bkpinfo->nfs_mount = NULL; 707 707 return (res); 708 708 } … … 717 717 void reset_bkpinfo(struct s_bkpinfo *bkpinfo) 718 718 { 719 int i ;719 int i = 0; 720 720 721 721 log_msg(1, "Hi"); 722 722 723 assert(bkpinfo != NULL); 724 /* BERLIOS : Useless 723 725 memset((void *) bkpinfo, 0, sizeof(struct s_bkpinfo)); 726 */ 727 724 728 bkpinfo->manual_cd_tray = FALSE; 725 729 bkpinfo->internal_tape_block_size = DEFAULT_INTERNAL_TAPE_BLOCK_SIZE; 726 paranoid_free(bkpinfo->media_device); 730 bkpinfo->boot_loader = '\0'; 731 727 732 for (i = 0; i <= MAX_NOOF_MEDIA; i++) { 728 733 bkpinfo->media_size[i] = -1; 729 734 } 730 bkpinfo->boot_loader = '\0'; 731 bkpinfo->boot_device[0] = '\0'; 732 bkpinfo->zip_exe[0] = '\0'; 733 bkpinfo->zip_suffix[0] = '\0'; 734 bkpinfo->restore_path[0] = '\0'; 735 736 paranoid_free(bkpinfo->media_device); 737 paranoid_free(bkpinfo->boot_device); 738 paranoid_free(bkpinfo->zip_exe); 739 paranoid_free(bkpinfo->zip_suffix); 740 paranoid_free(bkpinfo->restore_path); 735 741 bkpinfo->use_lzo = FALSE; 736 bkpinfo->do_not_compress_these[0] = '\0';742 paranoid_free(bkpinfo->do_not_compress_these); 737 743 bkpinfo->verify_data = FALSE; 738 744 bkpinfo->backup_data = FALSE; … … 741 747 (am_I_in_disaster_recovery_mode()? TRUE : FALSE); 742 748 if (bkpinfo->disaster_recovery) { 743 strcpy(bkpinfo->isodir, "/");749 paranoid_alloc(bkpinfo->isodir, "/"); 744 750 } else { 745 strcpy(bkpinfo->isodir, "/var/cache/mondo/iso");746 } 747 strcpy(bkpinfo->prefix, STD_PREFIX);748 749 bkpinfo->scratchdir[0] = '\0';751 paranoid_alloc(bkpinfo->isodir, "/var/cache/mondo/iso"); 752 } 753 paranoid_alloc(bkpinfo->prefix, STD_PREFIX); 754 755 paranoid_free(bkpinfo->scratchdir); 750 756 bkpinfo->make_filelist = TRUE; // unless -J supplied to mondoarchive 751 sprintf(bkpinfo->tmpdir, "/tmp/tmpfs/mondo.tmp.%d", (int) (random() % 32768)); // for mondorestore 757 paranoid_free(bkpinfo->tmpdir); 758 asprintf(&bkpinfo->tmpdir, "/tmp/tmpfs/mondo.tmp.%d", (int) (random() % 32768)); // for mondorestore 752 759 bkpinfo->optimal_set_size = 0; 753 760 bkpinfo->backup_media_type = none; 754 strcpy(bkpinfo->include_paths, "/");755 bkpinfo->exclude_paths[0] = '\0';756 bkpinfo->call_before_iso[0] = '\0';757 bkpinfo->call_make_iso[0] = '\0';758 bkpinfo->call_burn_iso[0] = '\0';759 bkpinfo->call_after_iso[0] = '\0';760 bkpinfo->image_devs[0] = '\0';761 bkpinfo->postnuke_tarball[0] = '\0';762 bkpinfo->kernel_path[0] = '\0';763 bkpinfo->nfs_mount[0] = '\0';764 bkpinfo->nfs_remote_dir[0] = '\0';761 paranoid_alloc(bkpinfo->include_paths, "/"); 762 paranoid_free(bkpinfo->exclude_paths); 763 paranoid_free(bkpinfo->call_before_iso); 764 paranoid_free(bkpinfo->call_make_iso); 765 paranoid_free(bkpinfo->call_burn_iso); 766 paranoid_free(bkpinfo->call_after_iso); 767 paranoid_free(bkpinfo->image_devs); 768 paranoid_free(bkpinfo->postnuke_tarball); 769 paranoid_free(bkpinfo->kernel_path); 770 paranoid_free(bkpinfo->nfs_mount); 771 paranoid_free(bkpinfo->nfs_remote_dir); 765 772 bkpinfo->wipe_media_first = FALSE; 766 773 bkpinfo->differential = FALSE; … … 773 780 774 781 775 776 777 782 /** 778 783 * Get the remaining free space (in MB) on @p partition. … … 782 787 long free_space_on_given_partition(char *partition) 783 788 { 784 char *command, *out_sz; 789 char *command = NULL; 790 char *out_sz = NULL; 785 791 long res; 786 792 … … 795 801 asprintf(&command, "df -m -P %s | tail -n1 | tr -s ' ' '\t' | cut -f4", 796 802 partition); 797 asprintf(&out_sz, call_program_and_get_last_line_of_output(command));803 out_sz = call_program_and_get_last_line_of_output(command); 798 804 paranoid_free(command); 799 805 if (strlen(out_sz) == 0) { … … 840 846 ("ln -sf `which mkfs.msdos` /sbin/mkfs.vfat", FALSE); 841 847 } 842 asprintf(&tmp, 843 call_program_and_get_last_line_of_output 844 ("free | grep Mem | head -n1 | tr -s ' ' '\t' | cut -f2")); 848 tmp = call_program_and_get_last_line_of_output 849 ("free | grep Mem | head -n1 | tr -s ' ' '\t' | cut -f2"); 845 850 if (atol(tmp) < 35000) { 846 851 retval++; … … 928 933 run_program_and_log_output 929 934 ("umount `mount | grep cdr | cut -d' ' -f3 | tr '\n' ' '`", 5); 930 asprintf(&tmp, 931 call_program_and_get_last_line_of_output 932 ("mount | grep -E \"cdr(om|w)\"")); 935 tmp = call_program_and_get_last_line_of_output("mount | grep -E \"cdr(om|w)\""); 933 936 if (strcmp("", tmp)) { 934 937 if (strstr(tmp, "autofs")) { … … 1021 1024 { 1022 1025 /*@ buffer ****************************************************** */ 1023 char *command ;1024 char *tmp ;1026 char *command = NULL; 1027 char *tmp = NULL; 1025 1028 1026 1029 /*@ end vars *************************************************** */ … … 1028 1031 assert_string_is_neither_NULL_nor_zerolength(config_file); 1029 1032 assert_string_is_neither_NULL_nor_zerolength(label); 1033 1030 1034 if (!does_file_exist(config_file)) { 1031 1035 asprintf(&tmp, "(read_cfg_var) Cannot find %s config file", … … 1033 1037 log_to_screen(tmp); 1034 1038 paranoid_free(tmp); 1035 value [0] = '\0';1039 value = NULL; 1036 1040 return (1); 1037 1041 } else if (strstr(value, "/dev/") && strstr(value, "t0") … … 1043 1047 asprintf(&command, "grep '%s .*' %s| cut -d' ' -f2,3,4,5", 1044 1048 label, config_file); 1045 strcpy(value, call_program_and_get_last_line_of_output(command));1049 value = call_program_and_get_last_line_of_output(command); 1046 1050 paranoid_free(command); 1047 1051 if (strlen(value) == 0) { … … 1052 1056 } 1053 1057 } 1054 1055 1058 1056 1059 … … 1101 1104 "grep -v \":\" /etc/fstab | grep -vx \"#.*\" | grep -w \"/boot\" | tr -s ' ' '\t' | cut -f1 | head -n1"); 1102 1105 log_msg(4, "Cool. Command = '%s'", command); 1103 asprintf(&tmp, call_program_and_get_last_line_of_output(command));1106 tmp = call_program_and_get_last_line_of_output(command); 1104 1107 paranoid_free(command); 1105 1108 1106 1109 log_msg(4, "tmp = '%s'", tmp); 1107 if (tmp [0]) {1110 if (tmp) { 1108 1111 log_it("/boot is at %s according to /etc/fstab", tmp); 1109 1112 if (strstr(tmp, "LABEL=")) { … … 1199 1202 return (1); 1200 1203 } 1201 asprintf(&tempfile, 1202 call_program_and_get_last_line_of_output 1203 ("mktemp -q /tmp/mojo-jojo.blah.XXXXXX")); 1204 tempfile = call_program_and_get_last_line_of_output 1205 ("mktemp -q /tmp/mojo-jojo.blah.XXXXXX"); 1204 1206 if (does_file_exist(config_file)) { 1205 1207 asprintf(&command, "grep -vx '%s .*' %s > %s", … … 1228 1230 if (mal) { 1229 1231 iamhere("Malloc'ing globals"); 1230 malloc_string(g_erase_tmpdir_and_scratchdir);1232 g_erase_tmpdir_and_scratchdir = NULL; 1231 1233 malloc_string(g_serial_string); 1232 malloc_string(g_magicdev_command);1233 1234 } else { 1234 1235 iamhere("Freeing globals"); … … 1268 1269 void stop_magicdev_if_necessary() 1269 1270 { 1270 strcpy(g_magicdev_command, 1271 call_program_and_get_last_line_of_output 1272 ("ps ax | grep -w magicdev | grep -v grep | tr -s '\t' ' '| cut -d' ' -f6-99")); 1273 if (g_magicdev_command[0]) { 1271 g_magicdev_command = call_program_and_get_last_line_of_output 1272 ("ps ax | grep -w magicdev | grep -v grep | tr -s '\t' ' '| cut -d' ' -f6-99"); 1273 if (g_magicdev_command) { 1274 1274 log_msg(1, "g_magicdev_command = '%s'", g_magicdev_command); 1275 1275 paranoid_system("killall magicdev"); … … 1283 1283 void restart_magicdev_if_necessary() 1284 1284 { 1285 char *tmp ;1286 1287 if ( g_magicdev_command && g_magicdev_command[0]) {1285 char *tmp = NULL; 1286 1287 if (!g_magicdev_command) { 1288 1288 asprintf(&tmp, "%s &", g_magicdev_command); 1289 1289 paranoid_system(tmp); -
trunk/mondo/mondo/common/libmondo-verify.c
r507 r688 5 5 * Functions for verifying backups (booted from hard drive, not CD). 6 6 */ 7 8 #include <unistd.h> 7 9 8 10 #include "my-stuff.h" … … 59 61 60 62 asprintf(&afio_found_changes, "%s.afio", ignorefiles_fname); 61 paranoid_system("sync");63 sync(); 62 64 63 65 /* sprintf (command, … … 193 195 { 194 196 195 /*@ buffer ********************************************************** */196 char *tmp ;197 char * mountpoint;198 // char ca, cb;199 char *command ;200 char *sz_exe ;197 char *tmp = NULL; 198 char *tmp1 = NULL; 199 char *tmp2 = NULL; 200 char *mountpoint = NULL; 201 char *command = NULL; 202 char *sz_exe = NULL; 201 203 static char *bufblkA = NULL; 202 204 static char *bufblkB = NULL; 203 205 const long maxbufsize = 65536L; 204 long currsizA = 0; 205 long currsizB = 0; 206 long j; 207 208 /*@ long ************************************************************ */ 209 long bigfile_num = 0; 206 long currsizA = 0L; 207 long currsizB = 0L; 208 long j = 0L; 209 long bigfile_num = 0L; 210 210 long slice_num = -1; 211 int res ;211 int res = 0; 212 212 213 213 static FILE *forig = NULL; … … 215 215 static long last_bigfile_num = -1; 216 216 static long last_slice_num = -1; 217 FILE *pin ;218 FILE *fin ;217 FILE *pin = NULL; 218 FILE *fin = NULL; 219 219 int retval = 0; 220 // long long outlen; 221 222 malloc_string(sz_exe); 220 223 221 if (!bufblkA) { 224 222 if (!(bufblkA = malloc(maxbufsize))) { … … 251 249 open_evalcall_form(tmp); 252 250 paranoid_free(tmp); 251 253 252 iamhere("after vsbf"); 254 253 asprintf(&mountpoint, "%s/archives", mtpt); … … 263 262 slice_num = last_slice_num + 1; 264 263 } 265 while (does_file_exist 266 (slice_fname 267 (bigfile_num, slice_num, mountpoint, bkpinfo->zip_suffix)) 268 || 269 does_file_exist(slice_fname 270 (bigfile_num, slice_num, mountpoint, ""))) { 271 // handle slices until end of CD 264 265 tmp = slice_fname(bigfile_num, slice_num, mountpoint, bkpinfo->zip_suffix); 266 tmp1 = slice_fname(bigfile_num, slice_num, mountpoint, ""); 267 while (does_file_exist(tmp) || does_file_exist(tmp1)) { 268 // handle slices until end of CD 272 269 if (slice_num == 0) { 273 270 log_msg(2, "ISO=%d bigfile=%ld --START--", 274 271 g_current_media_number, bigfile_num); 275 if (! 276 (fin = 277 fopen(slice_fname(bigfile_num, slice_num, mountpoint, ""), 278 "r"))) { 272 if (!(fin = fopen(tmp1,"r"))) { 279 273 log_msg(2, "Cannot open bigfile's info file"); 280 274 } else { … … 286 280 paranoid_fclose(fin); 287 281 } 288 asprintf(&tmp , "%s/%s", bkpinfo->restore_path,282 asprintf(&tmp2, "%s/%s", bkpinfo->restore_path, 289 283 biggiestruct.filename); 290 log_msg(2, "Opening biggiefile #%ld - '%s'", bigfile_num, tmp );291 if (!(forig = fopen(tmp , "r"))) {284 log_msg(2, "Opening biggiefile #%ld - '%s'", bigfile_num, tmp2); 285 if (!(forig = fopen(tmp2, "r"))) { 292 286 log_msg(2, "Failed to open bigfile. Darn."); 293 287 retval++; 294 288 } 295 paranoid_free(tmp );289 paranoid_free(tmp2); 296 290 297 291 slice_num++; 298 } else if (does_file_exist 299 (slice_fname(bigfile_num, slice_num, mountpoint, ""))) { 292 } else if (does_file_exist(tmp1)) { 300 293 log_msg(2, "ISO=%d bigfile=%ld ---END---", 301 294 g_current_media_number, bigfile_num); … … 307 300 g_current_media_number, bigfile_num, slice_num); 308 301 if (bkpinfo->compression_level > 0) { 309 asprintf(&command, "%s -dc %s 2>> %s", sz_exe, 310 slice_fname(bigfile_num, slice_num, mountpoint, 311 bkpinfo->zip_suffix), 312 MONDO_LOGFILE); 302 asprintf(&command, "%s -dc %s 2>> %s", sz_exe, tmp, MONDO_LOGFILE); 313 303 } else { 314 asprintf(&command, "cat %s", 315 slice_fname(bigfile_num, slice_num, mountpoint, 316 bkpinfo->zip_suffix)); 304 asprintf(&command, "cat %s", tmp); 317 305 } 318 306 if ((pin = popen(command, "r"))) { … … 356 344 } 357 345 } 346 paranoid_free(tmp); 347 paranoid_free(tmp1); 358 348 paranoid_free(mountpoint); 359 349 paranoid_free(sz_exe); … … 1072 1062 1073 1063 /* find the final blocks */ 1074 paranoid_system("sync");1064 sync(); 1075 1065 sleep(2); 1076 1066 closein_tape(bkpinfo); -
trunk/mondo/mondo/common/libmondo-verify.h
r687 r688 42 42 extern int openin_tape(struct s_bkpinfo *); 43 43 extern void popup_and_OK(char *); 44 extern bool popup_and_get_string(char *, char *, char * , int);44 extern bool popup_and_get_string(char *, char *, char *); 45 45 extern int read_file_from_tape_to_file(struct s_bkpinfo *, char *, 46 46 long long); … … 83 83 extern long g_start_time, g_minimum_progress, g_maximum_progress, 84 84 g_current_progress, g_currentY; 85 extern char err_log_lines[NOOF_ERR_LINES][MAX_STR_LEN];86 85 extern int g_current_media_number; 87 86 -
trunk/mondo/mondo/common/my-stuff.h
r687 r688 145 145 146 146 #define SCREEN_LENGTH 25 ///< The default size of the screen. 147 #define NOOF_ERR_LINES 6 ///< The number of lines of log output to keep at the bottom of the screen.148 147 #define ARBITRARY_MAXIMUM 2000 ///< The maximum number of items showing at once in the mountlist or filelist editor. 149 148 #define MAX_TAPECATALOG_ENTRIES 8192 ///< The maximum number of entries in the tape catalog. … … 335 334 336 335 /** @def VANILLA_SCSI_CDROM The first SCSI CD-ROM in the system (most likely to be the one to write to). */ 337 /** @def VANILLA_SCSI_TAPE The first SCSI tape in the system (most likely to be the one towrite to. */336 /** @def VANILLA_SCSI_TAPE The SCSI tape radical on the system (most likely to be the one towrite to. */ 338 337 /** @def DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE A string whose presence in a device name indicates the 339 338 * inability to check this device for errors in the mountlist. */ … … 345 344 #ifdef __FreeBSD__ 346 345 #define VANILLA_SCSI_CDROM "/dev/cd0" 347 #define VANILLA_SCSI_TAPE "/dev/sa 0"346 #define VANILLA_SCSI_TAPE "/dev/sa" 348 347 #define DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE "/dev/vinum/" 349 348 #define RAID_DEVICE_STUB DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE 350 349 #define SANE_FORMATS "swap image msdosfs nfs ntfs raid lvm ffs ufs ext2fs" 351 #define ALT_TAPE "/dev/ast 0"350 #define ALT_TAPE "/dev/ast" 352 351 #define MKE2FS_OR_NEWFS "newfs" 353 352 #define CP_BIN "gcp" 354 353 #else 355 354 #define VANILLA_SCSI_CDROM "/dev/scd0" 356 #define VANILLA_SCSI_TAPE "/dev/st 0"355 #define VANILLA_SCSI_TAPE "/dev/st" 357 356 #define DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE "/dev/md" 358 357 #define RAID_DEVICE_STUB DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE 359 358 #define SANE_FORMATS "swap image vfat ext2 ext3 xfs vfs jfs reiserfs dos minix coda nfs ntfs hpfs raid lvm cifs" 360 #define ALT_TAPE "/dev/ht 0"359 #define ALT_TAPE "/dev/ht" 361 360 #define MKE2FS_OR_NEWFS "mke2fs" 362 361 #define CP_BIN "cp" -
trunk/mondo/mondo/common/newt-specific-EXT.h
r59 r688 15 15 extern void log_to_screen(const char *fmt, ...); 16 16 extern void popup_and_OK(char *prompt); 17 extern bool popup_and_get_string(char *title, char *b, char *output, 18 int maxsize); 17 extern bool popup_and_get_string(char *title, char *b, char *output); 19 18 extern bool popup_with_buttons(char *p, char *button1, char *button2); 20 19 extern void refresh_log_screen(); -
trunk/mondo/mondo/common/newt-specific.c
r588 r688 13 13 #define MAX_NEWT_COMMENT_LEN 200 14 14 15 #if __cplusplus 16 extern "C" { 17 #endif 15 #include <unistd.h> 18 16 19 17 #include "my-stuff.h" … … 111 109 if (g_text_mode) { 112 110 while (1) { 113 sy stem("sync");111 sync(); 114 112 printf 115 113 ("---promptdialogYN---1--- %s\r\n---promptdialogYN---Q--- [yes] [no] ---\r\n--> ", … … 130 128 return (FALSE); 131 129 } else { 132 sy stem("sync");130 sync(); 133 131 printf 134 132 (_("Please enter either YES or NO (or yes or no, or y or n, or...)\n")); … … 156 154 assert_string_is_neither_NULL_nor_zerolength(prompt); 157 155 if (g_text_mode) { 158 sy stem("sync");156 sync(); 159 157 printf 160 158 ("---promptdialogOKC---1--- %s\r\n---promptdialogOKC---Q--- [OK] [Cancel] ---\r\n--> ", … … 279 277 paranoid_system("killall mindi 2> /dev/null"); 280 278 kill_anything_like_this("/mondo/do-not"); 281 kill_anything_like_this(" tmp.mondo");279 kill_anything_like_this("mondo.tmp"); 282 280 kill_anything_like_this("ntfsclone"); 283 281 sync(); … … 291 289 paranoid_free(tmp); 292 290 293 if (g_erase_tmpdir_and_scratchdir [0]) {291 if (g_erase_tmpdir_and_scratchdir) { 294 292 run_program_and_log_output(g_erase_tmpdir_and_scratchdir, 5); 295 293 } … … 339 337 void 340 338 finish(int signal) { 341 char *command; 342 malloc_string(command); 339 char *command = NULL; 343 340 344 341 /* if (signal==0) { popup_and_OK("Please press <enter> to quit."); } */ … … 349 346 chdir("/"); 350 347 run_program_and_log_output("umount " MNT_CDROM, FALSE); 351 run_program_and_log_output("rm -Rf /mondo.scratch.* / tmp.mondo.*",348 run_program_and_log_output("rm -Rf /mondo.scratch.* /mondo.tmp.*", 352 349 FALSE); 353 350 if (g_erase_tmpdir_and_scratchdir) { … … 394 391 395 392 /*@ buffers ********************************************************** */ 396 char *command ;397 char *tmp ;393 char *command = NULL; 394 char *tmp = NULL; 398 395 399 396 /*@ pointers ********************************************************* */ 400 FILE *fin ;397 FILE *fin = NULL; 401 398 402 399 /*@ int ************************************************************** */ 403 400 int i = 0; 401 size_t n = 0; 404 402 405 403 assert_string_is_neither_NULL_nor_zerolength(filename); … … 420 418 } else { 421 419 for (i = 0; i < g_noof_log_lines; i++) { 422 for (err_log_lines[i][0] = '\0'; 423 strlen(err_log_lines[i]) < 2 && !feof(fin);) { 424 (void) fgets(err_log_lines[i], MAX_NEWT_COMMENT_LEN, 425 fin); 420 for (; 421 strlen(err_log_lines[i]) < 2 && !feof(fin);) { 422 getline(&(err_log_lines[i]), &n, fin); 426 423 strip_spaces(err_log_lines[i]); 427 424 if (!strncmp(err_log_lines[i], "root:", 5)) { 428 425 asprintf(&tmp, "%s", err_log_lines[i] + 6); 429 strcpy(err_log_lines[i], tmp);430 paranoid_free(tmp);426 paranoid_free(err_log_lines[i]); 427 err_log_lines[i] = tmp; 431 428 } 432 429 if (feof(fin)) { … … 456 453 457 454 /*@ buffers ********************************************************** */ 458 char *output ;455 char *output = NULL; 459 456 460 457 … … 472 469 473 470 if (err_log_lines) { 471 paranoid_free(&err_log_lines[0]); 474 472 for (i = 1; i < g_noof_log_lines; i++) { 475 strcpy(err_log_lines[i - 1], 476 " "); 477 strcpy(err_log_lines[i - 1], err_log_lines[i]); 473 err_log_lines[i - 1] = err_log_lines[i]; 478 474 } 479 475 } … … 487 483 } 488 484 if (err_log_lines) 489 strcpy(err_log_lines[g_noof_log_lines - 1], output);485 err_log_lines[g_noof_log_lines - 1] = output; 490 486 if (g_text_mode) { 491 487 printf("%s\n", output); … … 493 489 refresh_log_screen(); 494 490 } 495 paranoid_free(output); 496 } 497 498 491 } 499 492 500 493 … … 670 663 * @param b The blurb (e.g. what you want the user to enter). 671 664 * @param output The string to put the user's answer in. It has to be freed by the caller 672 * @param maxsize The size in bytes allocated to @p output.673 665 * @return TRUE if the user pressed OK, FALSE if they pressed Cancel. 674 666 */ 675 bool popup_and_get_string(char *title, char *b, char *output, 676 int maxsize) { 667 bool popup_and_get_string(char *title, char *b, char *output) { 677 668 678 669 /*@ newt ************************************************************ */ … … 685 676 686 677 /*@ pointers ********************************************************* */ 687 char *entry_value ;678 char *entry_value = NULL; 688 679 689 680 /*@ buffers ********************************************************** */ 690 char *blurb; 691 char *original_contents; 681 char *blurb = NULL; 692 682 size_t n = 0; 683 bool ret = TRUE; 693 684 694 685 assert_string_is_neither_NULL_nor_zerolength(title); … … 699 690 ("---promptstring---1--- %s\r\n---promptstring---2--- %s\r\n---promptstring---Q---\r\n--> ", 700 691 title, b); 692 paranoid_free(output); 701 693 (void) getline(&output, &n, stdin); 702 694 if (output[strlen(output) - 1] == '\n') 703 695 output[strlen(output) - 1] = '\0'; 704 return ( TRUE);696 return (ret); 705 697 } 706 698 asprintf(&blurb, b); 707 699 text = newtTextboxReflowed(2, 1, blurb, 48, 5, 5, 0); 708 original_contents = output;709 700 710 701 type_here = 711 702 newtEntry(2, newtTextboxGetNumLines(text) + 2, 712 original_contents, 50, 713 #ifdef __cplusplus 714 0, NEWT_FLAG_RETURNEXIT 715 #else 716 (void *) &entry_value, NEWT_FLAG_RETURNEXIT 717 #endif 703 output, 50, 704 &entry_value, NEWT_FLAG_RETURNEXIT 718 705 ); 719 706 b_1 = newtButton(6, newtTextboxGetNumLines(text) + 4, _(" OK ")); 720 707 b_2 = newtButton(18, newtTextboxGetNumLines(text) + 4, _("Cancel")); 721 // newtOpenWindow (8, 5, 54, newtTextboxGetNumLines (text) + 9, title);722 708 newtCenteredWindow(54, newtTextboxGetNumLines(text) + 9, title); 723 709 myForm = newtForm(NULL, NULL, 0); … … 727 713 newtPushHelpLine(blurb); 728 714 paranoid_free(blurb); 715 729 716 b_res = newtRunForm(myForm); 730 output = entry_value;731 717 newtPopHelpLine(); 718 if (b_res == b_2) { 719 ret = FALSE; 720 } else { 721 // Copy entry_value before destroying the form 722 // clearing potentially output before 723 paranoid_alloc(output,entry_value); 724 } 732 725 newtFormDestroy(myForm); 733 726 newtPopWindow(); 734 if (b_res == b_2) { 735 paranoid_free(output); 736 output = original_contents; 737 paranoid_free(original_contents); 738 return (FALSE); 739 } else { 740 paranoid_free(original_contents); 741 return (TRUE); 742 } 727 return(ret); 743 728 } 744 729 … … 846 831 newtRefresh(); 847 832 for (i = g_noof_log_lines - 1; i >= 0; i--) { 848 err_log_lines[i][79] = '\0';833 //BERLIOS : removed for now, Think it's useless : err_log_lines[i][79] = '\0'; 849 834 newtDrawRootText(0, i + g_noof_rows - 1 - g_noof_log_lines, 850 835 err_log_lines[i]); … … 884 869 885 870 for (i = 0; i < g_noof_log_lines; i++) { 886 err_log_lines[i] = (char *) malloc(MAX_NEWT_COMMENT_LEN); 887 if (!err_log_lines[i]) { 888 fatal_error("Out of memory"); 889 } 890 } 891 892 for (i = 0; i < g_noof_log_lines; i++) { 893 err_log_lines[i][0] = '\0'; 871 err_log_lines[i] = NULL; 894 872 } 895 873 } … … 1575 1553 1576 1554 1577 #if __cplusplus1578 } /* extern "C" */1579 #endif1580 1581 1582 1555 void wait_until_software_raids_are_prepped(char *mdstat_file, 1583 1556 int wait_for_percentage); -
trunk/mondo/mondo/common/newt-specific.h
r59 r688 21 21 long max_val); 22 22 void popup_and_OK(char *prompt); 23 bool popup_and_get_string(char *title, char *b, char *output , int maxsize);23 bool popup_and_get_string(char *title, char *b, char *output); 24 24 bool popup_with_buttons(char *p, char *button1, char *button2); 25 25 void refresh_log_screen();
Note:
See TracChangeset
for help on using the changeset viewer.