Changeset 1653


Ignore:
Timestamp:
Sep 24, 2007, 2:01:42 PM (12 years ago)
Author:
bruno
Message:

reset_bkpinfo called as early as possible by both main program.
It creates a tmpdir cleanly with mkdtemp in setup_tmpdir subfunction, which takes in account TMPIR and TMP env var.
Remains to see what tmpfs does and tests

Location:
branches/2.2.5/mondo/src
Files:
2 edited

Legend:

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

    r1652 r1653  
    182182#include <sys/socket.h>
    183183#include <netdb.h>
     184#include <stdlib.h>
    184185#include <netinet/in.h>
    185186#include <arpa/inet.h>
     
    944945
    945946    unlink(MONDO_TRACEFILE);
    946     asprintf(&tmp,"rm -Rf %s/changed.files*",bkpinfo->tmpdir);
     947    asprintf(&tmp,"rm -Rf %s/changed.files*",MINDI_CACHE);
    947948    run_program_and_log_output(tmp, FALSE);
    948949    paranoid_free(tmp);
     
    962963}
    963964
    964 
     965void setup_tmpdir() {
     966   
     967    char *tmp = NULL;
     968
     969    if (getenv("TMPDIR")) {
     970        asprintf(&tmp, "%s/mondo.tmp.XXXXXX", getenv("TMPDIR"));
     971    } else if (getenv("TMP")) {
     972        asprintf(&tmp, "%s/mondo.tmp.XXXXXX", getenv("TMP"));
     973    } else {
     974        asprintf(&tmp, "/tmp/mondo.tmp.XXXXXX");
     975    }
     976    if ((bkpinfo->tmpdir = mkdtemp(bkpinfo->tmpdir)) == NULL) {
     977        log_it("Failed to create global tmp directory %s for Mondo.",bkpinfo->tmpdir);
     978        finish(-1);
     979    }
     980    //sprintf(bkpinfo->tmpdir, "%s/tmpfs/mondo.tmp.%d", "/tmp", (int) (random() % 32768));  // for mondorestore
     981}
    965982
    966983
     
    976993    assert(bkpinfo != NULL);
    977994    memset((void *) bkpinfo, 0, sizeof(struct s_bkpinfo));
     995
     996    /* special case for tmpdir as used eveywhere after */
     997    setup_tmpdir();
     998
    978999    bkpinfo->manual_cd_tray = FALSE;
    9791000    bkpinfo->internal_tape_block_size = DEFAULT_INTERNAL_TAPE_BLOCK_SIZE;
     
    10041025    bkpinfo->scratchdir[0] = '\0';
    10051026    bkpinfo->make_filelist = TRUE;  // unless -J supplied to mondoarchive
    1006     sprintf(bkpinfo->tmpdir, "%s/tmpfs/mondo.tmp.%d", "/tmp", (int) (random() % 32768));    // for mondorestore
    10071027    bkpinfo->optimal_set_size = 0;
    10081028    bkpinfo->backup_media_type = none;
  • branches/2.2.5/mondo/src/mondorestore/mondo-restore.c

    r1650 r1653  
    28922892        exit(127);
    28932893    }
     2894    if (!
     2895        (bkpinfo = malloc(sizeof(struct s_bkpinfo)))) {
     2896        fatal_error("Cannot malloc bkpinfo");
     2897    }
     2898    reset_bkpinfo();
    28942899
    28952900    g_loglevel = DEFAULT_MR_LOGLEVEL;
     
    29122917        g_text_mode = FALSE;
    29132918    }                           // newt :-)
    2914     if (!
    2915         (bkpinfo = malloc(sizeof(struct s_bkpinfo)))) {
    2916         fatal_error("Cannot malloc bkpinfo");
    2917     }
    29182919    if (!(mountlist = malloc(sizeof(struct mountlist_itself)))) {
    29192920        fatal_error("Cannot malloc mountlist");
     
    29382939    malloc_string(b);
    29392940    setup_MR_global_filenames();    // malloc() and set globals, using bkpinfo->tmpdir etc.
    2940     reset_bkpinfo();
    29412941    bkpinfo->backup_media_type = none;  // in case boot disk was made for one backup type but user wants to restore from another backup type
    29422942    bkpinfo->restore_data = TRUE;   // Well, yeah :-)
     
    29702970
    29712971/* Init directories */
    2972     make_hole_for_dir(bkpinfo->tmpdir);
    2973     sprintf(tmp, "mkdir -p %s", bkpinfo->tmpdir);
    2974     run_program_and_log_output(tmp, FALSE);
    29752972    make_hole_for_dir("/var/log");
    29762973    make_hole_for_dir("/tmp/tmpfs");    /* just in case... */
Note: See TracChangeset for help on using the changeset viewer.