Ignore:
Timestamp:
Aug 18, 2009, 2:37:55 PM (15 years ago)
Author:
Bruno Cornec
Message:

r3332@localhost: bruno | 2009-08-07 23:59:34 +0200

  • bkpinfo->tmpchdir is now dynamically allocated
  • reorganize how tmpdir and scratchdir are initialized and the startup of the main sections
  • change of interface for maintain_collection_of_recent_archives, mondo_makefilelist, chop_filelist
  • sensibly_set_tmpdir_and_scratchdir => sensibly_set_scratchdir
  • reset_bkpinfo => init_bkpinfo
  • add function mr_free_bkpinfo
  • Fix a bug in mr_strtok
  • mondoarchive seems to globally work. Newt stuff needs more testing
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/common/libmondo-tools.c

    r2320 r2321  
    429429
    430430    assert(bkpinfo != NULL);
     431
     432    if (!bkpinfo->tmpdir) {
     433        fatal_error("Tmpdir set to NULL !");
     434    }
     435
    431436    malloc_string(mtpt);
    432437    malloc_string(hostname);
     
    435440        (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type) ? 16 : 16) *
    436441        1024;
     442
     443    if (strlen(bkpinfo->tmpdir) < 2) {
     444        log_it("tmpdir is blank/missing");
     445        retval++;
     446    }
    437447
    438448    log_msg(1, "Foo");
     
    685695        fprintf(stderr, "Type 'man mondoarchive' for help.\n");
    686696    }
    687     if (strlen(bkpinfo->tmpdir) < 2) {
    688         log_it("tmpdir is blank/missing");
    689         retval++;
    690     }
    691697    if (bkpinfo->include_paths == NULL) {
    692698        mr_asprintf(&p, "/");
     
    751757    if ((bkpinfo->tmpdir != NULL) && (strstr(bkpinfo->tmpdir,"mondo.tmp.") != NULL)) {
    752758        /* purging a potential old tmpdir */
     759        log_it("Purging old tmpdir %s", bkpinfo->tmpdir);
    753760        mr_asprintf(&tmp,"rm -Rf %s",bkpinfo->tmpdir);
    754         system(tmp);
    755         paranoid_free(tmp);
     761        mr_free(bkpinfo->tmpdir);
     762        (void)system(tmp);
     763        mr_free(tmp);
    756764    }
    757765
     
    768776    if (p == NULL) {
    769777        log_it("Failed to create global tmp directory %s for Mondo.",tmp);
     778        mr_free(tmp);
    770779        finish(-1);
    771780    }
    772     strcpy(bkpinfo->tmpdir,p);
    773     paranoid_free(tmp);
    774 }
    775 
     781
     782    bkpinfo->tmpdir = p;
     783    log_it("bkpinfo->tmpdir is being set to %s", bkpinfo->tmpdir);
     784}
     785
     786/* Free all memory allocated into bkpinfo */
     787void mr_free_bkpinfo() {
     788
     789    mr_free(bkpinfo->scratchdir);
     790    mr_free(bkpinfo->tmpdir);
     791    mr_free(bkpinfo->include_paths);
     792    mr_free(bkpinfo->exclude_paths);
     793    mr_free(bkpinfo->nfs_user);
     794
     795    /* Then free the structure */
     796    mr_free(bkpinfo);
     797}
    776798
    777799/**
     
    779801 * @param bkpinfo The @c bkpinfo to reset.
    780802 */
    781 void reset_bkpinfo()
     803void init_bkpinfo()
    782804{
    783805    int i;
    784806
    785807    log_msg(1, "Hi");
    786     assert(bkpinfo != NULL);
    787     memset((void *) bkpinfo, 0, sizeof(struct s_bkpinfo));
    788 
     808
     809    /* Initialized in same order as in the structure declaration to detect errors more easily */
    789810    bkpinfo->media_device[0] = '\0';
    790811    for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
     
    805826    bkpinfo->use_star = FALSE;
    806827    bkpinfo->internal_tape_block_size = DEFAULT_INTERNAL_TAPE_BLOCK_SIZE;
    807     bkpinfo->disaster_recovery =
    808         (am_I_in_disaster_recovery_mode()? TRUE : FALSE);
     828    bkpinfo->disaster_recovery = (am_I_in_disaster_recovery_mode()? TRUE : FALSE);
    809829    if (bkpinfo->disaster_recovery) {
    810830        strcpy(bkpinfo->isodir, "/");
     
    813833    }
    814834    strcpy(bkpinfo->prefix, STD_PREFIX);
    815     sensibly_set_tmpdir_and_scratchdir();
    816 
     835    bkpinfo->scratchdir = NULL;
     836    bkpinfo->tmpdir = NULL;
    817837    bkpinfo->optimal_set_size = 0;
     838    bkpinfo->backup_media_type = none;
    818839    bkpinfo->make_filelist = TRUE;  // unless -J supplied to mondoarchive
     840    bkpinfo->include_paths = NULL;
     841    bkpinfo->exclude_paths = NULL;
    819842    bkpinfo->restore_path[0] = '\0';
    820843    bkpinfo->call_before_iso[0] = '\0';
     
    824847    bkpinfo->kernel_path[0] = '\0';
    825848    bkpinfo->nfs_mount[0] = '\0';
     849    bkpinfo->nfs_remote_dir[0] = '\0';
    826850    bkpinfo->nfs_user = NULL;
    827     bkpinfo->exclude_paths = NULL;
    828     bkpinfo->include_paths = NULL;
    829     bkpinfo->nfs_remote_dir[0] = '\0';
    830851    bkpinfo->postnuke_tarball[0] = '\0';
    831852    bkpinfo->wipe_media_first = FALSE;
     
    838859    bkpinfo->use_obdr = FALSE;
    839860    bkpinfo->restore_mode = interactive;
     861
     862    setup_tmpdir(NULL);
     863    sensibly_set_scratchdir();
    840864}
    841865
     
    13391363        if (!(fout = fopen(MONDO_LOGFILE, "a"))) {
    13401364            return;
    1341         }       // fatal_error("Failed to openout to logfile - sheesh..."); }
     1365        }
    13421366
    13431367        // add tabs to distinguish log levels
Note: See TracChangeset for help on using the changeset viewer.