Changeset 1655


Ignore:
Timestamp:
Sep 25, 2007, 12:54:32 AM (12 years ago)
Author:
bruno
Message:

Fix a bug where df was using locale to print messages and wasn't filtered correctly
Improve setup of tmpdir again

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

Legend:

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

    r1646 r1655  
    25162516    strcpy(tmp,
    25172517           call_program_and_get_last_line_of_output
    2518            ("df -m -P -t nonfs,msdosfs,ntfs,smbfs,smb,cifs,afs,ocfs,ocfs2,mvfs | tr -s '\t' ' ' | grep -vE \"none|Filesystem\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'"));
     2518           ("LANGUAGE=C df -m -P -t nonfs,msdosfs,ntfs,smbfs,smb,cifs,afs,ocfs,ocfs2,mvfs | tr -s '\t' ' ' | grep -vE \"none|Filesystem\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'"));
    25192519#else
    25202520    strcpy(tmp,
    25212521           call_program_and_get_last_line_of_output
    2522            ("df -m -P -x nfs -x vfat -x ntfs -x smbfs -x smb -x cifs -x afs -x ocfs -x ocfs2 -x mvfs | sed 's/                  /devdev/' | tr -s '\t' ' ' | grep -vE \"none|Filesystem|/dev/shm\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'"));
     2522           ("LANGUAGE=C df -m -P -x nfs -x vfat -x ntfs -x smbfs -x smb -x cifs -x afs -x ocfs -x ocfs2 -x mvfs | sed 's/                  /devdev/' | tr -s '\t' ' ' | grep -vE \"none|Filesystem|/dev/shm\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'"));
    25232523#endif
    25242524
     
    25312531        fatal_error("I couldn't figure out the tempdir!");
    25322532    }
    2533     sprintf(bkpinfo->tmpdir, "%s/tmp.mondo.%d", tmp,
    2534             (int) (random() % 32768));
     2533    setup_tmpdir(tmp);
    25352534    log_it("bkpinfo->tmpdir is being set to %s", bkpinfo->tmpdir);
    25362535
  • branches/2.2.5/mondo/src/common/libmondo-tools.c

    r1654 r1655  
    617617    }
    618618    make_hole_for_dir(bkpinfo->scratchdir);
    619     make_hole_for_dir(bkpinfo->tmpdir);
    620619    if (bkpinfo->backup_media_type == iso)
    621620        make_hole_for_dir(bkpinfo->isodir);
     
    902901    }
    903902    chmod(bkpinfo->scratchdir, 0700);
    904     chmod(bkpinfo->tmpdir, 0700);
    905903    g_backup_media_type = bkpinfo->backup_media_type;
    906904    paranoid_free(mtpt);
     
    963961}
    964962
    965 void setup_tmpdir() {
     963void setup_tmpdir(char *path) {
    966964   
    967965    char *tmp = NULL;
    968966    char *p = NULL;
    969967
     968    if (bkpinfo->tmpdir != NULL) {
     969        /* purging a potential old tmpdir */
     970        asprintf(&tmp,"rm -Rf %s",bkpinfo->tmpdir);
     971        run_program_and_log_output(tmp, FALSE);
     972        paranoid_free(tmp);
     973    }
     974       
    970975    if (getenv("TMPDIR")) {
    971976        asprintf(&tmp, "%s/mondo.tmp.XXXXXX", getenv("TMPDIR"));
    972977    } else if (getenv("TMP")) {
    973978        asprintf(&tmp, "%s/mondo.tmp.XXXXXX", getenv("TMP"));
     979    } else if (path != NULL) {
     980        asprintf(&tmp, "%s/mondo.tmp.XXXXXX", path);
    974981    } else {
    975982        asprintf(&tmp, "/tmp/mondo.tmp.XXXXXX");
  • branches/2.2.5/mondo/src/mondoarchive/mondo-cli.c

    r1645 r1655  
    244244        flag_set[i] = FALSE;
    245245    }
    246     //  strcpy (bkpinfo->tmpdir, "/root/images/mondo");
    247246    //  strcpy (bkpinfo->scratchdir, "/home");
    248247    for (j = 1; j <= MAX_NOOF_MEDIA; j++) {
     
    273272    sprintf(tmp, "rm -Rf %s/mondo.scratch.*", bkpinfo->scratchdir);
    274273    paranoid_system(tmp);
    275     sprintf(bkpinfo->tmpdir + strlen(bkpinfo->tmpdir), "/tmp.mondo.%ld",
    276             random() % 32767);
    277274    sprintf(bkpinfo->scratchdir + strlen(bkpinfo->scratchdir),
    278275            "/mondo.scratch.%ld", random() % 32767);
     
    853850    }
    854851    if (flag_set['T']) {
    855         sprintf(bkpinfo->tmpdir, "%s/tmp.mondo.%ld", flag_val['T'],
    856                 random() % 32768);
    857         sprintf(tmp, "touch %s/.foo.dat", flag_val['T']);
     852        setup_tmpdir(flag_val['T']);
     853        sprintf(tmp, "touch %s/.foo.dat", bkpinfo->tmpdir);
    858854        if (run_program_and_log_output(tmp, 1)) {
    859855            retval++;
     
    862858            fatal_error("I cannot write to the tempdir you specified.");
    863859        }
    864         sprintf(tmp, "ln -sf %s/.foo.dat %s/.bar.dat", flag_val['T'],
    865                 flag_val['T']);
     860        sprintf(tmp, "ln -sf %s/.foo.dat %s/.bar.dat", bkpinfo->tmpdir, bkpinfo->tmpdir);
    866861        if (run_program_and_log_output(tmp, 1)) {
    867862            retval++;
Note: See TracChangeset for help on using the changeset viewer.