Ignore:
Timestamp:
Jun 23, 2013, 12:34:33 AM (11 years ago)
Author:
Bruno Cornec
Message:
  • Remove the introduction of LogProgress in ListKernelModulePaths which should stay quiet
  • Remove a remaining support of max-noof-media in confidure.in now gone.
  • Fix #640 by cleaning up fully the managemnt of tmpdir and scratchdir (one function for the creation, one point of removal at end, intermediate removal if needed, clean naming conventions, unify mkdtemp usage, remove sensibly_set_tmpdir_and_scratchdir function). Consequence is that default dir for scratchdir if nothing else specified is /tmp using CLI and the largest partition using the GUI.
  • Fix a bug introduced in process_the_s_switch with intermediate variables which weren't initialized correctly.
File:
1 edited

Legend:

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

    r3150 r3154  
    409409        mr_free(tmp);
    410410    }
    411     make_hole_for_dir(bkpinfo->scratchdir);
    412411    if (bkpinfo->backup_media_type == iso)
    413412        make_hole_for_dir(bkpinfo->isodir);
     
    744743    char *p = NULL;
    745744
    746     if ((bkpinfo->tmpdir != NULL) && (strstr(bkpinfo->tmpdir,"mondo.tmp.") != NULL)) {
     745    if (bkpinfo->tmpdir != NULL) {
    747746        /* purging a potential old tmpdir */
    748         log_it("Purging old tmpdir %s", bkpinfo->tmpdir);
    749747        if (chdir("/tmp")) {
    750748            // FIXME
    751749        }
    752         mr_asprintf(&tmp,"rm -Rf %s",bkpinfo->tmpdir);
     750        if (strstr(bkpinfo->tmpdir,"mondo.tmp.") != NULL) {
     751            log_it("Purging old tmpdir %s", bkpinfo->tmpdir);
     752            mr_asprintf(&tmp,"rm -Rf %s",bkpinfo->tmpdir);
     753        } else {
     754            log_it("Purging old tmpdir %s/mondo.tmp.*", bkpinfo->tmpdir);
     755            mr_asprintf(&tmp,"rm -Rf %s/mondo.tmp.*",bkpinfo->tmpdir);
     756        }
    753757        paranoid_system(tmp);
    754         paranoid_free(tmp);
    755     }
    756 
    757     /* Always take in account env first */
    758     if (getenv("TMPDIR")) {
     758        mr_free(tmp);
     759    }
     760
     761    /* Always take in account arg first, then env, then default */
     762    if (path != NULL) {
     763        mr_asprintf(&tmp, "%s/mondo.tmp.XXXXXX", path);
     764    } else if (getenv("TMPDIR")) {
    759765        mr_asprintf(&tmp, "%s/mondo.tmp.XXXXXX", getenv("TMPDIR"));
    760     } else if (getenv("TMP")) {
    761         mr_asprintf(&tmp, "%s/mondo.tmp.XXXXXX", getenv("TMP"));
    762     } else if (path != NULL) {
    763         mr_asprintf(&tmp, "%s/mondo.tmp.XXXXXX", path);
     766    } else if (getenv("MRTMP")) {
     767        mr_asprintf(&tmp, "%s/mondo.tmp.XXXXXX", getenv("MRTMP"));
    764768    } else {
    765769        mr_asprintf(&tmp, "/tmp/mondo.tmp.XXXXXX");
     
    772776    strcpy(bkpinfo->tmpdir,p);
    773777    paranoid_free(tmp);
     778
     779    mr_asprintf(&tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir);
     780    paranoid_system(tmp);
     781    mr_free(tmp);
     782}
     783
     784void setup_scratchdir(char *path) {
     785
     786    char *tmp = NULL;
     787    char *p = NULL;
     788
     789    if (bkpinfo->scratchdir != NULL) {
     790        /* purging a potential old scratchdir */
     791        if (chdir("/tmp")) {
     792            // FIXME
     793        }
     794        if (strstr(bkpinfo->scratchdir,"mondo.scratch.") != NULL) {
     795            log_it("Purging old scratchdir %s", bkpinfo->scratchdir);
     796            mr_asprintf(&tmp,"rm -Rf %s",bkpinfo->scratchdir);
     797        } else {
     798            log_it("Purging old scratchdir %s/mondo.scratch.*", bkpinfo->scratchdir);
     799            mr_asprintf(&tmp,"rm -Rf %s/mondo.scratch.*",bkpinfo->scratchdir);
     800        }
     801        paranoid_system(tmp);
     802        mr_free(tmp);
     803    }
     804
     805    /* Always take in account arg first, then env, then default */
     806    if (path != NULL) {
     807        mr_asprintf(&tmp, "%s/mondo.scratch.XXXXXX", path);
     808    } else if (getenv("MRSCRATCH")) {
     809        mr_asprintf(&tmp, "%s/mondo.scratch.XXXXXX", getenv("MRSCRATCH"));
     810    } else {
     811        mr_asprintf(&tmp, "/tmp/mondo.scratch.XXXXXX");
     812    }
     813    p = mkdtemp(tmp);
     814    if (p == NULL) {
     815        log_it("Failed to create global scratch directory %s for Mondo.",tmp);
     816        finish(-1);
     817    }
     818    strcpy(bkpinfo->scratchdir,p);
     819    paranoid_free(tmp);
     820
     821    mr_asprintf(&tmp, "mkdir -p %s", bkpinfo->scratchdir);
     822    paranoid_system(tmp);
     823    mr_free(tmp);
    774824}
    775825
     
    811861    }
    812862    strcpy(bkpinfo->prefix, STD_PREFIX);
    813     sensibly_set_tmpdir_and_scratchdir();
     863    setup_tmpdir(NULL);
     864    setup_scratchdir(NULL);
    814865
    815866    bkpinfo->optimal_set_size = 0;
Note: See TracChangeset for help on using the changeset viewer.