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-devices.c

    r3152 r3154  
    5050
    5151extern void setup_tmpdir(char *path);
     52extern void setup_scratchdir(char *path);
    5253
    5354static char g_cdrw_drive_is_here[MAX_STR_LEN / 4] = "";
     
    21742175{
    21752176    char *tmp = NULL;
     2177    char *sz = NULL;
    21762178    char *tmpro = NULL;
    21772179    char *tmp1 = NULL;
     
    22102212    }
    22112213    */
     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    }
    22122234    log_msg(3, "media type = %s",
    22132235            bkptype_to_string(bkpinfo->backup_media_type));
    2214     if (archiving_to_media) {
    2215         sensibly_set_tmpdir_and_scratchdir();
    2216     }
    22172236    bkpinfo->cdrw_speed = (bkpinfo->backup_media_type == cdstream) ? 2 : 4;
    22182237    bkpinfo->compression_level =
     
    27742793            finish(1);
    27752794        }
     2795        /*  if modified to another path */
     2796        if (strstr(bkpinfo->tmpdir,"mondo.tmp.") != NULL) {
     2797            setup_tmpdir(bkpinfo->tmpdir);
     2798        }
    27762799        if (!popup_and_get_string
    27772800            ("Scratch directory",
     
    27802803            log_to_screen("User has chosen not to backup the PC");
    27812804            finish(1);
     2805        }
     2806        /*  if modified to another path */
     2807        if (strstr(bkpinfo->scratchdir,"mondo.scratch.") != NULL) {
     2808            setup_scratchdir(bkpinfo->scratchdir);
    27822809        }
    27832810        if (ask_me_yes_or_no("Do you want to backup extended attributes?")) {
     
    29342961    paranoid_free(tmp);
    29352962}
    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 utilityGroup
    2947  */
    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 #else
    2960     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 #endif
    2962 
    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             // FIXME
    2979         }
    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 
    29972963
    29982964
Note: See TracChangeset for help on using the changeset viewer.