Changeset 3154 in MondoRescue for branches/3.0/mondo/src/common/libmondo-devices.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-devices.c
r3152 r3154 50 50 51 51 extern void setup_tmpdir(char *path); 52 extern void setup_scratchdir(char *path); 52 53 53 54 static char g_cdrw_drive_is_here[MAX_STR_LEN / 4] = ""; … … 2174 2175 { 2175 2176 char *tmp = NULL; 2177 char *sz = NULL; 2176 2178 char *tmpro = NULL; 2177 2179 char *tmp1 = NULL; … … 2210 2212 } 2211 2213 */ 2214 if (archiving_to_media) { 2215 setup_tmpdir(NULL); 2216 /* 2217 * Set the scratchdir to reside on the partition with the most free space. 2218 * Automatically excludes DOS, NTFS, SMB, and NFS filesystems. 2219 */ 2220 #ifdef __FreeBSD__ 2221 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output("LANGUAGE=C df -m -P -t nonfs,msdosfs,ntfs,ntfs-3g,vmhgfs,smbfs,smb,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | grep -vE \"none|Filesystem\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -nr | awk '{print $NF;}' | while read x ; do test -w $x && echo $x && break ; done")); 2222 #else 2223 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output("LANGUAGE=C df -m -P -x nfs -x nfs4 -x fuse.sshfs -x fuse -x vfat -x ntfs -x ntfs-3g -x vmhgfs -x smbfs -x smb -x cifs -x afs -x gfs -x ocfs -x ocfs2 -x mvfs -x nsspool -x nssvol -x iso9660 | grep -vE \"none|Filesystem|/dev/shm\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -nr | awk '{print $NF;}' | while read x ; do test -w $x && echo $x && break ; done")); 2224 #endif 2225 2226 if (tmp[0] != '/') { 2227 mr_asprintf(&sz, "%s", tmp); 2228 mr_free(tmp); 2229 mr_asprintf(&tmp, "/%s", sz); 2230 mr_free(sz); 2231 } 2232 setup_scratchdir(tmp); 2233 } 2212 2234 log_msg(3, "media type = %s", 2213 2235 bkptype_to_string(bkpinfo->backup_media_type)); 2214 if (archiving_to_media) {2215 sensibly_set_tmpdir_and_scratchdir();2216 }2217 2236 bkpinfo->cdrw_speed = (bkpinfo->backup_media_type == cdstream) ? 2 : 4; 2218 2237 bkpinfo->compression_level = … … 2774 2793 finish(1); 2775 2794 } 2795 /* if modified to another path */ 2796 if (strstr(bkpinfo->tmpdir,"mondo.tmp.") != NULL) { 2797 setup_tmpdir(bkpinfo->tmpdir); 2798 } 2776 2799 if (!popup_and_get_string 2777 2800 ("Scratch directory", … … 2780 2803 log_to_screen("User has chosen not to backup the PC"); 2781 2804 finish(1); 2805 } 2806 /* if modified to another path */ 2807 if (strstr(bkpinfo->scratchdir,"mondo.scratch.") != NULL) { 2808 setup_scratchdir(bkpinfo->scratchdir); 2782 2809 } 2783 2810 if (ask_me_yes_or_no("Do you want to backup extended attributes?")) { … … 2934 2961 paranoid_free(tmp); 2935 2962 } 2936 2937 2938 2939 2940 2941 2942 /**2943 * Set the tmpdir and scratchdir to reside on the partition with the most free space.2944 * Automatically excludes DOS, NTFS, SMB, and NFS filesystems.2945 * @param bkpinfo The backup information structure. @c bkpinfo->tmpdir and @c bkpinfo->scratchdir will be set.2946 * @ingroup utilityGroup2947 */2948 void sensibly_set_tmpdir_and_scratchdir()2949 {2950 char *tmp = NULL;2951 char *tmp1 = NULL;2952 char *command = NULL;2953 char *sz = NULL;2954 2955 assert(bkpinfo != NULL);2956 2957 #ifdef __FreeBSD__2958 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output("LANGUAGE=C df -m -P -t nonfs,msdosfs,ntfs,ntfs-3g,vmhgfs,smbfs,smb,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | grep -vE \"none|Filesystem\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -nr | awk '{print $NF;}' | while read x ; do test -w $x && echo $x && break ; done"));2959 #else2960 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output("LANGUAGE=C df -m -P -x nfs -x nfs4 -x fuse.sshfs -x fuse -x vfat -x ntfs -x ntfs-3g -x vmhgfs -x smbfs -x smb -x cifs -x afs -x gfs -x ocfs -x ocfs2 -x mvfs -x nsspool -x nssvol -x iso9660 | grep -vE \"none|Filesystem|/dev/shm\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -nr | awk '{print $NF;}' | while read x ; do test -w $x && echo $x && break ; done"));2961 #endif2962 2963 if (tmp[0] != '/') {2964 mr_asprintf(&sz, "%s", tmp);2965 paranoid_free(tmp);2966 mr_asprintf(&tmp, "/%s", sz);2967 mr_free(sz);2968 }2969 if (!tmp[0]) {2970 fatal_error("I couldn't figure out the tempdir!");2971 }2972 setup_tmpdir(tmp);2973 log_it("bkpinfo->tmpdir is being set to %s", bkpinfo->tmpdir);2974 2975 /* Before changing remove old ones if any */2976 if (bkpinfo->scratchdir) {2977 if (chdir("/tmp")) {2978 // FIXME2979 }2980 mr_asprintf(&tmp1, "rm -Rf %s", bkpinfo->scratchdir);2981 paranoid_system(tmp1);2982 mr_free(tmp1);2983 }2984 sprintf(bkpinfo->scratchdir, "%s/mondo.scratch.%d", tmp,2985 (int) (random() % 32768));2986 log_it("bkpinfo->scratchdir is being set to %s", bkpinfo->scratchdir);2987 2988 mr_asprintf(&command, "rm -Rf %s/tmp.mondo.* %s/mondo.scratch.*", tmp, tmp);2989 paranoid_free(tmp);2990 2991 paranoid_system(command);2992 mr_free(command);2993 }2994 2995 2996 2997 2963 2998 2964
Note:
See TracChangeset
for help on using the changeset viewer.