Changeset 2321


Ignore:
Timestamp:
Aug 18, 2009, 2:37:55 PM (10 years ago)
Author:
bruno
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
Location:
branches/2.2.10/mondo/src
Files:
24 edited

Legend:

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

    r2320 r2321  
    436436    mr_free(tmp);
    437437
    438     mr_asprintf(&tmp, "cp -f %s/archives/*list*.gz %s", bkpinfo->scratchdir,
    439             bkpinfo->tmpdir);
     438    mr_asprintf(&tmp, "cp -f %s/archives/*list*.gz %s", bkpinfo->scratchdir, bkpinfo->tmpdir);
    440439    if (run_program_and_log_output(tmp, 2)) {
    441440        mr_free(tmp);
     
    14311430                    register_in_tape_catalog(fileset, storing_set_no, -1,
    14321431                                         storing_afioball_fname);
    1433                     maintain_collection_of_recent_archives(bkpinfo->tmpdir,
    1434                                                        storing_afioball_fname);
     1432                    maintain_collection_of_recent_archives(storing_afioball_fname);
    14351433                    log_it("Writing EXAT files");
    14361434                    res +=
     
    22042202        if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    22052203            register_in_tape_catalog(fileset, curr_set_no, -1, curr_afioball_fname);
    2206             maintain_collection_of_recent_archives(bkpinfo->tmpdir, curr_afioball_fname);
     2204            maintain_collection_of_recent_archives(curr_afioball_fname);
    22072205            log_it("Writing EXAT files");
    22082206            res +=
     
    31073105            register_in_tape_catalog(biggieslice, biggie_file_number,
    31083106                                     slice_num, file_to_archive);
    3109             maintain_collection_of_recent_archives(bkpinfo->tmpdir,
    3110                                                    file_to_archive);
     3107            maintain_collection_of_recent_archives(file_to_archive);
    31113108            res = move_files_to_stream(file_to_archive, NULL);
    31123109        } else {
  • branches/2.2.10/mondo/src/common/libmondo-cli.c

    r2320 r2321  
    548548                            DSFptr->check = 1;
    549549                        }
     550                        mr_free(token);
    550551                    }
    551                     mr_free(token);
    552552                    mr_free(mount_list);
    553553                } else {
     
    791791            /* Fatal error; exit */
    792792            case 1:
     793                mr_free(token);
    793794                fatal_error("Error processing -I option");
    794795            /* Everything is OK; process to archive data */
     
    15091510        if (opt == '?') {
    15101511            bad_switches = TRUE;
    1511             /*log_it("Invalid option: %c\n",optopt); */
    15121512        } else {
    15131513            if (flag_set[opt]) {
  • branches/2.2.10/mondo/src/common/libmondo-devices-EXT.h

    r1647 r2321  
    4949extern char *list_of_NFS_mounts_only(void);
    5050
    51 extern void sensibly_set_tmpdir_and_scratchdir();
     51extern void sensibly_set_scratchdir();
    5252
    5353
  • branches/2.2.10/mondo/src/common/libmondo-devices.c

    r2320 r2321  
    4242extern char *MONDO_LOGFILE;
    4343
    44 extern void setup_tmpdir(char *path);
    45 
    4644static char g_cdrw_drive_is_here[MAX_STR_LEN / 4] = "";
    4745static char g_cdrom_drive_is_here[MAX_STR_LEN / 4] = "";
     
    111109    bool is_this_a_ramdisk = FALSE;
    112110
    113     malloc_string(comment);
    114111    mr_asprintf(&tmp, "%s", where_is_root_mounted());
    115     mr_asprintf(&comment, "root is mounted at %s\n", tmp);
     112    mr_asprintf(&comment, "root is currently mounted at %s\n", tmp);
    116113    log_msg(0, comment);
    117114    mr_free(comment);
    118     log_msg(0,
    119             "No, Schlomo, that doesn't mean %s is the root partition. It's just a debugging message. Relax. It's part of am_I_in_disaster_recovery_mode().",
    120             tmp);
    121115
    122116#ifdef __FreeBSD__
     
    138132    if (is_this_a_ramdisk) {
    139133        if (!does_file_exist("/THIS-IS-A-RAMDISK")) {
    140             log_to_screen
    141                 ("Using /dev/root is stupid of you but I'll forgive you.");
     134            log_to_screen("Using /dev/root is stupid of you but I'll forgive you.");
    142135            is_this_a_ramdisk = FALSE;
    143136        }
     
    146139        is_this_a_ramdisk = TRUE;
    147140    }
    148     log_msg(1, "Is this a ramdisk? result = %d", is_this_a_ramdisk);
     141    log_msg(1, "Is this a ramdisk? result = %s", (is_this_a_ramdisk) ? "TRUE" : "FALSE");
    149142    return (is_this_a_ramdisk);
    150143}
     
    13741367            mr_asprintf(&tmp, "%s/isodir/%s/%s-%d.iso", bkpinfo->tmpdir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, cd_number_i_want);
    13751368            if (does_file_exist(tmp)) {
    1376                 log_msg(1,
    1377                         "FIXME - hacking bkpinfo->isodir from '%s' to %s/isodir",
    1378                         bkpinfo->isodir, bkpinfo->tmpdir);
     1369                log_msg(1, "FIXME - hacking bkpinfo->isodir from '%s' to %s/isodir", bkpinfo->isodir, bkpinfo->tmpdir);
    13791370                sprintf(bkpinfo->isodir, "%s/isodir", bkpinfo->tmpdir);
    13801371            }
     
    14741465    }
    14751466    */
    1476     log_msg(3, "media type = %s",
    1477             bkptype_to_string(bkpinfo->backup_media_type));
    1478     if (archiving_to_media) {
    1479         sensibly_set_tmpdir_and_scratchdir();
    1480     }
     1467    log_msg(3, "media type = %s", bkptype_to_string(bkpinfo->backup_media_type));
    14811468    bkpinfo->cdrw_speed = (bkpinfo->backup_media_type == cdstream) ? 2 : 4;
    14821469    bkpinfo->compression_level =
     
    19711958            finish(1);
    19721959        }
    1973         strcpy(bkpinfo->tmpdir, p);
    1974         mr_free(p);
     1960        mr_free(bkpinfo->tmpdir);
     1961        bkpinfo->tmpdir = p;
    19751962
    19761963        p = popup_and_get_string("Scratch directory", "Please enter your scratch directory.", bkpinfo->scratchdir);
     
    21402127 * @ingroup utilityGroup
    21412128 */
    2142 void sensibly_set_tmpdir_and_scratchdir()
     2129void sensibly_set_scratchdir()
    21432130{
    21442131    char *tmp = NULL;
    21452132    char *command = NULL;
    21462133    char *sz = NULL;
    2147 
    2148     assert(bkpinfo != NULL);
    21492134
    21502135#ifdef __FreeBSD__
     
    21612146    }
    21622147    if (!tmp[0]) {
    2163         fatal_error("I couldn't figure out the tempdir!");
    2164     }
    2165     setup_tmpdir(tmp);
    2166     log_it("bkpinfo->tmpdir is being set to %s", bkpinfo->tmpdir);
    2167 
     2148        fatal_error("I couldn't figure out the scratchdir!");
     2149    }
    21682150    mr_asprintf(&sz, "%s/mondo.scratch.%d", tmp, (int) (random() % 32768));
    21692151    mr_free(bkpinfo->scratchdir);
     
    21712153    log_it("bkpinfo->scratchdir is being set to %s", bkpinfo->scratchdir);
    21722154
    2173     mr_asprintf(&command, "rm -Rf %s/tmp.mondo.* %s/mondo.scratch.*", tmp, tmp);
     2155    mr_asprintf(&command, "rm -Rf %s/mondo.scratch.*", tmp);
    21742156    mr_free(tmp);
    21752157
  • branches/2.2.10/mondo/src/common/libmondo-devices.h

    r1647 r2321  
    4141char *list_of_NFS_mounts_only();
    4242
    43 void sensibly_set_tmpdir_and_scratchdir();
     43void sensibly_set_scratchdir();
    4444
    4545
  • branches/2.2.10/mondo/src/common/libmondo-filelist-EXT.h

    r1647 r2321  
    11/* libmondo-filelist-EXT.h */
    22
    3 extern int chop_filelist(char *filelist, char *outdir, long maxsetsizeK);
     3extern int chop_filelist(char *filelist, long maxsetsizeK);
    44extern int call_filelist_chopper();
    55extern void free_filelist(struct s_node *filelist);
  • branches/2.2.10/mondo/src/common/libmondo-filelist.c

    r2320 r2321  
    3636
    3737
    38 int mondo_makefilelist(char *logfile, char *tmpdir, char *scratchdir,
    39                        char *include_paths, char *excp, int differential,
    40                        char *userdef_filelist);
     38int mondo_makefilelist(char *logfile, char *include_paths, char *excp, int differential, char *userdef_filelist);
    4139
    4240
     
    106104    }
    107105
    108     noof_sets = chop_filelist(filelist, bkpinfo->tmpdir, bkpinfo->optimal_set_size);
     106    noof_sets = chop_filelist(filelist, bkpinfo->optimal_set_size);
    109107    mr_free(filelist);
    110108    estimate_noof_media_required(noof_sets);    // for cosmetic purposes
     
    194192 *
    195193 * @param filelist The big filelist (filelist.full) to chop up.
    196  * @param outdir The directory to place the files (filelist.N where N is
    197  * an integer, biggielist.txt, and LAST-FILELIST-NUMBER) created
    198194 * @param maxsetsizeK Optimal size of a fileset (X above).
    199195 * @return number of errors encountered (0 for success).
    200196 */
    201 int chop_filelist(char *filelist, char *outdir, long maxsetsizeK)
     197int chop_filelist(char *filelist, long maxsetsizeK)
    202198{
    203199/*@ long ****************************************/
     
    228224
    229225    assert_string_is_neither_NULL_nor_zerolength(filelist);
    230     assert_string_is_neither_NULL_nor_zerolength(outdir);
    231226    assert(maxsetsizeK > 0);
    232227
     
    245240    curr_set_no = 0;
    246241    curr_set_size = 0;
    247     mr_asprintf(&outfname, "%s/filelist.%ld", outdir, curr_set_no);
    248     mr_asprintf(&biggie_fname, "%s/biggielist.txt", outdir);
     242    mr_asprintf(&outfname, "%s/filelist.%ld", bkpinfo->tmpdir, curr_set_no);
     243    mr_asprintf(&biggie_fname, "%s/biggielist.txt", bkpinfo->tmpdir);
    249244    log_it("outfname=%s; biggie_fname=%s", outfname, biggie_fname);
    250245    if (!(fbig = fopen(biggie_fname, "w"))) {
     
    298293                curr_set_size = 0;
    299294
    300                 mr_asprintf(&outfname, "%s/filelist.%ld", outdir, curr_set_no);
     295                mr_asprintf(&outfname, "%s/filelist.%ld", bkpinfo->tmpdir, curr_set_no);
    301296                if (!(fout = fopen(outfname, "w"))) {
    302297                    log_OS_error("Unable to openout outfname");
     
    328323    mr_free(biggie_fname);
    329324
    330     mr_asprintf(&outfname, "%s/LAST-FILELIST-NUMBER", outdir);
     325    mr_asprintf(&outfname, "%s/LAST-FILELIST-NUMBER", bkpinfo->tmpdir);
    331326    mr_asprintf(&tmp, "%ld", curr_set_no);
    332327    if (write_one_liner_data_file(outfname, tmp)) {
     
    13071302    if (bkpinfo->make_filelist) {
    13081303        res =
    1309             mondo_makefilelist(MONDO_LOGFILE, bkpinfo->tmpdir, bkpinfo->scratchdir, bkpinfo->include_paths, bkpinfo->exclude_paths, bkpinfo->differential, NULL);
     1304            mondo_makefilelist(MONDO_LOGFILE, bkpinfo->include_paths, bkpinfo->exclude_paths, bkpinfo->differential, NULL);
    13101305    } else {
    13111306        res =
    1312             mondo_makefilelist(MONDO_LOGFILE, bkpinfo->tmpdir, bkpinfo->scratchdir, NULL, bkpinfo->exclude_paths, bkpinfo->differential, bkpinfo->include_paths);
     1307            mondo_makefilelist(MONDO_LOGFILE, NULL, bkpinfo->exclude_paths, bkpinfo->differential, bkpinfo->include_paths);
    13131308    }
    13141309
     
    13771372            while((token = mr_strtok(sth, delims, &lastpos))) {
    13781373                mr_strcat(find_excludes," -path %s -prune -o", token);
     1374                mr_free(token);
    13791375            }
    13801376        }
     
    15421538 * Create the filelist for the backup. It will be stored in [scratchdir]/archives/filelist.full.
    15431539 * @param logfile Unused.
    1544  * @param tmpdir The tmpdir of the backup.
    1545  * @param scratchdir The scratchdir of the backup.
    15461540 * @param include_paths The paths to back up, or NULL if you're using a user-defined filelist.
    15471541 * @param excp The paths to NOT back up.
     
    15521546 * @bug Return value is meaningless.
    15531547 */
    1554 int mondo_makefilelist(char *logfile, char *tmpdir, char *scratchdir,
    1555                        char *include_paths, char *excp, int differential,
    1556                        char *userdef_filelist)
     1548int mondo_makefilelist(char *logfile, char *include_paths, char *excp, int differential, char *userdef_filelist)
    15571549{
    15581550    char *p, *q;
     
    15771569    }
    15781570    // make hole for filelist
    1579     mr_asprintf(&command, "mkdir -p %s/archives", scratchdir);
     1571    mr_asprintf(&command, "mkdir -p %s/archives", bkpinfo->scratchdir);
    15801572    paranoid_system(command);
    15811573    mr_free(command);
    15821574
    1583     mr_asprintf(&sz_filelist, "%s/tmpfs/filelist.full", tmpdir);
     1575    mr_asprintf(&sz_filelist, "%s/tmpfs/filelist.full", bkpinfo->tmpdir);
    15841576    make_hole_for_file(sz_filelist);
    15851577
     
    16401632        mr_free(tmp1);
    16411633
    1642         mr_asprintf(&exclude_paths, " %s %s %s %s %s . ..  " MNT_CDROM " " MNT_FLOPPY " /media /tmp  /proc /sys " MINDI_CACHE, MONDO_CACHE, (excp == NULL) ? "" : excp, tmp2, (tmpdir[0] == '/' && tmpdir[1] == '/') ? (tmpdir + 1) : tmpdir, (scratchdir[0] == '/' && scratchdir[1] == '/') ? (scratchdir + 1) : scratchdir);
     1634        mr_asprintf(&exclude_paths, " %s %s %s %s %s . ..  " MNT_CDROM " " MNT_FLOPPY " /media /tmp  /proc /sys " MINDI_CACHE, MONDO_CACHE, (excp == NULL) ? "" : excp, tmp2, (bkpinfo->tmpdir[0] == '/' && bkpinfo->tmpdir[1] == '/') ? (bkpinfo->tmpdir + 1) : bkpinfo->tmpdir, (bkpinfo->scratchdir[0] == '/' && bkpinfo->scratchdir[1] == '/') ? (bkpinfo->scratchdir + 1) : bkpinfo->scratchdir);
    16431635        mr_free(tmp2);
    16441636
    16451637        log_msg(2, "Excluding paths = '%s'", exclude_paths);
    16461638        log_msg(2, "Generating skeleton filelist so that we can track our progress");
    1647         sprintf(g_skeleton_filelist, "%s/tmpfs/skeleton.txt", tmpdir);
     1639        sprintf(g_skeleton_filelist, "%s/tmpfs/skeleton.txt", bkpinfo->tmpdir);
    16481640        make_hole_for_file(g_skeleton_filelist);
    16491641        log_msg(4, "g_skeleton_entries = %ld", g_skeleton_entries);
     
    16751667    }
    16761668    log_msg(2, "Copying new filelist to scratchdir");
    1677     mr_asprintf(&command, "mkdir -p %s/archives", scratchdir);
     1669    mr_asprintf(&command, "mkdir -p %s/archives", bkpinfo->scratchdir);
    16781670    paranoid_system(command);
    16791671    mr_free(command);
    16801672
    1681     mr_asprintf(&command, "cp -f %s %s/archives/", sz_filelist, scratchdir);
     1673    mr_asprintf(&command, "cp -f %s %s/archives/", sz_filelist, bkpinfo->scratchdir);
    16821674    paranoid_system(command);
    16831675    mr_free(command);
    16841676
    1685     mr_asprintf(&command, "mv -f %s %s", sz_filelist, tmpdir);
     1677    mr_asprintf(&command, "mv -f %s %s", sz_filelist, bkpinfo->tmpdir);
    16861678    paranoid_system(command);
    16871679    mr_free(command);
  • branches/2.2.10/mondo/src/common/libmondo-filelist.h

    r1647 r2321  
    33 */
    44
    5 int chop_filelist(char *filelist, char *outdir, long maxsetsizeK);
     5int chop_filelist(char *filelist, long maxsetsizeK);
    66int call_filelist_chopper();
    77void free_filelist(struct s_node *filelist);
  • branches/2.2.10/mondo/src/common/libmondo-raid.c

    r2260 r2321  
    10251025    }
    10261026    // tokenise string
    1027     token = mr_strtok (string, delims, &lastpos);
     1027    token = mr_strtok(string, delims, &lastpos);
    10281028    // get RAID device name
    10291029    mr_asprintf(&strtmp,"%s%s", device_prefix, token);
     
    10321032    mr_free(token);
    10331033    // skip ':' and status
    1034     token = mr_strtok (string, delims, &lastpos);
     1034    token = mr_strtok(string, delims, &lastpos);
    10351035    mr_free(token);
    1036     token = mr_strtok (string, delims, &lastpos);
     1036    token = mr_strtok(string, delims, &lastpos);
    10371037    if (!strcmp(token, "inactive")) {
    10381038      log_msg(1, "RAID device '%s' inactive.\n",
     
    10451045
    10461046    // get RAID level
    1047     token = mr_strtok (string, delims, &lastpos);
     1047    token = mr_strtok(string, delims, &lastpos);
    10481048    if (!strcmp(token, "multipath")) {
    10491049      raidlist->el[raidlist->entries].raid_level = -2;
  • branches/2.2.10/mondo/src/common/libmondo-stream-EXT.h

    r2303 r2321  
    88extern void insist_on_this_tape_number(int tapeno);
    99extern void log_tape_pos(void);
    10 extern int maintain_collection_of_recent_archives(char *td,
    11                                                   char *latest_fname);
     10extern int maintain_collection_of_recent_archives(char *latest_fname);
    1211extern int openin_cdstream();
    1312extern int openin_tape();
  • branches/2.2.10/mondo/src/common/libmondo-stream.c

    r2316 r2321  
    513513 * assumed to be a fileset, otherwise if it contains "slice" it's a slice,
    514514 * otherwise we generate a fatal_error().
    515  * @param td The current @c bkpinfo->tempdir (file will be placed in <tt>td</tt>/tmpfs/backcatalog/).
    516515 * @param latest_fname The file to place in the collection.
    517516 * @return 0, always.
     
    519518 * @bug The detection won't work for uncompressed afioballs (they end in ".afio", no dot afterwards). // Not true. They end in '.' -Hugo
    520519 */
    521 int maintain_collection_of_recent_archives(char *td, char *latest_fname)
     520int maintain_collection_of_recent_archives(char *latest_fname)
    522521{
    523522    long long final_alleged_writeK, final_projected_certain_writeK,
     
    543542    } else {
    544543        log_it("fname = %s", latest_fname);
    545         fatal_error
    546             ("Unknown type. Internal error in maintain_collection_of_recent_archives()");
    547     }
    548     mr_asprintf(&tmpdir, "%s/tmpfs/backcatalog", td);
     544        fatal_error("Unknown type. Internal error in maintain_collection_of_recent_archives()");
     545    }
     546    mr_asprintf(&tmpdir, "%s/tmpfs/backcatalog", bkpinfo->tmpdir);
    549547    mkdir(tmpdir, 0x700);
    550548    mr_asprintf(&command, "cp -f %s %s", latest_fname, tmpdir);
  • branches/2.2.10/mondo/src/common/libmondo-stream.h

    r2303 r2321  
    1010void insist_on_this_tape_number(int tapeno);
    1111void log_tape_pos(void);
    12 int maintain_collection_of_recent_archives(char *td, char *latest_fname);
     12int maintain_collection_of_recent_archives(char *latest_fname);
    1313int openin_cdstream();
    1414int openin_tape();
  • branches/2.2.10/mondo/src/common/libmondo-string.c

    r2318 r2321  
    513513            mr_asprintf(&output, "%s%s", q, value);
    514514        }
    515         p++;
     515        p+= strlen(token);
    516516        q = p;
    517517    }
     
    692692    numA = atol(stringA + start_of_numbers_in_A);
    693693    numB = atol(stringB + start_of_numbers_in_B);
    694     /*
    695        sprintf(tmp,"Comparing %s and %s --> %ld,%ld\n",stringA,stringB,numA,numB);
    696        log_to_screen(tmp);
    697      */
    698694    return ((int) (numA - numB));
    699695}
  • branches/2.2.10/mondo/src/common/libmondo-tools-EXT.h

    r1917 r2321  
    1212extern int read_cfg_var(char *config_file, char *label, char *value);
    1313extern int write_cfg_var(char *config_file, char *label, char *value);
    14 extern void reset_bkpinfo();
     14extern void init_bkpinfo();
    1515#ifdef __FreeBSD__
    1616extern void initialize_raidrec(struct vinum_volume *vv);
  • 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
  • branches/2.2.10/mondo/src/common/libmondo-tools.h

    r1917 r2321  
    1515int read_cfg_var(char *config_file, char *label, char *value);
    1616int write_cfg_var(char *config_file, char *label, char *value);
    17 void reset_bkpinfo();
     17void init_bkpinfo();
    1818#ifdef __FreeBSD__
    1919void initialize_raidrec(struct vinum_volume *vv);
  • branches/2.2.10/mondo/src/common/libmondo-verify.c

    r2296 r2321  
    312312                            bkpinfo->restore_path,
    313313                            biggiestruct.filename);
    314                 mr_asprintf(&tmp, "echo \"%s/%s not found\" >> %s/biggies.changed",
    315                             bkpinfo->restore_path,
    316                             biggiestruct.filename,
    317                             bkpinfo->tmpdir);
     314                mr_asprintf(&tmp, "echo \"%s/%s not found\" >> %s/biggies.changed", bkpinfo->restore_path, biggiestruct.filename, bkpinfo->tmpdir);
    318315                system(tmp);
    319316                mr_free(tmp);
  • branches/2.2.10/mondo/src/common/mondostructures.h

    r2320 r2321  
    2525
    2626/** @def MAX_NOOF_MEDIA The maximum number of media that can be used in any one backup. */
    27 
    2827///* So we can override it in config.h: */
    2928//#ifndef MAX_NOOF_MEDIA
     
    327326 * that function may in turn pass the bkpinfo to other functions which use other fields.
    328327 *
    329  * To fill out the bkpinfo first call reset_bkpinfo() and pre_param_configuration(). Then set
     328 * To fill out the bkpinfo first call init_bkpinfo() and pre_param_configuration(). Then set
    330329 * the backup-specific parameters (see mondo/mondoarchive/mondo-cli.c-\>process_switches for
    331330 * an example). After that, you should call post_param_configuration() to set some final
     
    488487   * of space here.
    489488   */
    490     char tmpdir[MAX_STR_LEN / 4];
     489    char *tmpdir;
    491490
    492491  /**
     
    501500   */
    502501    t_bkptype backup_media_type;
    503 //  bool blank_dvd_first;
    504502
    505503  /**
     
    667665   */
    668666    bool expanded;
    669 };
    670 
    671 
    672 
    673 /**
    674  * A structure to wrap a FIFO device for writing to a tape/CD stream.
    675  * @bug Is this structure used (w/the move to a standalone @c buffer and all)?
    676  */
    677 struct s_wrapfifo {
    678         /**
    679      * The device we write to or read from (a FIFO).
    680      */
    681     char public_device[MAX_STR_LEN / 4];
    682 
    683         /**
    684      * The actual device that data from the FIFO should be buffered and written to.
    685      */
    686     char private_device[MAX_STR_LEN / 4];
    687 
    688         /**
    689      * A buffer for holding data read from the FIFO.
    690      */
    691     char internal_buffer_IN_fifo[MAX_STR_LEN / 4];
    692 
    693         /**
    694      * A buffer for holding data to be written to the FIFO.
    695      */
    696     char internal_buffer_OUT_fifo[MAX_STR_LEN / 4];
    697 
    698         /**
    699      * If TRUE, then we're writing directly to the tape streamer; if FALSE, we're writing to the FIFO.
    700      */
    701     bool writing_to_private_device;
    702667};
    703668
  • branches/2.2.10/mondo/src/common/newt-specific.c

    r2320 r2321  
    3333
    3434extern struct s_bkpinfo *bkpinfo;
     35extern void mr_free_bkpinfo();
    3536
    3637/*@unused@*/
     
    280281        mr_asprintf(&tmp1,"kill `%s`", tmp);
    281282        run_program_and_log_output(tmp1, TRUE);
    282         paranoid_free(tmp1);
    283     }
    284     paranoid_free(tmp);
     283        mr_free(tmp1);
     284    }
     285    mr_free(tmp);
    285286}
    286287
     
    423424        }
    424425        /* Free all allocated strings in bkpinfo */
    425         mr_free(bkpinfo->nfs_user);
    426         mr_free(bkpinfo->exclude_paths);
    427         mr_free(bkpinfo->include_paths);
    428         mr_free(bkpinfo->scratchdir);
    429 
    430         /* Then free the structure */
    431         mr_free(bkpinfo);
     426        mr_free_bkpinfo();
    432427        free_libmondo_global_strings();
    433428        free_newt_stuff();
     
    601596        strcpy(title, ttl);
    602597        strcpy(g_isoform_header_str, title);
    603 //  center_string (title, 80);
    604598        if (g_text_mode) {
    605599            log_msg(0, title);
     
    922916            newtInit();
    923917            newtCls();
    924             newtPushHelpLine
    925                 ("Welcome to Mondo Rescue, by Dev Team and the Internet. All rights reversed.");
    926             /*  newtDrawRootText(28,0,"Welcome to Mondo Rescue"); */
     918            newtPushHelpLine("Welcome to Mondo Rescue, by Dev Team and the Internet. All rights reversed.");
    927919            newtDrawRootText(18, 0, WELCOME_STRING);
    928920            newtRefresh();
  • branches/2.2.10/mondo/src/mondoarchive/mondoarchive.c

    r2320 r2321  
    170170    char *say_at_end = NULL;
    171171
    172 /* Make sure I'm root; abort if not */
    173     if (getuid() != 0) {
    174         fprintf(stderr, "Please run as root.\r\n");
    175         exit(127);
    176     }
    177 
    178 /* If -V, -v or --version then echo version no. and quit */
    179     if (argc == 2
    180         && (!strcmp(argv[argc - 1], "-v") || !strcmp(argv[argc - 1], "-V")
    181             || !strcmp(argv[argc - 1], "--version"))) {
    182         printf("mondoarchive v%s\nSee man page for help\n", PACKAGE_VERSION);
    183         exit(0);
    184     }
    185 
    186172/* Initialize variables */
    187 
    188     printf("Initializing...\n");
    189     if (!(bkpinfo = malloc(sizeof(struct s_bkpinfo)))) {
    190         fatal_error("Cannot malloc bkpinfo");
    191     }
    192     reset_bkpinfo();
    193173
    194174    res = 0;
    195175    retval = 0;
    196176    diffs = 0;
    197     malloc_libmondo_global_strings();
     177
     178    printf("Initializing...\n");
     179
     180    bkpinfo = (struct s_bkpinfo *)mr_malloc(sizeof(struct s_bkpinfo));
     181    init_bkpinfo();
    198182
    199183    /* initialize log file with time stamp */
     
    201185    log_msg(0, "Time started: %s", mr_date());
    202186
     187    /* Memory allocation is done in those functions */
     188    malloc_libmondo_global_strings();
     189    if (argc == 1) {
     190        g_text_mode = FALSE;
     191    } else {
     192        g_text_mode = TRUE;
     193    }
     194    setup_newt_stuff();
     195
     196    /* Make sure I'm root; abort if not */
     197    if (getuid() != 0) {
     198        fatal_error("Please run as root.\n");
     199    }
     200
     201    /* If -V, -v or --version then echo version no. and quit */
     202    if (argc == 2 && (!strcmp(argv[argc - 1], "-v") || !strcmp(argv[argc - 1], "-V") || !strcmp(argv[argc - 1], "--version"))) {
     203        printf("mondoarchive v%s\nSee man page for help\n", PACKAGE_VERSION);
     204        finish(0);
     205    }
     206
     207
    203208    /* make sure PATH environmental variable allows access to mkfs, fdisk, etc. */
    204209    mr_asprintf(&tmp1,"%s:/sbin:/usr/sbin:/usr/local/sbin",getenv("PATH"));
    205210    setenv("PATH", tmp1, 1);
    206     paranoid_free(tmp1);
     211    mr_free(tmp1);
    207212
    208213    /* Add the ARCH environment variable for ia64 purposes */
    209214    mr_asprintf(&tmp1,"%s",get_architecture());
    210215    setenv("ARCH", tmp1, 1);
    211     paranoid_free(tmp1);
     216    mr_free(tmp1);
    212217
    213218    /* Add MONDO_SHARE environment variable for mindi */
     
    231236        g_loglevel = 10;
    232237        g_text_mode = TRUE;
    233         setup_newt_stuff();
    234238        if (!strstr(argv[2], "filelist")) {
    235239            printf("Sorry - filelist goes first\n");
     
    242246    if (argc == 4 && !strcmp(argv[1], "setfattr")) {
    243247        g_loglevel = 10;
    244         g_text_mode = TRUE;
    245         setup_newt_stuff();
    246248        finish(set_fattr_list(argv[2], argv[3]));
    247249    }
     
    249251    if (argc == 3 && !strcmp(argv[1], "wildcards")) {
    250252        g_loglevel = 10;
    251         g_text_mode = TRUE;
    252         setup_newt_stuff();
    253253        malloc_string(tmp);
    254254        turn_wildcard_chars_into_literal_chars(tmp, argv[2]);
     
    260260    if (argc == 4 && !strcmp(argv[1], "getfacl")) {
    261261        g_loglevel = 10;
    262         g_text_mode = TRUE;
    263         setup_newt_stuff();
    264262        if (!strstr(argv[2], "filelist")) {
    265263            printf("Sorry - filelist goes first\n");
     
    272270    if (argc == 4 && !strcmp(argv[1], "setfacl")) {
    273271        g_loglevel = 10;
    274         g_text_mode = TRUE;
    275         setup_newt_stuff();
    276272        finish(set_acl_list(argv[2], argv[3]));
    277273    }
     
    279275    if (argc > 2 && !strcmp(argv[1], "find-cd")) {
    280276        g_loglevel = 10;
    281         g_text_mode = TRUE;
    282         setup_newt_stuff();
    283277        malloc_string(tmp);
    284278        if (find_cdrw_device(tmp)) {
     
    299293    if (argc > 2 && !strcmp(argv[1], "find-dvd")) {
    300294        g_loglevel = 10;
    301         g_text_mode = TRUE;
    302         setup_newt_stuff();
    303295        malloc_string(tmp);
    304296        if (find_dvd_device(tmp, atoi(argv[2]))) {
     
    331323/* Process command line, if there is one. If not, ask user for info. */
    332324    if (argc == 1) {
    333         g_text_mode = FALSE;
    334         setup_newt_stuff();
    335325        res = interactively_obtain_media_parameters_from_user(TRUE);    /* yes, archiving */
    336326        if (res) {
     
    347337            finish(1);
    348338        }
    349         setup_newt_stuff();
    350339    }
    351340
    352341/* Finish configuring global structures */
    353342    if (post_param_configuration()) {
    354         fatal_error
    355             ("Post-param initialization phase failed. Perhaps bad parameters were supplied to mondoarchive? Please review the documentation, error messages and logs. Exiting...");
    356     }
    357 
    358     log_to_screen
    359         ("BusyBox's sources are available from http://www.busybox.net");
     343        fatal_error("Post-param initialization phase failed. Perhaps bad parameters were supplied to mondoarchive? Please review the documentation, error messages and logs. Exiting...");
     344    }
     345
     346    log_to_screen("BusyBox's sources are available from http://www.busybox.net");
    360347
    361348    /* If we're meant to backup then backup */
     
    412399    if (say_at_end != NULL) {
    413400        log_to_screen(say_at_end);
    414         paranoid_free(say_at_end);
     401        mr_free(say_at_end);
    415402    }
    416403    mr_asprintf(&tmp, "umount %s/tmpfs", bkpinfo->tmpdir);
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-compare.c

    r2296 r2321  
    675675                        0, "Verifying archives against filesystem");
    676676
    677     if (bkpinfo->disaster_recovery
    678         && does_file_exist("/tmp/CDROM-LIVES-HERE")) {
     677    if (bkpinfo->disaster_recovery && does_file_exist("/tmp/CDROM-LIVES-HERE")) {
    679678        strcpy(bkpinfo->media_device,
    680679               last_line_of_file("/tmp/CDROM-LIVES-HERE"));
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c

    r2316 r2321  
    18411841void setup_MR_global_filenames()
    18421842{
    1843     char *temppath;
    1844 
    18451843    assert(bkpinfo != NULL);
    18461844
     
    18541852    malloc_string(g_isodir_device);
    18551853
    1856     temppath = bkpinfo->tmpdir;
    1857 
    1858     sprintf(g_biggielist_txt, "%s/%s", temppath, BIGGIELIST_TXT_STUB);
    1859     sprintf(g_filelist_full, "%s/%s", temppath, FILELIST_FULL_STUB);
    1860     sprintf(g_filelist_imagedevs, "%s/tmp/filelist.imagedevs", temppath);
    1861     sprintf(g_imagedevs_restthese, "%s/tmp/imagedevs.restore-these", temppath);
     1854    sprintf(g_biggielist_txt, "%s/%s", bkpinfo->tmpdir, BIGGIELIST_TXT_STUB);
     1855    sprintf(g_filelist_full, "%s/%s", bkpinfo->tmpdir, FILELIST_FULL_STUB);
     1856    sprintf(g_filelist_imagedevs, "%s/tmp/filelist.imagedevs", bkpinfo->tmpdir);
     1857    sprintf(g_imagedevs_restthese, "%s/tmp/imagedevs.restore-these", bkpinfo->tmpdir);
    18621858    if (bkpinfo->disaster_recovery) {
    18631859        sprintf(g_mondo_cfg_file, "/%s", MONDO_CFG_FILE_STUB);
    18641860        sprintf(g_mountlist_fname, "/%s", MOUNTLIST_FNAME_STUB);
    18651861    } else {
    1866         sprintf(g_mondo_cfg_file, "%s/%s", temppath, MONDO_CFG_FILE_STUB);
    1867         sprintf(g_mountlist_fname, "%s/%s", temppath, MOUNTLIST_FNAME_STUB);
     1862        sprintf(g_mondo_cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB);
     1863        sprintf(g_mountlist_fname, "%s/%s", bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB);
    18681864    }
    18691865}
  • branches/2.2.10/mondo/src/mondorestore/mondorestore.c

    r2320 r2321  
    27202720        exit(127);
    27212721    }
    2722     if (!
    2723         (bkpinfo = malloc(sizeof(struct s_bkpinfo)))) {
    2724         fatal_error("Cannot malloc bkpinfo");
    2725     }
    2726     reset_bkpinfo();
     2722    bkpinfo = (struct s_bkpinfo *)mr_malloc(sizeof(struct s_bkpinfo));
     2723    init_bkpinfo();
    27272724
    27282725    g_loglevel = DEFAULT_MR_LOGLEVEL;
    27292726
    2730 /* Configure global variables */
     2727    /* Configure global variables */
     2728    malloc_libmondo_global_strings();
    27312729#ifdef __FreeBSD__
    2732     if (strstr
    2733         (call_program_and_get_last_line_of_output("cat /tmp/cmdline"),
    2734          "textonly"))
     2730    if (strstr(call_program_and_get_last_line_of_output("cat /tmp/cmdline"), "textonly"))
    27352731#else
    2736     if (strstr
    2737         (call_program_and_get_last_line_of_output("cat /proc/cmdline"),
    2738          "textonly"))
     2732    if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "textonly"))
    27392733#endif
    27402734    {
     
    27442738        g_text_mode = FALSE;
    27452739    }                           // newt :-)
    2746     if (!(mountlist = malloc(sizeof(struct mountlist_itself)))) {
    2747         fatal_error("Cannot malloc mountlist");
    2748     }
    2749     if (!(raidlist = malloc(sizeof(struct raidlist_itself)))) {
    2750         fatal_error("Cannot malloc raidlist");
    2751     }
    2752 
    2753     malloc_libmondo_global_strings();
    2754 
    2755     strcpy(g_mondo_home,
    2756            call_program_and_get_last_line_of_output("which mondorestore"));
     2740
     2741    /* Init GUI */
     2742    setup_newt_stuff();         /* call newtInit and setup screen log */
     2743
     2744    strcpy(g_mondo_home, call_program_and_get_last_line_of_output("which mondorestore"));
    27572745    g_current_media_number = 1; // precaution
    27582746
     
    27742762    log_msg(1, "FYI - g_mountlist_fname = %s", g_mountlist_fname);
    27752763    if (strlen(g_mountlist_fname) < 3) {
    2776         fatal_error
    2777             ("Serious error in malloc()'ing. Could be a bug in your glibc.");
     2764        fatal_error("Serious error in malloc()'ing. Could be a bug in your glibc.");
    27782765    }
    27792766    mkdir(MNT_CDROM, 0x770);
     
    27832770    mr_asprintf(&tmp, "%s.orig", g_mountlist_fname);
    27842771    if (!does_file_exist(g_mountlist_fname)) {
    2785         log_msg(2,
    2786                 "%ld: Warning - g_mountlist_fname (%s) does not exist yet",
    2787                 __LINE__, g_mountlist_fname);
     2772        log_msg(2, "%ld: Warning - g_mountlist_fname (%s) does not exist yet", __LINE__, g_mountlist_fname);
    27882773    } else if (!does_file_exist(tmp)) {
    27892774        mr_free(tmp);
     
    27972782    make_hole_for_dir("/tmp/tmpfs");    /* just in case... */
    27982783    run_program_and_log_output("umount " MNT_CDROM, FALSE);
    2799     /*
    2800     run_program_and_log_output("ln -sf /var/log/mondo-archive.log /tmp/mondorestore.log",
    2801          FALSE);
    2802          */
    28032784
    28042785    run_program_and_log_output("rm -Rf /tmp/tmpfs/mondo.tmp.*", FALSE);
    28052786
    2806     /* Init GUI */
    2807     setup_newt_stuff();         /* call newtInit and setup screen log */
    28082787    welcome_to_mondorestore();
    28092788    if (bkpinfo->disaster_recovery) {
     
    28142793
    28152794    log_it("what time is it");
     2795
     2796    mountlist = (struct mountlist_itself *)mr_malloc(sizeof(struct mountlist_itself));
     2797    raidlist = (struct raidlist_itself *)mr_malloc(sizeof(struct raidlist_itself));
    28162798
    28172799    /* Process command-line parameters */
  • branches/2.2.10/mondo/src/mondorestore/mr-externs.h

    r2316 r2321  
    6161extern char *popup_and_get_string(char *, char *, char *);
    6262extern void setup_newt_stuff(void);
    63 extern void reset_bkpinfo();
     63extern void init_bkpinfo();
    6464extern int read_cfg_var(char *, char *, char *);
    6565extern int read_file_from_stream_to_file(char *,
Note: See TracChangeset for help on using the changeset viewer.