Changeset 1994 for trunk


Ignore:
Timestamp:
Jun 28, 2008, 12:41:33 AM (11 years ago)
Author:
bruno
Message:

merge content for trunk from old laptop

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/mondo/src/mondorestore/mondo-rstr-tools.c

    r1106 r1994  
    66#include <unistd.h>
    77#include "my-stuff.h"
    8 #include "../common/mondostructures.h"
    9 #include "../common/libmondo.h"
     8#include "mr_mem.h"
     9#include "mr_msg.h"
     10#include "mr_str.h"
     11
     12#include "mondostructures.h"
     13#include "libmondo.h"
    1014#include "mr-externs.h"
    1115#include "mondo-rstr-tools.h"
     
    1317#include <pthread.h>
    1418#endif
    15 #include "mr_mem.h"
    1619
    1720extern bool g_sigpipe_caught;
     
    3639extern char *g_mondo_cfg_file;  // where m*ndo-restore.cfg (the config file) is stored
    3740extern char *g_mountlist_fname; // where mountlist.txt (the mountlist file) is stored
    38 extern char *g_mondo_home;      // homedir of Mondo; usually /usr/local/share/mondo
    39 extern struct s_bkpinfo *g_bkpinfo_DONTUSETHIS;
    4041
    4142extern t_bkptype g_backup_media_type;
     
    6364    mr_free(g_mondo_cfg_file);
    6465    mr_free(g_mountlist_fname);
    65     mr_free(g_mondo_home);
    6666    mr_free(g_tmpfs_mountpt);
    6767    mr_free(g_isodir_device);
     
    254254        mr_free(tmp);
    255255    }
    256     mr_asprintf(&tmp,
    257             "Checking to see if f=%s, file=%s, is in the list of biggiefiles",
     256    mr_msg(2, "Checking to see if f=%s, file=%s, is in the list of biggiefiles",
    258257            f, file);
    259     mr_msg(2, tmp);
    260     mr_free(tmp);
    261 
    262258    mr_asprintf(&command, "grep -E '^%s$' %s", file, list_fname);
    263259    mr_free(file);
     
    299295    read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device);
    300296    if (bkpinfo->disaster_recovery) {
    301 /* Patch Conor Daly 26-june-2004
    302  * Don't let this clobber an existing bkpinfo->isodir */
     297    /* Patch Conor Daly 26-june-2004
     298    * Don't let this clobber an existing bkpinfo->isodir */
    303299        if (!bkpinfo->isodir) {
    304300            mr_allocstr(bkpinfo->isodir, "/tmp/isodir");
     
    328324        }
    329325        run_program_and_log_output("df -m", FALSE);
    330         mr_asprintf(&tmp,
    331                 "The 'mount' command is '%s'. PLEASE report this command to be if you have problems, ok?",
     326        mr_msg(1, "The 'mount' command is '%s'. PLEASE report this command to be if you have problems, ok?",
    332327                mount_isodir_command);
    333         mr_msg(1, tmp);
    334         mr_free(tmp);
    335 
    336328        if (run_program_and_log_output(mount_isodir_command, FALSE)) {
    337329            popup_and_OK
     
    350342    }
    351343    i = what_number_cd_is_this(bkpinfo);    /* has the side-effect of calling mount_cdrom() */
    352     mr_asprintf(&tmp, "%s #%d has been mounted via loopback mount",
     344    mr_msg(1, "%s #%d has been mounted via loopback mount",
    353345            bkpinfo->backup_media_string, i);
    354     mr_msg(1, tmp);
    355     mr_free(tmp);
    356 
    357346    if (i < 0) {
    358347        popup_and_OK
     
    371360void kill_petris(void)
    372361{
    373     char *command;
     362    char *command = NULL;
    374363    mr_asprintf(&command,
    375364            "kill `ps 2> /dev/null | grep petris 2> /dev/null | grep -v grep | cut -d' ' -f2` 2> /dev/null");
     
    394383    int res = 0;
    395384
    396     char *tmp = NULL;
    397385    char *command = NULL;
    398386    char *mountdir = NULL;
    399387    char *mountpoint = NULL;
    400388    char *additional_parameters = NULL;
    401     char *p1 = NULL;
    402     char *p2 = NULL;
    403     char *p3 = NULL;
    404 
     389 
    405390    assert_string_is_neither_NULL_nor_zerolength(device);
    406391    assert_string_is_neither_NULL_nor_zerolength(mpt);
     
    422407        return (0);
    423408    }
    424     mr_asprintf(&tmp, "Mounting device %s   ", device);
    425     mr_msg(1, tmp);
    426 
     409    mr_msg(1, "Mounting device %s   ", device);
    427410    if (writeable) {
    428         mr_asprintf(&p1, "-o rw");
    429     } else {
    430         mr_asprintf(&p1, "-o ro");
    431     }
    432     tmp = find_home_of_exe("setfattr");
    433     if (tmp) {
    434         mr_asprintf(&p2, ",user_xattr");
    435     } else {
    436         mr_asprintf(&p2, "%s", "");
    437     }
    438     mr_free(tmp);
    439 
    440     tmp = find_home_of_exe("setfacl");
    441     if (tmp) {
    442         mr_asprintf(&p3, ",acl");
    443     } else {
    444         mr_asprintf(&p3, "%s", "");
    445     }
    446     mr_free(tmp);
    447 
    448     mr_asprintf(&additional_parameters, "%s%s%s", p1, p2, p3);
    449     mr_free(p1);
    450     mr_free(p2);
    451     mr_free(p3);
     411        mr_asprintf(&additional_parameters, "-o rw");
     412    } else {
     413        mr_asprintf(&additional_parameters, "-o ro");
     414    }
     415    if (find_home_of_exe("setfattr")) {
     416        mr_strcat(additional_parameters, ",user_xattr");
     417    }
     418    if (find_home_of_exe("setfacl")) {
     419        mr_strcat(additional_parameters, ",acl");
     420    }
    452421
    453422    if (!strcmp(mountpoint, "swap")) {
     
    483452        mr_msg(1, "command was '%s'", command);
    484453        if (!strcmp(mountpoint, "swap")) {
    485             log_to_screen(tmp);
     454            log_to_screen("Unable to mount device %s (type %s) at %s", device,
     455                format, mountdir);
    486456        } else {
    487457            mr_msg(2, "Retrying w/o the '-t' switch");
     
    500470        }
    501471    }
    502     mr_free(tmp);
    503472    mr_free(command);
    504473    mr_free(mountdir);
     
    516485 *END_MOUNT_DEVICE                                                        *
    517486 **************************************************************************/
    518 
    519487
    520488
     
    553521                    "Again with the /proc - why is this in your mountlist?");
    554522        } else if (is_this_device_mounted(mountlist->el[lino].device)) {
    555             mr_asprintf(&tmp, _("%s is already mounted"),
     523            log_to_screen(_("%s is already mounted"),
    556524                    mountlist->el[lino].device);
    557             log_to_screen(tmp);
    558             mr_free(tmp);
    559525        } else if (strcmp(mountlist->el[lino].mountpoint, "none")
    560526                   && strcmp(mountlist->el[lino].mountpoint, "lvm")
     
    576542            if (res) {
    577543                if (these_failed != NULL) { /* not the first time */
    578                     mr_asprintf(&tmp, "%s %s", these_failed, mountlist->el[lino].device);
    579                     mr_free(these_failed);
    580                     these_failed = tmp;
     544                    mr_strcat(these_failed, " %s", mountlist->el[lino].device);
    581545                } else { /* The first time */
    582                     mr_asprintf(&these_failed, "%s ", mountlist->el[lino].device);
     546                    mr_asprintf(&these_failed, "%s", mountlist->el[lino].device);
    583547                }
    584548            }
     
    620584    }
    621585    run_program_and_log_output("df -m", 3);
    622     mr_free((void*) mountlist);
     586    mr_free(mountlist);
    623587    return (retval);
    624588}
     
    640604{
    641605    char *mount_cmd = NULL;
    642     int i, res;
     606    int i = 0, res = 0;
    643607#ifdef __FreeBSD__
    644608    char *mddev = NULL;
     
    895859            mr_free(value);
    896860
    897             mr_asprintf(&tmp, "Backup medium is TAPE --- dev=%s",
     861            mr_msg(2, "Backup medium is TAPE --- dev=%s",
    898862                    bkpinfo->media_device);
    899             mr_msg(2, tmp);
    900             mr_free(tmp);
    901863        } else {
    902864            mr_allocstr(bkpinfo->media_device, "/dev/cdrom");
     
    990952
    991953    read_cfg_var(g_mondo_cfg_file, "please-dont-eject", tmp);
    992 #ifdef __FreeBSD__
    993     tmp1 = call_program_and_get_last_line_of_output("cat /tmp/cmdline");
    994 #else
    995954    tmp1 = call_program_and_get_last_line_of_output("cat /proc/cmdline");
    996 #endif
    997955    if ((tmp != NULL) || strstr(tmp1,"donteject")) {
    998956        bkpinfo->please_dont_eject = TRUE;
     
    10881046                    mr_free(iso_mnt);
    10891047                    mr_free(iso_path);
    1090                     mr_asprintf(&iso_mnt, "%s", "");
    1091                     mr_asprintf(&iso_path, "%s", "");
    1092 
     1048                    mr_asprintf(&iso_mnt, "");
     1049                    mr_asprintf(&iso_path, "");
    10931050                    if (mount_cdrom(bkpinfo)) {
    10941051                        fatal_error
     
    11191076                media_specified_by_user = bkpinfo->backup_media_type;
    11201077                get_cfg_file_from_archive(bkpinfo);
    1121 /*
    1122               if (media_specified_by_user != cdr && media_specified_by_user == cdrw)
    1123                 { g_restoring_live_from_cd = FALSE; }
    1124 */
    11251078            }
    11261079        }
     
    11501103s_node *process_filelist_and_biggielist(struct s_bkpinfo *bkpinfo)
    11511104{
    1152     struct s_node *filelist;
     1105    struct s_node *filelist = NULL;
    11531106
    11541107    char *command = NULL;
     
    12521205        mr_msg(1, "Warning - %s does not exist", g_filelist_full);
    12531206    }
    1254 //  popup_and_OK("Wonderful.");
    12551207
    12561208    mr_msg(2, "Forking");
     
    12621214
    12631215    case 0:
    1264         log_to_screen(("Pre-processing filelist"));
     1216        log_to_screen(_("Pre-processing filelist"));
    12651217        if (!does_file_exist(g_biggielist_txt)) {
    12661218            mr_asprintf(&command, "> %s", g_biggielist_txt);
     
    12681220            mr_free(command);
    12691221        }
    1270         mr_asprintf(&command, "grep  -E '^/dev/.*$' %s > %s",
     1222        mr_asprintf(&command, "grep -E '^/dev/.*' %s > %s",
    12711223                g_biggielist_txt, g_filelist_imagedevs);
    12721224        paranoid_system(command);
     
    13561308int run_boot_loader(bool offer_to_hack_scripts)
    13571309{
    1358     int res;
     1310    int res = 0;
    13591311    int retval = 0;
    13601312
     
    13691321    read_cfg_var(g_mondo_cfg_file, "bootloader.device", device);
    13701322    read_cfg_var(g_mondo_cfg_file, "bootloader.name", name);
    1371     mr_asprintf(&tmp, "run_boot_loader: device='%s', name='%s'", device, name);
    1372     mr_msg(2, tmp);
    1373     mr_free(tmp);
    1374 
     1323    mr_msg(2, "run_boot_loader: device='%s', name='%s'", device, name);
    13751324    sync();
    13761325    if (!strcmp(name, "LILO")) {
     
    13791328        res = run_elilo(offer_to_hack_scripts);
    13801329    } else if (!strcmp(name, "GRUB")) {
    1381 //      if ( does_file_exist(DO_MBR_PLEASE) || (offer_to_hack_scripts && ask_me_yes_or_no("Because of bugs in GRUB, you're much better off running mondorestore --mbr after this program terminates. Are you sure you want to install GRUB right now?")))
    1382 //        {
    13831330        res = run_grub(offer_to_hack_scripts, device);
    1384 //    unlink(DO_MBR_PLEASE);
    1385 //  }
    1386 //      else
    1387 //        {
    1388 //    mr_msg(1, "Not running run_grub(). Was a bad idea anyway.");
    1389 //    res = 1;
    1390 //  }
    13911331    } else if (!strcmp(name, "RAW")) {
    13921332        res = run_raw_mbr(offer_to_hack_scripts, device);
     
    14871427
    14881428    assert_string_is_neither_NULL_nor_zerolength(bd);
     1429    editor = find_my_editor();
    14891430
    14901431    if (offer_to_run_stabgrub
     
    15181459                newtSuspend();
    15191460            }
    1520             editor = find_my_editor();
    15211461            mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
    15221462            paranoid_system(tmp);
     
    15241464
    15251465            mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/grub.conf", editor);
    1526             mr_free(editor);
    1527 
    15281466            paranoid_system(tmp);
    15291467            mr_free(tmp);
     
    15781516        mvaddstr_and_log_it(g_currentY++, 74, _("Done."));
    15791517    }
     1518    mr_free(editor);
    15801519    return (res);
    15811520}
     
    15991538    int done = 0;
    16001539
     1540    editor = find_my_editor();
    16011541    if (offer_to_run_stabelilo
    16021542        && ask_me_yes_or_no(_("Did you change the mountlist?")))
     
    16201560                    newtSuspend();
    16211561                }
    1622                 editor = find_my_editor();
    16231562                mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
    16241563                paranoid_system(tmp);
     
    16261565
    16271566                mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/elilo.conf", editor);
    1628                 mr_free(editor);
    1629 
    16301567                paranoid_system(tmp);
    16311568                mr_free(tmp);
     
    16481585        res = TRUE;
    16491586    }
     1587    mr_free(editor);
    16501588    return (res);
    16511589}
     
    16761614    }
    16771615
     1616    editor = find_my_editor();
    16781617    if (offer_to_run_stablilo
    16791618        && ask_me_yes_or_no(_("Did you change the mountlist?"))) {
     
    16951634                    newtSuspend();
    16961635                }
    1697                 editor = find_my_editor();
    16981636                mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
    16991637                paranoid_system(tmp);
     
    17011639
    17021640                mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/lilo.conf", editor);
    1703                 mr_free(editor);
    1704 
    17051641                paranoid_system(tmp);
    17061642                mr_free(tmp);
     
    17091645                    newtResume();
    17101646                }
    1711 //              newtCls();
    17121647                if (ask_me_yes_or_no(_("Edit them again?"))) {
    17131648                    continue;
     
    17611696                                   " lilo -M /dev/sda", 3);
    17621697    }
     1698    mr_free(editor);
    17631699    return (res);
    17641700}
     
    17851721    assert_string_is_neither_NULL_nor_zerolength(bd);
    17861722
     1723    editor = find_my_editor();
    17871724    if (offer_to_hack_scripts
    17881725        && ask_me_yes_or_no(_("Did you change the mountlist?"))) {
     
    17971734                    newtSuspend();
    17981735                }
    1799                 editor = find_my_editor();
    18001736                mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
    1801                 mr_free(editor);
    1802 
    18031737                paranoid_system(tmp);
    18041738                mr_free(tmp);
     
    18071741                    newtResume();
    18081742                }
    1809 //              newtCls();
    18101743            }
    18111744            popup_and_get_string(_("Boot device"),
    1812                                  _
    1813                                  ("Please confirm/enter the boot device. If in doubt, try /dev/hda"), bd);
     1745                                 _("Please confirm/enter the boot device. If in doubt, try /dev/hda"), bd);
    18141746            mr_asprintf(&command, "stabraw-me %s", bd);
    18151747            res = run_program_and_log_output(command, 3);
     
    18261758        /* nuke mode */
    18271759        mvaddstr_and_log_it(g_currentY, 0,
    1828                             _
    1829                             ("Restoring MBR...                                               "));
     1760                            _("Restoring MBR...                                               "));
    18301761        mr_asprintf(&command, "raw-MR %s /tmp/mountlist.txt", bd);
    18311762        mr_msg(2, "run_raw_mbr() --- command='%s'", command);
     
    18411772        mvaddstr_and_log_it(g_currentY++, 74, _("Done."));
    18421773    }
     1774    mr_free(editor);
    18431775    return (res);
    18441776}
     
    19541886{
    19551887    log_to_screen
    1956         (_
    1957          ("Mondorestore is terminating in response to a signal from the OS"));
     1888        (_("Mondorestore is terminating in response to a signal from the OS"));
    19581889    paranoid_MR_finish(254);
    19591890}
     
    20922023            mr_free(command);
    20932024        } else {
    2094             mr_asprintf(&tmp1, "%s%s", tmp, _("...not mounted anyway :-) OK"));
    2095             mr_free(tmp);
    2096             tmp = tmp1;
     2025            mr_strcat(tmp, _("...not mounted anyway :-) OK"));
    20972026            res = 0;
    20982027        }
    20992028        g_current_progress++;
    21002029        if (res) {
    2101             mr_asprintf(&tmp1, "%s%s", tmp, _("...Failed"));
    2102             mr_free(tmp);
    2103             tmp = tmp1;
     2030            mr_strcat(tmp, _("...Failed"));
    21042031            retval++;
    21052032            log_to_screen(tmp);
     
    21202047        log_to_screen(_("All partitions were unmounted OK."));
    21212048    }
    2122     mr_free((void*) mountlist);
     2049    mr_free(mountlist);
    21232050    return (retval);
    21242051}
     
    21822109    int res = 0;
    21832110
    2184     bool try_plan_B;
     2111    bool try_plan_B = FALSE;
    21852112
    21862113    assert(bkpinfo != NULL);
     
    22352162        mr_msg(2,
    22362163                "Mounted floppy OK but I don't trust it because the archives might contain more up-to-date config file than the floppy does.");
    2237 // NB: If busybox does not support 'mount -o loop' then Plan A WILL NOT WORK.
     2164        // NB: If busybox does not support 'mount -o loop' then Plan A WILL NOT WORK.
    22382165        mr_msg(2, "Processing floppy (plan A?)");
    22392166        mr_asprintf(&ramdisk_fname, "%s/mindi.rdz", mountpt);
     
    23552282        mr_free(command);
    23562283
    2357         mr_asprintf(&command, "cp -f %s/%s %s",tmp1,
     2284        mr_asprintf(&command, "cp -f %s/%s %s",
     2285                tmp1,
    23582286                MOUNTLIST_FNAME_STUB, mountlist_file);
    23592287        mr_free(tmp1);
     
    24052333    mr_asprintf(&command, "cp -f %s /%s", cfg_file, MONDO_CFG_FILE_STUB);
    24062334    mr_free(cfg_file);
    2407 
    24082335    run_program_and_log_output(command, FALSE);
    24092336    mr_free(command);
     
    24112338    mr_asprintf(&command, "cp -f %s /%s", mountlist_file, MOUNTLIST_FNAME_STUB);
    24122339    mr_free(mountlist_file);
    2413 
    24142340    run_program_and_log_output(command, FALSE);
    24152341    mr_free(command);
     
    24512377            return;
    24522378        }
    2453         for (unfinished_mdstat_devices = i = 0; i <= raidlist->entries;
    2454              i++) {
     2379        for (unfinished_mdstat_devices = i = 0; i <= raidlist->entries; i++) {
    24552380            if (raidlist->el[i].progress < wait_for_percentage) {
    24562381                unfinished_mdstat_devices++;
Note: See TracChangeset for help on using the changeset viewer.