Changeset 3154 in MondoRescue for branches/3.0/mondo/src/common/libmondo-cli.c


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-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        }
Note: See TracChangeset for help on using the changeset viewer.