Changeset 3828 in MondoRescue


Ignore:
Timestamp:
Mar 4, 2024, 4:52:07 PM (2 months ago)
Author:
Bruno Cornec
Message:

manages restore_path dynamically

Location:
branches/3.3/mondo/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3/mondo/src/common/libmondo-tools.c

    r3827 r3828  
    850850    bkpinfo->include_paths = NULL;
    851851    bkpinfo->exclude_devs = NULL;
    852     bkpinfo->restore_path[0] = '\0';
     852    bkpinfo->restore_path = NULL;
    853853    bkpinfo->call_before_iso = NULL;
    854854    bkpinfo->call_make_iso = NULL;
  • branches/3.3/mondo/src/common/libmondo-verify.c

    r3613 r3828  
    295295                paranoid_fclose(fin);
    296296            }
    297             if (bkpinfo->restore_path) {
     297            if (bkpinfo->restore_path != NULL) {
    298298                mr_asprintf(tmp, "%s/%s", bkpinfo->restore_path, biggiestruct.filename);
    299299                log_msg(2, "Opening biggiefile #%ld - '%s'", bigfile_num, tmp);
     
    869869        mr_free(comment);
    870870
    871         if (bkpinfo->restore_path) {
     871        if (bkpinfo->restore_path != NULL) {
    872872            mr_asprintf(logical_fname, "%s/%s", bkpinfo->restore_path, orig_fname);
    873873            res = verify_a_biggiefile_from_stream(logical_fname, size);
  • branches/3.3/mondo/src/common/mondostructures.h

    r3827 r3828  
    535535   * without overwriting the old ones. Ignored during a backup.
    536536   */
    537     char restore_path[MAX_STR_LEN];
     537    char *restore_path;
    538538
    539539  /**
  • branches/3.3/mondo/src/common/newt-specific.c

    r3827 r3828  
    435435        mr_free(bkpinfo->call_after_iso);
    436436        mr_free(bkpinfo->call_before_iso);
     437        mr_free(bkpinfo->restore_path);
    437438        /* Then free the structure */
    438439        paranoid_free(bkpinfo);
  • branches/3.3/mondo/src/mondorestore/mondorestore.c

    r3822 r3828  
    18541854    log_msg(2, "interactive_mode --- starting (great, assertions OK)");
    18551855
    1856     malloc_string(tmp);
    18571856    assert(bkpinfo != NULL);
    18581857    assert(mountlist != NULL);
     
    19621961                if (!ask_me_yes_or_no("Re-edit the mountlist?")) {
    19631962                    retval++;
    1964                     goto end_of_func;
     1963                    log_it("Leaving interactive_mode()");
     1964                    return (retval);
    19651965                }
    19661966            }
     
    19721972        unmount_all_devices(mountlist);
    19731973        retval++;
    1974         goto end_of_func;
     1974        log_it("Leaving interactive_mode()");
     1975        return (retval);
    19751976    }
    19761977
     
    19881989             */
    19891990            if (filelist) {
    1990               gotos_suck:
    1991                 strcpy(tmp, old_restpath);
    1992                 // (NB: %s is where your filesystem is mounted now, by default)", MNT_RESTORING);
    1993                 if (popup_and_get_string("Restore path", "Restore files to where?", tmp, MAX_STR_LEN / 4)) {
     1991                gotos_suck:
     1992                // (NB: MNT_RESTORING is where your filesystem is mounted now, by default)
     1993                tmp = mr_popup_and_get_string("Restore path", "Restore files to where?", old_restpath);
     1994                if (tmp != NULL) {
    19941995                    if (!strcmp(tmp, "/")) {
    19951996                        if (!ask_me_yes_or_no("Are you sure?")) {
     1997                            mr_free(tmp);
    19961998                            goto gotos_suck;
    19971999                        }
    1998                         tmp[0] = '\0';  // so we restore to [blank]/file/name :)
     2000                        mr_asprintf(tmp, "%s", ""); // so we restore to [blank]/file/name :)
    19992001                    }
    2000                     strcpy(bkpinfo->restore_path, tmp);
     2002                    mr_asprintf(bkpinfo->restore_path, "%s", tmp);
    20012003                    log_msg(1, "Restoring subset");
    20022004                    retval += restore_everything(filelist);
    2003                     free_filelist(filelist);
    20042005                } else {
    2005                     strcpy(bkpinfo->restore_path, old_restpath);
    2006                     free_filelist(filelist);
     2006                    mr_free(bkpinfo->restore_path);
     2007                    mr_asprintf(bkpinfo->restore_path, "%s", old_restpath);
    20072008                }
     2009                free_filelist(filelist);
    20082010                if (!ask_me_yes_or_no("Restore another subset of your backup?")) {
    20092011                    done = TRUE;
     
    20632065    }
    20642066  end_of_func:
    2065     paranoid_free(tmp);
    20662067    log_it("Leaving interactive_mode()");
    20672068    return (retval);
     
    24532454
    24542455    char *old_restpath = NULL;
     2456    char *tmp2 = NULL;
    24552457
    24562458    struct mountlist_itself *mountlist = NULL;
     
    24662468    }
    24672469
    2468     strcpy(bkpinfo->restore_path, "/");
     2470    mr_asprintf(bkpinfo->restore_path, "%s", "/");
    24692471    if (!g_restoring_live_from_cd && !g_restoring_live_from_netfs) {
    24702472        popup_and_OK("Please insert tape/CD/USB Key, then hit 'OK' to continue.");
     
    24962498        save_filelist(filelist, "/tmp/selected-files.txt");
    24972499        mr_asprintf(old_restpath, "%s", bkpinfo->restore_path);
    2498         if (popup_and_get_string("Restore path", "Restore files to where? ", bkpinfo->restore_path, MAX_STR_LEN / 4)) {
     2500        tmp2 = mr_popup_and_get_string("Restore path", "Restore files to where? ", bkpinfo->restore_path);
     2501        mr_free(bkpinfo->restore_path);
     2502        if (tmp2 == NULL) {
    24992503            log_it("Restoring everything");
    25002504            retval += restore_everything(filelist);
    2501             free_filelist(filelist);
    2502             strcpy(bkpinfo->restore_path, old_restpath);
     2505            mr_asprintf(bkpinfo->restore_path, "%s", old_restpath);
    25032506        } else {
    2504             free_filelist(filelist);
    2505         }
    2506         strcpy(bkpinfo->restore_path, old_restpath);
     2507            bkpinfo->restore_path = tmp2;
     2508        }
     2509        free_filelist(filelist);
    25072510        mr_free(old_restpath);
    25082511    } else {
     
    28292832
    28302833        log_it("About to call load_mountlist and load_raidtab");
    2831         strcpy(bkpinfo->restore_path, MNT_RESTORING);
     2834        mr_asprintf(bkpinfo->restore_path, "%s", MNT_RESTORING);
    28322835        read_cfg_file_into_bkpinfo(g_mondo_cfg_file);
    28332836        retval = load_mountlist(mountlist, g_mountlist_fname);
Note: See TracChangeset for help on using the changeset viewer.