Ignore:
Timestamp:
Jul 17, 2006, 3:44:46 PM (13 years ago)
Author:
bcornec
Message:

Huge memory management patch.
Still not finished but a lot as been done.
What remains is around some functions returning strings, and some structure members.
(Could not finish due to laptop failure !)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/mondo/mondo/common/libmondo-verify.c

    r507 r688  
    55 * Functions for verifying backups (booted from hard drive, not CD).
    66 */
     7
     8#include <unistd.h>
    79
    810#include "my-stuff.h"
     
    5961
    6062    asprintf(&afio_found_changes, "%s.afio", ignorefiles_fname);
    61     paranoid_system("sync");
     63    sync();
    6264
    6365/*  sprintf (command,
     
    193195{
    194196
    195     /*@ buffer ********************************************************** */
    196     char *tmp;
    197     char *mountpoint;
    198 //  char ca, cb;
    199     char *command;
    200     char *sz_exe;
     197    char *tmp = NULL;
     198    char *tmp1 = NULL;
     199    char *tmp2 = NULL;
     200    char *mountpoint = NULL;
     201    char *command = NULL;
     202    char *sz_exe = NULL;
    201203    static char *bufblkA = NULL;
    202204    static char *bufblkB = NULL;
    203205    const long maxbufsize = 65536L;
    204     long currsizA = 0;
    205     long currsizB = 0;
    206     long j;
    207 
    208     /*@ long ************************************************************ */
    209     long bigfile_num = 0;
     206    long currsizA = 0L;
     207    long currsizB = 0L;
     208    long j = 0L;
     209    long bigfile_num = 0L;
    210210    long slice_num = -1;
    211     int res;
     211    int res = 0;
    212212
    213213    static FILE *forig = NULL;
     
    215215    static long last_bigfile_num = -1;
    216216    static long last_slice_num = -1;
    217     FILE *pin;
    218     FILE *fin;
     217    FILE *pin = NULL;
     218    FILE *fin = NULL;
    219219    int retval = 0;
    220 //  long long outlen;
    221 
    222     malloc_string(sz_exe);
     220
    223221    if (!bufblkA) {
    224222        if (!(bufblkA = malloc(maxbufsize))) {
     
    251249    open_evalcall_form(tmp);
    252250    paranoid_free(tmp);
     251
    253252    iamhere("after vsbf");
    254253    asprintf(&mountpoint, "%s/archives", mtpt);
     
    263262        slice_num = last_slice_num + 1;
    264263    }
    265     while (does_file_exist
    266            (slice_fname
    267             (bigfile_num, slice_num, mountpoint, bkpinfo->zip_suffix))
    268            ||
    269            does_file_exist(slice_fname
    270                            (bigfile_num, slice_num, mountpoint, ""))) {
    271 // handle slices until end of CD
     264
     265    tmp = slice_fname(bigfile_num, slice_num, mountpoint, bkpinfo->zip_suffix);
     266    tmp1 = slice_fname(bigfile_num, slice_num, mountpoint, "");
     267    while (does_file_exist(tmp) || does_file_exist(tmp1)) {
     268        // handle slices until end of CD
    272269        if (slice_num == 0) {
    273270            log_msg(2, "ISO=%d  bigfile=%ld --START--",
    274271                    g_current_media_number, bigfile_num);
    275             if (!
    276                 (fin =
    277                  fopen(slice_fname(bigfile_num, slice_num, mountpoint, ""),
    278                        "r"))) {
     272            if (!(fin = fopen(tmp1,"r"))) {
    279273                log_msg(2, "Cannot open bigfile's info file");
    280274            } else {
     
    286280                paranoid_fclose(fin);
    287281            }
    288             asprintf(&tmp, "%s/%s", bkpinfo->restore_path,
     282            asprintf(&tmp2, "%s/%s", bkpinfo->restore_path,
    289283                     biggiestruct.filename);
    290             log_msg(2, "Opening biggiefile #%ld - '%s'", bigfile_num, tmp);
    291             if (!(forig = fopen(tmp, "r"))) {
     284            log_msg(2, "Opening biggiefile #%ld - '%s'", bigfile_num, tmp2);
     285            if (!(forig = fopen(tmp2, "r"))) {
    292286                log_msg(2, "Failed to open bigfile. Darn.");
    293287                retval++;
    294288            }
    295             paranoid_free(tmp);
     289            paranoid_free(tmp2);
    296290
    297291            slice_num++;
    298         } else if (does_file_exist
    299                    (slice_fname(bigfile_num, slice_num, mountpoint, ""))) {
     292        } else if (does_file_exist(tmp1)) {
    300293            log_msg(2, "ISO=%d  bigfile=%ld ---END---",
    301294                    g_current_media_number, bigfile_num);
     
    307300                    g_current_media_number, bigfile_num, slice_num);
    308301            if (bkpinfo->compression_level > 0) {
    309                 asprintf(&command, "%s -dc %s 2>> %s", sz_exe,
    310                          slice_fname(bigfile_num, slice_num, mountpoint,
    311                                      bkpinfo->zip_suffix),
    312                          MONDO_LOGFILE);
     302                asprintf(&command, "%s -dc %s 2>> %s", sz_exe, tmp, MONDO_LOGFILE);
    313303            } else {
    314                 asprintf(&command, "cat %s",
    315                          slice_fname(bigfile_num, slice_num, mountpoint,
    316                                      bkpinfo->zip_suffix));
     304                asprintf(&command, "cat %s", tmp);
    317305            }
    318306            if ((pin = popen(command, "r"))) {
     
    356344        }
    357345    }
     346    paranoid_free(tmp);
     347    paranoid_free(tmp1);
    358348    paranoid_free(mountpoint);
    359349    paranoid_free(sz_exe);
     
    10721062
    10731063    /* find the final blocks */
    1074     paranoid_system("sync");
     1064    sync();
    10751065    sleep(2);
    10761066    closein_tape(bkpinfo);
Note: See TracChangeset for help on using the changeset viewer.