Changeset 2990 in MondoRescue
- Timestamp:
- Apr 5, 2012, 12:55:31 AM (12 years ago)
- Location:
- branches/3.0/mondo
- Files:
-
- 3 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.0/mondo/src/mondorestore/mondo-prep.c
r2989 r2990 178 178 179 179 int do_my_funky_lvm_stuff(bool just_erase_existing_volumes, 180 180 bool vacuum_pack) 181 181 { 182 /** 182 /** buffers **********************************************/ 183 183 char *tmp; 184 184 char *tmp1 = NULL; … … 192 192 char *vgchange_sz; 193 193 char *vgremove_sz; 194 // 194 // char *do_this_last; 195 195 196 196 /** char **************************************************/ … … 232 232 malloc_string(vgchange_sz); 233 233 malloc_string(vgremove_sz); 234 // 234 // malloc_string(do_this_last); // postpone lvcreate call if necessary 235 235 command = malloc(512); 236 236 237 // 237 // do_this_last[0] = '\0'; 238 238 log_it("STARTING"); 239 239 log_msg(1, "OK, opened i-want-my-lvm. Shutting down LVM volumes..."); … … 303 303 *q = '\0'; 304 304 log_msg(1, "Deleting old entries at /dev/%s", tmp); 305 // 306 // 305 // sprintf(command, "%s -f %s", vgremove_sz, tmp); 306 // run_program_and_log_output(command, 1); 307 307 sprintf(command, "rm -Rf /dev/%s", tmp); 308 308 run_program_and_log_output(command, 1); … … 398 398 paranoid_fclose(fin); 399 399 log_msg(1, "Closed i-want-my-lvm. Finished doing funky stuff."); 400 400 end_of_i_want_my_lvm: 401 401 paranoid_free(tmp); 402 402 paranoid_free(incoming); … … 409 409 paranoid_free(vgchange_sz); 410 410 paranoid_free(vgremove_sz); 411 // 411 // paranoid_free(do_this_last); 412 412 system("sync"); 413 413 system("sync"); … … 504 504 if (j >= new_mountlist->entries) { 505 505 strcpy(new_mountlist-> 506 506 el[new_mountlist->entries].device, p); 507 507 strcpy(new_mountlist-> 508 509 508 el[new_mountlist->entries].mountpoint, 509 "raid"); 510 510 strcpy(new_mountlist-> 511 512 511 el[new_mountlist->entries].format, 512 "raid"); 513 513 new_mountlist->el[new_mountlist->entries]. 514 514 size = old_mountlist->el[lino].size; … … 526 526 } else { 527 527 strcpy(new_mountlist->el[new_mountlist->entries].device, 528 528 old_mountlist->el[lino].device); 529 529 strcpy(new_mountlist->el[new_mountlist->entries].mountpoint, 530 530 old_mountlist->el[lino].mountpoint); 531 531 strcpy(new_mountlist->el[new_mountlist->entries].format, 532 532 old_mountlist->el[lino].format); 533 533 new_mountlist->el[new_mountlist->entries].size = 534 534 old_mountlist->el[lino].size; … … 551 551 * @return 0 for success, nonzero for failure. 552 552 */ 553 int create_raid_device_via_mdadm(struct raidlist_itself *raidlist, char *device) 554 { 555 /** int **************************************************************/ 556 int i = 0; 557 int j = 0; 558 int v = 0; 559 int res = 0; 560 561 /** buffers ***********************************************************/ 562 char *devices = NULL; 563 char *level = NULL; 564 char *program = NULL; 565 char *tmp = NULL; 566 char *tmp1 = NULL; 567 568 // leave straight away if raidlist is initial or has no entries 569 if (!raidlist || raidlist->entries == 0) { 570 log_msg(1, "No RAID arrays found."); 571 return 1; 572 } else { 573 log_msg(1, "%d RAID arrays found.", raidlist->entries); 574 } 575 // find raidlist entry for requested device 576 for (i = 0; i < raidlist->entries; i++) { 577 if (!strcmp(raidlist->el[i].raid_device, device)) break; 578 } 579 // check whether RAID device was found in raidlist 580 if (i == raidlist->entries) { 581 log_msg(1, "RAID device %s not found in list.", device); 582 return 1; 583 } else { 584 log_msg(1, "RAID device %s found in list (%d).", device, i); 585 } 586 587 // create device list from normal disks followed by spare ones 588 if (raidlist->el[i].data_disks.el[0].device != NULL) { 553 int create_raid_device_via_mdadm(struct raidlist_itself *raidlist, char *device, bool test) { 554 /** int **************************************************************/ 555 int i = 0; 556 int j = 0; 557 int v = 0; 558 int res = 0; 559 560 /** buffers ***********************************************************/ 561 char *devices = NULL; 562 char *level = NULL; 563 char *program = NULL; 564 char *tmp = NULL; 565 char *tmp1 = NULL; 566 567 // leave straight away if raidlist is initial or has no entries 568 if (!raidlist || raidlist->entries == 0) { 569 log_msg(1, "No RAID arrays found."); 570 return 1; 571 } else { 572 log_msg(1, "%d RAID arrays found.", raidlist->entries); 573 } 574 // find raidlist entry for requested device 575 for (i = 0; i < raidlist->entries; i++) { 576 if (!strcmp(raidlist->el[i].raid_device, device)) break; 577 } 578 // check whether RAID device was found in raidlist 579 if (i == raidlist->entries) { 580 log_msg(1, "RAID device %s not found in list.", device); 581 return 1; 582 } else { 583 log_msg(1, "RAID device %s found in list (%d).", device, i); 584 } 585 586 // create device list from normal disks followed by spare ones 587 if (raidlist->el[i].data_disks.el[0].device != NULL) { 589 588 mr_asprintf(&devices, "%s", raidlist->el[i].data_disks.el[0].device); 590 log_msg(4, "Adding device %s to list", raidlist->el[i].data_disks.el[0].device); 591 } else { 592 log_msg(1, "Strange, there are entries but no device"); 593 } 594 for (j = 1; j < raidlist->el[i].data_disks.entries; j++) { 595 mr_strcat(devices, " %s", raidlist->el[i].data_disks.el[j].device); 596 log_msg(4, "Adding device %s to list", raidlist->el[i].data_disks.el[j].device); 597 } 598 for (j = 0; j < raidlist->el[i].spare_disks.entries; j++) { 599 mr_strcat(devices, " %s", raidlist->el[i].spare_disks.el[j].device); 600 log_msg(4, "Adding spare device %s to list", raidlist->el[i].spare_disks.el[j].device); 601 } 602 log_msg(4, "RAID devices: %s", devices); 603 // translate RAID level 604 if (raidlist->el[i].raid_level == -2) { 605 mr_asprintf(&level, "multipath"); 606 } else if (raidlist->el[i].raid_level == -1) { 607 mr_asprintf(&level, "linear"); 608 } else { 609 mr_asprintf(&level, "raid%d", raidlist->el[i].raid_level); 610 } 611 // create RAID device: 612 // - RAID device, number of devices and devices mandatory 613 // - parity algorithm, chunk size and spare devices optional 614 // - faulty devices ignored 615 // - persistent superblock always used as this is recommended 616 617 mr_asprintf(&program, "mdadm --create --force --run --auto=yes %s --level=%s --raid-devices=%d", raidlist->el[i].raid_device, level, raidlist->el[i].data_disks.entries); 618 mr_free(level); 619 log_msg(4, "cmd built: %s", program); 620 // Restoring the UUID and Version stored at backup time of present 621 for (v = 0; v < raidlist->el[i].additional_vars.entries ; v++ ) { 622 log_msg(4,"Working on additional param #%d (Label: %s)",v,raidlist->el[i].additional_vars.el[v].label); 623 if ((raidlist->el[i].additional_vars.el[v].label != NULL) && (strcmp(raidlist->el[i].additional_vars.el[v].label,"UUID") == 0)) { 624 // We have a UUID to handle 625 if (raidlist->el[i].additional_vars.el[v].value != NULL) { 626 // force its restoration in order to avoid modifying all conf files using it 627 log_it("Managing previous UUID %s", raidlist->el[i].additional_vars.el[v].value); 628 mr_strcat(program, " --uuid %s",raidlist->el[i].additional_vars.el[v].value); 629 break; 630 } else { 631 log_msg(1,"Unable to manage previous NULL UUID"); 632 } 633 } 634 if ((raidlist->el[i].additional_vars.el[v].label != NULL) && (strcmp(raidlist->el[i].additional_vars.el[v].label,"Version") == 0)) { 635 // We have a Version to handle 636 if (raidlist->el[i].additional_vars.el[v].value != NULL) { 637 // force its restoration in order to support all complex boot loader + md format cases 638 // Also see bug #473 639 log_it("Managing previous Version %s", raidlist->el[i].additional_vars.el[v].value); 640 mr_strcat(program, " -e %s",raidlist->el[i].additional_vars.el[v].value); 641 break; 642 } else { 643 log_msg(1,"Unable to manage previous NULL Version"); 644 } 645 } 646 } 647 log_msg(4, "cmd built: %s", program); 648 if (raidlist->el[i].parity != -1) { 649 switch(raidlist->el[i].parity) { 650 case 0: 651 mr_strcat(program, " --parity=%s", "la"); 652 break; 653 case 1: 654 mr_strcat(program, " --parity=%s", "ra"); 655 break; 656 case 2: 657 mr_strcat(program, " --parity=%s", "ls"); 658 break; 659 case 3: 660 mr_strcat(program, " --parity=%s", "rs"); 661 break; 662 default: 663 fatal_error("Unknown RAID parity algorithm."); 664 break; 665 } 666 } 667 log_msg(4, "cmd built: %s", program); 668 if (raidlist->el[i].chunk_size != -1) { 669 mr_strcat(program, " --chunk=%d", raidlist->el[i].chunk_size); 670 } 671 if (raidlist->el[i].spare_disks.entries > 0) { 672 mr_strcat(program, " --spare-devices=%d", raidlist->el[i].spare_disks.entries); 673 } 674 log_msg(4, "cmd built: %s", program); 675 mr_strcat(program, " %s", devices); 676 log_msg(2, "RAID device re-created with the following command:\n%s\n", program); 677 res = run_program_and_log_output(program, 1); 678 // free memory 679 mr_free(devices); 680 mr_free(program); 681 // return to calling instance 682 return res; 589 log_msg(4, "Adding device %s to list", raidlist->el[i].data_disks.el[0].device); 590 } else { 591 log_msg(1, "Strange, there are entries but no device"); 592 } 593 for (j = 1; j < raidlist->el[i].data_disks.entries; j++) { 594 mr_strcat(devices, " %s", raidlist->el[i].data_disks.el[j].device); 595 log_msg(4, "Adding device %s to list", raidlist->el[i].data_disks.el[j].device); 596 } 597 for (j = 0; j < raidlist->el[i].spare_disks.entries; j++) { 598 mr_strcat(devices, " %s", raidlist->el[i].spare_disks.el[j].device); 599 log_msg(4, "Adding spare device %s to list", raidlist->el[i].spare_disks.el[j].device); 600 } 601 log_msg(4, "RAID devices: %s", devices); 602 // translate RAID level 603 if (raidlist->el[i].raid_level == -2) { 604 mr_asprintf(&level, "multipath"); 605 } else if (raidlist->el[i].raid_level == -1) { 606 mr_asprintf(&level, "linear"); 607 } else { 608 mr_asprintf(&level, "raid%d", raidlist->el[i].raid_level); 609 } 610 // create RAID device: 611 // - RAID device, number of devices and devices mandatory 612 // - parity algorithm, chunk size and spare devices optional 613 // - faulty devices ignored 614 // - persistent superblock always used as this is recommended 615 616 mr_asprintf(&program, "mdadm --create --force --run --auto=yes %s --level=%s --raid-devices=%d", raidlist->el[i].raid_device, level, raidlist->el[i].data_disks.entries); 617 mr_free(level); 618 log_msg(4, "cmd built: %s", program); 619 // Restoring the UUID and Version stored at backup time of present 620 for (v = 0; v < raidlist->el[i].additional_vars.entries ; v++ ) { 621 log_msg(4,"Working on additional param #%d (Label: %s)",v,raidlist->el[i].additional_vars.el[v].label); 622 if ((raidlist->el[i].additional_vars.el[v].label != NULL) && (strcmp(raidlist->el[i].additional_vars.el[v].label,"UUID") == 0)) { 623 // We have a UUID to handle 624 if (raidlist->el[i].additional_vars.el[v].value != NULL) { 625 // force its restoration in order to avoid modifying all conf files using it 626 log_it("Managing previous UUID %s", raidlist->el[i].additional_vars.el[v].value); 627 mr_strcat(program, " --uuid %s",raidlist->el[i].additional_vars.el[v].value); 628 break; 629 } else { 630 log_msg(1,"Unable to manage previous NULL UUID"); 631 } 632 } 633 if ((raidlist->el[i].additional_vars.el[v].label != NULL) && (strcmp(raidlist->el[i].additional_vars.el[v].label,"Version") == 0)) { 634 // We have a Version to handle 635 if (raidlist->el[i].additional_vars.el[v].value != NULL) { 636 // force its restoration in order to support all complex boot loader + md format cases 637 // Also see bug #473 638 log_it("Managing previous Version %s", raidlist->el[i].additional_vars.el[v].value); 639 mr_strcat(program, " -e %s",raidlist->el[i].additional_vars.el[v].value); 640 break; 641 } else { 642 log_msg(1,"Unable to manage previous NULL Version"); 643 } 644 } 645 } 646 log_msg(4, "cmd built: %s", program); 647 if (raidlist->el[i].parity != -1) { 648 switch(raidlist->el[i].parity) { 649 case 0: 650 mr_strcat(program, " --parity=%s", "la"); 651 break; 652 case 1: 653 mr_strcat(program, " --parity=%s", "ra"); 654 break; 655 case 2: 656 mr_strcat(program, " --parity=%s", "ls"); 657 break; 658 case 3: 659 mr_strcat(program, " --parity=%s", "rs"); 660 break; 661 default: 662 fatal_error("Unknown RAID parity algorithm."); 663 break; 664 } 665 } 666 log_msg(4, "cmd built: %s", program); 667 if (raidlist->el[i].chunk_size != -1) { 668 mr_strcat(program, " --chunk=%d", raidlist->el[i].chunk_size); 669 } 670 if (raidlist->el[i].spare_disks.entries > 0) { 671 mr_strcat(program, " --spare-devices=%d", raidlist->el[i].spare_disks.entries); 672 } 673 log_msg(4, "cmd built: %s", program); 674 mr_strcat(program, " %s", devices); 675 log_msg(2, "RAID device re-created with the following command:\n%s\n", program); 676 if (test == TRUE) { 677 res = run_program_and_log_output(program, 1); 678 } else { 679 // test mode, always returns TRUE without executing the mdadm command 680 res = TRUE; 681 } 682 // free memory 683 mr_free(devices); 684 mr_free(program); 685 // return to calling instance 686 return res; 683 687 } 684 688 … … 736 740 } 737 741 if (is_this_device_mounted(device)) { 738 mr_asprintf(&tmp, "%s is mounted - cannot format it 742 mr_asprintf(&tmp, "%s is mounted - cannot format it ", device); 739 743 log_to_screen(tmp); 740 744 paranoid_free(tmp); … … 772 776 773 777 /* format raid partition */ 774 // 778 // sprintf (program, "mkraid --really-force %s", device); --- disabled -- BB, 02/12/2003 775 779 sprintf(program, 776 780 "for plex in `vinum lv -r %s | grep '^P' | tr '\t' ' ' | tr -s ' ' | cut -d' ' -f2`; do echo $plex; done > /tmp/plexes", … … 829 833 log_msg(1, "Making %s", device); 830 834 // use mkraid if it exists, otherwise use mdadm 831 832 res = create_raid_device_via_mdadm(raidlist, device);833 835 if (run_program_and_log_output("which mkraid", FALSE)) { 836 res = create_raid_device_via_mdadm(raidlist, device, TRUE); 837 log_msg(1, "Creating RAID device %s via mdadm returned %d", device, res); 834 838 } else { 835 839 sprintf(program, "mkraid --really-force %s", device); … … 845 849 system("sync"); 846 850 sleep(2); 847 // 848 // 849 // 850 // 851 // 851 // log_to_screen("Starting %s", device); 852 // sprintf(program, "raidstart %s", device); 853 // res = run_program_and_log_output(program, 1); 854 // log_msg(1, "%s returned %d", program, res); 855 // system("sync"); sleep(1); 852 856 #endif 853 857 system("sync"); … … 931 935 */ 932 936 int format_everything(struct mountlist_itself *mountlist, bool interactively, 933 937 struct raidlist_itself *raidlist) 934 938 { 935 939 /** int **************************************************************/ … … 937 941 int lino; 938 942 int res; 939 // 940 // 943 // int i; 944 // struct list_of_disks *drivelist; 941 945 942 946 /** long *************************************************************/ … … 958 962 (interactively) ? "true" : "false"); 959 963 log_it(tmp); 960 mvaddstr_and_log_it(g_currentY, 0, "Formatting partitions 964 mvaddstr_and_log_it(g_currentY, 0, "Formatting partitions "); 961 965 open_progress_form("Formatting partitions", 962 963 964 966 "I am now formatting your hard disk partitions.", 967 "This may take up to five minutes.", "", 968 mountlist->entries + 1); 965 969 966 970 progress_step = … … 1000 1004 sleep(2); 1001 1005 // This last step is probably necessary 1002 // 1003 // 1004 // 1005 // 1006 // log_to_screen("Re-starting software RAIDs..."); 1007 // start_all_raid_devices(mountlist); 1008 // system("sync"); system("sync"); system("sync"); 1009 // sleep(5); 1006 1010 // do LVMs now 1007 1011 log_msg(1, "Creating LVMs"); … … 1014 1018 /* 1015 1019 for(i=0; i<3; i++) 1016 1017 1018 1019 1020 1021 1022 1020 { 1021 res = do_my_funky_lvm_stuff(FALSE, FALSE); 1022 if (!res) { break; } 1023 sleep(3); 1024 res = do_my_funky_lvm_stuff(TRUE, FALSE); 1025 sleep(3); 1026 } 1023 1027 if (res) { 1024 1028 log_msg(1, "Vacuum-packing..."); … … 1065 1069 continue; 1066 1070 } else if (!does_file_exist(me->device) 1067 1068 1071 && strncmp(me->device, "/dev/hd", 7) 1072 && strncmp(me->device, "/dev/sd", 7)) { 1069 1073 sprintf(tmp, 1070 1074 "Not formatting %s yet - doesn't exist - probably an LVM", … … 1154 1158 */ 1155 1159 int make_dummy_partitions(FILE * pout_to_fdisk, char *drivename, 1156 1160 int devno_we_must_allow_for) 1157 1161 { 1158 1162 /** int **************************************************************/ … … 1274 1278 fprintf(f, "\n\n%u partitions:\n", lp->d_npartitions); 1275 1279 fprintf(f, 1276 "# 1280 "# size offset fstype [fsize bsize bps/cpg]\n"); 1277 1281 pp = lp->d_partitions; 1278 1282 for (i = 0; i < lp->d_npartitions; i++, pp++) { 1279 1283 if (pp->p_size) { 1280 fprintf(f, " 1284 fprintf(f, " %c: %8lu %8lu ", 'a' + i, (u_long) pp->p_size, 1281 1285 (u_long) pp->p_offset); 1282 1286 if (pp->p_fstype < FSMAXTYPES) … … 1287 1291 1288 1292 case FS_UNUSED: /* XXX */ 1289 fprintf(f, " 1293 fprintf(f, " %5lu %5lu %5.5s ", (u_long) pp->p_fsize, 1290 1294 (u_long) (pp->p_fsize * pp->p_frag), ""); 1291 1295 break; 1292 1296 1293 1297 case FS_BSDFFS: 1294 fprintf(f, " 1298 fprintf(f, " %5lu %5lu %5u ", (u_long) pp->p_fsize, 1295 1299 (u_long) (pp->p_fsize * pp->p_frag), pp->p_cpg); 1296 1300 break; 1297 1301 1298 1302 case FS_BSDLFS: 1299 fprintf(f, " 1303 fprintf(f, " %5lu %5lu %5d", (u_long) pp->p_fsize, 1300 1304 (u_long) (pp->p_fsize * pp->p_frag), pp->p_cpg); 1301 1305 break; … … 1313 1317 fprintf(f, "- %lu", 1314 1318 (u_long) ((pp->p_offset + pp->p_size + 1315 1316 1319 lp->d_secpercyl - 1) / lp->d_secpercyl - 1320 1)); 1317 1321 if (pp->p_size % lp->d_secpercyl) 1318 1322 putc('*', f); … … 1352 1356 /* 1353 1357 * Nobody in these enligthened days uses the CHS geometry for 1354 * anything, but nontheless try to get it right. 1358 * anything, but nontheless try to get it right. If we fail 1355 1359 * to get any good ideas from the device, construct something 1356 1360 * which is IBM-PC friendly. … … 1436 1440 lp->d_partitions[c - 'a'].p_cpg = 64; 1437 1441 } else if (!strcasecmp(mountlist->el[idx].format, "raid") 1438 1442 || !strcasecmp(mountlist->el[idx].format, "vinum")) { 1439 1443 lp->d_partitions[c - 'a'].p_fstype = FS_VINUM; 1440 1444 } else if (!strcmp(mountlist->el[idx].format, "swap")) { … … 1607 1611 1608 1612 /* OK, we've found partition /dev/hdxN in mountlist; let's prep it */ 1609 /* For FreeBSD, that is 1613 /* For FreeBSD, that is /dev/adXsY */ 1610 1614 1611 1615 log_it("Found partition %s in mountlist", device_str); … … 1615 1619 #if __FreeBSD__ 1616 1620 // FreeBSD doesn't let you write to blk devices in <512byte chunks. 1617 // 1618 // 1621 // sprintf(tmp, "dd if=/dev/zero of=%s count=1 bs=512", drivename); 1622 // if (run_program_and_log_output(tmp, TRUE)) { 1619 1623 file = open(drivename, O_WRONLY); 1620 1624 if (file != -1) { … … 1639 1643 fflush(pout_to_fdisk); 1640 1644 } 1641 // 1642 // 1645 // sprintf(tmp, "dd if=/dev/zero of=%s count=1 bs=512", drivename); 1646 // run_program_and_log_output(tmp, 1); 1643 1647 #endif 1644 1648 if (current_devno > 1) { 1645 1649 previous_devno = 1646 1650 make_dummy_partitions(pout_to_fdisk, drivename, 1647 1651 current_devno); 1648 1652 } 1649 1653 } … … 1726 1730 * Create partition number @p partno on @p drive with @p fdisk. 1727 1731 * @param drive The drive to create the partition on. 1728 // 1732 // * @param partno The partition number of the new partition (1-4 are primary, >=5 is logical). 1729 1733 * @param prev_partno The partition number of the most recently prepped partition. 1730 1734 * @param format The filesystem type of this partition (used to set the type). … … 1763 1767 1764 1768 log_it("partition_device('%s', %d, %d, '%s', %lld) --- starting", 1765 1769 drive, partno, prev_partno, format, partsize); 1766 1770 1767 1771 if (!strncmp(drive, RAID_DEVICE_STUB, strlen(RAID_DEVICE_STUB))) { … … 1802 1806 1803 1807 1804 /* 1805 /* 1808 /* sprintf(tmp,"Partitioning %s ",partition_name); */ 1809 /* mvaddstr_and_log_it(g_currentY+1,30,tmp); */ 1806 1810 p = (char *) strrchr(partition_name, '/'); 1807 1811 sprintf(logfile, "/tmp/fdisk.log.%s", ++p); … … 1876 1880 retval = 1877 1881 set_partition_type(pout_to_fdisk, drive, partno, format, 1878 1882 partsize); 1879 1883 if (retval) { 1880 1884 log_msg(1, "Failed. Trying again..."); 1881 1885 retval = 1882 1886 set_partition_type(pout_to_fdisk, drive, partno, 1883 1887 format, partsize); 1884 1888 } 1885 1889 } … … 1916 1920 retval = 1917 1921 set_partition_type(pout_to_fdisk, drive, partno, format, 1918 1922 partsize); 1919 1923 if (retval) { 1920 1924 sprintf(tmp, "Partitioned %s but failed to set its type", … … 1970 1974 /** buffer *********************************************************/ 1971 1975 struct list_of_disks *drivelist; 1972 /* 1976 /* struct mountlist_itself new_mtlist, *mountlist; */ 1973 1977 1974 1978 /** end ************************************************************/ … … 1978 1982 1979 1983 log_it("partition_everything() --- starting"); 1980 mvaddstr_and_log_it(g_currentY, 0, "Partitioning hard drives 1981 /* 1984 mvaddstr_and_log_it(g_currentY, 0, "Partitioning hard drives "); 1985 /* mountlist=orig_mtlist; */ 1982 1986 if (mountlist_contains_raid_devices(mountlist)) { 1983 /* 1984 /* 1987 /* mountlist=&new_mtlist; */ 1988 /* extrapolate_mountlist_to_include_raid_partitions(mountlist,orig_mtlist); */ 1985 1989 log_msg(0, 1986 1990 "Mountlist, including the partitions incorporated in RAID devices:-"); … … 2004 2008 /* 2005 2009 if (does_file_exist("/tmp/i-want-my-lvm")) 2006 2007 2008 2010 { 2011 wipe_MBRs_and_reboot_if_necessary(mountlist); // i.e. if it wasn't done recently 2012 } 2009 2013 */ 2010 2014 2011 2015 open_progress_form("Partitioning devices", 2012 2013 2014 2016 "I am now going to partition all your drives.", 2017 "This should not take more than five minutes.", "", 2018 mountlist->entries); 2015 2019 2016 2020 make_list_of_drives_in_mountlist(mountlist, drivelist); … … 2052 2056 */ 2053 2057 int set_partition_type(FILE * pout_to_fdisk, const char *drive, int partno, 2054 2058 const char *format, long long partsize) 2055 2059 { 2056 2060 /** buffers *********************************************************/ … … 2092 2096 } 2093 2097 } else if (strcmp(format, "ext2") == 0 2094 2095 2096 2097 2098 2099 2098 || strcmp(format, "reiserfs") == 0 2099 || strcmp(format, "ext3") == 0 2100 || strcmp(format, "ext4") == 0 2101 || strcmp(format, "xfs") == 0 2102 || strcmp(format, "jfs") == 0 2103 || strcmp(format, "btrfs") == 0) { 2100 2104 strcpy(partcode, "83"); 2101 2105 } else if (strcmp(format, "minix") == 0) { … … 2110 2114 strcpy(partcode, "7"); 2111 2115 } else if ((strcmp(format, "ufs") == 0) 2112 2116 || (strcmp(format, "ffs") == 0)) { /* raid autodetect */ 2113 2117 strcpy(partcode, "a5"); 2114 2118 } else if (strcmp(format, "lvm") == 0) { … … 2260 2264 sprintf(program, "vinum stop -f %s", raid_device); 2261 2265 #else 2262 2263 2266 // use raidstop if it exists, otherwise use mdadm 2267 if (run_program_and_log_output("which raidstop", FALSE)) { 2264 2268 sprintf(program, "mdadm -S %s", raid_device); 2265 2269 } else { … … 2427 2431 strcpy(program, "mkfs -t ext4 -F -q"); 2428 2432 } else if (strcmp(format, "btrfs") == 0) { 2429 2433 strcpy(program, "mkfs.btrfs"); 2430 2434 } else if (strcmp(format, "minix") == 0) { 2431 2435 strcpy(program, "mkfs.minix"); … … 2467 2471 * There are a few problems with this function: 2468 2472 * - It won't work if there was any unallocated space on the user's hard drive 2469 * 2473 * when it was backed up. 2470 2474 * - It won't work if the user's hard drive lies about its size (more common 2471 * 2475 * than you'd think). 2472 2476 * 2473 2477 * @param mountlist The mountlist to use for resizing @p drive_name. … … 2483 2487 /** int *************************************************************/ 2484 2488 int partno, lastpart; 2485 /** remove driveno, noof_drives stan benoit apr 2002**/2486 2489 2487 2490 /** float ***********************************************************/ -
branches/3.0/mondo/test/test-mountlist.c
r2394 r2990 3 3 * 4 4 * Test program for mountlist management at restore time 5 * C n be used on host system with valgrind easier than with mondorestore5 * Can be used on host system with valgrind easier than with mondorestore 6 6 */ 7 7 #include <stdio.h> … … 12 12 #include "../mondorestore/mondorestore.h" 13 13 #include "../mondorestore/mr-externs.h" 14 15 #define RAIDTAB_TEST "/tmp/raidtab" 16 #define MOUNTLIST_TEST "/tmp/mountlist.txt" 14 17 15 18 extern void twenty_seconds_til_yikes(void); … … 68 71 69 72 setup_newt_stuff(); 70 mr_asprintf(&g_mountlist_fname, "/tmp/mountlist.txt");73 mr_asprintf(&g_mountlist_fname, MOUNTLIST_TEST); 71 74 log_it("before mountlist"); 72 75 load_mountlist(mountlist, g_mountlist_fname); … … 74 77 resize_mountlist_proportionately_to_suit_new_drives(mountlist); 75 78 log_it("after resize_mountlist_proportionately_to_suit_new_drives"); 76 load_raidtab_into_raidlist(raidlist, RAIDTAB_ FNAME);79 load_raidtab_into_raidlist(raidlist, RAIDTAB_TEST); 77 80 log_it("after load_raidtab_into_raidlist"); 78 81 edit_mountlist(g_mountlist_fname, mountlist, raidlist); … … 83 86 mr_free(flaws_str); 84 87 88 log_it("before check raidlist content"); 89 log_it("after check raidlist content"); 90 91 log_it("before create mdadm dev"); 92 create_raid_device_via_mdadm(raidlist,"/dev/md0",FALSE); 93 log_it("after create mdadm dev"); 94 85 95 mr_free(MONDO_LOGFILE); 86 96 exit(0);
Note:
See TracChangeset
for help on using the changeset viewer.