Changeset 3147 in MondoRescue for branches/3.1/mondo/src/mondorestore


Ignore:
Timestamp:
Jun 19, 2013, 8:34:46 AM (13 years ago)
Author:
Bruno Cornec
Message:
  • First pass on svn merge -r 2935:3146 ../3.0
Location:
branches/3.1/mondo/src/mondorestore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/3.1/mondo/src/mondorestore/mondo-prep.c

    r2937 r3147  
    110110            popup_and_OK
    111111                ("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");
    113113        }
    114114    }
     
    171171
    172172int do_my_funky_lvm_stuff(bool just_erase_existing_volumes,
    173                           bool vacuum_pack)
     173                            bool vacuum_pack)
    174174{
    175     /**  buffers **********************************************/
     175    /** buffers **********************************************/
    176176    char *tmp = NULL;
    177177    char *tmp1 = NULL;
     
    188188    char *p;
    189189    char *q;
     190    char *r;
    190191
    191192    /** int ***************************************************/
     
    442443    /** pointers *********************************************************/
    443444    char *p;
     445    char *q;
    444446
    445447    /** init *************************************************************/
     
    503505        } else {
    504506            strcpy(new_mountlist->el[new_mountlist->entries].device,
    505                   old_mountlist->el[lino].device);
     507                    old_mountlist->el[lino].device);
    506508            strcpy(new_mountlist->el[new_mountlist->entries].mountpoint,
    507                   old_mountlist->el[lino].mountpoint);
     509                    old_mountlist->el[lino].mountpoint);
    508510            strcpy(new_mountlist->el[new_mountlist->entries].format,
    509                   old_mountlist->el[lino].format);
     511                    old_mountlist->el[lino].format);
    510512            new_mountlist->el[new_mountlist->entries].size =
    511513                old_mountlist->el[lino].size;
     
    527529 * @return 0 for success, nonzero for failure.
    528530 */
    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;
     531int 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;
    545542
    546543  malloc_string(bootdevice);
     
    735732            /* format raid partition */
    736733            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);
    738735            if (g_fprep) {
    739736                fprintf(g_fprep, "%s\n", program);
     
    752749
    753750                mr_asprintf(tmp, "vinum init %s", line);
    754                 system(tmp);
     751                paranoid_system(tmp);
    755752                mr_free(tmp);
    756753
     
    781778        log_to_screen("Initializing RAID device %s", device);
    782779
    783 // Shouldn't be necessary.
     780        // Shouldn't be necessary.
    784781        log_to_screen("Stopping %s", device);
    785782        stop_raid_device(device);
     
    789786        log_msg(1, "Making %s", device);
    790787        // 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);
    794791        } else {
    795792            mr_asprintf(program, "mkraid --really-force %s", device);
     
    884881 */
    885882int format_everything(struct mountlist_itself *mountlist, bool interactively,
    886                           struct raidlist_itself *raidlist)
     883                            struct raidlist_itself *raidlist)
    887884{
    888885    /** int **************************************************************/
     
    907904    log_it("format_everything (mountlist, interactively = %s", (interactively) ? "true" : "false");
    908905
    909     mvaddstr_and_log_it(g_currentY, 0, "Formatting partitions     ");
     906    mvaddstr_and_log_it(g_currentY, 0, "Formatting partitions      ");
    910907    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);
    914911
    915912    progress_step =
     
    949946    sleep(2);
    950947// 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);
    955952// do LVMs now
    956953    log_msg(1, "Creating LVMs");
     
    992989            continue;
    993990        } 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)) {
    996993            log_it("Not formatting %s yet - doesn't exist - probably an LVM", me->device);
    997994            continue;
     
    10491046    }
    10501047    newtSuspend();
    1051     system("clear");
     1048    paranoid_system("clear");
    10521049    newtResume();
    10531050    return (retval);
     
    10641061 */
    10651062int make_dummy_partitions(FILE * pout_to_fdisk, char *drivename,
    1066                           int devno_we_must_allow_for)
     1063                            int devno_we_must_allow_for)
    10671064{
    10681065    /** int **************************************************************/
     
    11781175    fprintf(f, "\n\n%u partitions:\n", lp->d_npartitions);
    11791176    fprintf(f,
    1180             "#        size   offset    fstype   [fsize bsize bps/cpg]\n");
     1177            "#        size   offset    fstype   [fsize bsize bps/cpg]\n");
    11811178    pp = lp->d_partitions;
    11821179    for (i = 0; i < lp->d_npartitions; i++, pp++) {
    11831180        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,
    11851182                    (u_long) pp->p_offset);
    11861183            if (pp->p_fstype < FSMAXTYPES)
     
    11911188
    11921189            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,
    11941191                        (u_long) (pp->p_fsize * pp->p_frag), "");
    11951192                break;
    11961193
    11971194            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,
    11991196                        (u_long) (pp->p_fsize * pp->p_frag), pp->p_cpg);
    12001197                break;
    12011198
    12021199            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,
    12041201                        (u_long) (pp->p_fsize * pp->p_frag), pp->p_cpg);
    12051202                break;
     
    12171214            fprintf(f, "- %lu",
    12181215                    (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));
    12211218            if (pp->p_size % lp->d_secpercyl)
    12221219                putc('*', f);
     
    12561253    /*
    12571254     * Nobody in these enligthened days uses the CHS geometry for
    1258      * anything, but nontheless try to get it right.  If we fail
     1255     * anything, but nontheless try to get it right.    If we fail
    12591256     * to get any good ideas from the device, construct something
    12601257     * which is IBM-PC friendly.
     
    13401337                lp->d_partitions[c - 'a'].p_cpg = 64;
    13411338            } else if (!strcasecmp(mountlist->el[idx].format, "raid")
    1342                       || !strcasecmp(mountlist->el[idx].format, "vinum")) {
     1339                        || !strcasecmp(mountlist->el[idx].format, "vinum")) {
    13431340                lp->d_partitions[c - 'a'].p_fstype = FS_VINUM;
    13441341            } else if (!strcmp(mountlist->el[idx].format, "swap")) {
     
    14221419    char *format = NULL;
    14231420    char *tmp = NULL;
     1421    char *tmp1 = NULL;
    14241422    char *tmp1 = NULL;
    14251423
     
    15111509
    15121510        /* 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 */
    15141512
    15151513        log_it("Found partition %s in mountlist", device_str);
     
    15401538                previous_devno =
    15411539                    make_dummy_partitions(pout_to_fdisk, drivename,
    1542                                           current_devno);
     1540                                            current_devno);
    15431541            }
    15441542        }
     
    15951593        sync();
    15961594        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 ------------------");
    15991597        mr_asprintf(tmp, "cat %s >> %s", FDISK_LOG, MONDO_LOGFILE);
    16001598        system(tmp);
     
    16251623 * Create partition number @p partno on @p drive with @p fdisk.
    16261624 * @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).
    16281626 * @param prev_partno The partition number of the most recently prepped partition.
    16291627 * @param format The filesystem type of this partition (used to set the type).
     
    16561654
    16571655    log_it("partition_device('%s', %d, %d, '%s', %lld) --- starting",
    1658           drive, partno, prev_partno, format, partsize);
     1656            drive, partno, prev_partno, format, partsize);
    16591657
    16601658    if (!strncmp(drive, RAID_DEVICE_STUB, strlen(RAID_DEVICE_STUB))) {
     
    17431741            retval =
    17441742                set_partition_type(pout_to_fdisk, drive, partno, format,
    1745                                   partsize);
     1743                                    partsize);
    17461744            if (retval) {
    17471745                log_msg(1, "Failed. Trying again...");
    17481746                retval =
    17491747                    set_partition_type(pout_to_fdisk, drive, partno,
    1750                                       format, partsize);
     1748                                        format, partsize);
    17511749            }
    17521750        }
     
    17831781            retval =
    17841782                set_partition_type(pout_to_fdisk, drive, partno, format,
    1785                                   partsize);
     1783                                    partsize);
    17861784            if (retval) {
    17871785                log_it("Partitioned %s but failed to set its type", partition_name);
     
    18321830    /** buffer *********************************************************/
    18331831    struct list_of_disks *drivelist;
    1834     /*  struct mountlist_itself new_mtlist, *mountlist; */
     1832    /*  struct mountlist_itself new_mtlist, *mountlist; */
    18351833
    18361834    /** end ************************************************************/
     
    18401838
    18411839    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; */
    18441842    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); */
    18471845        log_msg(0,
    18481846                "Mountlist, including the partitions incorporated in RAID devices:-");
     
    18651863
    18661864    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);
    18701868
    18711869    make_list_of_drives_in_mountlist(mountlist, drivelist);
     
    18851883    }
    18861884    newtSuspend();
    1887     system("clear");
     1885    paranoid_system("clear");
    18881886    newtResume();
    18891887    paranoid_free(drivelist);
     
    19061904 */
    19071905int 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)
    19091907{
    19101908    /** buffers *********************************************************/
     
    19391937        }
    19401938    } 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) {
    19461945        mr_asprintf(partcode, "83");
    19471946    } else if (strcmp(format, "minix") == 0) {
     
    19561955        mr_asprintf(partcode, "7");
    19571956    } else if ((strcmp(format, "ufs") == 0)
    1958               || (strcmp(format, "ffs") == 0)) {   /* raid autodetect */
     1957                || (strcmp(format, "ffs") == 0)) { /* raid autodetect */
    19591958        mr_asprintf(partcode, "a5");
    19601959    } else if (strcmp(format, "lvm") == 0) {
     
    21082107    mr_asprintf(program, "vinum stop -f %s", raid_device);
    21092108#else
    2110     // use raidstop if it exists, otherwise use mdadm
    2111     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)) {
    21122111        mr_asprintf(program, "mdadm -S %s", raid_device);
    21132112    } else {
     
    21742173    /** pointers ********************************************************/
    21752174    FILE *fin;
     2175    char *q;
    21762176    int i;
    21772177
     
    22032203                for (p = dev; *p > 32; p++);
    22042204                *p = '\0';
    2205                 res = stop_raid_device(dev);
     2205                retval += stop_raid_device(dev);
    22062206                mr_free(dev);
    22072207            }
     
    22612261    } else if (strcmp(format, "ext4") == 0) {
    22622262        mr_asprintf(program, "mkfs -t ext4 -F -q");
     2263    } else if (strcmp(format, "btrfs") == 0) {
     2264              strcpy(program, "mkfs.btrfs");
    22632265    } else if (strcmp(format, "minix") == 0) {
    22642266        mr_asprintf(program, "mkfs.minix");
     
    22972299 * There are a few problems with this function:
    22982300 * - 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.
    23002302 * - 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).
    23022304 *
    23032305 * @param mountlist The mountlist to use for resizing @p drive_name.
     
    23112313    /** int *************************************************************/
    23122314    int partno, lastpart;
    2313                /** remove driveno, noof_drives stan benoit apr 2002**/
    23142315
    23152316    /** float ***********************************************************/
  • branches/3.1/mondo/src/mondorestore/mondo-rstr-compare.c

    r2704 r3147  
    7171        return (1);
    7272    }
    73     fread((void *) &biggiestruct, 1, sizeof(biggiestruct), fin);
     73    if (fread((void *) &biggiestruct, 1, sizeof(biggiestruct), fin)) {
     74        // FIXME
     75    }
    7476    paranoid_fclose(fin);
    7577
     
    218220    int retval = 0;
    219221    int res;
    220     long noof_lines;
    221222    long archiver_errors;
    222223    bool use_star;
     
    289290    if (use_star) {
    290291        // 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);
    292293    } else {
    293294        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);
     
    308309    if (length_of_file(logfile) > 5) {
    309310        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);
    311312        mr_free(command);
    312313
     
    337338{
    338339    int retval = 0;
    339     int res;
    340340    int current_tarball_number = 0;
    341341
     
    409409            log_to_screen(progress_str);
    410410        } else {
    411             res = compare_a_tarball(tarball_fname, current_tarball_number);
     411            retval += compare_a_tarball(tarball_fname, current_tarball_number);
    412412
    413413            g_current_progress++;
     
    459459    assert(bkpinfo != NULL);
    460460
    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    }
    464470    insist_on_this_cd_number(g_current_media_number);
    465471    unlink(MONDO_CACHE"/changed.txt");
     
    467473    resA = compare_all_tarballs();
    468474    resB = compare_all_biggiefiles();
    469     chdir(cwd);
     475    if (chdir(cwd)) {
     476        // FIXME
     477    }
    470478    noof_changed_files = count_lines_in_file(MONDO_CACHE"/changed.txt");
    471479    if (noof_changed_files) {
     
    594602
    595603            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            }
    599613            popup_changelist_from_file(MONDO_CACHE"/changed.files");
    600             chdir(cwd);
     614            if (chdir(cwd)) {
     615                // FIXME
     616            }
    601617            log_msg(2, "Returning from popup_changelist_from_file()");
    602618        }
     
    634650    assert(bkpinfo != NULL);
    635651    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    }
    638658
    639659    mvaddstr_and_log_it(g_currentY,
     
    647667    }
    648668    res = verify_tape_backups();
    649     chdir(dir);
     669    if (chdir(dir)) {
     670        // FIXME
     671    }
    650672    if (length_of_file(MONDO_CACHE"/changed.txt") > 2
    651673        && length_of_file(MONDO_CACHE"/changed.files") > 2) {
     
    686708    malloc_string(dir);
    687709
    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    }
    690716
    691717    mvaddstr_and_log_it(g_currentY,
    692718                        0, "Verifying archives against filesystem");
    693719    res = verify_tape_backups();
    694     chdir(dir);
     720    if (chdir(dir)) {
     721        // FIXME
     722    }
    695723    if (res) {
    696724        mvaddstr_and_log_it(g_currentY++, 74, "Failed.");
  • branches/3.1/mondo/src/mondorestore/mondo-rstr-newt.c

    r2937 r3147  
    137137    /** int **************************************************************/
    138138    int i = 0;
    139     int num_to_add = 0;
    140139
    141140    /** newt *************************************************************/
     
    233232    mr_asprintf(drive_to_add, "%s", device_str);
    234233    for (i = strlen(drive_to_add); isdigit(drive_to_add[i - 1]); i--);
    235     num_to_add = atoi(drive_to_add + i);
    236234    mr_free(drive_to_add);
    237235
     
    19431941        finish(1);
    19441942    }
    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");
    19471944    i = 4;
    19481945    bAdd = newtCompactButton(i, 17, " Add ");
     
    24232420    newtComponent b2;
    24242421    newtComponent b3;
    2425     newtComponent b_res;
    24262422
    24272423
     
    24342430    myForm = newtForm(NULL, NULL, 0);
    24352431    newtFormAddComponents(myForm, b1, b2, b3, NULL);
    2436     b_res = newtRunForm(myForm);
    24372432    newtFormDestroy(myForm);
    24382433    newtPopWindow();
     
    28862881            mr_getline(tmp, stdin);
    28872882            output = tmp[0];
    2888             free(tmp);
     2883            mr_free(tmp);
    28892884        }
    28902885        return (output);
  • branches/3.1/mondo/src/mondorestore/mondo-rstr-tools.c

    r2937 r3147  
    8080char *incoming = NULL;
    8181char *question = NULL;
     82char *q;
    8283
    8384assert_string_is_neither_NULL_nor_zerolength(infname);
     
    209210if (is_this_device_mounted(g_isodir_device)) {
    210211    log_to_screen("WARNING - isodir is already mounted");
    211     already_mounted = TRUE;
    212212} else {
    213213    mr_asprintf(mount_isodir_command, "mount %s", g_isodir_device);
     
    10821082char *tmp;
    10831083char *tmp1 = NULL;
     1084char *q;
    10841085int res = 0;
    10851086pid_t pid;
     
    10881089malloc_string(tmp);
    10891090
    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    }
    10921097    log_msg(1, "chdir(%s)", bkpinfo->tmpdir);
    10931098    log_to_screen("Extracting filelist and biggielist from media...");
     
    11161121        }
    11171122    }
    1118     chdir(tmp);
     1123    if (chdir(tmp)) {
     1124        // FIXME
     1125    }
    11191126
    11201127    log_msg(2, "Forking");
     
    11471154    unlink(MINDI_CACHE"/filelist.full.gz");
    11481155    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) {
    11531163            res = 1;
    11541164        } else {
    11551165            res = 0;
    11561166        }
    1157         mr_free(tmp1);
     1167        mr_free(q);
    11581168    } else {
    11591169        res = edit_filelist(filelist);
     
    12291239            newtSuspend();
    12301240        }
    1231         (void)system("chroot " MNT_RESTORING);
     1241        paranoid_system("chroot " MNT_RESTORING);
    12321242        if (!g_text_mode) {
    12331243            newtResume();
     
    12711281    backup_crucial_file(MNT_RESTORING, "/boot/grub/menu.lst");
    12721282    backup_crucial_file(MNT_RESTORING, "/boot/grub/grub.cfg");
     1283    backup_crucial_file(MNT_RESTORING, "/boot/grub2/grub.cfg");
    12731284    backup_crucial_file(MNT_RESTORING, "/etc/lilo.conf");
    12741285    backup_crucial_file(MNT_RESTORING, "/etc/elilo.conf");
    12751286    backup_crucial_file(MNT_RESTORING, "/boot/grub/device.map");
     1287    backup_crucial_file(MNT_RESTORING, "/boot/grub2/device.map");
    12761288    backup_crucial_file(MNT_RESTORING, "/etc/mtab");
    12771289    device = read_cfg_var(MINDI_CACHE"/mondorestore.cfg", "bootloader.device");
     
    13851397    char *p = NULL;
    13861398
    1387     int res = 0;
    13881399    bool done;
     1400    int res = 0;        /*  FALSE */
     1401    bool mntlistchg = FALSE;
     1402    FILE *fin = NULL;
    13891403
    13901404    assert_string_is_neither_NULL_nor_zerolength(bd);
     
    13971411                            0,
    13981412                            "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        }
    13991417        for (done = FALSE; !done;) {
    14001418            p = popup_and_get_string("Boot device", "Please confirm/enter the boot device. If in doubt, try /dev/hda", boot_device);
     
    14061424                continue;
    14071425            }
    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)){
    14151436                popup_and_OK
    14161437                    ("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                }
    14171441                if (!g_text_mode) {
    14181442                    newtSuspend();
     
    14261450                } else if (does_file_exist(MNT_RESTORING"/boot/grub/grub.cfg")) {
    14271451                    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);
    14281454                }
    14291455                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                                }
    14311461                paranoid_system(tmp);
    14321462                if (!g_text_mode) {
     
    14391469                        ("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.");
    14401470                    newtSuspend();
    1441                     system("chroot " MNT_RESTORING);
     1471                    paranoid_system("chroot " MNT_RESTORING);
    14421472                    newtResume();
    14431473                    popup_and_OK("Thank you.");
     
    15011531                ("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.");
    15021532            newtSuspend();
    1503             system("chroot " MNT_RESTORING);
     1533            paranoid_system("chroot " MNT_RESTORING);
    15041534            newtResume();
    15051535            popup_and_OK("Thank you.");
     
    18461876    FILE *fout;
    18471877    char *incoming = NULL;
     1878    char *q;
    18481879
    18491880    assert_string_is_neither_NULL_nor_zerolength(output_file);
     
    19351966                       "in preparation for the post-restoration reboot.",
    19361967                       "", mountlist->entries);
    1937     chdir("/");
     1968    if (chdir("/")) {
     1969        // FIXME
     1970    }
    19381971    for (i = 0;
    19391972         i < 10
     
    20322065/* @} - end restoreUtilityGroup */
    20332066
    2034 void wait_until_software_raids_are_prepped(char *mdstat_file,
    2035                                            int wait_for_percentage)
     2067void wait_until_software_raids_are_prepped(char *mdstat_file, int wait_for_percentage)
    20362068{
    20372069    struct raidlist_itself *raidlist;
    2038     int unfinished_mdstat_devices = 9999, i;
     2070    int unfinished_mdstat_devices = 9999;
     2071    int i = 0;
    20392072    char *screen_message = NULL;
    20402073
     
    20452078    while (unfinished_mdstat_devices > 0) {
    20462079            // FIXME: Prefix '/dev/' should really be dynamic!
    2047         if (parse_mdstat(raidlist, "/dev/")) {
     2080        if (parse_mdstat(MDSTAT_FILE, raidlist, "/dev/")) {
    20482081            log_to_screen("Sorry, cannot read %s", MDSTAT_FILE);
    20492082            log_msg(1,"Sorry, cannot read %s", MDSTAT_FILE);
    20502083            return;
    20512084        }
    2052         for (unfinished_mdstat_devices = i = 0; i <= raidlist->entries; i++) {
     2085        for (unfinished_mdstat_devices = 0; i <= raidlist->entries; i++) {
    20532086            if (raidlist->el[i].progress < wait_for_percentage) {
    20542087                unfinished_mdstat_devices++;
     
    20672100                    sleep(2);
    20682101                    // FIXME: Prefix '/dev/' should really be dynamic!
    2069                     if (parse_mdstat(raidlist, "/dev/")) {
     2102                    if (parse_mdstat(MDSTAT_FILE, raidlist, "/dev/")) {
    20702103                        break;
    20712104                    }
  • branches/3.1/mondo/src/mondorestore/mondoprep.h

    r2316 r3147  
    8282
    8383
    84 char *truncate_to_drive_name(char *partition);
     84char *truncate_to_drive_name(const char *partition);
    8585void create_mountlist_for_drive(struct mountlist_itself *mountlist,
    8686                                char *drive_name,
  • branches/3.1/mondo/src/mondorestore/mondorestore.c

    r2937 r3147  
    6363 */
    6464bool g_ISO_restore_mode = FALSE;    /* are we in Iso Mode? */
     65
     66/* Whether we should fail immediately at first error */
     67bool g_fail_immediately = FALSE;
    6568
    6669/**
     
    618621        ("Label/Identify your ext2/ext3/ext4 partitions if necessary?")) {
    619622        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");
    621624        if (does_file_exist("/tmp/fstab.new")) {
    622625            mr_asprintf(fstab_fname, "/tmp/fstab.new");
     
    710713
    711714
    712 /*            MONDO - saving your a$$ since Feb 18th, 2000            */
     715/*            MONDO - saving your systems since Feb 18th, 2000            */
    713716
    714717
     
    730733    int retval = 0;
    731734    int res = 0;
    732     bool boot_loader_installed = FALSE;
    733735    char *tmp = NULL;
    734736    char *tmp1 = NULL;
     
    829831        log_msg(1,
    830832                "Great! Boot loader was installed. No need for msg at end.");
    831         boot_loader_installed = TRUE;
    832833    }
    833834    clean_blkid();
     
    836837    mvaddstr_and_log_it(g_currentY,
    837838                        0,
    838                         "Using tune2fs to identify your ext2,3 partitions");
     839                        "Using tune2fs/tune4fs to identify your ext2,3,4 partitions");
    839840
    840841    mr_asprintf(tmp, "label-partitions-as-necessary %s < /tmp/fstab >> %s 2>> %s", MINDI_CACHE"/mountlist.txt", MONDO_LOGFILE, MONDO_LOGFILE);
     
    16011602
    16021603        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);
    16041605            if (strstr(tarball_fname, ".bz2")) {
    16051606                mr_strcat(command, " -bz");
     
    16391640        }
    16401641
    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;
    16491653                }
    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;
    16621665                }
    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) {
    16671672            mr_asprintf(command, "cat %s >> %s", temp_log, MONDO_LOGFILE);
    1668             system(command);
     1673            paranoid_system(command);
    16691674            paranoid_free(command);
    16701675
    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            }
    16731679        } else {
    16741680            log_msg(2, "Fileset #%d processed OK", current_tarball_number);
     
    17821788        if (strstr(tarball_fname, ".star.")) {
    17831789            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);
    17851791        } else {
    17861792            use_star = FALSE;
     
    18161822    if (strstr(tarball_fname, ".star.")) {
    18171823        // 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);
    18191825        if (filelist) {
    18201826            mr_strcat(command, " list=%s", filelist_subset_fname);
     
    22162222    res = read_header_block_from_stream(&biggie_size, biggie_fname, &ctrl_chr);
    22172223    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);
    22202225    }
    22212226
     
    23542359    mr_free(tmp);
    23552360
    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    }
    23572364
    23582365    run_program_and_log_output("pwd", 5);
     
    24702477    log_msg(2, "restore_everything() --- starting");
    24712478    g_current_media_number = 1;
    2472     getcwd(cwd, MAX_STR_LEN - 1);
     2479    if (getcwd(cwd, MAX_STR_LEN - 1)) {
     2480        // FIXME
     2481    }
    24732482    mr_asprintf(tmp, "mkdir -p %s", bkpinfo->restore_path);
    24742483    run_program_and_log_output(tmp, FALSE);
     
    24762485
    24772486    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    }
    24802493    log_msg(1, "path is now %s", newpath);
    24812494    log_msg(1, "restoring everything");
     
    25112524        resB = restore_all_biggiefiles_from_CD(filelist);
    25122525    }
    2513     chdir(cwd);
     2526    if (chdir(cwd)) {
     2527        //FIXME
     2528    }
    25142529    if (resA + resB) {
    25152530        log_to_screen("Errors occurred while data was being restored.");
     
    26542669    if (argc == 2 && strcmp(argv[1], "--edit-mountlist") == 0) {
    26552670#ifdef __FreeBSD__
    2656         system("mv -f /tmp/raidconf.txt /etc/raidtab");
     2671        paranoid_system("mv -f /tmp/raidconf.txt /etc/raidtab");
    26572672        if (!does_file_exist("/etc/raidtab"))
    2658             system("vinum printconfig > /etc/raidtab");
     2673            paranoid_system("vinum printconfig > /etc/raidtab");
    26592674#endif
    26602675        load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME);
    26612676        res = let_user_edit_the_mountlist(mountlist, raidlist);
    26622677#ifdef __FreeBSD__
    2663         system("mv -f /etc/raidtab /tmp/raidconf.txt");
     2678        paranoid_system("mv -f /etc/raidtab /tmp/raidconf.txt");
    26642679#endif
    26652680        paranoid_MR_finish(res);
     
    27342749
    27352750    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]));
    27372752    }
    27382753
     
    28202835                        mr_asprintf(tmp, "sshfs -o ro %s /tmp/isodir", bkpinfo->netfs_mount);
    28212836                    }
    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                        }
    28252844                    } 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                        }
    28272850                    }
    28282851                }
     
    29562979    if (strstr(bkpinfo->tmpdir,"mondo.tmp.") != NULL) {
    29572980        mr_asprintf(tmp, "rm -Rf %s", bkpinfo->tmpdir);
    2958         system(tmp);
     2981        paranoid_system(tmp);
    29592982        mr_free(tmp);
    29602983    }
Note: See TracChangeset for help on using the changeset viewer.