Changeset 2937 in MondoRescue for branches/3.1/mondo/src/mondorestore/mondo-prep.c
- Timestamp:
- Jan 28, 2012, 1:51:28 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.1/mondo/src/mondorestore/mondo-prep.c
r2816 r2937 10 10 #include "mondoprep.h" 11 11 #include "../common/libmondo.h" 12 #include "../common/libmondo-tools-EXT.h" 12 13 #include "mondo-rstr-tools-EXT.h" 13 14 #include <sys/ioctl.h> … … 43 44 44 45 FILE *g_fprep = NULL; 45 46 46 extern char *g_mondo_cfg_file; // where m*ndo-restore.cfg (the config file) is stored 47 47 48 48 int g_partition_table_locked_up = 0; 49 50 51 52 53 54 55 56 49 57 50 … … 323 316 res = run_program_and_log_output(command, 5); 324 317 if (res > 0 && (p = strstr(command, "lvm "))) { 318 log_msg(0, "%s --> %d failed so removing lvm just in case", command, res); 325 319 *p = *(p + 1) = *(p + 2) = ' '; 326 320 res = run_program_and_log_output(command, 5); … … 545 539 char *level = NULL; 546 540 char *program = NULL; 541 char *tmp = NULL; 542 char *oldmd = NULL; 543 char *bootdevice; 544 char *name; 545 546 malloc_string(bootdevice); 547 malloc_string(name); 547 548 548 549 // leave straight away if raidlist is initial or has no entries … … 589 590 // - faulty devices ignored 590 591 // - persistent superblock always used as this is recommended 591 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); 592 // As per bug #473, the parameter "-e 0.90" is used only when: 593 // 1) It detects that system boots from Raid-1 594 // 2) grub bootloader < v1 is used. 595 // Otherwise it won't boot which is bad. 596 read_cfg_var(g_mondo_cfg_file, "bootloader.device", bootdevice); 597 read_cfg_var(g_mondo_cfg_file, "bootloader.name", name); 598 if (strcmp(name,"GRUB") == 0) { 599 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("grub --version")); 600 if ((strstr(tmp, "GRUB 0.9") != NULL) && (strcmp(raidlist->el[i].raid_device,device) == 0)) { 601 mr_free(oldmd); 602 mr_asprintf(oldmd, "-e 0.90"); 603 log_it("Forcing old metadata 0.90 for md on %s for old GRUB", device); 604 } 605 } else if ((strcmp(name,"LILO") == 0) && (strcmp(raidlist->el[i].raid_device,device) == 0)) { 606 mr_free(oldmd); 607 mr_asprintf(oldmd, "-e 0.90"); 608 log_it("Forcing old metadata 0.90 for md on %s for LILO", device); 609 } else { 610 mr_asprintf(oldmd, ""); 611 } 612 mr_free(device); 613 mr_free(name); 614 615 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); 616 mr_free(oldmd); 592 617 if (raidlist->el[i].parity != -1) { 593 618 mr_asprintf(strtmp, "%s", program); … … 2289 2314 2290 2315 /** float ***********************************************************/ 2291 long longfactor;2316 float factor; 2292 2317 long long new_size; 2293 2318 … … 2322 2347 2323 2348 drivemntlist = malloc(sizeof(struct mountlist_reference)); 2324 drivemntlist->el = 2325 malloc(sizeof(struct mountlist_line *) * MAX_MOUNTLIST_ENTRIES); 2349 drivemntlist->el = malloc(sizeof(struct mountlist_line *) * MAX_MOUNTLIST_ENTRIES); 2326 2350 2327 2351 if (!drivemntlist) { … … 2337 2361 } 2338 2362 2339 if (original_size_of_drive <= 0 ) {2363 if (original_size_of_drive <= 0LL) { 2340 2364 log_to_screen("Cannot resize %s's entries. Drive not found.", drive_name); 2341 2365 return; 2342 2366 } 2343 factor = (current_size_of_drive) / (original_size_of_drive); 2344 log_to_screen("Disk %s was %lld MB; is now %lld MB; Proportionally resizing partitions (factor ~= %lld)", drive_name, original_size_of_drive/1024, current_size_of_drive/1024, factor); 2367 factor = ((float)current_size_of_drive/(float)original_size_of_drive); 2368 mr_asprintf(tmp, "Disk %s was %lld MB; is now %lld MB; Proportionally resizing partitions (factor ~= %.5f)", 2369 drive_name, original_size_of_drive/1024, current_size_of_drive/1024, factor); 2370 log_to_screen(tmp); 2371 mr_free(tmp); 2345 2372 2346 2373 lastpart = drivemntlist->entries - 1; … … 2348 2375 /* the 'atoi' thing is to make sure we don't try to resize _images_, whose formats will be numeric */ 2349 2376 if (!atoi(drivemntlist->el[partno]->format)) { 2350 new_size = ( drivemntlist->el[partno]->size) * factor;2377 new_size = (long long)((drivemntlist->el[partno]->size) * factor); 2351 2378 } else { 2352 2379 new_size = drivemntlist->el[partno]->size;
Note:
See TracChangeset
for help on using the changeset viewer.