Changeset 2324 in MondoRescue for branches/2.2.10/mondo/src/mondorestore/mondo-prep.c
- Timestamp:
- Aug 18, 2009, 3:13:54 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/mondorestore/mondo-prep.c
r2323 r2324 484 484 fgets(incoming, MAX_STR_LEN - 1, fin)); 485 485 if (!feof(fin)) { 486 mr_asprintf(tmp, "Investigating %s", old_mountlist->el[lino].device); 487 log_it(tmp); 488 mr_free(tmp); 486 log_it("Investigating %s", old_mountlist->el[lino].device); 489 487 490 488 for (fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin) … … 497 495 *p = '\0'; 498 496 for (p--; p > incoming && *(p - 1) > 32; p--); 499 mr_asprintf(tmp, "Extrapolating %s", p); 500 log_it(tmp); 501 mr_free(tmp); 497 log_it("Extrapolating %s", p); 502 498 503 499 for (j = 0; … … 518 514 new_mountlist->entries++; 519 515 } else { 520 mr_asprintf(tmp, "Not adding %s to mountlist: it's already there", p); 521 log_it(tmp); 522 mr_free(tmp); 516 log_it("Not adding %s to mountlist: it's already there", p); 523 517 } 524 518 } … … 585 579 for (j = 1; j < raidlist->el[i].data_disks.entries; j++) { 586 580 mr_asprintf(strtmp, "%s", devices); 587 paranoid_free(devices); 588 mr_asprintf(devices, "%s %s", strtmp, 589 raidlist->el[i].data_disks.el[j].device); 590 paranoid_free(strtmp); 581 mr_free(devices); 582 mr_asprintf(devices, "%s %s", strtmp, raidlist->el[i].data_disks.el[j].device); 583 mr_free(strtmp); 591 584 } 592 585 for (j = 0; j < raidlist->el[i].spare_disks.entries; j++) { 593 586 mr_asprintf(strtmp, "%s", devices); 594 paranoid_free(devices); 595 mr_asprintf(devices, "%s %s", strtmp, 596 raidlist->el[i].spare_disks.el[j].device); 597 paranoid_free(strtmp); 587 mr_free(devices); 588 mr_asprintf(devices, "%s %s", strtmp, raidlist->el[i].spare_disks.el[j].device); 589 mr_free(strtmp); 598 590 } 599 591 // translate RAID level … … 613 605 if (raidlist->el[i].parity != -1) { 614 606 mr_asprintf(strtmp, "%s", program); 615 paranoid_free(program);607 mr_free(program); 616 608 switch(raidlist->el[i].parity) { 617 609 case 0: … … 635 627 if (raidlist->el[i].chunk_size != -1) { 636 628 mr_asprintf(strtmp, "%s", program); 637 paranoid_free(program);629 mr_free(program); 638 630 mr_asprintf(program, "%s --chunk=%d", strtmp, raidlist->el[i].chunk_size); 639 paranoid_free(strtmp);631 mr_free(strtmp); 640 632 } 641 633 if (raidlist->el[i].spare_disks.entries > 0) { 642 634 mr_asprintf(strtmp, "%s", program); 643 paranoid_free(program);635 mr_free(program); 644 636 mr_asprintf(program, "%s --spare-devices=%d", strtmp, raidlist->el[i].spare_disks.entries); 645 paranoid_free(strtmp);637 mr_free(strtmp); 646 638 } 647 639 mr_asprintf(strtmp, "%s", program); 648 paranoid_free(program);640 mr_free(program); 649 641 mr_asprintf(program, "%s %s", strtmp, devices); 650 paranoid_free(strtmp);642 mr_free(strtmp); 651 643 res = run_program_and_log_output(program, 1); 652 // free memory 653 paranoid_free(devices); 654 paranoid_free(level); 655 paranoid_free(program); 656 // return to calling instance 644 mr_free(devices); 645 mr_free(level); 646 mr_free(program); 657 647 return res; 658 648 } … … 688 678 689 679 if (strstr(format, "raid")) { // do not form RAID disks; do it to /dev/md* instead 690 mr_asprintf(tmp, "Not formatting %s (it is a RAID disk)", device); 691 log_it(tmp); 692 mr_free(tmp); 680 log_it("Not formatting %s (it is a RAID disk)", device); 693 681 return (0); 694 682 } … … 700 688 #endif 701 689 if (strlen(format) <= 2) { 702 mr_asprintf(tmp, "%s has a really small format type ('%s') - this is probably a hexadecimal string, which would suggest the partition is an image --- I shouldn't format it", device, format); 703 log_it(tmp); 704 mr_free(tmp); 690 log_it("%s has a really small format type ('%s') - this is probably a hexadecimal string, which would suggest the partition is an image --- I shouldn't format it", device, format); 705 691 return (0); 706 692 } 707 693 if (is_this_device_mounted(device)) { 708 mr_asprintf(tmp, "%s is mounted - cannot format it ", device); 709 log_to_screen(tmp); 710 mr_free(tmp); 694 log_to_screen("%s is mounted - cannot format it ", device); 711 695 return (1); 712 696 } … … 736 720 char line[MAX_STR_LEN]; 737 721 738 mr_asprintf(tmp, "Initializing Vinum device %s (this may take a *long* time)", device); 739 log_to_screen(tmp); 740 mr_free(tmp); 722 log_to_screen("Initializing Vinum device %s (this may take a *long* time)", device); 741 723 742 724 /* format raid partition */ … … 782 764 } 783 765 #else 784 mr_asprintf(tmp, "Initializing RAID device %s", device);766 log_to_screen(tmp, "Initializing RAID device %s", device); 785 767 log_to_screen(tmp); 786 768 mr_free(tmp); … … 989 971 me = &mountlist->el[lino]; // the current mountlist entry 990 972 if (!strcmp(me->mountpoint, "image")) { 991 mr_asprintf(tmp, "Not formatting %s - it's an image", me->device); 992 log_it(tmp); 993 mr_free(tmp); 973 log_it("Not formatting %s - it's an image", me->device); 994 974 } else if (!strcmp(me->format, "raid")) { 995 mr_asprintf(tmp, "Not formatting %s - it's a raid-let", me->device); 996 log_it(tmp); 997 mr_free(tmp); 975 log_it("Not formatting %s - it's a raid-let", me->device); 998 976 continue; 999 977 } else if (!strcmp(me->format, "lvm")) { 1000 mr_asprintf(tmp, "Not formatting %s - it's an LVM", me->device); 1001 log_it(tmp); 1002 mr_free(tmp); 978 log_it("Not formatting %s - it's an LVM", me->device); 1003 979 continue; 1004 980 } else if (!strncmp(me->device, "/dev/md", 7)) { 1005 mr_asprintf(tmp, "Already formatted %s - it's a soft-RAID dev", me->device); 1006 log_it(tmp); 1007 mr_free(tmp); 981 log_it("Already formatted %s - it's a soft-RAID dev", me->device); 1008 982 continue; 1009 983 } else if (!does_file_exist(me->device) 1010 984 && strncmp(me->device, "/dev/hd", 7) 1011 985 && strncmp(me->device, "/dev/sd", 7)) { 1012 mr_asprintf(tmp, "Not formatting %s yet - doesn't exist - probably an LVM", me->device); 1013 log_it(tmp); 1014 mr_free(tmp); 986 log_it("Not formatting %s yet - doesn't exist - probably an LVM", me->device); 1015 987 continue; 1016 988 } else { … … 1048 1020 } 1049 1021 1050 mr_asprintf(tmp, "format_everything () - %s", (retval) ? "failed!" : "finished successfully"); 1051 log_it(tmp); 1052 mr_free(tmp); 1022 log_it("format_everything () - %s", (retval) ? "failed!" : "finished successfully"); 1053 1023 1054 1024 if (g_partition_table_locked_up > 0) { … … 1103 1073 int res; 1104 1074 1105 /** buffers **********************************************************/1106 char *tmp = NULL;1107 1108 1075 /** end **************************************************************/ 1109 1076 … … 1111 1078 1112 1079 if (devno_we_must_allow_for >= 5) { 1113 mr_asprintf(tmp, "Making dummy primary 1 on %s", drivename); 1114 log_it(tmp); 1115 mr_free(tmp); 1080 log_it("Making dummy primary 1 on %s", drivename); 1116 1081 1117 1082 g_maximum_progress++; … … 1127 1092 } 1128 1093 for (; current_devno < devno_we_must_allow_for; current_devno++) { 1129 mr_asprintf(tmp, "Creating dummy partition %d on %s", current_devno, drivename); 1130 log_it(tmp); 1131 mr_free(tmp); 1094 log_it("Creating dummy partition %d on %s", current_devno, drivename); 1132 1095 g_maximum_progress++; 1133 1096 res = … … 1468 1431 malloc_string(format); 1469 1432 1470 mr_asprintf(tmp, "Partitioning drive %s", drivename); 1471 log_it(tmp); 1472 mr_free(tmp); 1433 log_it("Partitioning drive %s", drivename); 1473 1434 1474 1435 #if __FreeBSD__ … … 1565 1526 file = open(drivename, O_WRONLY); 1566 1527 if (file != -1) { 1567 mr_asprintf(tmp, "Warning - unable to open %s for wiping it's partition table", drivename); 1568 log_to_screen(tmp); 1569 mr_free(tmp); 1528 log_to_screen("Warning - unable to open %s for wiping it's partition table", drivename); 1570 1529 } 1571 1530 1572 1531 for (i = 0; i < 512; i++) { 1573 1532 if (!write(file, "\0", 1)) { 1574 mr_asprintf(tmp, "Warning - unable to write to %s", drivename); 1575 log_to_screen(tmp); 1576 mr_free(tmp); 1533 log_to_screen("Warning - unable to write to %s", drivename); 1577 1534 } 1578 1535 } … … 1633 1590 1634 1591 if (pout_to_fdisk) { 1635 // mark relevant partition as bootable1592 // mark relevant partition as bootable 1636 1593 mr_asprintf(tmp, "a\n%s\n", call_program_and_get_last_line_of_output ("make-me-bootable /tmp/mountlist.txt dummy")); 1637 1594 fput_string_one_char_at_a_time(pout_to_fdisk, tmp); 1638 1595 mr_free(tmp); 1639 1596 1640 // close fdisk1597 // close fdisk 1641 1598 fput_string_one_char_at_a_time(pout_to_fdisk, "w\n"); 1642 1599 system("sync"); … … 1708 1665 1709 1666 if (!strncmp(drive, RAID_DEVICE_STUB, strlen(RAID_DEVICE_STUB))) { 1710 mr_asprintf(tmp, "Not partitioning %s - it is a virtual drive", drive); 1711 log_it(tmp); 1712 mr_free(tmp); 1713 1667 log_it("Not partitioning %s - it is a virtual drive", drive); 1714 1668 return (0); 1715 1669 } … … 1725 1679 1726 1680 if (is_this_device_mounted(partition_name)) { 1727 mr_asprintf(tmp, "%s is mounted, and should not be partitioned", partition_name); 1728 log_to_screen(tmp); 1729 mr_free(tmp); 1681 log_to_screen("%s is mounted, and should not be partitioned", partition_name); 1730 1682 mr_free(partition_name); 1731 1683 return (1); … … 1769 1721 } 1770 1722 mr_strcat(output, "\n"); 1771 mr_asprintf(tmp,"PARTSIZE = +%ld",(long)partsize); 1772 log_it(tmp); 1773 mr_free(tmp); 1723 log_it("PARTSIZE = +%ld",(long)partsize); 1774 1724 1775 1725 log_it("---fdisk command---"); … … 1826 1776 format, -1); 1827 1777 if (res) { 1828 mr_asprintf(tmp, "Failed to vacuum-pack %s", partition_name); 1829 log_it(tmp); 1830 mr_free(tmp); 1778 log_it("Failed to vacuum-pack %s", partition_name); 1831 1779 1832 1780 retval++; … … 1840 1788 partsize); 1841 1789 if (retval) { 1842 mr_asprintf(tmp, "Partitioned %s but failed to set its type", partition_name); 1843 log_it(tmp); 1844 mr_free(tmp); 1790 log_it("Partitioned %s but failed to set its type", partition_name); 1845 1791 } else { 1846 1792 if (partsize > 0) { 1847 mr_asprintf(tmp, "Partition %s created+configured OK", partition_name); 1848 log_to_screen(tmp); 1849 mr_free(tmp); 1793 log_to_screen("Partition %s created+configured OK", partition_name); 1850 1794 } else { 1851 1795 log_it("Returning from a successful vacuum-pack"); … … 2425 2369 return; 2426 2370 } 2427 mr_asprintf(tmp, "Expanding entries to suit drive %s (%ld MB)", drive_name, current_size_of_drive); 2428 log_to_screen(tmp); 2429 mr_free(tmp); 2371 log_to_screen("Expanding entries to suit drive %s (%ld MB)", drive_name, current_size_of_drive); 2430 2372 2431 2373 drivemntlist = malloc(sizeof(struct mountlist_reference)); … … 2445 2387 2446 2388 if (original_size_of_drive <= 0) { 2447 mr_asprintf(tmp, "Cannot resize %s's entries. Drive not found.", drive_name); 2448 log_to_screen(tmp); 2449 mr_free(tmp); 2389 log_to_screen("Cannot resize %s's entries. Drive not found.", drive_name); 2450 2390 return; 2451 2391 } 2452 2392 factor = (float) (current_size_of_drive) / (float) (original_size_of_drive); 2453 mr_asprintf(tmp, "Disk %s was %ld MB; is now %ld MB; factor = %f", drive_name, original_size_of_drive, current_size_of_drive, factor); 2454 log_to_screen(tmp); 2455 mr_free(tmp); 2393 log_to_screen("Disk %s was %ld MB; is now %ld MB; factor = %f", drive_name, original_size_of_drive, current_size_of_drive, factor); 2456 2394 2457 2395 lastpart = drivemntlist->entries - 1; … … 2478 2416 } 2479 2417 2480 mr_asprintf(tmp, "Changing %s from %lld KB to %ld KB", drivemntlist->el[partno]->device, drivemntlist->el[partno]->size, newsizL); 2481 log_to_screen(tmp); 2482 mr_free(tmp); 2418 log_to_screen("Changing %s from %lld KB to %ld KB", drivemntlist->el[partno]->device, drivemntlist->el[partno]->size, newsizL); 2483 2419 drivemntlist->el[partno]->size = newsizL; 2484 2420 } 2485 2421 final_size = get_phys_size_of_drive(drive_name); 2486 mr_asprintf(tmp, "final_size = %ld MB", final_size); 2487 log_to_screen(tmp); 2488 mr_free(tmp); 2422 log_to_screen("final_size = %ld MB", final_size); 2489 2423 } 2490 2424
Note:
See TracChangeset
for help on using the changeset viewer.