Changeset 3154


Ignore:
Timestamp:
Jun 23, 2013, 12:34:33 AM (6 years ago)
Author:
bruno
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.
Location:
branches/3.0
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0/mindi/mindi

    r3149 r3154  
    841841### Sq-Mod End
    842842###
    843     noof_lines=0
    844843    # Get rid of duplicates, so that if a live kernel module also appears
    845844    # in $EXTRA_MODS that it won't get reported as "live module file not found" twice.
    846     for module in `echo $module_list $EXTRA_MODS | tr ' ' '\n' | sort -u` ; do
    847         noof_lines=$(($noof_lines+1))
    848     done
    849     progress=0
    850845    for module in `echo $module_list $EXTRA_MODS | tr ' ' '\n' | sort -u` ; do
    851846        r=`find /lib/modules/$kern -type f | grep "/${module}\..*o" | tail -n1`
     
    860855        fi
    861856        LogFile "INFO: module $module --> $r"
    862         progress=$(($progress+1))
    863         LogProgress $progress $noof_lines
    864857    done
    865858    find /lib/modules/$kern/modules.* -type f 2> /dev/null
  • branches/3.0/mindi/rootfs/etc/init.d/rcS

    r3153 r3154  
    5252    umount -d /mnt/cdrom 2> /dev/null
    5353    mount / -o rw,remount > /dev/null 2> /dev/null
    54     LogIt "Launching Shell"
    5554    for i in `cat /proc/cmdline`; do
    5655        echo $i | grep -qi console= && console=`echo $i | cut -d= -f2`
  • branches/3.0/mondo/configure.in

    r3150 r3154  
    3737AC_ARG_ENABLE(static-mr, AS_HELP_STRING(--enable-static-mr,Link mondorestore statically), do_static_mr=$withval, do_static_mr= )
    3838AC_ARG_ENABLE(debug, AS_HELP_STRING(--enable-debug,Add debugging flags), CFLAGS="$CFLAGS -g", )
    39 AC_ARG_WITH(max-noof-media, AS_HELP_STRING(--with-max-noof-media=NUM,Compile for a certain maximum number of media (default 50)), max_noof_media=$withval, max_noof_media=50)
    4039AC_ARG_WITH(tape-block-size, AS_HELP_STRING(--with-tape-block-size=NUM,Set tape block size in kilobytes (default 131072)), exttape=${withval:=131072}, exttape=131072)
    4140if test x$do_static_mr = xyes; then
  • branches/3.0/mondo/src/common/libmondo-cli.c

    r3150 r3154  
    3939
    4040extern void setup_tmpdir(char *path);
     41extern void setup_scratchdir(char *path);
    4142void mr_make_devlist_from_pathlist(char *pathlist, char mode);
    4243extern double g_kernel_version;
     
    7778
    7879    /*@ buffers *************** */
    79     char *tmp;
     80    char *tmp = NULL;
    8081    char flag_val[128][MAX_STR_LEN];
    8182    bool flag_set[128];
    8283
    83     tmp = malloc(9*MAX_STR_LEN);
    8484    for (i = 0; i < 128; i++) {
    8585        flag_val[i][0] = '\0';
     
    9393        retval += res;
    9494    }
    95 /*
    96   if (!retval)
    97     {
    98 */
     95
    9996    log_msg(3, "Switches:-");
    10097    for (i = 0; i < 128; i++) {
    10198        if (flag_set[i]) {
    102             sprintf(tmp, "-%c %s", i, flag_val[i]);
     99            mr_asprintf(&tmp, "-%c %s", i, flag_val[i]);
    103100            log_msg(3, tmp);
    104         }
    105     }
    106 //    }
    107     /*  Before erasing dirs go into a safe place */
    108     if (chdir("/tmp")) {
    109         // FIXME
    110     }
    111     sprintf(tmp, "rm -Rf %s/tmp.mondo.*", bkpinfo->tmpdir);
    112     paranoid_system(tmp);
    113     sprintf(tmp, "rm -Rf %s/mondo.scratch.*", bkpinfo->scratchdir);
    114     paranoid_system(tmp);
    115     sprintf(bkpinfo->scratchdir + strlen(bkpinfo->scratchdir),
    116             "/mondo.scratch.%ld", random() % 32767);
    117     sprintf(tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir);
    118     paranoid_system(tmp);
    119     sprintf(tmp, "mkdir -p %s", bkpinfo->scratchdir);
    120     paranoid_system(tmp);
    121     paranoid_free(tmp);
     101            mr_free(tmp);
     102        }
     103    }
     104
    122105    return (retval);
    123106}
    124 
    125 
    126107
    127108
     
    135116int process_the_s_switch(char *value)
    136117{
    137     int j;
    138     char tmp[MAX_STR_LEN], *p, comment[MAX_STR_LEN];
    139 
    140118    assert(bkpinfo != NULL);
    141119    assert(value != NULL);
    142120
    143121    bkpinfo->media_size = -1;   /* dummy value */
    144     bkpinfo->media_size = friendly_sizestr_to_sizelong(p);
     122    bkpinfo->media_size = friendly_sizestr_to_sizelong(value);
    145123    log_msg(3, "media_size = %ld", bkpinfo->media_size);
    146124    if (bkpinfo->media_size <= 0) {
    147         log_msg(1, "You gave media an invalid size %s\n", p);
     125        log_msg(1, "You gave media an invalid size %s\n", value);
    148126        return (-1);
    149127    }
     
    802780
    803781    if (flag_set['S']) {
    804         /* Before changing remove old ones if any */
    805         if (bkpinfo->scratchdir) {
    806             if (chdir("/tmp")) {
    807                 // FIXME
    808             }
    809             mr_asprintf(&tmp1, "rm -Rf %s", bkpinfo->scratchdir);
    810             paranoid_system(tmp1);
    811             mr_free(tmp1);
    812         }
    813         sprintf(bkpinfo->scratchdir, "%s/mondo.scratch.%ld", flag_val['S'],
    814                 random() % 32768);
     782        setup_scratchdir(flag_val['S']);
     783        sprintf(tmp, "touch %s/.foo.dat", bkpinfo->scratchdir);
     784        if (run_program_and_log_output(tmp, 1)) {
     785            retval++;
     786            log_to_screen("Please specify a scratchdir which I can write to. :)");
     787            fatal_error("I cannot write to the scratchdir you specified.");
     788        }
     789        sprintf(tmp, "ln -sf %s/.foo.dat %s/.bar.dat", bkpinfo->scratchdir, bkpinfo->scratchdir);
     790        if (run_program_and_log_output(tmp, 1)) {
     791            retval++;
     792            log_to_screen("Please don't specify a SAMBA or VFAT or NFS scratchdir.");
     793            fatal_error("I cannot write to the scratchdir you specified.");
     794        }
    815795    }
    816796
     
    820800        if (run_program_and_log_output(tmp, 1)) {
    821801            retval++;
    822             log_to_screen
    823                 ("Please specify a tempdir which I can write to. :)");
     802            log_to_screen("Please specify a tempdir which I can write to. :)");
    824803            fatal_error("I cannot write to the tempdir you specified.");
    825804        }
     
    827806        if (run_program_and_log_output(tmp, 1)) {
    828807            retval++;
    829             log_to_screen
    830                 ("Please don't specify a SAMBA or VFAT or NFS tmpdir.");
     808            log_to_screen("Please don't specify a SAMBA or VFAT or NFS tmpdir.");
    831809            fatal_error("I cannot write to the tempdir you specified.");
    832810        }
  • branches/3.0/mondo/src/common/libmondo-devices-EXT.h

    r2713 r3154  
    4848extern char *list_of_NETFS_mounts_only(void);
    4949
    50 extern void sensibly_set_tmpdir_and_scratchdir();
    51 
    52 
    5350extern bool set_dev_to_this_if_rx_OK(char *, char *);
    5451
  • 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
  • branches/3.0/mondo/src/common/libmondo-devices.h

    r2713 r3154  
    4040char *list_of_NETFS_mounts_only();
    4141
    42 void sensibly_set_tmpdir_and_scratchdir();
    43 
    44 
    4542bool set_dev_to_this_if_rx_OK(char *output, char *dev);
    4643
  • branches/3.0/mondo/src/common/libmondo-raid.c

    r3060 r3154  
    10541054            raidlist->el[raidlist->entries].additional_vars.entries = v;
    10551055            // skip ':' and status
    1056             token = mr_strtok (string, delims, &lastpos);
     1056            token = mr_strtok(string, delims, &lastpos);
    10571057            if (token == NULL) {
    10581058                // should not happen !
     
    10601060            }
    10611061            mr_free(token);
    1062             token = mr_strtok (string, delims, &lastpos);
     1062            token = mr_strtok(string, delims, &lastpos);
    10631063            if (token == NULL) {
    10641064                // should not happen !
     
    10661066            }
    10671067            if (!strcmp(token, "inactive")) {
    1068                 log_msg(1, "RAID device '%s' inactive.\n",
    1069                 raidlist->el[raidlist->entries].raid_device);
     1068                log_msg(1, "RAID device '%s' inactive.\n", raidlist->el[raidlist->entries].raid_device);
    10701069                mr_free(string);
    10711070                mr_free(token);
     
    10751074
    10761075            // get RAID level
    1077             token = mr_strtok (string, delims, &lastpos);
     1076            token = mr_strtok(string, delims, &lastpos);
    10781077            if (token == NULL) {
    10791078                // should not happen !
  • 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;
  • branches/3.0/mondo/src/common/newt-specific.c

    r3141 r3154  
    356356        paranoid_system("killall mindi 2> /dev/null");
    357357        kill_anything_like_this("/mondo/do-not");
    358         kill_anything_like_this("tmp.mondo");
     358        kill_anything_like_this("mondo.tmp");
    359359        kill_anything_like_this("ntfsclone");
    360360        sync();
Note: See TracChangeset for help on using the changeset viewer.