Changeset 2816 in MondoRescue for branches/2.2.10/mondo/src/mondorestore/mondo-prep.c
- Timestamp:
- Apr 29, 2011, 3:42:55 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/mondorestore/mondo-prep.c
r2704 r2816 466 466 { 467 467 if (!does_file_exist("/etc/raidtab")) { 468 log_to_screen 469 ("Cannot find /etc/raidtab - cannot extrapolate the fdisk entries"); 468 log_to_screen("Cannot find /etc/raidtab - cannot extrapolate the fdisk entries"); 470 469 finish(1); 471 470 } … … 690 689 if (!vinum_started_yet) { 691 690 if (!does_file_exist("/tmp/raidconf.txt")) { 692 log_to_screen 693 ("/tmp/raidconf.txt does not exist. I therefore cannot start Vinum."); 691 log_to_screen("/tmp/raidconf.txt does not exist. I therefore cannot start Vinum."); 694 692 } else { 695 693 int res; … … 698 696 ("vinum create /tmp/raidconf.txt", TRUE); 699 697 if (res) { 700 log_to_screen 701 ("`vinum create /tmp/raidconf.txt' returned errors. Please fix them and re-run mondorestore."); 698 log_to_screen("`vinum create /tmp/raidconf.txt' returned errors. Please fix them and re-run mondorestore."); 702 699 finish(1); 703 700 } … … 757 754 } 758 755 #else 759 log_to_screen(tmp, "Initializing RAID device %s", device); 760 log_to_screen(tmp); 761 mr_free(tmp); 756 log_to_screen("Initializing RAID device %s", device); 762 757 763 758 // Shouldn't be necessary. … … 808 803 mr_asprintf(tmp, "Formatting %s as %s", device, format); 809 804 update_progress_form(tmp); 810 mr_free(tmp);811 805 812 806 res = run_program_and_log_output(program, FALSE); … … 1005 999 if (retval) { 1006 1000 mvaddstr_and_log_it(g_currentY++, 74, "Failed."); 1007 log_to_screen 1008 ("Errors occurred during the formatting of your hard drives."); 1001 log_to_screen("Errors occurred during the formatting of your hard drives."); 1009 1002 } else { 1010 1003 mvaddstr_and_log_it(g_currentY++, 74, "Done."); … … 1016 1009 if (retval > 0 && !interactively) { 1017 1010 //123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 1018 log_to_screen 1019 ("Partition table locked up %d times. At least one 'mkfs' (format) command", 1020 g_partition_table_locked_up); 1021 log_to_screen 1022 ("failed. I think these two events are related. Sometimes, fdisk's ioctl() call"); 1023 log_to_screen 1024 ("to refresh its copy of the partition table causes the kernel to lock the "); 1025 log_to_screen 1026 ("partition table. I believe this has just happened."); 1027 if (ask_me_yes_or_no 1028 ("Please choose 'yes' to reboot and try again; or 'no' to ignore this warning and continue.")) 1029 { 1011 log_to_screen("Partition table locked up %d times. At least one 'mkfs' (format) command", g_partition_table_locked_up); 1012 log_to_screen("failed. I think these two events are related. Sometimes, fdisk's ioctl() call"); 1013 log_to_screen("to refresh its copy of the partition table causes the kernel to lock the "); 1014 log_to_screen("partition table. I believe this has just happened."); 1015 if (ask_me_yes_or_no("Please choose 'yes' to reboot and try again; or 'no' to ignore this warning and continue.")) { 1030 1016 sync(); 1031 1017 sync(); … … 1034 1020 } 1035 1021 } else { 1036 log_to_screen 1037 ("Partition table locked up %d time%c. However, disk formatting succeeded.", 1038 g_partition_table_locked_up, 1039 (g_partition_table_locked_up == 1) ? '.' : 's'); 1022 log_to_screen("Partition table locked up %d time%c. However, disk formatting succeeded.", g_partition_table_locked_up, (g_partition_table_locked_up == 1) ? '.' : 's'); 1040 1023 } 1041 1024 } … … 1462 1445 mr_asprintf(command, "disklabel -B %s", basename(drivename)); 1463 1446 if (system(command)) { 1464 log_to_screen 1465 ("Warning! Unable to make the drive bootable."); 1447 log_to_screen("Warning! Unable to make the drive bootable."); 1466 1448 } 1467 1449 mr_free(command); … … 1550 1532 #ifndef __IA64__ 1551 1533 if (current_devno == 5 && previous_devno == 4) { 1552 log_to_screen 1553 ("You must leave at least one partition spare as the Extended partition."); 1534 log_to_screen("You must leave at least one partition spare as the Extended partition."); 1554 1535 mr_free(device_str); 1555 1536 mr_free(format); … … 1566 1547 retval += label_drive_or_slice(mountlist, device_str, 0); 1567 1548 if (system(tmp)) { 1568 log_to_screen 1569 ("Warning! Unable to make the slice bootable."); 1549 log_to_screen("Warning! Unable to make the slice bootable."); 1570 1550 } 1571 1551 mr_free(tmp); … … 1611 1591 1612 1592 if (g_partition_table_locked_up > 0) { 1613 log_to_screen 1614 ("A flaw in the Linux kernel has locked the partition table. Even calling partprobe did not suceed :-("); 1593 log_to_screen("A flaw in the Linux kernel has locked the partition table. Even calling partprobe did not suceed :-("); 1615 1594 } 1616 1595 } … … 1875 1854 if (retval) { 1876 1855 mvaddstr_and_log_it(g_currentY++, 74, "Failed."); 1877 log_to_screen 1878 ("Errors occurred during the partitioning of your hard drives."); 1856 log_to_screen("Errors occurred during the partitioning of your hard drives."); 1879 1857 } else { 1880 1858 mvaddstr_and_log_it(g_currentY++, 74, "Done."); … … 2311 2289 2312 2290 /** float ***********************************************************/ 2313 float factor; 2314 float new_size; 2315 // float newcylinderno; 2291 long long factor; 2292 long long new_size; 2316 2293 2317 2294 /** long *************************************************************/ 2318 long newsizL = 0L;2319 long current_size_of_drive = 0L;2320 long original_size_of_drive = 0L;2321 long final_size = 0L; /* all in Megabytes*/2295 long long newsizL = 0LL; 2296 long long totalsizL = 0LL; 2297 long long current_size_of_drive = 0LL; /* use KB interally for precision */ 2298 long long original_size_of_drive = 0LL; /* use KB interally for precision */ 2322 2299 struct mountlist_reference *drivemntlist; 2323 2300 … … 2336 2313 } 2337 2314 2338 current_size_of_drive = get_phys_size_of_drive(drive_name);2339 2340 if (current_size_of_drive <= 0 ) {2315 current_size_of_drive = (long long) get_phys_size_of_drive(drive_name) * 1024LL; 2316 2317 if (current_size_of_drive <= 0LL) { 2341 2318 log_it("Not resizing to match %s - can't find drive", drive_name); 2342 2319 return; 2343 2320 } 2344 log_to_screen("Expanding entries to suit drive %s (%l d MB)", drive_name, current_size_of_drive);2321 log_to_screen("Expanding entries to suit drive %s (%lld MB)", drive_name, current_size_of_drive / 1024); 2345 2322 2346 2323 drivemntlist = malloc(sizeof(struct mountlist_reference)); … … 2354 2331 2355 2332 for (partno = 0; partno < drivemntlist->entries; partno++) { 2356 if (drivemntlist->el[partno]->size > 0) { 2357 original_size_of_drive += (drivemntlist->el[partno]->size / 1024L); 2333 if (drivemntlist->el[partno]->size > 0LL) { 2334 /* Keep KB here */ 2335 original_size_of_drive += drivemntlist->el[partno]->size; 2358 2336 } 2359 2337 } … … 2363 2341 return; 2364 2342 } 2365 factor = ( float) (current_size_of_drive) / (float)(original_size_of_drive);2366 log_to_screen("Disk %s was %l d MB; is now %ld MB; factor = %f", drive_name, original_size_of_drive, current_size_of_drive, factor);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 2345 2368 2346 lastpart = drivemntlist->entries - 1; … … 2370 2348 /* the 'atoi' thing is to make sure we don't try to resize _images_, whose formats will be numeric */ 2371 2349 if (!atoi(drivemntlist->el[partno]->format)) { 2372 new_size = ( float) (drivemntlist->el[partno]->size) * factor;2350 new_size = (drivemntlist->el[partno]->size) * factor; 2373 2351 } else { 2374 2352 new_size = drivemntlist->el[partno]->size; … … 2379 2357 drivemntlist->el[partno]->device, 2380 2358 drivemntlist->el[partno]->mountpoint); 2381 newsizL = (long) new_size; // It looks wrong but it's not 2382 } else { 2383 newsizL = (long) new_size; 2384 } 2359 } 2360 newsizL = new_size; 2385 2361 2386 2362 /* Do not apply the factor if partition was of negative size */ 2387 if (newsizL < 0 ) {2363 if (newsizL < 0LL) { 2388 2364 newsizL = drivemntlist->el[partno]->size; 2389 2365 } 2390 2391 log_to_screen("Changing %s from %lld KB to %ld KB", drivemntlist->el[partno]->device, drivemntlist->el[partno]->size, newsizL); 2366 totalsizL += newsizL; 2367 2368 log_to_screen("Changing %s from %lld KB to %lld KB", drivemntlist->el[partno]->device, drivemntlist->el[partno]->size, newsizL); 2392 2369 drivemntlist->el[partno]->size = newsizL; 2393 2370 } 2394 final_size = get_phys_size_of_drive(drive_name); 2395 log_to_screen("final_size = %ld MB", final_size); 2371 // Ensures over-allocation alert and prompt for interactive mode does not happen 2372 if (totalsizL > current_size_of_drive) { 2373 log_to_screen("Last partition size calculated would be over-allocated, reducing %s from %lld KB to %lld KB.", drivemntlist->el[lastpart]->device, drivemntlist->el[lastpart]->size, drivemntlist->el[lastpart]->size - (totalsizL - current_size_of_drive)); 2374 drivemntlist->el[drivemntlist->entries-1]->size -= (totalsizL - current_size_of_drive); 2375 } else if (totalsizL < current_size_of_drive) { 2376 log_to_screen("Last partition size calculated would be under-allocated, increasing %s from %lld KB to %lld KB.",drivemntlist->el[lastpart]->device, drivemntlist->el[lastpart]->size, drivemntlist->el[lastpart]->size + (current_size_of_drive - totalsizL)); 2377 drivemntlist->el[drivemntlist->entries-1]->size += (current_size_of_drive - totalsizL); 2378 } 2379 log_to_screen("final_size = %lld MB", current_size_of_drive / 1024); 2396 2380 } 2397 2381
Note:
See TracChangeset
for help on using the changeset viewer.