Changeset 3834 in MondoRescue


Ignore:
Timestamp:
Mar 5, 2024, 1:57:03 AM (3 months ago)
Author:
Bruno Cornec
Message:

manages scratchdir dynamically

Location:
branches/3.3/mondo/src/common
Files:
4 edited

Legend:

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

    r3831 r3834  
    27512751
    27522752        if (bkpinfo->exclude_paths != NULL ) {
    2753             strncpy(p,bkpinfo->exclude_paths,(16*MAX_STR_LEN)-1);
     2753            mr_asprintf(p, "%s", bkpinfo->exclude_paths);
    27542754        } else {
    2755             p[0] = '\0';
    2756         }
    2757         popup_and_get_string("Exclude paths", "Please enter paths which you do NOT want to backup. Separate them with '|'. NB: /tmp and /proc are always excluded. :-) Just hit 'Enter' if you want to do a full system backup.", p, (16*MAX_STR_LEN)-1);
    2758         if (p == NULL) {
     2755            mr_asprintf(p, "%s", "");
     2756        }
     2757        tmp = mr_popup_and_get_string("Exclude paths", "Please enter paths which you do NOT want to backup. Separate them with '|'. NB: /tmp and /proc are always excluded. :-) Just hit 'Enter' if you want to do a full system backup.", p);
     2758        mr_free(p);
     2759        if (tmp == NULL) {
    27592760            log_to_screen("User has chosen not to backup the machine");
    27602761            finish(1);
    27612762        }
    27622763        mr_free(bkpinfo->exclude_paths);
    2763         mr_asprintf(tmp, "%s", p);
    27642764        bkpinfo->exclude_paths = tmp;
    27652765
    27662766        mr_asprintf(oldtmp, "%s", bkpinfo->tmpdir);
    27672767        if (bkpinfo->tmpdir != NULL ) {
    2768             strncpy(p,bkpinfo->tmpdir,(MAX_STR_LEN / 4)-1);
     2768            mr_asprintf(p, "%s", bkpinfo->tmpdir);
    27692769        } else {
    2770             p[0] = '\0';
    2771         }
    2772         if (!popup_and_get_string("Temporary directory", "Please enter your temporary directory.", p, (4*MAX_STR_LEN)-1)) {
     2770            mr_asprintf(p, "%s", "");
     2771        }
     2772        tmp = mr_popup_and_get_string("Temporary directory", "Please enter your temporary directory.", p);
     2773        mr_free(p);
     2774        if (tmp == NULL) {
     2775            mr_free(oldtmp);
    27732776            log_to_screen("User has chosen not to backup the machine");
    27742777            finish(1);
    27752778        }
    27762779        /*  if modified to another path */
    2777         if (strcmp(p,oldtmp) != 0) {
    2778             setup_tmpdir(p);
     2780        if (strcmp(tmp,oldtmp) != 0) {
     2781            setup_tmpdir(tmp);
    27792782        }
    27802783        mr_free(oldtmp);
     
    27822785        mr_asprintf(oldtmp, "%s", bkpinfo->scratchdir);
    27832786        if (bkpinfo->scratchdir != NULL ) {
    2784             strncpy(p,bkpinfo->scratchdir,(MAX_STR_LEN / 4)-1);
     2787            mr_asprintf(p, "%s", bkpinfo->scratchdir);
    27852788        } else {
    2786             p[0] = '\0';
    2787         }
    2788         if (!popup_and_get_string("Scratch directory", "Please enter your scratch directory.", p, (4*MAX_STR_LEN)-1)) {
     2789            mr_asprintf(p, "%s", "");
     2790        }
     2791        tmp = mr_popup_and_get_string("Scratch directory", "Please enter your scratch directory.", p);
     2792        mr_free(p);
     2793        if (tmp == NULL) {
     2794            mr_free(oldtmp);
    27892795            log_to_screen("User has chosen not to backup the machine");
    27902796            finish(1);
    27912797        }
    27922798        /*  if modified to another path */
    2793         if (strcmp(p,oldtmp) != 0) {
    2794             setup_scratchdir(p);
     2799        if (strcmp(tmp,oldtmp) != 0) {
     2800            setup_scratchdir(tmp);
    27952801        }
    27962802        mr_free(oldtmp);
  • branches/3.3/mondo/src/common/libmondo-tools.c

    r3833 r3834  
    743743        mr_asprintf(tmp, "/tmp/mondo.tmp.XXXXXX");
    744744    }
     745    mr_free(bkpinfo->tmpdir);
    745746    bkpinfo->tmpdir = mkdtemp(tmp);
    746747    if (bkpinfo->tmpdir == NULL) {
     
    756757
    757758    char *tmp = NULL;
    758     char *p = NULL;
    759759
    760760    if (bkpinfo->scratchdir != NULL) {
     
    786786        mr_asprintf(tmp, "/tmp/mondo.scratch.XXXXXX");
    787787    }
    788     p = mkdtemp(tmp);
    789     if (p == NULL) {
     788    mr_free(bkpinfo->scratchdir);
     789    bkpinfo->scratchdir = mkdtemp(tmp);
     790    if (bkpinfo->scratchdir == NULL) {
    790791        log_it("Failed to create global scratch directory %s for Mondo.",tmp);
     792        mr_free(tmp);
    791793        finish(-1);
    792794    }
    793     strcpy(bkpinfo->scratchdir,p);
    794795    log_it("bkpinfo->scratchdir is being set to %s", bkpinfo->scratchdir);
    795     paranoid_free(tmp);
    796 
    797     mr_asprintf(tmp, "mkdir -p %s", bkpinfo->scratchdir);
    798     paranoid_system(tmp);
    799     mr_free(tmp);
     796    mr_system("mkdir -p %s", bkpinfo->scratchdir);
    800797}
    801798
     
    828825   
    829826    /*  We need tmpdir as early as possible for further function calls */
    830     bkpinfo->tmpdir = NULL;         // Really setup after
    831     bkpinfo->scratchdir[0] = '\0';          // Really setup after
     827    bkpinfo->tmpdir = NULL;             // Really setup just after
     828    bkpinfo->scratchdir = NULL;         // Really setup just after
    832829    setup_tmpdir(NULL);
    833830    setup_scratchdir(NULL);
  • branches/3.3/mondo/src/common/mondostructures.h

    r3833 r3834  
    481481   * As such, it needs to be at least as large as the largest CD/DVD/ISO.
    482482   */
    483     char scratchdir[MAX_STR_LEN / 4];
     483    char *scratchdir;
    484484
    485485  /**
  • branches/3.3/mondo/src/common/newt-specific.c

    r3833 r3834  
    411411            }
    412412        }
    413         if (bkpinfo->scratchdir) {
     413        if (bkpinfo->scratchdir != NULL) {
    414414            log_msg(8,"scratchdir is %s", bkpinfo->scratchdir);
    415415            if (strstr(bkpinfo->scratchdir ,"mondo.scratch.") != NULL) {
     
    440440        mr_free(bkpinfo->zip_suffix);
    441441        mr_free(bkpinfo->tmpdir);
     442        mr_free(bkpinfo->scratchdir);
    442443        /* Then free the structure */
    443444        paranoid_free(bkpinfo);
Note: See TracChangeset for help on using the changeset viewer.