Changeset 3147 in MondoRescue for branches/3.1/mondo/src/mondorestore
- Timestamp:
- Jun 19, 2013, 8:34:46 AM (13 years ago)
- Location:
- branches/3.1/mondo/src/mondorestore
- Files:
-
- 6 edited
-
mondo-prep.c (modified) (42 diffs)
-
mondo-rstr-compare.c (modified) (12 diffs)
-
mondo-rstr-newt.c (modified) (6 diffs)
-
mondo-rstr-tools.c (modified) (19 diffs)
-
mondoprep.h (modified) (1 diff)
-
mondorestore.c (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/3.1/mondo/src/mondorestore/mondo-prep.c
r2937 r3147 110 110 popup_and_OK 111 111 ("I must now reboot. Please leave the boot media in the drive and repeat your actions - e.g. type 'nuke' - and it should work fine."); 112 system("reboot");112 paranoid_system("reboot"); 113 113 } 114 114 } … … 171 171 172 172 int do_my_funky_lvm_stuff(bool just_erase_existing_volumes, 173 bool vacuum_pack)173 bool vacuum_pack) 174 174 { 175 /** buffers **********************************************/175 /** buffers **********************************************/ 176 176 char *tmp = NULL; 177 177 char *tmp1 = NULL; … … 188 188 char *p; 189 189 char *q; 190 char *r; 190 191 191 192 /** int ***************************************************/ … … 442 443 /** pointers *********************************************************/ 443 444 char *p; 445 char *q; 444 446 445 447 /** init *************************************************************/ … … 503 505 } else { 504 506 strcpy(new_mountlist->el[new_mountlist->entries].device, 505 old_mountlist->el[lino].device);507 old_mountlist->el[lino].device); 506 508 strcpy(new_mountlist->el[new_mountlist->entries].mountpoint, 507 old_mountlist->el[lino].mountpoint);509 old_mountlist->el[lino].mountpoint); 508 510 strcpy(new_mountlist->el[new_mountlist->entries].format, 509 old_mountlist->el[lino].format);511 old_mountlist->el[lino].format); 510 512 new_mountlist->el[new_mountlist->entries].size = 511 513 old_mountlist->el[lino].size; … … 527 529 * @return 0 for success, nonzero for failure. 528 530 */ 529 int create_raid_device_via_mdadm(struct raidlist_itself *raidlist, char *device) 530 { 531 /** int **************************************************************/ 532 int i = 0; 533 int j = 0; 534 int res = 0; 535 536 /** buffers ***********************************************************/ 537 char *devices = NULL; 538 char *strtmp = NULL; 539 char *level = NULL; 540 char *program = NULL; 541 char *tmp = NULL; 542 char *oldmd = NULL; 543 char *bootdevice; 544 char *name; 531 int create_raid_device_via_mdadm(struct raidlist_itself *raidlist, char *device, bool test) { 532 /** int **************************************************************/ 533 int i = 0; 534 int j = 0; 535 int v = 0; 536 int res = 0; 537 538 /** buffers ***********************************************************/ 539 char *devices = NULL; 540 char *level = NULL; 541 char *program = NULL; 545 542 546 543 malloc_string(bootdevice); … … 735 732 /* format raid partition */ 736 733 mr_asprintf(program, "for plex in `vinum lv -r %s | grep '^P' | tr '\t' ' ' | tr -s ' ' | cut -d' ' -f2`; do echo $plex; done > /tmp/plexes", basename(device)); 737 system(program);734 paranoid_system(program); 738 735 if (g_fprep) { 739 736 fprintf(g_fprep, "%s\n", program); … … 752 749 753 750 mr_asprintf(tmp, "vinum init %s", line); 754 system(tmp);751 paranoid_system(tmp); 755 752 mr_free(tmp); 756 753 … … 781 778 log_to_screen("Initializing RAID device %s", device); 782 779 783 // Shouldn't be necessary.780 // Shouldn't be necessary. 784 781 log_to_screen("Stopping %s", device); 785 782 stop_raid_device(device); … … 789 786 log_msg(1, "Making %s", device); 790 787 // use mkraid if it exists, otherwise use mdadm 791 if (run_program_and_log_output("which mkraid", FALSE)) {792 res = create_raid_device_via_mdadm(raidlist, device);793 log_msg(1, "Creating RAID device %s via mdadm returned %d", device, res);788 if (run_program_and_log_output("which mkraid", FALSE)) { 789 res = create_raid_device_via_mdadm(raidlist, device, TRUE); 790 log_msg(1, "Creating RAID device %s via mdadm returned %d", device, res); 794 791 } else { 795 792 mr_asprintf(program, "mkraid --really-force %s", device); … … 884 881 */ 885 882 int format_everything(struct mountlist_itself *mountlist, bool interactively, 886 struct raidlist_itself *raidlist)883 struct raidlist_itself *raidlist) 887 884 { 888 885 /** int **************************************************************/ … … 907 904 log_it("format_everything (mountlist, interactively = %s", (interactively) ? "true" : "false"); 908 905 909 mvaddstr_and_log_it(g_currentY, 0, "Formatting partitions ");906 mvaddstr_and_log_it(g_currentY, 0, "Formatting partitions "); 910 907 open_progress_form("Formatting partitions", 911 "I am now formatting your hard disk partitions.",912 "This may take up to five minutes.", "",913 mountlist->entries + 1);908 "I am now formatting your hard disk partitions.", 909 "This may take up to five minutes.", "", 910 mountlist->entries + 1); 914 911 915 912 progress_step = … … 949 946 sleep(2); 950 947 // This last step is probably necessary 951 // log_to_screen("Re-starting software RAIDs...");952 // start_all_raid_devices(mountlist);953 // system("sync"); system("sync");system("sync");954 // sleep(5);948 // log_to_screen("Re-starting software RAIDs..."); 949 // start_all_raid_devices(mountlist); 950 // paranoid_system("sync"); paranoid_system("sync"); paranoid_system("sync"); 951 // sleep(5); 955 952 // do LVMs now 956 953 log_msg(1, "Creating LVMs"); … … 992 989 continue; 993 990 } else if (!does_file_exist(me->device) 994 && strncmp(me->device, "/dev/hd", 7)995 && strncmp(me->device, "/dev/sd", 7)) {991 && strncmp(me->device, "/dev/hd", 7) 992 && strncmp(me->device, "/dev/sd", 7)) { 996 993 log_it("Not formatting %s yet - doesn't exist - probably an LVM", me->device); 997 994 continue; … … 1049 1046 } 1050 1047 newtSuspend(); 1051 system("clear");1048 paranoid_system("clear"); 1052 1049 newtResume(); 1053 1050 return (retval); … … 1064 1061 */ 1065 1062 int make_dummy_partitions(FILE * pout_to_fdisk, char *drivename, 1066 int devno_we_must_allow_for)1063 int devno_we_must_allow_for) 1067 1064 { 1068 1065 /** int **************************************************************/ … … 1178 1175 fprintf(f, "\n\n%u partitions:\n", lp->d_npartitions); 1179 1176 fprintf(f, 1180 "# size offset fstype [fsize bsize bps/cpg]\n");1177 "# size offset fstype [fsize bsize bps/cpg]\n"); 1181 1178 pp = lp->d_partitions; 1182 1179 for (i = 0; i < lp->d_npartitions; i++, pp++) { 1183 1180 if (pp->p_size) { 1184 fprintf(f, " %c: %8lu %8lu ", 'a' + i, (u_long) pp->p_size,1181 fprintf(f, " %c: %8lu %8lu ", 'a' + i, (u_long) pp->p_size, 1185 1182 (u_long) pp->p_offset); 1186 1183 if (pp->p_fstype < FSMAXTYPES) … … 1191 1188 1192 1189 case FS_UNUSED: /* XXX */ 1193 fprintf(f, " %5lu %5lu %5.5s ", (u_long) pp->p_fsize,1190 fprintf(f, " %5lu %5lu %5.5s ", (u_long) pp->p_fsize, 1194 1191 (u_long) (pp->p_fsize * pp->p_frag), ""); 1195 1192 break; 1196 1193 1197 1194 case FS_BSDFFS: 1198 fprintf(f, " %5lu %5lu %5u ", (u_long) pp->p_fsize,1195 fprintf(f, " %5lu %5lu %5u ", (u_long) pp->p_fsize, 1199 1196 (u_long) (pp->p_fsize * pp->p_frag), pp->p_cpg); 1200 1197 break; 1201 1198 1202 1199 case FS_BSDLFS: 1203 fprintf(f, " %5lu %5lu %5d", (u_long) pp->p_fsize,1200 fprintf(f, " %5lu %5lu %5d", (u_long) pp->p_fsize, 1204 1201 (u_long) (pp->p_fsize * pp->p_frag), pp->p_cpg); 1205 1202 break; … … 1217 1214 fprintf(f, "- %lu", 1218 1215 (u_long) ((pp->p_offset + pp->p_size + 1219 lp->d_secpercyl - 1) / lp->d_secpercyl -1220 1));1216 lp->d_secpercyl - 1) / lp->d_secpercyl - 1217 1)); 1221 1218 if (pp->p_size % lp->d_secpercyl) 1222 1219 putc('*', f); … … 1256 1253 /* 1257 1254 * Nobody in these enligthened days uses the CHS geometry for 1258 * anything, but nontheless try to get it right. If we fail1255 * anything, but nontheless try to get it right. If we fail 1259 1256 * to get any good ideas from the device, construct something 1260 1257 * which is IBM-PC friendly. … … 1340 1337 lp->d_partitions[c - 'a'].p_cpg = 64; 1341 1338 } else if (!strcasecmp(mountlist->el[idx].format, "raid") 1342 || !strcasecmp(mountlist->el[idx].format, "vinum")) {1339 || !strcasecmp(mountlist->el[idx].format, "vinum")) { 1343 1340 lp->d_partitions[c - 'a'].p_fstype = FS_VINUM; 1344 1341 } else if (!strcmp(mountlist->el[idx].format, "swap")) { … … 1422 1419 char *format = NULL; 1423 1420 char *tmp = NULL; 1421 char *tmp1 = NULL; 1424 1422 char *tmp1 = NULL; 1425 1423 … … 1511 1509 1512 1510 /* OK, we've found partition /dev/hdxN in mountlist; let's prep it */ 1513 /* For FreeBSD, that is /dev/adXsY */1511 /* For FreeBSD, that is /dev/adXsY */ 1514 1512 1515 1513 log_it("Found partition %s in mountlist", device_str); … … 1540 1538 previous_devno = 1541 1539 make_dummy_partitions(pout_to_fdisk, drivename, 1542 current_devno);1540 current_devno); 1543 1541 } 1544 1542 } … … 1595 1593 sync(); 1596 1594 paranoid_pclose(pout_to_fdisk); 1597 log_msg(0,1598 "------------------- fdisk.log looks like this ------------------");1595 paranoid_system("sync"); 1596 log_msg(0,"------------------- fdisk.log looks like this ------------------"); 1599 1597 mr_asprintf(tmp, "cat %s >> %s", FDISK_LOG, MONDO_LOGFILE); 1600 1598 system(tmp); … … 1625 1623 * Create partition number @p partno on @p drive with @p fdisk. 1626 1624 * @param drive The drive to create the partition on. 1627 // * @param partno The partition number of the new partition (1-4 are primary, >=5 is logical).1625 // * @param partno The partition number of the new partition (1-4 are primary, >=5 is logical). 1628 1626 * @param prev_partno The partition number of the most recently prepped partition. 1629 1627 * @param format The filesystem type of this partition (used to set the type). … … 1656 1654 1657 1655 log_it("partition_device('%s', %d, %d, '%s', %lld) --- starting", 1658 drive, partno, prev_partno, format, partsize);1656 drive, partno, prev_partno, format, partsize); 1659 1657 1660 1658 if (!strncmp(drive, RAID_DEVICE_STUB, strlen(RAID_DEVICE_STUB))) { … … 1743 1741 retval = 1744 1742 set_partition_type(pout_to_fdisk, drive, partno, format, 1745 partsize);1743 partsize); 1746 1744 if (retval) { 1747 1745 log_msg(1, "Failed. Trying again..."); 1748 1746 retval = 1749 1747 set_partition_type(pout_to_fdisk, drive, partno, 1750 format, partsize);1748 format, partsize); 1751 1749 } 1752 1750 } … … 1783 1781 retval = 1784 1782 set_partition_type(pout_to_fdisk, drive, partno, format, 1785 partsize);1783 partsize); 1786 1784 if (retval) { 1787 1785 log_it("Partitioned %s but failed to set its type", partition_name); … … 1832 1830 /** buffer *********************************************************/ 1833 1831 struct list_of_disks *drivelist; 1834 /* struct mountlist_itself new_mtlist, *mountlist; */1832 /* struct mountlist_itself new_mtlist, *mountlist; */ 1835 1833 1836 1834 /** end ************************************************************/ … … 1840 1838 1841 1839 log_it("partition_everything() --- starting"); 1842 mvaddstr_and_log_it(g_currentY, 0, "Partitioning hard drives ");1843 /* mountlist=orig_mtlist; */1840 mvaddstr_and_log_it(g_currentY, 0, "Partitioning hard drives "); 1841 /* mountlist=orig_mtlist; */ 1844 1842 if (mountlist_contains_raid_devices(mountlist)) { 1845 /* mountlist=&new_mtlist; */1846 /* extrapolate_mountlist_to_include_raid_partitions(mountlist,orig_mtlist); */1843 /* mountlist=&new_mtlist; */ 1844 /* extrapolate_mountlist_to_include_raid_partitions(mountlist,orig_mtlist); */ 1847 1845 log_msg(0, 1848 1846 "Mountlist, including the partitions incorporated in RAID devices:-"); … … 1865 1863 1866 1864 open_progress_form("Partitioning devices", 1867 "I am now going to partition all your drives.",1868 "This should not take more than five minutes.", "",1869 mountlist->entries);1865 "I am now going to partition all your drives.", 1866 "This should not take more than five minutes.", "", 1867 mountlist->entries); 1870 1868 1871 1869 make_list_of_drives_in_mountlist(mountlist, drivelist); … … 1885 1883 } 1886 1884 newtSuspend(); 1887 system("clear");1885 paranoid_system("clear"); 1888 1886 newtResume(); 1889 1887 paranoid_free(drivelist); … … 1906 1904 */ 1907 1905 int set_partition_type(FILE * pout_to_fdisk, const char *drive, int partno, 1908 const char *format, long long partsize)1906 const char *format, long long partsize) 1909 1907 { 1910 1908 /** buffers *********************************************************/ … … 1939 1937 } 1940 1938 } else if (strcmp(format, "ext2") == 0 1941 || strcmp(format, "reiserfs") == 0 1942 || strcmp(format, "ext3") == 0 1943 || strcmp(format, "ext4") == 0 1944 || strcmp(format, "xfs") == 0 1945 || strcmp(format, "jfs") == 0) { 1939 || strcmp(format, "reiserfs") == 0 1940 || strcmp(format, "ext3") == 0 1941 || strcmp(format, "ext4") == 0 1942 || strcmp(format, "xfs") == 0 1943 || strcmp(format, "jfs") == 0 1944 || strcmp(format, "btrfs") == 0) { 1946 1945 mr_asprintf(partcode, "83"); 1947 1946 } else if (strcmp(format, "minix") == 0) { … … 1956 1955 mr_asprintf(partcode, "7"); 1957 1956 } else if ((strcmp(format, "ufs") == 0) 1958 || (strcmp(format, "ffs") == 0)) { /* raid autodetect */1957 || (strcmp(format, "ffs") == 0)) { /* raid autodetect */ 1959 1958 mr_asprintf(partcode, "a5"); 1960 1959 } else if (strcmp(format, "lvm") == 0) { … … 2108 2107 mr_asprintf(program, "vinum stop -f %s", raid_device); 2109 2108 #else 2110 // use raidstop if it exists, otherwise use mdadm2111 if (run_program_and_log_output("which raidstop", FALSE)) {2109 // use raidstop if it exists, otherwise use mdadm 2110 if (run_program_and_log_output("which raidstop", FALSE)) { 2112 2111 mr_asprintf(program, "mdadm -S %s", raid_device); 2113 2112 } else { … … 2174 2173 /** pointers ********************************************************/ 2175 2174 FILE *fin; 2175 char *q; 2176 2176 int i; 2177 2177 … … 2203 2203 for (p = dev; *p > 32; p++); 2204 2204 *p = '\0'; 2205 re s= stop_raid_device(dev);2205 retval += stop_raid_device(dev); 2206 2206 mr_free(dev); 2207 2207 } … … 2261 2261 } else if (strcmp(format, "ext4") == 0) { 2262 2262 mr_asprintf(program, "mkfs -t ext4 -F -q"); 2263 } else if (strcmp(format, "btrfs") == 0) { 2264 strcpy(program, "mkfs.btrfs"); 2263 2265 } else if (strcmp(format, "minix") == 0) { 2264 2266 mr_asprintf(program, "mkfs.minix"); … … 2297 2299 * There are a few problems with this function: 2298 2300 * - It won't work if there was any unallocated space on the user's hard drive 2299 * when it was backed up.2301 * when it was backed up. 2300 2302 * - It won't work if the user's hard drive lies about its size (more common 2301 * than you'd think).2303 * than you'd think). 2302 2304 * 2303 2305 * @param mountlist The mountlist to use for resizing @p drive_name. … … 2311 2313 /** int *************************************************************/ 2312 2314 int partno, lastpart; 2313 /** remove driveno, noof_drives stan benoit apr 2002**/2314 2315 2315 2316 /** float ***********************************************************/ -
branches/3.1/mondo/src/mondorestore/mondo-rstr-compare.c
r2704 r3147 71 71 return (1); 72 72 } 73 fread((void *) &biggiestruct, 1, sizeof(biggiestruct), fin); 73 if (fread((void *) &biggiestruct, 1, sizeof(biggiestruct), fin)) { 74 // FIXME 75 } 74 76 paranoid_fclose(fin); 75 77 … … 218 220 int retval = 0; 219 221 int res; 220 long noof_lines;221 222 long archiver_errors; 222 223 bool use_star; … … 289 290 if (use_star) { 290 291 // doesn't use compressor_exe 291 mr_asprintf(command, "%s - diff H=exustar file=%s >> %s 2>> %s", archiver_exe, tarball_fname, logfile, logfile);292 mr_asprintf(command, "%s -sparse -diff H=exustar file=%s >> %s 2>> %s", archiver_exe, tarball_fname, logfile, logfile); 292 293 } else { 293 294 mr_asprintf(command, "%s -r -b %ld -M 16m -c %ld %s %s >> %s 2>> %s", archiver_exe, TAPE_BLOCK_SIZE, BUFSIZE, compressor_exe, tarball_fname, logfile, logfile); … … 308 309 if (length_of_file(logfile) > 5) { 309 310 mr_asprintf(command, "sed s/': \\\"'/\\|/ %s | sed s/'\\\": '/\\|/ | cut -d'|' -f2 | sort -u | grep -vE \"^dev/.*\" >> "MONDO_CACHE"/changed.txt", logfile); 310 system(command);311 paranoid_system(command); 311 312 mr_free(command); 312 313 … … 337 338 { 338 339 int retval = 0; 339 int res;340 340 int current_tarball_number = 0; 341 341 … … 409 409 log_to_screen(progress_str); 410 410 } else { 411 re s= compare_a_tarball(tarball_fname, current_tarball_number);411 retval += compare_a_tarball(tarball_fname, current_tarball_number); 412 412 413 413 g_current_progress++; … … 459 459 assert(bkpinfo != NULL); 460 460 461 getcwd(cwd, MAX_STR_LEN - 1); 462 chdir(bkpinfo->restore_path); 463 getcwd(new, MAX_STR_LEN - 1); 461 if (getcwd(cwd, MAX_STR_LEN - 1)) { 462 // FIXME 463 } 464 if (chdir(bkpinfo->restore_path)) { 465 //FIXME 466 } 467 if (getcwd(new, MAX_STR_LEN - 1)) { 468 // FIXME 469 } 464 470 insist_on_this_cd_number(g_current_media_number); 465 471 unlink(MONDO_CACHE"/changed.txt"); … … 467 473 resA = compare_all_tarballs(); 468 474 resB = compare_all_biggiefiles(); 469 chdir(cwd); 475 if (chdir(cwd)) { 476 // FIXME 477 } 470 478 noof_changed_files = count_lines_in_file(MONDO_CACHE"/changed.txt"); 471 479 if (noof_changed_files) { … … 594 602 595 603 log_msg(2, "calling popup_changelist_from_file()"); 596 getcwd(cwd, MAX_STR_LEN - 1); 597 chdir(bkpinfo->restore_path); 598 getcwd(new, MAX_STR_LEN - 1); 604 if (getcwd(cwd, MAX_STR_LEN - 1)) { 605 //FIXME 606 } 607 if (chdir(bkpinfo->restore_path)) { 608 // FIXME 609 } 610 if (getcwd(new, MAX_STR_LEN - 1)) { 611 //FIXME 612 } 599 613 popup_changelist_from_file(MONDO_CACHE"/changed.files"); 600 chdir(cwd); 614 if (chdir(cwd)) { 615 // FIXME 616 } 601 617 log_msg(2, "Returning from popup_changelist_from_file()"); 602 618 } … … 634 650 assert(bkpinfo != NULL); 635 651 malloc_string(dir); 636 getcwd(dir, MAX_STR_LEN); 637 chdir(bkpinfo->restore_path); 652 if (getcwd(dir, MAX_STR_LEN)) { 653 // FIXME 654 } 655 if (chdir(bkpinfo->restore_path)) { 656 // FIXME 657 } 638 658 639 659 mvaddstr_and_log_it(g_currentY, … … 647 667 } 648 668 res = verify_tape_backups(); 649 chdir(dir); 669 if (chdir(dir)) { 670 // FIXME 671 } 650 672 if (length_of_file(MONDO_CACHE"/changed.txt") > 2 651 673 && length_of_file(MONDO_CACHE"/changed.files") > 2) { … … 686 708 malloc_string(dir); 687 709 688 getcwd(dir, MAX_STR_LEN); 689 chdir(bkpinfo->restore_path); 710 if (getcwd(dir, MAX_STR_LEN)) { 711 // FIXME 712 } 713 if (chdir(bkpinfo->restore_path)) { 714 // FIXME 715 } 690 716 691 717 mvaddstr_and_log_it(g_currentY, 692 718 0, "Verifying archives against filesystem"); 693 719 res = verify_tape_backups(); 694 chdir(dir); 720 if (chdir(dir)) { 721 // FIXME 722 } 695 723 if (res) { 696 724 mvaddstr_and_log_it(g_currentY++, 74, "Failed."); -
branches/3.1/mondo/src/mondorestore/mondo-rstr-newt.c
r2937 r3147 137 137 /** int **************************************************************/ 138 138 int i = 0; 139 int num_to_add = 0;140 139 141 140 /** newt *************************************************************/ … … 233 232 mr_asprintf(drive_to_add, "%s", device_str); 234 233 for (i = strlen(drive_to_add); isdigit(drive_to_add[i - 1]); i--); 235 num_to_add = atoi(drive_to_add + i);236 234 mr_free(drive_to_add); 237 235 … … 1943 1941 finish(1); 1944 1942 } 1945 newtPushHelpLine 1946 (" Please edit the mountlist to your satisfaction, then click OK or Cancel."); 1943 newtPushHelpLine("WARNING: No LVM modification possible here. Edit /tmp/i-want-my-lvm instead"); 1947 1944 i = 4; 1948 1945 bAdd = newtCompactButton(i, 17, " Add "); … … 2423 2420 newtComponent b2; 2424 2421 newtComponent b3; 2425 newtComponent b_res;2426 2422 2427 2423 … … 2434 2430 myForm = newtForm(NULL, NULL, 0); 2435 2431 newtFormAddComponents(myForm, b1, b2, b3, NULL); 2436 b_res = newtRunForm(myForm);2437 2432 newtFormDestroy(myForm); 2438 2433 newtPopWindow(); … … 2886 2881 mr_getline(tmp, stdin); 2887 2882 output = tmp[0]; 2888 free(tmp);2883 mr_free(tmp); 2889 2884 } 2890 2885 return (output); -
branches/3.1/mondo/src/mondorestore/mondo-rstr-tools.c
r2937 r3147 80 80 char *incoming = NULL; 81 81 char *question = NULL; 82 char *q; 82 83 83 84 assert_string_is_neither_NULL_nor_zerolength(infname); … … 209 210 if (is_this_device_mounted(g_isodir_device)) { 210 211 log_to_screen("WARNING - isodir is already mounted"); 211 already_mounted = TRUE;212 212 } else { 213 213 mr_asprintf(mount_isodir_command, "mount %s", g_isodir_device); … … 1082 1082 char *tmp; 1083 1083 char *tmp1 = NULL; 1084 char *q; 1084 1085 int res = 0; 1085 1086 pid_t pid; … … 1088 1089 malloc_string(tmp); 1089 1090 1090 getcwd(tmp, MAX_STR_LEN); 1091 chdir(bkpinfo->tmpdir); 1091 if (getcwd(tmp, MAX_STR_LEN) == NULL) { 1092 // FIXME 1093 } 1094 if (chdir(bkpinfo->tmpdir)) { 1095 // FIXME 1096 } 1092 1097 log_msg(1, "chdir(%s)", bkpinfo->tmpdir); 1093 1098 log_to_screen("Extracting filelist and biggielist from media..."); … … 1116 1121 } 1117 1122 } 1118 chdir(tmp); 1123 if (chdir(tmp)) { 1124 // FIXME 1125 } 1119 1126 1120 1127 log_msg(2, "Forking"); … … 1147 1154 unlink(MINDI_CACHE"/filelist.full.gz"); 1148 1155 if (g_text_mode) { 1149 printf("Restore which directory? --> "); 1150 mr_getline(tmp1, stdin); 1151 toggle_path_selection(filelist, tmp1, TRUE); 1152 if (strlen(tmp1) == 0) { 1156 q = NULL; 1157 while (q == NULL) { 1158 printf("Restore which directory? --> "); 1159 mr_getline(q, stdin); 1160 } 1161 toggle_path_selection(filelist, q, TRUE); 1162 if (strlen(q) == 0) { 1153 1163 res = 1; 1154 1164 } else { 1155 1165 res = 0; 1156 1166 } 1157 mr_free( tmp1);1167 mr_free(q); 1158 1168 } else { 1159 1169 res = edit_filelist(filelist); … … 1229 1239 newtSuspend(); 1230 1240 } 1231 (void)system("chroot " MNT_RESTORING);1241 paranoid_system("chroot " MNT_RESTORING); 1232 1242 if (!g_text_mode) { 1233 1243 newtResume(); … … 1271 1281 backup_crucial_file(MNT_RESTORING, "/boot/grub/menu.lst"); 1272 1282 backup_crucial_file(MNT_RESTORING, "/boot/grub/grub.cfg"); 1283 backup_crucial_file(MNT_RESTORING, "/boot/grub2/grub.cfg"); 1273 1284 backup_crucial_file(MNT_RESTORING, "/etc/lilo.conf"); 1274 1285 backup_crucial_file(MNT_RESTORING, "/etc/elilo.conf"); 1275 1286 backup_crucial_file(MNT_RESTORING, "/boot/grub/device.map"); 1287 backup_crucial_file(MNT_RESTORING, "/boot/grub2/device.map"); 1276 1288 backup_crucial_file(MNT_RESTORING, "/etc/mtab"); 1277 1289 device = read_cfg_var(MINDI_CACHE"/mondorestore.cfg", "bootloader.device"); … … 1385 1397 char *p = NULL; 1386 1398 1387 int res = 0;1388 1399 bool done; 1400 int res = 0; /* FALSE */ 1401 bool mntlistchg = FALSE; 1402 FILE *fin = NULL; 1389 1403 1390 1404 assert_string_is_neither_NULL_nor_zerolength(bd); … … 1397 1411 0, 1398 1412 "Modifying fstab, mtab, device.map and menu.lst/grub.cfg, and running GRUB... "); 1413 /* Did we changed the mountlist ? If yes, then force editing conf files */ 1414 if ((fin = fopen(MONDO_MNTLISTCHG, "r")) != NULL) { 1415 mntlistchg = TRUE; 1416 } 1399 1417 for (done = FALSE; !done;) { 1400 1418 p = popup_and_get_string("Boot device", "Please confirm/enter the boot device. If in doubt, try /dev/hda", boot_device); … … 1406 1424 continue; 1407 1425 } 1408 mr_asprintf(command, "stabgrub-me %s", p); 1409 mr_free(p); 1410 1411 res = run_program_and_log_output(command, 1); 1412 mr_free(command); 1413 1414 if (res) { 1426 /* Only try to adapt grub here first if the mountlist wasn't changed before */ 1427 if (! mntlistchg) { 1428 mr_asprintf(command, "stabgrub-me %s", p); 1429 mr_free(p); 1430 1431 res = run_program_and_log_output(command, 1); 1432 mr_free(command); 1433 } 1434 1435 if ((res) || (mntlistchg)){ 1415 1436 popup_and_OK 1416 1437 ("GRUB installation failed. You will now edit fstab, mtab, device.map and menu.lst/grub.cfg in order to fix grub install"); 1438 } else { 1439 popup_and_OK("The mountlist was changed. You will now edit fstab, mtab, device.map and menu.lst/grub.cfg in order to fix grub install"); 1440 } 1417 1441 if (!g_text_mode) { 1418 1442 newtSuspend(); … … 1426 1450 } else if (does_file_exist(MNT_RESTORING"/boot/grub/grub.cfg")) { 1427 1451 sprintf(tmp, "chroot %s %s /boot/grub/grub.cfg", MNT_RESTORING, editor); 1452 } else if (does_file_exist(MNT_RESTORING"/boot/grub2/grub.cfg")) { 1453 sprintf(tmp, "chroot %s %s /boot/grub2/grub.cfg", MNT_RESTORING, editor); 1428 1454 } 1429 1455 paranoid_system(tmp); 1430 sprintf(tmp, "chroot %s %s /boot/grub/device.map", MNT_RESTORING, editor); 1456 if (does_file_exist(MNT_RESTORING"/boot/grub/device.map")) { 1457 sprintf(tmp, "chroot %s %s /boot/grub/device.map", MNT_RESTORING, editor); 1458 } else if (does_file_exist(MNT_RESTORING"/boot/grub2/device.map")) { 1459 sprintf(tmp, "chroot %s %s /boot/grub2/device.map", MNT_RESTORING, editor); 1460 } 1431 1461 paranoid_system(tmp); 1432 1462 if (!g_text_mode) { … … 1439 1469 ("GRUB installation failed. Please fix the conf files so that a manual install using 'grub-install' or similar command works. You are now chroot()'ed to your restored system. Please type 'exit' when you are done."); 1440 1470 newtSuspend(); 1441 system("chroot " MNT_RESTORING);1471 paranoid_system("chroot " MNT_RESTORING); 1442 1472 newtResume(); 1443 1473 popup_and_OK("Thank you."); … … 1501 1531 ("Because of bugs in GRUB's own installer, GRUB was not installed properly. Please install the boot loader manually now, using this chroot()'ed shell prompt. Type 'exit' when you have finished."); 1502 1532 newtSuspend(); 1503 system("chroot " MNT_RESTORING);1533 paranoid_system("chroot " MNT_RESTORING); 1504 1534 newtResume(); 1505 1535 popup_and_OK("Thank you."); … … 1846 1876 FILE *fout; 1847 1877 char *incoming = NULL; 1878 char *q; 1848 1879 1849 1880 assert_string_is_neither_NULL_nor_zerolength(output_file); … … 1935 1966 "in preparation for the post-restoration reboot.", 1936 1967 "", mountlist->entries); 1937 chdir("/"); 1968 if (chdir("/")) { 1969 // FIXME 1970 } 1938 1971 for (i = 0; 1939 1972 i < 10 … … 2032 2065 /* @} - end restoreUtilityGroup */ 2033 2066 2034 void wait_until_software_raids_are_prepped(char *mdstat_file, 2035 int wait_for_percentage) 2067 void wait_until_software_raids_are_prepped(char *mdstat_file, int wait_for_percentage) 2036 2068 { 2037 2069 struct raidlist_itself *raidlist; 2038 int unfinished_mdstat_devices = 9999, i; 2070 int unfinished_mdstat_devices = 9999; 2071 int i = 0; 2039 2072 char *screen_message = NULL; 2040 2073 … … 2045 2078 while (unfinished_mdstat_devices > 0) { 2046 2079 // FIXME: Prefix '/dev/' should really be dynamic! 2047 if (parse_mdstat( raidlist, "/dev/")) {2080 if (parse_mdstat(MDSTAT_FILE, raidlist, "/dev/")) { 2048 2081 log_to_screen("Sorry, cannot read %s", MDSTAT_FILE); 2049 2082 log_msg(1,"Sorry, cannot read %s", MDSTAT_FILE); 2050 2083 return; 2051 2084 } 2052 for (unfinished_mdstat_devices = i =0; i <= raidlist->entries; i++) {2085 for (unfinished_mdstat_devices = 0; i <= raidlist->entries; i++) { 2053 2086 if (raidlist->el[i].progress < wait_for_percentage) { 2054 2087 unfinished_mdstat_devices++; … … 2067 2100 sleep(2); 2068 2101 // FIXME: Prefix '/dev/' should really be dynamic! 2069 if (parse_mdstat( raidlist, "/dev/")) {2102 if (parse_mdstat(MDSTAT_FILE, raidlist, "/dev/")) { 2070 2103 break; 2071 2104 } -
branches/3.1/mondo/src/mondorestore/mondoprep.h
r2316 r3147 82 82 83 83 84 char *truncate_to_drive_name(c har *partition);84 char *truncate_to_drive_name(const char *partition); 85 85 void create_mountlist_for_drive(struct mountlist_itself *mountlist, 86 86 char *drive_name, -
branches/3.1/mondo/src/mondorestore/mondorestore.c
r2937 r3147 63 63 */ 64 64 bool g_ISO_restore_mode = FALSE; /* are we in Iso Mode? */ 65 66 /* Whether we should fail immediately at first error */ 67 bool g_fail_immediately = FALSE; 65 68 66 69 /** … … 618 621 ("Label/Identify your ext2/ext3/ext4 partitions if necessary?")) { 619 622 mvaddstr_and_log_it(g_currentY, 0, 620 "Using tune2fs to identify your ext2,3,4 partitions");623 "Using tune2fs/tune4fs to identify your ext2,3,4 partitions"); 621 624 if (does_file_exist("/tmp/fstab.new")) { 622 625 mr_asprintf(fstab_fname, "/tmp/fstab.new"); … … 710 713 711 714 712 /* MONDO - saving your a$$since Feb 18th, 2000 */715 /* MONDO - saving your systems since Feb 18th, 2000 */ 713 716 714 717 … … 730 733 int retval = 0; 731 734 int res = 0; 732 bool boot_loader_installed = FALSE;733 735 char *tmp = NULL; 734 736 char *tmp1 = NULL; … … 829 831 log_msg(1, 830 832 "Great! Boot loader was installed. No need for msg at end."); 831 boot_loader_installed = TRUE;832 833 } 833 834 clean_blkid(); … … 836 837 mvaddstr_and_log_it(g_currentY, 837 838 0, 838 "Using tune2fs to identify your ext2,3partitions");839 "Using tune2fs/tune4fs to identify your ext2,3,4 partitions"); 839 840 840 841 mr_asprintf(tmp, "label-partitions-as-necessary %s < /tmp/fstab >> %s 2>> %s", MINDI_CACHE"/mountlist.txt", MONDO_LOGFILE, MONDO_LOGFILE); … … 1601 1602 1602 1603 if (use_star) { 1603 mr_asprintf(command, "star -x -force-remove - U " STAR_ACL_SZ " errctl=file=%s", tarball_fname);1604 mr_asprintf(command, "star -x -force-remove -sparse -U " STAR_ACL_SZ " file=%s", tarball_fname); 1604 1605 if (strstr(tarball_fname, ".bz2")) { 1605 1606 mr_strcat(command, " -bz"); … … 1639 1640 } 1640 1641 1641 if (g_getfattr) { 1642 log_msg(1, "Setting fattr list %s", xattr_fname); 1643 if (length_of_file(xattr_fname) > 0) { 1644 res = set_fattr_list(filelist_subset_fname, xattr_fname); 1645 if (res) { 1646 log_to_screen("Errors occurred while setting extended attributes"); 1647 } else { 1648 log_msg(1, "I set xattr OK"); 1642 if (! use_star) { 1643 if (g_getfattr) { 1644 log_msg(1, "Setting fattr list %s", xattr_fname); 1645 if (length_of_file(xattr_fname) > 0) { 1646 res = set_fattr_list(filelist_subset_fname, xattr_fname); 1647 if (res) { 1648 log_to_screen("Errors occurred while setting extended attributes"); 1649 } else { 1650 log_msg(1, "I set xattr OK"); 1651 } 1652 retval += res; 1649 1653 } 1650 retval += res; 1651 } 1652 } 1653 if (g_getfacl) { 1654 log_msg(1, "Setting acl list %s", acl_fname); 1655 if (length_of_file(acl_fname) > 0) { 1656 res = set_acl_list(filelist_subset_fname, acl_fname); 1657 if (res) { 1658 log_to_screen 1659 ("Errors occurred while setting access control lists"); 1660 } else { 1661 log_msg(1, "I set ACL OK"); 1654 } 1655 if (g_getfacl) { 1656 log_msg(1, "Setting acl list %s", acl_fname); 1657 if (length_of_file(acl_fname) > 0) { 1658 res = set_acl_list(filelist_subset_fname, acl_fname); 1659 if (res) { 1660 log_to_screen("Errors occurred while setting access control lists"); 1661 } else { 1662 log_msg(1, "I set ACL OK"); 1663 } 1664 retval += res; 1662 1665 } 1663 retval += res; 1664 } 1665 } 1666 if (retval) { 1666 } 1667 } else { 1668 retval = res; 1669 } 1670 // Be verbose for star 1671 if (retval || use_star) { 1667 1672 mr_asprintf(command, "cat %s >> %s", temp_log, MONDO_LOGFILE); 1668 system(command);1673 paranoid_system(command); 1669 1674 paranoid_free(command); 1670 1675 1671 log_msg(2, "Errors occurred while processing fileset #%d", 1672 current_tarball_number); 1676 if (retval) { 1677 log_msg(2, "Errors occurred while processing fileset #%d", current_tarball_number); 1678 } 1673 1679 } else { 1674 1680 log_msg(2, "Fileset #%d processed OK", current_tarball_number); … … 1782 1788 if (strstr(tarball_fname, ".star.")) { 1783 1789 use_star = TRUE; 1784 mr_asprintf(command, "star - t file=%s %s", afio_fname, executable);1790 mr_asprintf(command, "star -sparse -t file=%s %s", afio_fname, executable); 1785 1791 } else { 1786 1792 use_star = FALSE; … … 1816 1822 if (strstr(tarball_fname, ".star.")) { 1817 1823 // star 1818 mr_asprintf(command, "star - x file=%s %s", afio_fname, executable);1824 mr_asprintf(command, "star -sparse -x file=%s %s", afio_fname, executable); 1819 1825 if (filelist) { 1820 1826 mr_strcat(command, " list=%s", filelist_subset_fname); … … 2216 2222 res = read_header_block_from_stream(&biggie_size, biggie_fname, &ctrl_chr); 2217 2223 if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) { 2218 res = 2219 read_EXAT_files_from_tape(&biggie_size, biggie_fname, &ctrl_chr, xattr_fname, acl_fname); 2224 res = read_EXAT_files_from_tape(&biggie_size, biggie_fname, &ctrl_chr, xattr_fname, acl_fname); 2220 2225 } 2221 2226 … … 2354 2359 mr_free(tmp); 2355 2360 2356 chdir(bkpinfo->restore_path); /* I don't know why this is needed _here_ but it seems to be. -HR, 02/04/2002 */ 2361 if (chdir(bkpinfo->restore_path)) { /* I don't know why this is needed _here_ but it seems to be. -HR, 02/04/2002 */ 2362 //FIXME 2363 } 2357 2364 2358 2365 run_program_and_log_output("pwd", 5); … … 2470 2477 log_msg(2, "restore_everything() --- starting"); 2471 2478 g_current_media_number = 1; 2472 getcwd(cwd, MAX_STR_LEN - 1); 2479 if (getcwd(cwd, MAX_STR_LEN - 1)) { 2480 // FIXME 2481 } 2473 2482 mr_asprintf(tmp, "mkdir -p %s", bkpinfo->restore_path); 2474 2483 run_program_and_log_output(tmp, FALSE); … … 2476 2485 2477 2486 log_msg(1, "Changing dir to %s", bkpinfo->restore_path); 2478 chdir(bkpinfo->restore_path); 2479 getcwd(newpath, MAX_STR_LEN - 1); 2487 if (chdir(bkpinfo->restore_path)) { 2488 //FIXME 2489 } 2490 if (getcwd(newpath, MAX_STR_LEN - 1)) { 2491 // FIXME 2492 } 2480 2493 log_msg(1, "path is now %s", newpath); 2481 2494 log_msg(1, "restoring everything"); … … 2511 2524 resB = restore_all_biggiefiles_from_CD(filelist); 2512 2525 } 2513 chdir(cwd); 2526 if (chdir(cwd)) { 2527 //FIXME 2528 } 2514 2529 if (resA + resB) { 2515 2530 log_to_screen("Errors occurred while data was being restored."); … … 2654 2669 if (argc == 2 && strcmp(argv[1], "--edit-mountlist") == 0) { 2655 2670 #ifdef __FreeBSD__ 2656 system("mv -f /tmp/raidconf.txt /etc/raidtab");2671 paranoid_system("mv -f /tmp/raidconf.txt /etc/raidtab"); 2657 2672 if (!does_file_exist("/etc/raidtab")) 2658 system("vinum printconfig > /etc/raidtab");2673 paranoid_system("vinum printconfig > /etc/raidtab"); 2659 2674 #endif 2660 2675 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME); 2661 2676 res = let_user_edit_the_mountlist(mountlist, raidlist); 2662 2677 #ifdef __FreeBSD__ 2663 system("mv -f /etc/raidtab /tmp/raidconf.txt");2678 paranoid_system("mv -f /etc/raidtab /tmp/raidconf.txt"); 2664 2679 #endif 2665 2680 paranoid_MR_finish(res); … … 2734 2749 2735 2750 if (argc == 3 && strcmp(argv[1], "--mdconv") == 0) { 2736 finish(create_raidtab_from_mdstat( argv[2]));2751 finish(create_raidtab_from_mdstat(MDSTAT_FILE,argv[2])); 2737 2752 } 2738 2753 … … 2820 2835 mr_asprintf(tmp, "sshfs -o ro %s /tmp/isodir", bkpinfo->netfs_mount); 2821 2836 } 2822 } else { 2823 if (bkpinfo->netfs_user) { 2824 mr_asprintf(tmp, "mount %s@%s -o nolock,ro /tmp/isodir", bkpinfo->netfs_user,bkpinfo->netfs_mount); 2837 } else { 2838 if (strstr(bkpinfo->netfs_proto, "smbfs")) { 2839 if (bkpinfo->netfs_user) { 2840 mr_asprintf(tmp, "mount -t cifs %s /tmp/isodir -o user=%s,nolock,ro ", bkpinfo->netfs_mount,bkpinfo->netfs_user); 2841 } else { 2842 mr_asprintf(tmp, "mount -t cifs %s /tmp/isodir -o nolock,ro ", bkpinfo->netfs_mount); 2843 } 2825 2844 } else { 2826 mr_asprintf(tmp, "mount %s -o nolock,ro /tmp/isodir", bkpinfo->netfs_mount); 2845 if (bkpinfo->netfs_user) { 2846 mr_asprintf(tmp, "mount %s@%s -o nolock,ro /tmp/isodir", bkpinfo->netfs_user,bkpinfo->netfs_mount); 2847 } else { 2848 mr_asprintf(tmp, "mount %s -o nolock,ro /tmp/isodir", bkpinfo->netfs_mount); 2849 } 2827 2850 } 2828 2851 } … … 2956 2979 if (strstr(bkpinfo->tmpdir,"mondo.tmp.") != NULL) { 2957 2980 mr_asprintf(tmp, "rm -Rf %s", bkpinfo->tmpdir); 2958 system(tmp);2981 paranoid_system(tmp); 2959 2982 mr_free(tmp); 2960 2983 }
Note:
See TracChangeset
for help on using the changeset viewer.
