Changeset 3833 in MondoRescue


Ignore:
Timestamp:
Mar 5, 2024, 1:24:48 AM (4 months ago)
Author:
Bruno Cornec
Message:

manages tmpdir dynamically

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

Legend:

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

    r3830 r3833  
    710710
    711711    char *tmp = NULL;
    712     char *p = NULL;
    713 
    714     if (bkpinfo->tmpdir[0] != '\0') {
     712
     713    if (bkpinfo->tmpdir != NULL) {
    715714        /* purging a potential old tmpdir */
    716715        if (chdir("/tmp")) {
     
    744743        mr_asprintf(tmp, "/tmp/mondo.tmp.XXXXXX");
    745744    }
    746     p = mkdtemp(tmp);
    747     if (p == NULL) {
     745    bkpinfo->tmpdir = mkdtemp(tmp);
     746    if (bkpinfo->tmpdir == NULL) {
    748747        printf("Failed to create global tmp directory %s for Mondo.",tmp);
    749748        mr_free(tmp);
    750749        finish(-1);
    751750    }
    752     strcpy(bkpinfo->tmpdir,p);
    753     mr_free(tmp);
    754 
    755751    log_it("bkpinfo->tmpdir is being set to %s", bkpinfo->tmpdir);
    756 
    757752    mr_system("mkdir -p %s/tmpfs", bkpinfo->tmpdir);
    758753}
     
    833828   
    834829    /*  We need tmpdir as early as possible for further function calls */
    835     bkpinfo->tmpdir[0] = '\0';          // Really setup after
     830    bkpinfo->tmpdir = NULL;         // Really setup after
    836831    bkpinfo->scratchdir[0] = '\0';          // Really setup after
    837832    setup_tmpdir(NULL);
  • branches/3.3/mondo/src/common/mondostructures.h

    r3830 r3833  
    489489   * of space here.
    490490   */
    491     char tmpdir[MAX_STR_LEN / 4];
     491    char *tmpdir;
    492492
    493493  /**
  • branches/3.3/mondo/src/common/newt-specific.c

    r3830 r3833  
    402402            mr_free(command);
    403403        }
    404         if (bkpinfo->tmpdir) {
     404        if (bkpinfo->tmpdir != NULL) {
    405405            log_msg(8,"tempdir is %s",bkpinfo->tmpdir);
    406406            if (strstr(bkpinfo->tmpdir ,"mondo.tmp.") != NULL) {
     
    439439        mr_free(bkpinfo->zip_exe);
    440440        mr_free(bkpinfo->zip_suffix);
     441        mr_free(bkpinfo->tmpdir);
    441442        /* Then free the structure */
    442443        paranoid_free(bkpinfo);
  • branches/3.3/mondo/src/mondorestore/mondo-rstr-tools.c

    r3830 r3833  
    18191819void setup_MR_global_filenames()
    18201820{
    1821     char *temppath;
    1822 
    18231821    assert(bkpinfo != NULL);
    18241822
     
    18331831    malloc_string(g_isodir_format);
    18341832
    1835     temppath = bkpinfo->tmpdir;
    1836 
    1837     sprintf(g_biggielist_txt, "%s/%s", temppath, BIGGIELIST_TXT_STUB);
    1838     sprintf(g_filelist_full, "%s/%s", temppath, FILELIST_FULL_STUB);
    1839     sprintf(g_filelist_imagedevs, "%s/tmp/filelist.imagedevs", temppath);
    1840 //  sprintf(g_imagedevs_pot, "%s/tmp/imagedevs.pot", temppath);
     1833    sprintf(g_biggielist_txt, "%s/%s", bkpinfo->tmpdir, BIGGIELIST_TXT_STUB);
     1834    sprintf(g_filelist_full, "%s/%s", bkpinfo->tmpdir, FILELIST_FULL_STUB);
     1835    sprintf(g_filelist_imagedevs, "%s/tmp/filelist.imagedevs", bkpinfo->tmpdir);
     1836//  sprintf(g_imagedevs_pot, "%s/tmp/imagedevs.pot", bkpinfo->tmpdir);
    18411837    sprintf(g_imagedevs_restthese, "%s/tmp/imagedevs.restore-these",
    1842             temppath);
     1838            bkpinfo->tmpdir);
    18431839    if (bkpinfo->disaster_recovery) {
    18441840        sprintf(g_mondo_cfg_file, "/%s", MONDO_CFG_FILE_STUB);
    18451841        sprintf(g_mountlist_fname, "/%s", MOUNTLIST_FNAME_STUB);
    18461842    } else {
    1847         sprintf(g_mondo_cfg_file, "%s/%s", temppath, MONDO_CFG_FILE_STUB);
    1848         sprintf(g_mountlist_fname, "%s/%s", temppath, MOUNTLIST_FNAME_STUB);
     1843        sprintf(g_mondo_cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB);
     1844        sprintf(g_mountlist_fname, "%s/%s", bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB);
    18491845    }
    18501846}
  • branches/3.3/mondo/src/mondorestore/mondorestore.c

    r3832 r3833  
    28202820
    28212821        log_msg(2, "Still here. Yay.");
    2822         if ((strlen(bkpinfo->tmpdir) > 0) && (strstr(bkpinfo->tmpdir,"mondo.tmp.") != NULL)) {
     2822        if ((bkpinfo->tmpdir != NULL) && (strlen(bkpinfo->tmpdir) > 0) && (strstr(bkpinfo->tmpdir,"mondo.tmp.") != NULL)) {
    28232823            mr_asprintf(tmp, "rm -Rf %s/*", bkpinfo->tmpdir);
    28242824            run_program_and_log_output(tmp, FALSE);
Note: See TracChangeset for help on using the changeset viewer.