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


Ignore:
Timestamp:
Jun 25, 2013, 10:53:14 PM (11 years ago)
Author:
Bruno Cornec
Message:
  • Apply fixes to 3.1 tree so that at least mondo compiles again (but that branch probably doesn't work at all again).
Location:
branches/3.1/mondo/src/mondorestore
Files:
5 edited

Legend:

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

    r3148 r3161  
    188188    char *p;
    189189    char *q;
    190     char *r;
    191190
    192191    /** int ***************************************************/
     
    391390        }
    392391        mr_asprintf(tmp1, "echo \"%s\" >> /tmp/out.sh", command);
    393         system(tmp1);
     392        if (system(tmp1)) {
     393            //FIXME
     394        }
    394395        mr_free(tmp1);
    395396        sleep(1);
     
    443444    /** pointers *********************************************************/
    444445    char *p;
    445     char *q;
    446446
    447447    /** init *************************************************************/
     
    533533    int i   = 0;
    534534    int j   = 0;
    535     int v   = 0;
    536535    int res = 0;
    537536   
     
    540539    char *level   = NULL;
    541540    char *program = NULL;
    542 
    543   malloc_string(bootdevice);
    544   malloc_string(name);
    545  
     541    char *strtmp = NULL;
     542    char *oldmd = NULL;
     543
    546544  // leave straight away if raidlist is initial or has no entries
    547545  if (!raidlist || raidlist->entries == 0) {
     
    587585  // - faulty devices ignored
    588586  // - persistent superblock always used as this is recommended
    589   // As per bug #473, the parameter "-e 0.90" is used only when:
    590   //   1) It detects that system boots from Raid-1
    591   //   2) grub bootloader < v1 is used.
    592   // Otherwise it won't boot which is bad.
    593     read_cfg_var(g_mondo_cfg_file, "bootloader.device", bootdevice);
    594     read_cfg_var(g_mondo_cfg_file, "bootloader.name", name);
    595     if (strcmp(name,"GRUB") == 0) {
    596         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("grub --version"));
    597         if ((strstr(tmp, "GRUB 0.9") != NULL) && (strcmp(raidlist->el[i].raid_device,device) == 0)) {
    598             mr_free(oldmd);
    599             mr_asprintf(oldmd, "-e 0.90");
    600             log_it("Forcing old metadata 0.90 for md on %s for old GRUB", device);
    601         }
    602     } else if ((strcmp(name,"LILO") == 0) && (strcmp(raidlist->el[i].raid_device,device) == 0)) {
    603         mr_free(oldmd);
    604         mr_asprintf(oldmd, "-e 0.90");
    605         log_it("Forcing old metadata 0.90 for md on %s for LILO", device);
    606     } else {
    607         mr_asprintf(oldmd, "");
    608     }
    609     mr_free(device);
    610     mr_free(name);
    611587
    612588  mr_asprintf(program, "mdadm --create --force --run --auto=yes %s --level=%s --raid-devices=%d %s", raidlist->el[i].raid_device, level, raidlist->el[i].data_disks.entries, oldmd);
     
    632608      break;
    633609    }
    634     paranoid_free(strtmp);
     610    mr_free(strtmp);
    635611  }
    636612  if (raidlist->el[i].chunk_size != -1) {
     
    10391015                sync();
    10401016                sync();
    1041                 system("reboot");
     1017                if (system("reboot")) {
     1018                    // FIXME
     1019                }
    10421020            }
    10431021        } else {
     
    14201398    char *tmp = NULL;
    14211399    char *tmp1 = NULL;
    1422     char *tmp1 = NULL;
    1423     char *tmp1 = NULL;
    14241400
    14251401    /** end *************************************************************/
     
    15941570        sync();
    15951571        paranoid_pclose(pout_to_fdisk);
    1596         paranoid_system("sync");
     1572        sync();
    15971573        log_msg(0,"------------------- fdisk.log looks like this ------------------");
    15981574        mr_asprintf(tmp, "cat %s >> %s", FDISK_LOG, MONDO_LOGFILE);
    1599         system(tmp);
     1575        if (system(tmp)) {
     1576            // FIXME
     1577        }
    16001578        mr_free(tmp);
    16011579
     
    16451623
    16461624    /** pointers **********************************************************/
    1647     char *p;
    16481625    char *part_table_fmt = NULL;
    16491626    FILE *fout;
     
    16761653        return (1);
    16771654    }
    1678 
    1679 
    1680     p = (char *) strrchr(partition_name, '/');
    16811655
    16821656    /* BERLIOS: should not be called each time */
     
    19161890
    19171891    /** pointers *********************************************************/
    1918     char *p;
    19191892    FILE *fout;
    19201893
     
    19281901
    19291902    partition = build_partition_name(drive, partno);
    1930     p = (char *) strrchr(partition, '/');
    19311903    if (strcmp(format, "swap") == 0) {
    19321904        mr_asprintf(partcode, "82");
     
    21692141    char *dev;
    21702142    char *p;
    2171     int res;
    21722143#endif
    21732144
    21742145    /** pointers ********************************************************/
    21752146    FILE *fin;
    2176     char *q;
    21772147    int i;
    21782148
     
    22332203char *which_format_command_do_i_need(char *format)
    22342204{
    2235     /** int *************************************************************/
    2236     int res = 0;
    2237 
    22382205    /** buffers *********************************************************/
    22392206    char *program = NULL;
     
    22922259#endif
    22932260        log_it("Unknown format (%s) - assuming '%s' will do", format, program);
    2294         res = 0;
    22952261    }
    22962262    return (program);
     
    23202286    float factor;
    23212287    long long new_size;
     2288    char *tmp = NULL;
    23222289
    23232290    /** long *************************************************************/
  • branches/3.1/mondo/src/mondorestore/mondo-rstr-compare.c

    r3147 r3161  
    228228    char *archiver_exe = NULL;
    229229    char *tmp1 = NULL;
    230     char *filelist_name = NULL;
    231230    char *logfile = NULL;
    232231    char *compressor_exe = NULL;
     
    234233    use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE;
    235234    assert_string_is_neither_NULL_nor_zerolength(tarball_fname);
    236     mr_asprintf(filelist_name, MNT_CDROM "/archives/filelist.%d", current_tarball_number);
    237     noof_lines = count_lines_in_file(filelist_name);
    238     mr_free(filelist_name);
    239235
    240236    if (strstr(tarball_fname, ".bz2")) {
  • branches/3.1/mondo/src/mondorestore/mondo-rstr-newt.c

    r3147 r3161  
    531531    assert(raidrec != NULL);
    532532
    533     system("grep Pers /proc/mdstat > /tmp/raid-personalities.txt 2> /dev/null");
     533    if (system("grep Pers /proc/mdstat > /tmp/raid-personalities.txt 2> /dev/null")) {
     534        // FIXME
     535    }
    534536    personalities = last_line_of_file("/tmp/raid-personalities.txt");
    535537    mr_asprintf(prompt, "Please enter the RAID level you want. %s", personalities);
     
    22722274    char *q = NULL;
    22732275    char *r = NULL;
    2274     char *s = NULL;
    22752276    char *idev = NULL;
    22762277    bool ret = FALSE;       /* Should be false by default, and modfiy if conditions respected */
  • branches/3.1/mondo/src/mondorestore/mondo-rstr-tools.c

    r3148 r3161  
    8080char *incoming = NULL;
    8181char *question = NULL;
    82 char *q;
    83 char *q;
    8482
    8583assert_string_is_neither_NULL_nor_zerolength(infname);
     
    182180    char *mds = NULL;
    183181    int retval = 0, i;
    184     bool already_mounted = FALSE;
    185182    char *isodir_format = NULL;
    186183
     
    553550    mr_free(command);
    554551
    555     chdir(bkpinfo->tmpdir);
     552    if (chdir(bkpinfo->tmpdir)) {
     553        //FIXME
     554    }
    556555
    557556    mr_free(mountpt);
     
    576575        if (try_plan_B) {
    577576            log_msg(2, "gcffa --- OK, switching to Plan B");
    578             chdir(bkpinfo->tmpdir);
     577            if (chdir(bkpinfo->tmpdir)) {
     578                // FIXME
     579            }
    579580            run_program_and_log_output("mkdir -p tmp", FALSE);
    580581
     
    10821083char *command = NULL;
    10831084char *tmp;
    1084 char *tmp1 = NULL;
    10851085char *q;
    10861086int res = 0;
     
    14021402    bool mntlistchg = FALSE;
    14031403    FILE *fin = NULL;
    1404     bool mntlistchg = FALSE;
    1405     FILE *fin = NULL;
    14061404
    14071405    assert_string_is_neither_NULL_nor_zerolength(bd);
     
    14361434            }
    14371435
    1438             if ((res) || (mntlistchg)){
    1439                 popup_and_OK
    1440                     ("GRUB installation failed. You will now edit fstab, mtab, device.map and menu.lst/grub.cfg in order to fix grub install");
    1441                 } else {
    1442                     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");
    1443                 }
    1444                 if (!g_text_mode) {
    1445                     newtSuspend();
    1446                 }
    1447                 sprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor);
    1448                 paranoid_system(tmp);
    1449                 sprintf(tmp, "chroot %s %s /etc/mtab", MNT_RESTORING, editor);
    1450                 paranoid_system(tmp);
    1451                 if (does_file_exist(MNT_RESTORING"/boot/grub/menu.lst")) {
    1452                     sprintf(tmp, "chroot %s %s /boot/grub/menu.lst", MNT_RESTORING, editor);
    1453                 } else if (does_file_exist(MNT_RESTORING"/boot/grub/grub.cfg")) {
    1454                     sprintf(tmp, "chroot %s %s /boot/grub/grub.cfg", MNT_RESTORING, editor);
    1455                 } else if (does_file_exist(MNT_RESTORING"/boot/grub2/grub.cfg")) {
    1456                     sprintf(tmp, "chroot %s %s /boot/grub2/grub.cfg", MNT_RESTORING, editor);
    1457                 }
    1458                 paranoid_system(tmp);
    1459                 if (does_file_exist(MNT_RESTORING"/boot/grub/device.map")) {
    1460                     sprintf(tmp, "chroot %s %s /boot/grub/device.map", MNT_RESTORING, editor);
    1461                 } else if (does_file_exist(MNT_RESTORING"/boot/grub2/device.map")) {
    1462                     sprintf(tmp, "chroot %s %s /boot/grub2/device.map", MNT_RESTORING, editor);
    1463                                 }
    1464                 paranoid_system(tmp);
    1465                 if (!g_text_mode) {
    1466                     newtResume();
    1467                 }
    1468                 sprintf(command, "stabgrub-me %s", boot_device);
    1469                 res = run_program_and_log_output(command, 1);
    1470                 if (res) {
    1471                     popup_and_OK
    1472                         ("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.");
    1473                     newtSuspend();
    1474                     paranoid_system("chroot " MNT_RESTORING);
    1475                     newtResume();
    1476                     popup_and_OK("Thank you.");
    1477                 } else {
    1478                     popup_and_OK("GRUB is now installed correctly");
    1479                     done = TRUE;
    1480                 }
     1436            if ((res) || (mntlistchg)) {
     1437                popup_and_OK("GRUB installation failed. You will now edit fstab, mtab, device.map and menu.lst/grub.cfg in order to fix grub install");
    14811438            } 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            }
     1441            if (!g_text_mode) {
     1442                newtSuspend();
     1443            }
     1444            mr_asprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor);
     1445            paranoid_system(tmp);
     1446            mr_free(tmp);
     1447
     1448            mr_asprintf(tmp, "chroot %s %s /etc/mtab", MNT_RESTORING, editor);
     1449            paranoid_system(tmp);
     1450            mr_free(tmp);
     1451
     1452            if (does_file_exist(MNT_RESTORING"/boot/grub/menu.lst")) {
     1453                mr_asprintf(tmp, "chroot %s %s /boot/grub/menu.lst", MNT_RESTORING, editor);
     1454            } else if (does_file_exist(MNT_RESTORING"/boot/grub/grub.cfg")) {
     1455                mr_asprintf(tmp, "chroot %s %s /boot/grub/grub.cfg", MNT_RESTORING, editor);
     1456            } else if (does_file_exist(MNT_RESTORING"/boot/grub2/grub.cfg")) {
     1457                mr_asprintf(tmp, "chroot %s %s /boot/grub2/grub.cfg", MNT_RESTORING, editor);
     1458            }
     1459            paranoid_system(tmp);
     1460            mr_free(tmp);
     1461
     1462            if (does_file_exist(MNT_RESTORING"/boot/grub/device.map")) {
     1463                mr_asprintf(tmp, "chroot %s %s /boot/grub/device.map", MNT_RESTORING, editor);
     1464            } else if (does_file_exist(MNT_RESTORING"/boot/grub2/device.map")) {
     1465                mr_asprintf(tmp, "chroot %s %s /boot/grub2/device.map", MNT_RESTORING, editor);
     1466            }
     1467            paranoid_system(tmp);
     1468            mr_free(tmp);
     1469
     1470            if (!g_text_mode) {
     1471                newtResume();
     1472            }
     1473            mr_asprintf(command, "stabgrub-me %s", boot_device);
     1474            res = run_program_and_log_output(command, 1);
     1475            mr_free(command);
     1476            if (res) {
     1477                popup_and_OK("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.");
     1478                newtSuspend();
     1479                paranoid_system("chroot " MNT_RESTORING);
     1480                newtResume();
     1481                popup_and_OK("Thank you.");
     1482            } else {
     1483                popup_and_OK("GRUB is now installed correctly");
    14821484                done = TRUE;
    14831485            }
     
    18791881    FILE *fout;
    18801882    char *incoming = NULL;
    1881     char *q;
    1882     char *q;
    18831883
    18841884    assert_string_is_neither_NULL_nor_zerolength(output_file);
  • branches/3.1/mondo/src/mondorestore/mondorestore.c

    r3147 r3161  
    12301230
    12311231    if (strcmp(outfile_fname, "/dev/null")) {
    1232         chown(outfile_fname, biggiestruct.properties.st_uid, biggiestruct.properties.st_gid);
     1232        if (chown(outfile_fname, biggiestruct.properties.st_uid, biggiestruct.properties.st_gid)) {
     1233            // FIXME
     1234        }
    12331235        chmod(outfile_fname, biggiestruct.properties.st_mode);
    12341236        ubuf->actime = biggiestruct.properties.st_atime;
     
    14751477    if (strcmp(outfile_fname, "/dev/null")) {
    14761478        chmod(outfile_fname, biggiestruct.properties.st_mode);
    1477         chown(outfile_fname, biggiestruct.properties.st_uid, biggiestruct.properties.st_gid);
     1479        if (chown(outfile_fname, biggiestruct.properties.st_uid, biggiestruct.properties.st_gid)) {
     1480            // FIXME
     1481        }
    14781482        ubuf->actime = biggiestruct.properties.st_atime;
    14791483        ubuf->modtime = biggiestruct.properties.st_mtime;
Note: See TracChangeset for help on using the changeset viewer.