Changeset 2405 in MondoRescue
- Timestamp:
- Sep 17, 2009, 3:45:24 AM (15 years ago)
- Location:
- branches/2.2.10/mondo/src
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-archive.c
r2383 r2405 979 979 void *create_afio_files_in_background(void *inbuf) 980 980 { 981 long int archiving_set_no ;982 char *archiving_filelist_fname ;983 char *archiving_afioball_fname ;981 long int archiving_set_no = 0L; 982 char *archiving_filelist_fname = NULL; 983 char *archiving_afioball_fname = NULL; 984 984 char *curr_xattr_list_fname = NULL; 985 985 char *curr_acl_list_fname = NULL; … … 994 994 int this_thread_no = g_current_thread_no++; 995 995 996 malloc_string(archiving_filelist_fname);997 malloc_string(archiving_afioball_fname);998 996 p_last_set_archived = (int *) inbuf; 999 997 p_archival_threads_running = (int *) (inbuf + 4); … … 1002 1000 bkpinfo_bis = (struct s_bkpinfo *) (inbuf + BKPINFO_LOC_OFFSET); 1003 1001 1004 sprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, 0L);1005 for (archiving_set_no = 0; does_file_exist(archiving_filelist_fname); 1006 sprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no)) {1002 mr_asprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, 0L); 1003 1004 while (does_file_exist(archiving_filelist_fname)) { 1007 1005 if (g_exiting) { 1006 mr_free(archiving_filelist_fname); 1008 1007 fatal_error("Execution run aborted (pthread)"); 1009 1008 } 1010 1009 if (archiving_set_no >= MAX_NOOF_SETS_HERE) { 1010 mr_free(archiving_filelist_fname); 1011 1011 fatal_error("Maximum number of filesets exceeded. Adjust MAX_NOOF_SETS_HERE, please."); 1012 1012 } 1013 1013 if (!semaphore_p()) { 1014 1014 log_msg(3, "P sem failed (pid=%d)", (int) getpid()); 1015 mr_free(archiving_filelist_fname); 1015 1016 fatal_error("Cannot get semaphore P"); 1016 1017 } … … 1020 1021 *p_next_set_to_archive = *p_next_set_to_archive + 1; 1021 1022 if (!semaphore_v()) { 1023 mr_free(archiving_filelist_fname); 1022 1024 fatal_error("Cannot get semaphore V"); 1023 1025 } 1024 1026 1025 1027 /* backup this set of files */ 1026 sprintf(archiving_afioball_fname, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no, bkpinfo->zip_suffix); 1027 sprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no); 1028 mr_asprintf(archiving_afioball_fname, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no, bkpinfo->zip_suffix); 1029 mr_free(archiving_filelist_fname); 1030 mr_asprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no); 1028 1031 if (!does_file_exist(archiving_filelist_fname)) { 1029 log_msg(3, 1030 "%s[%d:%d] - well, I would archive %d, except that it doesn't exist. I'll stop now.", 1031 FORTY_SPACES, getpid(), this_thread_no, 1032 archiving_set_no); 1032 log_msg(3, "[%d:%d] - well, I would archive %d, except that it doesn't exist. I'll stop now.", getpid(), this_thread_no, archiving_set_no); 1033 1033 break; 1034 1034 } … … 1036 1036 mr_asprintf(tmp, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no - ARCH_BUFFER_NUM, bkpinfo->zip_suffix); 1037 1037 if (does_file_exist(tmp)) { 1038 log_msg(4, "%s[%d:%d] - waiting for storer", FORTY_SPACES, 1039 getpid(), this_thread_no); 1038 log_msg(4, "[%d:%d] - waiting for storer", getpid(), this_thread_no); 1040 1039 while (does_file_exist(tmp)) { 1041 1040 sleep(1); … … 1045 1044 mr_free(tmp); 1046 1045 1047 log_msg(4, " %s[%d:%d] - EXATing %d...", FORTY_SPACES, getpid(),1048 this_thread_no, archiving_set_no); 1046 log_msg(4, "[%d:%d] - EXATing %d...", getpid(), this_thread_no, archiving_set_no); 1047 1049 1048 if (g_getfattr) { 1050 1049 mr_asprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no); … … 1058 1057 } 1059 1058 1060 log_msg(4, "%s[%d:%d] - archiving %d...", FORTY_SPACES, getpid(), 1061 this_thread_no, archiving_set_no); 1062 res = 1063 archive_this_fileset(archiving_filelist_fname, 1064 archiving_afioball_fname, 1065 archiving_set_no); 1059 log_msg(4, "[%d:%d] - archiving %d...", getpid(), this_thread_no, archiving_set_no); 1060 res = archive_this_fileset(archiving_filelist_fname, archiving_afioball_fname, archiving_set_no); 1061 mr_free(archiving_afioball_fname); 1062 1066 1063 retval += res; 1067 1064 … … 1069 1066 log_to_screen("Errors occurred while archiving set %ld. Please review logs.", archiving_set_no); 1070 1067 } 1068 1071 1069 if (!semaphore_p()) { 1070 mr_free(archiving_filelist_fname); 1072 1071 fatal_error("Cannot get semaphore P"); 1073 1072 } … … 1080 1079 1081 1080 if (!semaphore_v()) { 1081 mr_free(archiving_filelist_fname); 1082 1082 fatal_error("Cannot get semaphore V"); 1083 1083 } 1084 log_msg(4, "%s[%d:%d] - archived %d OK", FORTY_SPACES, getpid(), 1085 this_thread_no, archiving_set_no); 1084 log_msg(4, "[%d:%d] - archived %d OK", getpid(), this_thread_no, archiving_set_no); 1086 1085 archiving_set_no++; 1087 } 1086 1087 mr_free(archiving_filelist_fname); 1088 mr_asprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, archiving_set_no); 1089 } 1090 mr_free(archiving_filelist_fname); 1091 1088 1092 if (!semaphore_p()) { 1089 1093 fatal_error("Cannot get semaphore P"); … … 1093 1097 fatal_error("Cannot get semaphore V"); 1094 1098 } 1095 log_msg(3, "%s[%d:%d] - exiting", FORTY_SPACES, getpid(), 1096 this_thread_no); 1097 paranoid_free(archiving_filelist_fname); 1098 paranoid_free(archiving_afioball_fname); 1099 log_msg(3, "[%d:%d] - exiting", getpid(), this_thread_no); 1099 1100 pthread_exit(NULL); 1100 1101 } … … 1327 1328 assert(bkpinfo != NULL); 1328 1329 malloc_string(result_str); 1329 transfer_block = 1330 malloc(sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64); 1330 transfer_block = malloc(sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64); 1331 1331 memset((void *) transfer_block, 0, 1332 1332 sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64); … … 1638 1638 char *message_to_screen = NULL; 1639 1639 char *sz_blank_disk = NULL; 1640 char *fnam;1641 1640 char *tmp2 = NULL; 1642 1641 char *tmp3 = NULL; … … 1645 1644 1646 1645 malloc_string(old_pwd); 1647 malloc_string(fnam);1648 1646 assert(bkpinfo != NULL); 1649 1647 assert_string_is_neither_NULL_nor_zerolength(destfile); … … 1879 1877 } 1880 1878 paranoid_free(old_pwd); 1881 paranoid_free(fnam);1882 1879 return (retval); 1883 1880 } … … 2529 2526 /** 2530 2527 * Make sure the user has a valid CD-R(W) in the CD drive. 2531 * @param cdrw_dev Set to the CD-R(W) device checked. 2532 * @param keep_looping If TRUE, keep pestering user until they insist 2533 * or insert a correct CD; if FALSE, only check once. 2534 * @return 0 (there was an OK CD in the drive) or 1 (there wasn't). 2535 */ 2536 int interrogate_disk_currently_in_cdrw_drive(char *cdrw_dev, bool keep_looping) { 2537 int res = 0; 2538 char *bkp = NULL; 2528 * @return the CD-R(W) device checked or NULL 2529 */ 2530 char *interrogate_disk_currently_in_cdrw_drive(char *cdrw_dev) { 2539 2531 char *cdrecord = NULL; 2540 2541 mr_asprintf(bkp, "%s", cdrw_dev); 2542 if (find_cdrw_device(cdrw_dev)) { 2543 strcpy(cdrw_dev, bkp); 2544 } else { 2532 char *cdrw_dev = NULL; 2533 2534 cdrw_dev = find_cdrw_device(); 2535 if (cdrw_dev != NULL) { 2545 2536 if (!system("which cdrecord > /dev/null 2> /dev/null")) { 2546 2537 mr_asprintf(cdrecord, "cdrecord dev=%s -atip", cdrw_dev); … … 2551 2542 } 2552 2543 if (cdrecord != NULL) { 2553 if (!keep_looping) { 2554 retract_CD_tray_and_defeat_autorun(); 2555 res = run_program_and_log_output(cdrecord, 5); 2556 } else { 2557 while ((res = run_program_and_log_output(cdrecord, 5))) { 2558 retract_CD_tray_and_defeat_autorun(); 2559 if (ask_me_yes_or_no 2560 ("Unable to examine CD. Are you sure this is a valid CD-R(W) CD?")) 2561 { 2562 log_msg(1, "Well, he insisted..."); 2563 break; 2564 } 2565 } 2544 retract_CD_tray_and_defeat_autorun(); 2545 if (run_program_and_log_output(cdrecord, 5)) { 2546 /* As it didn't work, return NULL */ 2547 mr_free(cdrw_dev); 2566 2548 } 2567 2549 } 2568 } 2569 mr_free(bkp); 2570 2571 mr_free(cdrecord); 2572 return (res); 2550 mr_free(cdrecord); 2551 } 2552 return(cdrw_dev); 2573 2553 } 2574 2554 … … 2586 2566 char *tmp = NULL; 2587 2567 char *cdrom_dev = NULL; 2588 char *cdrw_dev ;2568 char *cdrw_dev = NULL; 2589 2569 char *our_serial_str = NULL; 2590 2570 bool ok_go_ahead_burn_it; … … 2592 2572 int attempt_to_mount_returned_this = 999; 2593 2573 char *mtpt = NULL; 2594 char *szcdno ;2595 char *szserfname ;2596 char *szunmount ;2574 char *szcdno = NULL; 2575 char *szserfname = NULL; 2576 char *szunmount = NULL; 2597 2577 char *mds = NULL; 2598 2599 malloc_string(cdrw_dev);2600 malloc_string(szcdno);2601 malloc_string(szserfname);2602 malloc_string(szunmount);2603 2578 2604 2579 mds = media_descriptor_string(g_backup_media_type); … … 2621 2596 mr_asprintf(tmp, "umount %s", cdrom_dev); 2622 2597 run_program_and_log_output(tmp, 1); 2623 sprintf(szcdno, "%s/archives/THIS-CD-NUMBER", mtpt);2624 sprintf(szserfname, "%s/archives/SERIAL-STRING", mtpt);2625 sprintf(szunmount, "umount %s", mtpt);2598 mr_asprintf(szcdno, "%s/archives/THIS-CD-NUMBER", mtpt); 2599 mr_asprintf(szserfname, "%s/archives/SERIAL-STRING", mtpt); 2600 mr_asprintf(szunmount, "umount %s", mtpt); 2626 2601 cd_number = -1; 2627 2602 mr_asprintf(tmp, "mount %s %s", cdrom_dev, mtpt); … … 2629 2604 attempt_to_mount_returned_this = run_program_and_log_output(tmp, 1); 2630 2605 mr_free(tmp); 2606 2631 2607 if (attempt_to_mount_returned_this) { 2632 2608 log_msg(4, "Failed to mount %s at %s", cdrom_dev, mtpt); 2633 2609 log_to_screen("If there's a CD/DVD in the drive, it's blank."); 2634 /* 2635 if (interrogate_disk_currently_in_cdrw_drive(cdrw_dev, FALSE)) 2636 { 2637 ok_go_ahead_burn_it = FALSE; 2638 log_to_screen("There isn't a writable CD/DVD in the drive."); 2639 } 2640 else 2641 { 2642 log_to_screen("Confirmed. There is a blank CD/DVD in the drive."); 2643 } 2644 */ 2645 } else if (!does_file_exist(szcdno) 2646 || !does_file_exist(szserfname)) { 2610 } else if (!does_file_exist(szcdno) || !does_file_exist(szserfname)) { 2647 2611 mds = media_descriptor_string(g_backup_media_type); 2648 log_to_screen 2649 ("%s has data on it but it's probably not a Mondo CD.", mds); 2612 log_to_screen("%s has data on it but it's probably not a Mondo CD.", mds); 2650 2613 mr_free(mds); 2651 2614 } else { … … 2664 2627 // FIXME - should be able to use last_line_of_file(), surely? 2665 2628 } 2629 mr_free(szcdno); 2630 mr_free(szserfname); 2631 2666 2632 run_program_and_log_output(szunmount, 1); 2633 mr_free(szunmount); 2634 2667 2635 log_msg(2, "paafcd: cd_number = %d", cd_number); 2668 2636 log_msg(2, "our serial str = %s; g_serial_string = %s", our_serial_str, g_serial_string); … … 2686 2654 log_msg(2, 2687 2655 "paafcd: Can't find CD-ROM drive. Perhaps it has a blank %s in it?", mds); 2688 if (interrogate_disk_currently_in_cdrw_drive(cdrw_dev, FALSE)) { 2656 cdrw_dev = interrogate_disk_currently_in_cdrw_drive(); 2657 if (cdrw_dev == NULL) { 2689 2658 ok_go_ahead_burn_it = FALSE; 2690 2659 log_to_screen("There isn't a writable %s in the drive.", mds); 2691 2660 } 2661 mr_free(cdrw_dev); 2692 2662 mr_free(mds); 2693 2663 } … … 2709 2679 2710 2680 mds = media_descriptor_string(g_backup_media_type); 2711 log_msg(2, 2712 "paafcd: OK, I assume I have a blank/reusable %s in the drive...", mds); 2681 log_msg(2, "paafcd: OK, I assume I have a blank/reusable %s in the drive...", mds); 2713 2682 2714 2683 log_to_screen("Proceeding w/ %s in drive.", mds); 2715 2684 mr_free(mds); 2716 2685 2717 paranoid_free(cdrw_dev);2718 2686 paranoid_free(mtpt); 2719 paranoid_free(szcdno);2720 paranoid_free(szserfname);2721 paranoid_free(szunmount);2722 2687 if (pmountable) { 2723 2688 if (attempt_to_mount_returned_this) { … … 2729 2694 2730 2695 } 2731 2732 2733 2734 2735 2736 2737 2696 2738 2697 … … 2764 2723 2765 2724 /* @} - end of utilityGroup */ 2766 2767 2768 2769 2770 2771 2772 2725 2773 2726 -
branches/2.2.10/mondo/src/common/libmondo-cli.c
r2389 r2405 654 654 655 655 /*@ buffers ** */ 656 char *tmp = NULL;657 656 char *tmp1 = NULL; 658 657 char *tmp2 = NULL; … … 668 667 669 668 struct stat buf; 670 671 malloc_string(tmp);672 669 673 670 assert(bkpinfo != NULL); … … 1377 1374 finish(0); 1378 1375 } 1379 mr_free(tmp);1380 1376 1381 1377 if ((flag_set['L']) && (! bkpinfo->restore_data)) { -
branches/2.2.10/mondo/src/common/libmondo-devices.c
r2400 r2405 1407 1407 char *tmp = NULL; 1408 1408 char *p = NULL; 1409 char *tmp1 = NULL;1410 1409 char *mds = NULL; 1411 1410 char *sz_size = NULL; 1412 1411 char *command = NULL; 1413 1412 char *comment = NULL; 1414 char *prompt;1415 1413 int i; 1416 1414 FILE *fin; 1417 1415 1418 malloc_string(prompt);1419 malloc_string(tmp1);1420 1416 assert(bkpinfo != NULL); 1421 1417 bkpinfo->nonbootable_backup = FALSE; … … 1456 1452 if (archiving_to_media) { 1457 1453 if ((bkpinfo->backup_media_type != dvd) && (bkpinfo->backup_media_type != usb)) { 1458 if (ask_me_yes_or_no 1459 ("Is your computer a laptop, or does the CD writer incorporate BurnProof technology?")) 1460 { 1454 if (ask_me_yes_or_no("Is your computer a laptop, or does the CD writer incorporate BurnProof technology?")) { 1461 1455 bkpinfo->manual_cd_tray = TRUE; 1462 1456 } 1463 1457 } 1464 if ((bkpinfo->compression_level = 1465 which_compression_level()) == -1) { 1458 if ((bkpinfo->compression_level = which_compression_level()) == -1) { 1466 1459 log_to_screen("User has chosen not to backup the PC"); 1467 1460 finish(1); … … 1495 1488 mr_free(comment); 1496 1489 1497 bkpinfo->cdrw_speed = atoi(tmp1); // if DVD then this shouldn't ever be used anyway :) 1490 bkpinfo->cdrw_speed = atoi(tmp); // if DVD then this shouldn't ever be used anyway :) 1491 mr_free(tmp); 1498 1492 1499 1493 mr_asprintf(comment, "How much data (in Megabytes) will each %s store?", mds); … … 2022 2016 } 2023 2017 paranoid_free(sz_size); 2024 paranoid_free(tmp1);2025 paranoid_free(prompt);2026 2018 return (0); 2027 2019 } -
branches/2.2.10/mondo/src/common/libmondo-filelist.c
r2404 r2405 1507 1507 char *sz_filelist; 1508 1508 char *exclude_paths = NULL; 1509 char *tmp;1510 1509 int i; 1511 1510 FILE *fout; … … 1516 1515 char *tmp2 = NULL; 1517 1516 1518 malloc_string(tmp);1519 malloc_string(g_skeleton_filelist);1520 1517 mr_asprintf(sz_datefile,MONDO_CACHE"/difflevel.%d" , 0); 1521 1518 if (!include_paths && !userdef_filelist) { … … 1587 1584 log_msg(2, "Excluding paths = '%s'", exclude_paths); 1588 1585 log_msg(2, "Generating skeleton filelist so that we can track our progress"); 1589 sprintf(g_skeleton_filelist, "%s/tmpfs/skeleton.txt", bkpinfo->tmpdir);1586 mr_asprintf(g_skeleton_filelist, "%s/tmpfs/skeleton.txt", bkpinfo->tmpdir); 1590 1587 make_hole_for_file(g_skeleton_filelist); 1591 1588 log_msg(4, "g_skeleton_entries = %ld", g_skeleton_entries); … … 1631 1628 paranoid_free(sz_filelist); 1632 1629 log_msg(2, "Freeing variables"); 1633 paranoid_free(tmp); 1634 paranoid_free(g_skeleton_filelist); 1630 mr_free(g_skeleton_filelist); 1635 1631 log_msg(2, "Exiting"); 1636 1632 return (0); -
branches/2.2.10/mondo/src/common/libmondo-fork.c
r2392 r2405 95 95 * @return Exit code of @c mkisofs (0 is success, anything else indicates failure). 96 96 */ 97 int 98 eval_call_to_make_ISO(char *basic_call, char *isofile, int cd_no, char *what_i_am_doing) { 97 int eval_call_to_make_ISO(char *basic_call, char *isofile, int cd_no, char *what_i_am_doing) { 99 98 100 99 /*@ int's *** */ … … 106 105 char *ultimate_call = NULL; 107 106 char *tmp = NULL; 108 char *incoming, *old_stderr;109 107 110 108 char *cd_number_str = NULL; … … 119 117 assert(bkpinfo != NULL); 120 118 assert_string_is_neither_NULL_nor_zerolength(isofile); 121 malloc_string(incoming);122 malloc_string(old_stderr);123 124 incoming[0] = '\0';125 old_stderr[0] = '\0';126 119 127 120 if ((bkpinfo->netfs_user) && (strstr(bkpinfo->netfs_proto,"nfs"))) { … … 187 180 } 188 181 mr_free(command); 189 paranoid_free(incoming);190 paranoid_free(old_stderr);191 182 return (retval); 192 183 } -
branches/2.2.10/mondo/src/common/libmondo-raid.c
r2357 r2405 591 591 { 592 592 FILE *fin; 593 char *tmp;594 593 char *label; 595 594 char *value; … … 597 596 int v; 598 597 599 malloc_string(tmp);600 malloc_string(label);601 malloc_string(value);602 598 assert(raidlist != NULL); 603 599 assert_string_is_neither_NULL_nor_zerolength(fname); … … 606 602 log_it("Raidtab is very small or non-existent. Ignoring it."); 607 603 raidlist->entries = 0; 608 paranoid_free(tmp);609 paranoid_free(label);610 paranoid_free(value);611 604 return (0); 612 605 } 613 606 if (!(fin = fopen(fname, "r"))) { 614 607 log_it("Cannot open raidtab"); 615 paranoid_free(tmp);616 paranoid_free(label);617 paranoid_free(value);618 608 return (1); 619 609 } 620 610 items = 0; 621 611 log_it("Loading raidtab..."); 612 malloc_string(label); 613 malloc_string(value); 622 614 get_next_raidtab_line(fin, label, value); 623 615 while (!feof(fin)) { … … 631 623 v++; 632 624 get_next_raidtab_line(fin, label, value); 633 log_it(tmp);634 625 } 635 626 raidlist->el[items].additional_vars.entries = v; … … 651 642 log_msg(1, "Raidtab loaded successfully."); 652 643 log_msg(1, "%d RAID devices in raidtab", items); 653 paranoid_free(tmp);654 644 paranoid_free(label); 655 645 paranoid_free(value); -
branches/2.2.10/mondo/src/common/libmondo-stream.c
r2383 r2405 1315 1315 while (ctrl_chr != BLK_START_AN_AFIO_OR_SLICE) { 1316 1316 res = 1317 read_header_block_from_stream(&temp_size, temp_fname, 1318 &ctrl_chr); 1317 read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr); 1319 1318 if (ctrl_chr == BLK_START_AN_AFIO_OR_SLICE) { 1320 1319 break; … … 1326 1325 while (ctrl_chr != BLK_START_FILE) { 1327 1326 res = 1328 read_header_block_from_stream(&temp_size, temp_fname, 1329 &ctrl_chr); 1327 read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr); 1330 1328 if (ctrl_chr == BLK_START_FILE) { 1331 1329 break; … … 1348 1346 } 1349 1347 while (strcmp(pA, pB)) { 1350 log_msg(6, "Skipping %s (it's not %s)", temp_fname, 1351 the_file_I_was_reading); 1348 log_msg(6, "Skipping %s (it's not %s)", temp_fname, the_file_I_was_reading); 1352 1349 for (size = temp_size; size > 0; size -= bytes_to_write) { 1353 1350 bytes_to_write = … … 1357 1354 } 1358 1355 res = 1359 read_header_block_from_stream(&temp_size, temp_fname, 1360 &ctrl_chr); 1356 read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr); 1361 1357 if (ctrl_chr != BLK_STOP_FILE) { 1362 1358 wrong_marker(BLK_STOP_FILE, ctrl_chr); 1363 1359 } 1364 1360 res = 1365 read_header_block_from_stream(&temp_size, temp_fname, 1366 &ctrl_chr); 1361 read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr); 1367 1362 if (ctrl_chr != BLK_STOP_AN_AFIO_OR_SLICE) { 1368 1363 wrong_marker(BLK_STOP_AN_AFIO_OR_SLICE, ctrl_chr); 1369 1364 } 1370 1365 res = 1371 read_header_block_from_stream(&temp_size, temp_fname, 1372 &ctrl_chr); 1366 read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr); 1373 1367 if (ctrl_chr != BLK_START_AN_AFIO_OR_SLICE) { 1374 1368 wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr); 1375 1369 } 1376 1370 res = 1377 read_header_block_from_stream(&temp_size, temp_fname, 1378 &ctrl_chr); 1371 read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr); 1379 1372 if (ctrl_chr != BLK_START_FILE) { 1380 1373 wrong_marker(BLK_START_FILE, ctrl_chr); … … 1393 1386 } 1394 1387 } 1395 log_msg(2, "Reading %s (it matches %s)", temp_fname, 1396 the_file_I_was_reading); 1388 log_msg(2, "Reading %s (it matches %s)", temp_fname, the_file_I_was_reading); 1397 1389 paranoid_free(temp_fname); 1398 1390 paranoid_free(datablock); -
branches/2.2.10/mondo/src/common/libmondo-string.c
r2400 r2405 202 202 long outval; 203 203 int i; 204 char *tmp;205 204 char *tmp1 = NULL; 206 205 char ch; … … 208 207 assert_string_is_neither_NULL_nor_zerolength(incoming); 209 208 210 malloc_string(tmp);211 209 if (!incoming[0]) { 212 free(tmp);213 210 return (0); 214 211 } … … 216 213 fatal_error("Please use integers only. No decimal points."); 217 214 } 218 strcpy(tmp, incoming); 219 i = (int) strlen(tmp); 220 if (tmp[i - 1] == 'B' || tmp[i - 1] == 'b') { 221 tmp[i - 1] = '\0'; 222 } 223 for (i = 0; i < (int) strlen(tmp) && isdigit(tmp[i]); i++); 224 ch = tmp[i]; 225 tmp[i] = '\0'; 226 outval = atol(tmp); 227 paranoid_free(tmp); 215 216 mr_asprintf(tmp1, "%s", incoming); 217 i = (int) strlen(tmp1); 218 if (tmp1[i - 1] == 'B' || tmp1[i - 1] == 'b') { 219 tmp1[i - 1] = '\0'; 220 } 221 for (i = 0; i < (int) strlen(tmp1) && isdigit(tmp1[i]); i++); 222 ch = tmp1[i]; 223 tmp1[i] = '\0'; 224 outval = atol(tmp1); 225 paranoid_free(tmp1); 226 228 227 if (ch == 'g' || ch == 'G') { 229 228 outval = outval * 1024; -
branches/2.2.10/mondo/src/common/libmondo-tools.c
r2383 r2405 393 393 char *mondo_mkisofs_sz = NULL; 394 394 char *command = NULL; 395 char *mtpt;396 395 char *hostname = NULL; 397 396 char *ip_address = NULL; … … 413 412 } 414 413 415 malloc_string(mtpt);416 414 bkpinfo->optimal_set_size = 417 415 (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type) ? 16 : 16) * … … 700 698 } 701 699 g_backup_media_type = bkpinfo->backup_media_type; 702 paranoid_free(mtpt);703 700 return (retval); 704 701 } -
branches/2.2.10/mondo/src/include/my-stuff.h
r2382 r2405 344 344 #define ARCH_THREADS 2 ///< The number of simultaneous threads running afio in the background. 345 345 #define ARCH_BUFFER_NUM (ARCH_THREADS*4) // Number of permissible queued afio files 346 #define FORTY_SPACES " " ///< 40 spaces.347 ///< Size of the tmpfs, in megabytes, to attempt to mount (to speed up Mondo).348 /*349 #define PPCFG_RAMDISK_SIZE 350350 */351 352 346 #define DO_MBR_PLEASE "/tmp/DO-MBR-PLEASE" 353 347 -
branches/2.2.10/mondo/src/mondorestore/mondo-prep.c
r2383 r2405 61 61 { 62 62 char *command = NULL; 63 char *tmp;64 63 int lino; 65 64 int i; … … 72 71 // If LVMs are present and a zero-and-reboot wasn't recently undertaken 73 72 // then zero & insist on reboot. 74 malloc_string(tmp);75 73 buf = malloc(blocksize); 76 74 if (does_file_exist("/tmp/i-want-my-lvm")) // FIXME - cheating :) … … 91 89 if (lino == drivelist->entries) { 92 90 // zero & reboot 93 log_to_screen 94 ("I am sorry for the inconvenience but I must ask you to reboot."); 95 log_to_screen 96 ("I need to reset the Master Boot Record; in order to be"); 97 log_to_screen 98 ("sure the kernel notices, I must reboot after doing it."); 91 log_to_screen("I am sorry for the inconvenience but I must ask you to reboot."); 92 log_to_screen("I need to reset the Master Boot Record; in order to be"); 93 log_to_screen("sure the kernel notices, I must reboot after doing it."); 99 94 log_to_screen("Please hit 'Enter' to reboot."); 100 95 for (lino = 0; lino < drivelist->entries; lino++) { … … 127 122 } 128 123 // Still here? Cool! 129 paranoid_free(tmp);130 124 log_msg(1, "Cool. I didn't have to wipe anything."); 131 125 } -
branches/2.2.10/mondo/src/mondorestore/mondo-rstr-compare.c
r2357 r2405 43 43 44 44 /** needs malloc *******/ 45 char *checksum_ptr = NULL; 46 char *original_cksum_ptr = NULL; 47 char *bigfile_fname_ptr = NULL; 48 char *tmp_ptr = NULL; 49 char *command_ptr = NULL; 50 51 char *checksum, *bigfile_fname, *tmp, *command; 45 char *checksum = NULL; 46 char *original_cksum = NULL; 47 char *bigfile_fname = NULL; 48 char *tmp = NULL; 49 char *command = NULL; 52 50 53 51 char *p; … … 56 54 57 55 struct s_filename_and_lstat_info biggiestruct; 58 59 malloc_string(checksum);60 malloc_string(bigfile_fname);61 malloc_string(tmp);62 malloc_string(command);63 56 64 57 /********************************************************************* … … 83 76 paranoid_fclose(fin); 84 77 85 mr_asprintf(checksum _ptr, "%s", biggiestruct.checksum);86 mr_asprintf(bigfile_fname _ptr, "%s", biggiestruct.filename);78 mr_asprintf(checksum, "%s", biggiestruct.checksum); 79 mr_asprintf(bigfile_fname, "%s", biggiestruct.filename); 87 80 88 81 log_msg(2, "biggiestruct.filename = %s", biggiestruct.filename); … … 90 83 91 84 if (!g_text_mode) { 92 mr_asprintf(tmp _ptr, "Comparing %s", bigfile_fname_ptr);93 newtDrawRootText(0, 22, tmp _ptr);94 paranoid_free(tmp _ptr);85 mr_asprintf(tmp, "Comparing %s", bigfile_fname); 86 newtDrawRootText(0, 22, tmp); 87 paranoid_free(tmp); 95 88 newtRefresh(); 96 89 } 97 90 if (!checksum[0]) { 98 log_msg(2, "Warning - %s has no checksum", bigfile_fname _ptr);99 } 100 if (!strncmp(bigfile_fname _ptr, "/dev/", 5)) {101 log_msg(2, "IGNORING %s as begining with /dev", bigfile_fname _ptr);102 mr_free(bigfile_fname _ptr);91 log_msg(2, "Warning - %s has no checksum", bigfile_fname); 92 } 93 if (!strncmp(bigfile_fname, "/dev/", 5)) { 94 log_msg(2, "IGNORING %s as begining with /dev", bigfile_fname); 95 mr_free(bigfile_fname); 103 96 return (1); 104 97 } 105 98 106 mr_asprintf(command _ptr, "md5sum \"%s%s\" > /tmp/md5sum.txt 2> /tmp/errors", MNT_RESTORING, bigfile_fname_ptr);107 log_msg(2, command _ptr);108 i = system(command _ptr);109 mr_free(command _ptr);110 111 mr_asprintf(tmp _ptr, "cat /tmp/errors >> %s 2> /dev/null", MONDO_LOGFILE);112 paranoid_system(tmp _ptr);113 paranoid_free(tmp _ptr);99 mr_asprintf(command, "md5sum \"%s%s\" > /tmp/md5sum.txt 2> /tmp/errors", MNT_RESTORING, bigfile_fname); 100 log_msg(2, command); 101 i = system(command); 102 mr_free(command); 103 104 mr_asprintf(tmp, "cat /tmp/errors >> %s 2> /dev/null", MONDO_LOGFILE); 105 paranoid_system(tmp); 106 paranoid_free(tmp); 114 107 115 108 if (i) { … … 120 113 log_msg(2, 121 114 "Unable to open /tmp/md5sum.txt; can't get live checksum"); 122 mr_free(bigfile_fname _ptr);115 mr_free(bigfile_fname); 123 116 return (1); 124 117 } else { 125 mr_getline(original_cksum _ptr, fin);118 mr_getline(original_cksum, fin); 126 119 paranoid_fclose(fin); 127 p = strchr(original_cksum _ptr, ' ');120 p = strchr(original_cksum, ' '); 128 121 if (p) { 129 122 *p = '\0'; … … 131 124 } 132 125 } 133 mr_asprintf(tmp _ptr, "bigfile #%ld ('%s') ", bigfileno + 1, bigfile_fname_ptr);134 if ((original_cksum _ptr != NULL) && (strcmp(checksum_ptr, original_cksum_ptr) == 0)) {135 mr_strcat(tmp _ptr, " ... OK");136 } else { 137 mr_strcat(tmp _ptr, "... changed");126 mr_asprintf(tmp, "bigfile #%ld ('%s') ", bigfileno + 1, bigfile_fname); 127 if ((original_cksum != NULL) && (strcmp(checksum, original_cksum) == 0)) { 128 mr_strcat(tmp, " ... OK"); 129 } else { 130 mr_strcat(tmp, "... changed"); 138 131 retval++; 139 132 } 140 mr_free(checksum _ptr);141 mr_free(original_cksum _ptr);142 143 log_msg(1, tmp _ptr);144 paranoid_free(tmp _ptr);133 mr_free(checksum); 134 mr_free(original_cksum); 135 136 log_msg(1, tmp); 137 paranoid_free(tmp); 145 138 146 139 if (retval) { … … 148 141 fatal_error("Cannot openout changed.txt"); 149 142 } 150 fprintf(fout, "%s\n", bigfile_fname _ptr);143 fprintf(fout, "%s\n", bigfile_fname); 151 144 paranoid_fclose(fout); 152 145 } 153 mr_free(bigfile_fname_ptr); 154 155 paranoid_free(bigfile_fname); 156 paranoid_free(checksum); 157 paranoid_free(command); 158 paranoid_free(tmp); 146 mr_free(bigfile_fname); 159 147 160 148 return (retval); -
branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c
r2404 r2405 698 698 t_bkptype media_specified_by_user; 699 699 700 malloc_string(tmp);701 700 // assert_string_is_neither_NULL_nor_zerolength(cfg_file); 702 701 assert(bkpinfo != NULL); … … 1099 1098 g_backup_media_type = bkpinfo->backup_media_type; 1100 1099 paranoid_free(value); 1101 paranoid_free(tmp);1102 1100 return (0); 1103 1101 … … 1499 1497 char *command = NULL; 1500 1498 char *boot_device = NULL; 1501 char *rootdev;1502 char *rootdrive;1503 char *conffile;1504 1499 char *tmp = NULL; 1505 1500 char *editor = NULL; … … 1509 1504 bool done; 1510 1505 1511 malloc_string(rootdev);1512 malloc_string(rootdrive);1513 malloc_string(conffile);1514 1506 assert_string_is_neither_NULL_nor_zerolength(bd); 1515 1507 mr_asprintf(boot_device, "%s", bd); … … 1617 1609 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 1618 1610 } 1619 paranoid_free(rootdev);1620 paranoid_free(rootdrive);1621 paranoid_free(conffile);1622 1611 1623 1612 return (res); … … 2190 2179 2191 2180 /** malloc *****/ 2192 char *device;2193 2181 char *command = NULL; 2194 2182 char *cfg_file = NULL; 2195 char *mounted_cfgf_path;2196 2183 char *tmp = NULL; 2197 2184 char *tmp1 = NULL; 2198 2185 char *mountpt = NULL; 2199 char *ramdisk_fname;2200 2186 char *mountlist_file = NULL; 2201 2187 bool extract_mountlist_stub = FALSE; … … 2205 2191 2206 2192 assert(bkpinfo != NULL); 2207 malloc_string(mounted_cfgf_path);2208 malloc_string(ramdisk_fname);2209 malloc_string(device);2210 2193 log_msg(2, "gcffa --- starting"); 2211 2194 log_to_screen("I'm thinking..."); 2212 2195 mr_asprintf(mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir); 2213 device[0] = '\0';2214 2196 chdir(bkpinfo->tmpdir); 2215 2197 mr_asprintf(cfg_file, "%s", MONDO_CFG_FILE_STUB); … … 2394 2376 } 2395 2377 g_backup_media_type = bkpinfo->backup_media_type; 2396 paranoid_free(device);2397 paranoid_free(mounted_cfgf_path);2398 paranoid_free(ramdisk_fname);2399 2378 return (retval); 2400 2379 } -
branches/2.2.10/mondo/src/mondorestore/mondorestore.c
r2395 r2405 1028 1028 char *tmp = NULL; 1029 1029 char *bzip2_command = NULL; 1030 char *ntfsprog_command;1031 1030 char *suffix = NULL; 1032 1031 char *sz_devfile = NULL; … … 1050 1049 ubuf = &the_utime_buf; 1051 1050 assert(bkpinfo != NULL); 1052 1053 malloc_string(ntfsprog_command);1054 1051 1055 1052 pathname_of_last_file_restored[0] = '\0'; … … 1268 1265 mr_free(outfile_fname); 1269 1266 paranoid_free(bigblk); 1270 paranoid_free(ntfsprog_command);1271 1267 1272 1268 return (retval); … … 1307 1303 char *command = NULL; 1308 1304 char *outfile_fname = NULL; 1309 char *ntfsprog_command;1310 1305 char *sz_devfile = NULL; 1311 1306 char *ntfsprog_fifo = NULL; … … 1328 1323 1329 1324 malloc_string(tmp); 1330 malloc_string(ntfsprog_command);1331 1325 old_loglevel = g_loglevel; 1332 1326 assert(bkpinfo != NULL); … … 1516 1510 1517 1511 paranoid_free(tmp); 1518 paranoid_free(ntfsprog_command);1519 1512 g_loglevel = old_loglevel; 1520 1513 return (retval); … … 1929 1922 * @return 0 for success, nonzero for failure. 1930 1923 */ 1931 int 1932 restore_all_biggiefiles_from_CD(struct s_node *filelist) 1933 { 1924 int restore_all_biggiefiles_from_CD(struct s_node *filelist) { 1925 1934 1926 int retval = 0; 1935 1927 int res = 0;
Note:
See TracChangeset
for help on using the changeset viewer.