Changeset 3154 in MondoRescue for branches/3.0/mondo/src/common/libmondo-tools.c
- Timestamp:
- Jun 23, 2013, 12:34:33 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.0/mondo/src/common/libmondo-tools.c
r3150 r3154 409 409 mr_free(tmp); 410 410 } 411 make_hole_for_dir(bkpinfo->scratchdir);412 411 if (bkpinfo->backup_media_type == iso) 413 412 make_hole_for_dir(bkpinfo->isodir); … … 744 743 char *p = NULL; 745 744 746 if ( (bkpinfo->tmpdir != NULL) && (strstr(bkpinfo->tmpdir,"mondo.tmp.") != NULL)) {745 if (bkpinfo->tmpdir != NULL) { 747 746 /* purging a potential old tmpdir */ 748 log_it("Purging old tmpdir %s", bkpinfo->tmpdir);749 747 if (chdir("/tmp")) { 750 748 // FIXME 751 749 } 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 } 753 757 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")) { 759 765 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")); 764 768 } else { 765 769 mr_asprintf(&tmp, "/tmp/mondo.tmp.XXXXXX"); … … 772 776 strcpy(bkpinfo->tmpdir,p); 773 777 paranoid_free(tmp); 778 779 mr_asprintf(&tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir); 780 paranoid_system(tmp); 781 mr_free(tmp); 782 } 783 784 void 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); 774 824 } 775 825 … … 811 861 } 812 862 strcpy(bkpinfo->prefix, STD_PREFIX); 813 sensibly_set_tmpdir_and_scratchdir(); 863 setup_tmpdir(NULL); 864 setup_scratchdir(NULL); 814 865 815 866 bkpinfo->optimal_set_size = 0;
Note:
See TracChangeset
for help on using the changeset viewer.