Ignore:
Timestamp:
Sep 24, 2007, 3:04:43 AM (12 years ago)
Author:
Bruno Cornec
Message:

Render bkpinfo global (potential issue on thread, but should not be a problem as that structure is indeed static during archive)
Should solve the tmpdir issue from previous rev.
May still not compile

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.5/mondo/src/mondorestore/mondo-restore.c

    r1644 r1645  
    2424extern void twenty_seconds_til_yikes(void);
    2525
     26/* Reference to global bkpinfo */
     27struct s_bkpinfo *bkpinfo;
     28
    2629
    2730/* For use in other programs (ex. XMondo) */
     
    153156 * @ingroup restoreGuiGroup
    154157 */
    155 int let_user_edit_the_mountlist(struct s_bkpinfo *bkpinfo,
    156                                 struct mountlist_itself *mountlist,
     158int let_user_edit_the_mountlist(struct mountlist_itself *mountlist,
    157159                                struct raidlist_itself *raidlist)
    158160{
     
    259261 */
    260262int
    261 catchall_mode(struct s_bkpinfo *bkpinfo,
    262               struct mountlist_itself *mountlist,
     263catchall_mode(struct mountlist_itself *mountlist,
    263264              struct raidlist_itself *raidlist)
    264265{
     
    275276    iamhere("post wrm");
    276277    if (c == 'I' || c == 'N' || c == 'C') {
    277         interactively_obtain_media_parameters_from_user(bkpinfo, FALSE);
     278        interactively_obtain_media_parameters_from_user(FALSE);
    278279    } else {
    279280        popup_and_OK("No restoring or comparing will take place today.");
     
    302303    if (c == 'I') {
    303304        log_msg(2, "IM selected");
    304         retval += interactive_mode(bkpinfo, mountlist, raidlist);
     305        retval += interactive_mode(mountlist, raidlist);
    305306    } else if (c == 'N') {
    306307        log_msg(2, "NM selected");
    307         retval += nuke_mode(bkpinfo, mountlist, raidlist);
     308        retval += nuke_mode(mountlist, raidlist);
    308309    } else if (c == 'C') {
    309310        log_msg(2, "CM selected");
    310         retval += compare_mode(bkpinfo, mountlist, raidlist);
     311        retval += compare_mode(mountlist, raidlist);
    311312    }
    312313    paranoid_free(tmp);
     
    358359 **************************************************************************/
    359360
    360 static void clean_blkid(struct s_bkpinfo *bkpinfo) {
     361static void clean_blkid() {
    361362
    362363    char *tmp1 = NULL;
     
    388389 */
    389390int
    390 interactive_mode(struct s_bkpinfo *bkpinfo,
    391                  struct mountlist_itself *mountlist,
     391interactive_mode(struct mountlist_itself *mountlist,
    392392                 struct raidlist_itself *raidlist)
    393393{
     
    429429
    430430    iamhere("About to load config file");
    431     get_cfg_file_from_archive_or_bust(bkpinfo);
    432     read_cfg_file_into_bkpinfo(g_mondo_cfg_file, bkpinfo);
     431    get_cfg_file_from_archive_or_bust();
     432    read_cfg_file_into_bkpinfo(g_mondo_cfg_file);
    433433    iamhere("Done loading config file; resizing ML");
    434434    strcpy(tmp, bkpinfo->prefix);
     
    551551    {
    552552        log_msg(1, "Restoring all data");
    553         retval += restore_everything(bkpinfo, NULL);
     553        retval += restore_everything(NULL);
    554554    } else
    555555        if ((restore_all =
     
    559559        for (done = FALSE; !done;) {
    560560            unlink("/tmp/filelist.full");
    561             filelist = process_filelist_and_biggielist(bkpinfo);
     561            filelist = process_filelist_and_biggielist();
    562562            /* Now you have /tmp/tmpfs/filelist.restore-these and /tmp/tmpfs/biggielist.restore-these;
    563563               the former is a list of regular files; the latter, biggiefiles and imagedevs.
     
    578578                    strcpy(bkpinfo->restore_path, tmp);
    579579                    log_msg(1, "Restoring subset");
    580                     retval += restore_everything(bkpinfo, filelist);
     580                    retval += restore_everything(filelist);
    581581                    free_filelist(filelist);
    582582                } else {
     
    612612    }
    613613
    614     clean_blkid(bkpinfo);
     614    clean_blkid();
    615615    protect_against_braindead_sysadmins();
    616616    retval += unmount_all_devices(mountlist);
     
    663663 * Run an arbitrary restore mode (prompt the user), but from ISO images
    664664 * instead of real media.
    665  * @param bkpinfo The backup information structure. Most fields are used.
    666665 * @param mountlist The mountlist containing information about the user's partitions.
    667666 * @param raidlist The raidlist that goes with @p mountlist.
     
    670669 */
    671670int
    672 iso_mode(struct s_bkpinfo *bkpinfo,
    673          struct mountlist_itself *mountlist,
     671iso_mode(struct mountlist_itself *mountlist,
    674672         struct raidlist_itself *raidlist, bool nuke_me_please)
    675673{
     
    677675    int retval = 0;
    678676
    679     assert(bkpinfo != NULL);
    680677    assert(mountlist != NULL);
    681678    assert(raidlist != NULL);
    682     if (iso_fiddly_bits(bkpinfo, nuke_me_please)) {
     679    if (iso_fiddly_bits(nuke_me_please)) {
    683680        log_msg(1, "iso_mode --- returning w/ error");
    684681        return (1);
     
    686683        c = which_restore_mode();
    687684        if (c == 'I' || c == 'N' || c == 'C') {
    688             interactively_obtain_media_parameters_from_user(bkpinfo,
    689                                                             FALSE);
     685            interactively_obtain_media_parameters_from_user(FALSE);
    690686        }
    691687        if (c == 'I') {
    692             retval += interactive_mode(bkpinfo, mountlist, raidlist);
     688            retval += interactive_mode(mountlist, raidlist);
    693689        } else if (c == 'N') {
    694             retval += nuke_mode(bkpinfo, mountlist, raidlist);
     690            retval += nuke_mode(mountlist, raidlist);
    695691        } else if (c == 'C') {
    696             retval += compare_mode(bkpinfo, mountlist, raidlist);
     692            retval += compare_mode(mountlist, raidlist);
    697693        } else {
    698694            log_to_screen("OK, I shan't restore/compare any files.");
     
    732728 */
    733729int
    734 nuke_mode(struct s_bkpinfo *bkpinfo,
    735           struct mountlist_itself *mountlist,
     730nuke_mode(struct mountlist_itself *mountlist,
    736731          struct raidlist_itself *raidlist)
    737732{
     
    749744    log_msg(2, "nuke_mode --- starting");
    750745
    751     get_cfg_file_from_archive_or_bust(bkpinfo);
     746    get_cfg_file_from_archive_or_bust();
    752747    load_mountlist(mountlist, g_mountlist_fname);   // in case read_cfg_file_into_bkpinfo updated the mountlist
    753748#ifdef __FreeBSD__
     
    770765                tmpA, tmpB, tmpC);
    771766        if (ask_me_yes_or_no(tmp)) {
    772             retval = interactive_mode(bkpinfo, mountlist, raidlist);
     767            retval = interactive_mode(mountlist, raidlist);
    773768            goto after_the_nuke;
    774769        } else {
     
    828823
    829824        if (ask_me_yes_or_no("Try in interactive mode instead?")) {
    830             retval = interactive_mode(bkpinfo, mountlist, raidlist);
     825            retval = interactive_mode(mountlist, raidlist);
    831826            goto after_the_nuke;
    832827        } else
     
    844839    }
    845840    iamhere("Restoring everything");
    846     retval += restore_everything(bkpinfo, NULL);
     841    retval += restore_everything(NULL);
    847842    if (!run_boot_loader(FALSE)) {
    848843        log_msg(1,
     
    850845        boot_loader_installed = TRUE;
    851846    }
    852     clean_blkid(bkpinfo);
     847    clean_blkid();
    853848    protect_against_braindead_sysadmins();
    854849    retval += unmount_all_devices(mountlist);
     
    910905 * @return 0 for success, or the number of errors encountered.
    911906 */
    912 int restore_to_live_filesystem(struct s_bkpinfo *bkpinfo)
     907int restore_to_live_filesystem()
    913908{
    914909    int retval = 0;
     
    937932        sleep(1);
    938933    }
    939     interactively_obtain_media_parameters_from_user(bkpinfo, FALSE);
     934    interactively_obtain_media_parameters_from_user(FALSE);
    940935    log_msg(2, "bkpinfo->media_device = %s", bkpinfo->media_device);
    941936    if (!bkpinfo->media_device[0]) {
     
    948943    open_evalcall_form("Thinking...");
    949944
    950     get_cfg_file_from_archive_or_bust(bkpinfo);
    951     read_cfg_file_into_bkpinfo(g_mondo_cfg_file, bkpinfo);
     945    get_cfg_file_from_archive_or_bust();
     946    read_cfg_file_into_bkpinfo(g_mondo_cfg_file);
    952947    load_mountlist(mountlist, g_mountlist_fname);   // in case read_cfg_file_into_bkpinfo
    953948
     
    955950    retval = load_mountlist(mountlist, g_mountlist_fname);
    956951    load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME);
    957     filelist = process_filelist_and_biggielist(bkpinfo);
     952    filelist = process_filelist_and_biggielist();
    958953    if (filelist) {
    959954        save_filelist(filelist, "/tmp/selected-files.txt");
     
    963958                                 bkpinfo->restore_path, MAX_STR_LEN / 4)) {
    964959            iamhere("Restoring everything");
    965             retval += restore_everything(bkpinfo, filelist);
     960            retval += restore_everything(filelist);
    966961            free_filelist(filelist);
    967962            strcpy(bkpinfo->restore_path, old_restpath);
     
    10141009 */
    10151010int
    1016 restore_a_biggiefile_from_CD(struct s_bkpinfo *bkpinfo,
    1017                              long bigfileno,
     1011restore_a_biggiefile_from_CD(long bigfileno,
    10181012                             struct s_node *filelist,
    10191013                             char *pathname_of_last_file_restored)
     
    12041198                    g_current_media_number);
    12051199            log_to_screen(tmp);
    1206             insist_on_this_cd_number(bkpinfo, g_current_media_number);
     1200            insist_on_this_cd_number(g_current_media_number);
    12071201            log_to_screen("Continuing to restore.");
    12081202        } else {
     
    13451339 * @bug orig_checksum and biggiefile_size are unused (except to check that they are non-NULL).
    13461340 */
    1347 int restore_a_biggiefile_from_stream(struct s_bkpinfo *bkpinfo, char *orig_bf_fname, long biggiefile_number, char *orig_checksum,   //UNUSED
     1341int restore_a_biggiefile_from_stream(char *orig_bf_fname, long biggiefile_number, char *orig_checksum,  //UNUSED
    13481342                                     long long biggiefile_size, //UNUSED
    13491343                                     struct s_node *filelist,
     
    15181512        if (current_slice_number == 0) {
    15191513            res =
    1520                 read_file_from_stream_to_file(bkpinfo,
    1521                                               "/tmp/biggie-blah.txt",
     1514                read_file_from_stream_to_file("/tmp/biggie-blah.txt",
    15221515                                              slice_siz);
    15231516            if (!(fin = fopen("/tmp/biggie-blah.txt", "r"))) {
     
    15351528        } else {
    15361529            res =
    1537                 read_file_from_stream_to_stream(bkpinfo, pout, slice_siz);
     1530                read_file_from_stream_to_stream(pout, slice_siz);
    15381531        }
    15391532        retval += res;
     
    18371830 */
    18381831int
    1839 restore_a_tarball_from_stream(struct s_bkpinfo *bkpinfo,
    1840                               char *tarball_fname,
     1832restore_a_tarball_from_stream(char *tarball_fname,
    18411833                              long current_tarball_number,
    18421834                              struct s_node *filelist,
     
    18901882            bkpinfo->tmpdir, current_tarball_number);
    18911883//  sprintf(filelist_fname, "/tmp/tmpfs/temp-filelist.%ld", current_tarball_number);
    1892     res = read_file_from_stream_to_file(bkpinfo, afio_fname, size);
     1884    res = read_file_from_stream_to_file(afio_fname, size);
    18931885    if (strstr(tarball_fname, ".star")) {
    18941886        bkpinfo->use_star = TRUE;
     
    20312023 */
    20322024int
    2033 restore_all_biggiefiles_from_CD(struct s_bkpinfo *bkpinfo,
    2034                                 struct s_node *filelist)
     2025restore_all_biggiefiles_from_CD(struct s_node *filelist)
    20352026{
    20362027    int retval = 0;
     
    20992090                        "I'll continue to scan this CD for bigfiles to be restored.");
    21002091            } else if (does_file_exist(MNT_CDROM "/archives/NOT-THE-LAST")) {
    2101                 insist_on_this_cd_number(bkpinfo,
    2102                                          ++g_current_media_number);
     2092                insist_on_this_cd_number(++g_current_media_number);
    21032093                sprintf(tmp, "Restoring from %s #%d",
    2104                         media_descriptor_string(bkpinfo->
    2105                                                 backup_media_type),
     2094                        media_descriptor_string(bkpinfo->backup_media_type),
    21062095                        g_current_media_number);
    21072096                log_to_screen(tmp);
     
    21182107            update_progress_form(tmp);
    21192108            res =
    2120                 restore_a_biggiefile_from_CD(bkpinfo, bigfileno, filelist,
    2121                                              pathname_of_last_biggie_restored);
     2109                restore_a_biggiefile_from_CD(bigfileno, filelist, pathname_of_last_biggie_restored);
    21222110            iamhere(pathname_of_last_biggie_restored);
    21232111            if (fbw && pathname_of_last_biggie_restored[0]) {
     
    21802168 */
    21812169int
    2182 restore_all_tarballs_from_CD(struct s_bkpinfo *bkpinfo,
    2183                              struct s_node *filelist)
     2170restore_all_tarballs_from_CD(struct s_node *filelist)
    21842171{
    21852172    int retval = 0;
     
    22082195        g_current_media_number = 1;
    22092196    }
    2210     insist_on_this_cd_number(bkpinfo, g_current_media_number);
     2197    insist_on_this_cd_number(g_current_media_number);
    22112198    read_cfg_var(g_mondo_cfg_file, "last-filelist-number", tmp);
    22122199    max_val = atol(tmp) + 1;
     
    22202207                       progress_str, max_val);
    22212208    for (;;) {
    2222         insist_on_this_cd_number(bkpinfo, g_current_media_number);
     2209        insist_on_this_cd_number(g_current_media_number);
    22232210        update_progress_form(progress_str);
    22242211        sprintf(tarball_fname, MNT_CDROM "/archives/%ld.afio.bz2",
     
    23262313 */
    23272314int
    2328 restore_all_biggiefiles_from_stream(struct s_bkpinfo *bkpinfo,
    2329                                     struct s_node *filelist)
     2315restore_all_biggiefiles_from_stream(struct s_node *filelist)
    23302316{
    23312317    long noof_biggiefiles;
     
    23812367    if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) {
    23822368        res =
    2383             read_EXAT_files_from_tape(bkpinfo, &biggie_size, biggie_fname,
     2369            read_EXAT_files_from_tape(&biggie_size, biggie_fname,
    23842370                                      &ctrl_chr, xattr_fname, acl_fname);
    23852371    }
     
    24142400                current_bigfile_number + 1, biggie_size / 1024);
    24152401        update_progress_form(tmp);
    2416         res = restore_a_biggiefile_from_stream(bkpinfo, biggie_fname,
     2402        res = restore_a_biggiefile_from_stream(biggie_fname,
    24172403                                               current_bigfile_number,
    24182404                                               biggie_cksum,
     
    25052491 */
    25062492int
    2507 restore_all_tarballs_from_stream(struct s_bkpinfo *bkpinfo,
    2508                                  struct s_node *filelist)
     2493restore_all_tarballs_from_stream(struct s_node *filelist)
    25092494{
    25102495    int retval = 0;
     
    25722557            iamhere("Reading EXAT files from tape");
    25732558            res =
    2574                 read_EXAT_files_from_tape(bkpinfo, &tmp_size, tmp_fname,
     2559                read_EXAT_files_from_tape(&tmp_size, tmp_fname,
    25752560                                          &ctrl_chr, xattr_fname,
    25762561                                          acl_fname);
     
    25832568                current_afioball_number, tmp_fname, (long) tmp_size >> 10);
    25842569        res =
    2585             restore_a_tarball_from_stream(bkpinfo, tmp_fname,
     2570            restore_a_tarball_from_stream(tmp_fname,
    25862571                                          current_afioball_number,
    25872572                                          filelist, tmp_size, xattr_fname,
     
    26442629 * @ingroup restoreGroup
    26452630 */
    2646 int restore_everything(struct s_bkpinfo *bkpinfo, struct s_node *filelist)
     2631int restore_everything(struct s_node *filelist)
    26472632{
    26482633    int resA;
     
    26752660    mvaddstr_and_log_it(g_currentY, 0, "Preparing to read your archives");
    26762661    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    2677         mount_cdrom(bkpinfo);
     2662        mount_cdrom();
    26782663        mvaddstr_and_log_it(g_currentY++, 0,
    26792664                            "Restoring OS and data from streaming media");
    26802665        if (bkpinfo->backup_media_type == cdstream) {
    2681             openin_cdstream(bkpinfo);
     2666            openin_cdstream();
    26822667        } else {
    2683             assert_string_is_neither_NULL_nor_zerolength(bkpinfo->
    2684                                                          media_device);
    2685             openin_tape(bkpinfo);
    2686         }
    2687         resA = restore_all_tarballs_from_stream(bkpinfo, filelist);
    2688         resB = restore_all_biggiefiles_from_stream(bkpinfo, filelist);
     2668            assert_string_is_neither_NULL_nor_zerolength(bkpinfo->media_device);
     2669            openin_tape();
     2670        }
     2671        resA = restore_all_tarballs_from_stream(filelist);
     2672        resB = restore_all_biggiefiles_from_stream(filelist);
    26892673        if (bkpinfo->backup_media_type == cdstream) {
    2690             closein_cdstream(bkpinfo);
     2674            closein_cdstream();
    26912675        } else {
    2692             closein_tape(bkpinfo);
     2676            closein_tape();
    26932677        }
    26942678    } else {
    26952679        mvaddstr_and_log_it(g_currentY++, 0,
    26962680                            "Restoring OS and data from CD       ");
    2697         mount_cdrom(bkpinfo);
    2698         resA = restore_all_tarballs_from_CD(bkpinfo, filelist);
    2699         resB = restore_all_biggiefiles_from_CD(bkpinfo, filelist);
     2681        mount_cdrom();
     2682        resA = restore_all_tarballs_from_CD(filelist);
     2683        resB = restore_all_biggiefiles_from_CD(filelist);
    27002684    }
    27012685    chdir(cwd);
     
    27262710 */
    27272711int
    2728 restore_live_from_monitas_server(struct s_bkpinfo *bkpinfo,
    2729                                  char *monitas_device,
     2712restore_live_from_monitas_server(char *monitas_device,
    27302713                                 char *restore_this_directory,
    27312714                                 char *restore_here)
     
    27992782
    28002783    unlink(datadisks_fname);
    2801     read_cfg_file_into_bkpinfo(g_mondo_cfg_file, bkpinfo);
     2784    read_cfg_file_into_bkpinfo(g_mondo_cfg_file);
    28022785    retval = load_mountlist(&the_mountlist, g_mountlist_fname); // in case read_cfg_file_into_bkpinfo   strcpy(bkpinfo->media_device, monitas_device);
    28032786
     
    28262809    run_program_and_log_output(command, FALSE);
    28272810//  filelist = load_filelist(g_filelist_restthese);  // FIXME --- this probably doesn't work because it doesn't include the biggiefiles
    2828     retval += restore_everything(bkpinfo, filelist);
     2811    retval += restore_everything(filelist);
    28292812    free_filelist(filelist);
    28302813    log_msg(2, "--------End of restore_live_from_monitas_server--------");
     
    28982881    struct mountlist_itself *mountlist;
    28992882    struct raidlist_itself *raidlist;
    2900     struct s_bkpinfo *bkpinfo;
    29012883    struct s_node *filelist;
    29022884    char *a, *b;
     
    29582940    malloc_string(a);
    29592941    malloc_string(b);
    2960     setup_MR_global_filenames(bkpinfo); // malloc() and set globals, using bkpinfo->tmpdir etc.
    2961     reset_bkpinfo(bkpinfo);
     2942    setup_MR_global_filenames();    // malloc() and set globals, using bkpinfo->tmpdir etc.
     2943    reset_bkpinfo();
    29622944    bkpinfo->backup_media_type = none;  // in case boot disk was made for one backup type but user wants to restore from another backup type
    29632945    bkpinfo->restore_data = TRUE;   // Well, yeah :-)
     
    30273009            strcpy(g_mountlist_fname, "/tmp/mountlist.txt");
    30283010        }
    3029         res = let_user_edit_the_mountlist(bkpinfo, mountlist, raidlist);
     3011        res = let_user_edit_the_mountlist(mountlist, raidlist);
    30303012#ifdef __FreeBSD__
    30313013        system("mv -f /etc/raidtab /tmp/raidconf.txt");
     
    30603042        system("rm -Rf /tmp/*pih*");
    30613043
    3062         restore_a_biggiefile_from_CD(bkpinfo, 42, NULL, tmp);
     3044        restore_a_biggiefile_from_CD(42, NULL, tmp);
    30633045    }
    30643046
     
    31613143        if (argc == 5 && strcmp(argv[1], "--monitas-live") == 0) {
    31623144            retval =
    3163                 restore_live_from_monitas_server(bkpinfo,
    3164                                                  argv[2],
     3145                restore_live_from_monitas_server(argv[2],
    31653146                                                 argv[3], argv[4]);
    31663147        } else {
    31673148            log_msg(2, "Calling restore_to_live_filesystem()");
    3168             retval = restore_to_live_filesystem(bkpinfo);
     3149            retval = restore_to_live_filesystem();
    31693150        }
    31703151        log_msg(2, "Still here. Yay.");
     
    31863167        iamhere("About to call load_mountlist and load_raidtab");
    31873168        strcpy(bkpinfo->restore_path, MNT_RESTORING);
    3188         read_cfg_file_into_bkpinfo(g_mondo_cfg_file, bkpinfo);
     3169        read_cfg_file_into_bkpinfo(g_mondo_cfg_file);
    31893170        retval = load_mountlist(mountlist, g_mountlist_fname);
    31903171        retval += load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME);
     
    32453226        if (argc == 2 && strcmp(argv[1], "--nuke") == 0) {
    32463227            iamhere("nuking");
    3247             retval += nuke_mode(bkpinfo, mountlist, raidlist);
     3228            retval += nuke_mode(mountlist, raidlist);
    32483229        } else if (argc == 2 && strcmp(argv[1], "--interactive") == 0) {
    32493230            iamhere("catchall");
    3250             retval += catchall_mode(bkpinfo, mountlist, raidlist);
     3231            retval += catchall_mode(mountlist, raidlist);
    32513232        } else if (argc == 2 && strcmp(argv[1], "--compare") == 0) {
    32523233            iamhere("compare");
    3253             retval += compare_mode(bkpinfo, mountlist, raidlist);
     3234            retval += compare_mode(mountlist, raidlist);
    32543235        } else if (argc == 2 && strcmp(argv[1], "--iso") == 0) {
    32553236            iamhere("iso");
    3256             retval = iso_mode(bkpinfo, mountlist, raidlist, FALSE);
     3237            retval = iso_mode(mountlist, raidlist, FALSE);
    32573238        } else if (argc == 2 && strcmp(argv[1], "--mbr") == 0) {
    32583239            iamhere("mbr");
     
    32673248        } else if (argc == 2 && strcmp(argv[1], "--isonuke") == 0) {
    32683249            iamhere("isonuke");
    3269             retval = iso_mode(bkpinfo, mountlist, raidlist, TRUE);
     3250            retval = iso_mode(mountlist, raidlist, TRUE);
    32703251        } else if (argc != 1) {
    32713252            log_to_screen("Invalid paremeters");
     
    32733254        } else {
    32743255            iamhere("catchall (no mode specified in command-line call");
    3275             retval += catchall_mode(bkpinfo, mountlist, raidlist);
     3256            retval += catchall_mode(mountlist, raidlist);
    32763257        }
    32773258    }
Note: See TracChangeset for help on using the changeset viewer.