Changeset 2989 in MondoRescue
- Timestamp:
- Apr 4, 2012, 2:27:02 PM (12 years ago)
- Location:
- branches/3.0/mondo/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.0/mondo/src/common/libmondo-raid.c
r2982 r2989 598 598 { 599 599 FILE *fin; 600 char *tmp;601 600 char *label; 602 601 char *value; … … 604 603 int v; 605 604 606 malloc_string(tmp);607 malloc_string(label);608 malloc_string(value);609 605 assert(raidlist != NULL); 610 606 assert_string_is_neither_NULL_nor_zerolength(fname); … … 613 609 log_it("Raidtab is very small or non-existent. Ignoring it."); 614 610 raidlist->entries = 0; 615 paranoid_free(tmp);616 paranoid_free(label);617 paranoid_free(value);618 611 return (0); 619 612 } 620 613 if (!(fin = fopen(fname, "r"))) { 621 614 log_it("Cannot open raidtab"); 622 paranoid_free(tmp);623 paranoid_free(label);624 paranoid_free(value);625 615 return (1); 626 616 } 617 malloc_string(label); 618 malloc_string(value); 627 619 items = 0; 628 620 log_it("Loading raidtab..."); … … 636 628 strcpy(raidlist->el[items].additional_vars.el[v].label, label); 637 629 strcpy(raidlist->el[items].additional_vars.el[v].value, value); 630 log_msg(2,"Found raidtab entry Label: %s Value: %s",raidlist->el[items].additional_vars.el[v].label,raidlist->el[items].additional_vars.el[v].value); 638 631 v++; 639 632 get_next_raidtab_line(fin, label, value); 640 log_it(tmp);641 633 } 642 634 raidlist->el[items].additional_vars.entries = v; … … 658 650 log_msg(1, "Raidtab loaded successfully."); 659 651 log_msg(1, "%d RAID devices in raidtab", items); 660 paranoid_free(tmp);661 652 paranoid_free(label); 662 653 paranoid_free(value); … … 710 701 raidrec->raid_level = atoi(value); 711 702 } 703 log_msg(4,"Found raid level %d",raidrec->raid_level); 712 704 } else if (!strcmp(label, "nr-raid-disks")) { /* ignore it */ 713 705 } else if (!strcmp(label, "nr-spare-disks")) { /* ignore it */ … … 730 722 log_msg(1, "Unknown RAID parity algorithm '%s'\n.", value); 731 723 } 724 log_msg(4,"Found raid parity %d",raidrec->parity); 732 725 } else if (!strcmp(label, "device")) { 733 726 get_next_raidtab_line(fin, labelB, valueB); … … 755 748 strcpy(raidrec->additional_vars.el[v].label, label); 756 749 strcpy(raidrec->additional_vars.el[v].value, value); 757 raidrec->additional_vars.entries = ++v; 750 log_msg(4,"Found additional raid pair #%d: %s / %s",v,raidrec->additional_vars.el[v].label,raidrec->additional_vars.el[v].value); 751 v++; 752 raidrec->additional_vars.entries = v; 758 753 } 759 754 paranoid_free(labelB); … … 1042 1037 strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].label, "UUID"); 1043 1038 mr_asprintf(&cmd,"mdadm --detail %s | grep UUID | cut -d: -f2- | sed 's/^ *//'", raidlist->el[raidlist->entries].raid_device); 1039 mr_asprintf(&strtmp, "%s", call_program_and_get_last_line_of_output(cmd)); 1040 strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].value, strtmp); 1041 mr_free(strtmp); 1042 v++; 1043 // store the Version value in the additional_vars structure 1044 strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].label, "Version"); 1045 mr_asprintf(&cmd,"mdadm --detail %s | grep Version | cut -d: -f2- | sed 's/^ *//'", raidlist->el[raidlist->entries].raid_device); 1044 1046 mr_asprintf(&strtmp, "%s", call_program_and_get_last_line_of_output(cmd)); 1045 1047 strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].value, strtmp); -
branches/3.0/mondo/src/mondorestore/mondo-prep.c
r2988 r2989 565 565 char *tmp = NULL; 566 566 char *tmp1 = NULL; 567 char *oldmd = NULL; 568 char *name; 569 char *ver; 570 571 malloc_string(name); 572 malloc_string(ver); 573 567 574 568 // leave straight away if raidlist is initial or has no entries 575 569 if (!raidlist || raidlist->entries == 0) { … … 620 614 // - faulty devices ignored 621 615 // - persistent superblock always used as this is recommended 622 // As per bug #473, the parameter "-e 0.90" is used only when: 623 // 1) It detects that system boots from Raid-1 624 // 2) grub bootloader < v1 is used. 625 // Otherwise it won't boot which is bad. 626 if (read_cfg_var(g_mondo_cfg_file, "bootloader.name", name) != 0) { 627 log_msg(2, "Unable to find bootloader.name param in %s conf file\n", g_mondo_cfg_file); 628 strcpy(name,"NONE"); 629 } 630 if (read_cfg_var(g_mondo_cfg_file, "bootloader.ver", ver) != 0) { 631 log_msg(2, "No bootloader.ver param in %s conf file\n", g_mondo_cfg_file); 632 strcpy(ver,"NONE"); 633 } 634 if (strcmp(name,"GRUB") == 0) { 635 if ((strstr(ver, "GRUB 0.9") != NULL) && (strcmp(raidlist->el[i].raid_device,device) == 0)) { 636 mr_asprintf(&oldmd, "-e 0.90"); 637 log_it("Forcing old metadata (%s) for md on %s for old GRUB", oldmd, device); 638 } else { 639 mr_asprintf(&oldmd, ""); 640 } 641 } else if ((strcmp(name,"LILO") == 0) && (strcmp(raidlist->el[i].raid_device,device) == 0)) { 642 mr_asprintf(&oldmd, "-e 0.90"); 643 log_it("Forcing old metadata (%s) for md on %s for LILO", oldmd, device); 644 } else { 645 mr_asprintf(&oldmd, ""); 646 } 647 mr_free(name); 648 mr_free(ver); 649 log_msg(4, "RAID oldmd: %s", oldmd); 650 651 mr_asprintf(&program, "mdadm --create --force --run --auto=yes %s --level=%s --raid-devices=%d %s", raidlist->el[i].raid_device, level, raidlist->el[i].data_disks.entries, oldmd); 652 mr_free(oldmd); 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); 653 618 mr_free(level); 654 619 log_msg(4, "cmd built: %s", program); 655 // Restoring the UUID stored at backup time of present 656 for (v = 0; v <= raidlist->el[i].additional_vars.entries ; v++ ) { 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); 657 623 if ((raidlist->el[i].additional_vars.el[v].label != NULL) && (strcmp(raidlist->el[i].additional_vars.el[v].label,"UUID") == 0)) { 658 624 // We have a UUID to handle … … 663 629 break; 664 630 } else { 665 log_it("Unable to manage previous NULL UUID"); 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"); 666 644 } 667 645 }
Note:
See TracChangeset
for help on using the changeset viewer.