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

r3331@localhost: bruno | 2009-08-06 01:34:32 +0200

  • bkpinfo->scratchdir is now dynamically allocated
  • mondoarchive tests made in text+newt env. Seems OK. Valgrind errors to be fixed
File:
1 edited

Legend:

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

    r2296 r2320  
    12961296
    12971297    assert(bkpinfo != NULL);
    1298     log_it("tmpdir=%s; scratchdir=%s", bkpinfo->tmpdir,
    1299            bkpinfo->scratchdir);
     1298    log_it("tmpdir=%s; scratchdir=%s", bkpinfo->tmpdir, bkpinfo->scratchdir);
    13001299    if (bkpinfo->make_filelist) {
    13011300        mvaddstr_and_log_it(g_currentY, 0,
     
    13081307    if (bkpinfo->make_filelist) {
    13091308        res =
    1310             mondo_makefilelist(MONDO_LOGFILE, bkpinfo->tmpdir,
    1311                                bkpinfo->scratchdir, bkpinfo->include_paths,
    1312                                bkpinfo->exclude_paths,
    1313                                bkpinfo->differential, NULL);
     1309            mondo_makefilelist(MONDO_LOGFILE, bkpinfo->tmpdir, bkpinfo->scratchdir, bkpinfo->include_paths, bkpinfo->exclude_paths, bkpinfo->differential, NULL);
    13141310    } else {
    13151311        res =
    1316             mondo_makefilelist(MONDO_LOGFILE, bkpinfo->tmpdir,
    1317                                bkpinfo->scratchdir, NULL,
    1318                                bkpinfo->exclude_paths,
    1319                                bkpinfo->differential,
    1320                                bkpinfo->include_paths);
     1312            mondo_makefilelist(MONDO_LOGFILE, bkpinfo->tmpdir, bkpinfo->scratchdir, NULL, bkpinfo->exclude_paths, bkpinfo->differential, bkpinfo->include_paths);
    13211313    }
    13221314
     
    13821374        malloc_string(find_skeleton_marker);
    13831375        mr_asprintf(&find_excludes, " ");
    1384         while((token = mr_strtok (sth, delims, &lastpos))) {
    1385           mr_asprintf(&strtmp,"%s", find_excludes);
    1386           paranoid_free(find_excludes);
    1387           mr_asprintf(&find_excludes,"%s -path %s -prune -o", strtmp, token);
    1388           paranoid_free(strtmp);
    1389           mr_free(token);
     1376        if (sth != NULL) {
     1377            while((token = mr_strtok(sth, delims, &lastpos))) {
     1378                mr_strcat(find_excludes," -path %s -prune -o", token);
     1379            }
    13901380        }
    13911381#if linux
     
    13961386        mr_asprintf(&strtmp, "find '%s' -fstype mvfs -prune -o -path /proc -prune -o %s -type d -print > %s 2> /dev/null", dir, find_excludes, g_skeleton_filelist);
    13971387#endif
    1398         paranoid_free(find_excludes);
     1388        mr_free(find_excludes);
     1389
    13991390        log_msg(5, "find command = %s", strtmp);
    14001391        (void)system(strtmp);
    1401         paranoid_free(strtmp);
     1392        mr_free(strtmp);
     1393
    14021394        mr_asprintf(&tmp, "wc -l %s | awk '{print $1;}'", g_skeleton_filelist);
    1403         g_skeleton_entries =
    1404             1 + atol(call_program_and_get_last_line_of_output(tmp));
    1405         paranoid_free(tmp);
     1395        g_skeleton_entries = 1 + atol(call_program_and_get_last_line_of_output(tmp));
     1396        mr_free(tmp);
     1397
    14061398        sprintf(name_of_evalcall_form, "Making catalog of %s", dir);
    14071399        open_evalcall_form(name_of_evalcall_form);
     
    14151407                "grep -Fv '%s' %s > %s.new 2> /dev/null", dir,
    14161408                g_skeleton_filelist, g_skeleton_filelist);
    1417 //    log_msg(0, "fsm = %s", find_skeleton_marker);
    14181409        if (!system(find_skeleton_marker)) {
    14191410            percentage = (int) (skeleton_lino * 100 / g_skeleton_entries);
    14201411            skeleton_lino++;
    1421 //        log_msg(5, "Found %s", dir);
    1422 //        log_msg(2, "Incrementing skeleton_lino; now %ld/%ld (%d%%)", skeleton_lino, g_skeleton_entries, percentage);
    14231412            sprintf(find_skeleton_marker, "mv -f %s.new %s",
    14241413                    g_skeleton_filelist, g_skeleton_filelist);
    1425 //        log_msg(6, "fsm = %s", find_skeleton_marker);
    14261414            run_program_and_log_output(find_skeleton_marker, 8);
    14271415            time(&this_time);
     
    15701558    char *p, *q;
    15711559    char *sz_datefile;
    1572     char *sz_filelist, *exclude_paths, *tmp;
     1560    char *sz_filelist;
     1561    char *exclude_paths = NULL;
     1562    char *tmp;
    15731563    int i;
    15741564    FILE *fout;
     
    15811571    malloc_string(tmp);
    15821572    malloc_string(g_skeleton_filelist);
    1583     if (!(exclude_paths = malloc(8*MAX_STR_LEN))) {
    1584         fatal_error("Cannot malloc exclude_paths");
    1585     }
    15861573    mr_asprintf(&sz_datefile,MONDO_CACHE"/difflevel.%d" , 0);
    15871574    if (!include_paths && !userdef_filelist) {
     
    16371624        mr_free(command);
    16381625    } else {
    1639         log_msg(2, "include_paths = '%s'", include_paths);
     1626        if (include_paths) {
     1627            log_msg(2, "include_paths = '%s'", include_paths);
     1628        }
    16401629        log_msg(1, "Calculating filelist");
    16411630        mr_asprintf(&tmp2, "%s", call_program_and_get_last_line_of_output("mount | grep -Ew 'ntfs|ntfs-3g|fat|vfat|dos' | awk '{print $3}'"));
     
    16491638            log_msg(2, "Found windows files: %s",tmp2);
    16501639        }
    1651         paranoid_free(tmp1);
    1652 
    1653         snprintf(exclude_paths, (size_t)8*MAX_STR_LEN," %s %s %s %s %s . .. \
    1654 " MNT_CDROM " " MNT_FLOPPY " /media /tmp \
    1655 /proc /sys " MINDI_CACHE, MONDO_CACHE, excp, tmp2, (tmpdir[0] == '/' && tmpdir[1] == '/') ? (tmpdir + 1) : tmpdir, (scratchdir[0] == '/' && scratchdir[1] == '/') ? (scratchdir + 1) : scratchdir);
    1656         paranoid_free(tmp2);
     1640        mr_free(tmp1);
     1641
     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);
     1643        mr_free(tmp2);
    16571644
    16581645        log_msg(2, "Excluding paths = '%s'", exclude_paths);
    1659         log_msg(2,
    1660                 "Generating skeleton filelist so that we can track our progress");
     1646        log_msg(2, "Generating skeleton filelist so that we can track our progress");
    16611647        sprintf(g_skeleton_filelist, "%s/tmpfs/skeleton.txt", tmpdir);
    16621648        make_hole_for_file(g_skeleton_filelist);
     
    16671653        }
    16681654        i = 0;
    1669         if (strlen(include_paths) == 0) {
     1655        if ((!include_paths) || (strlen(include_paths) == 0)) {
    16701656            log_msg(1, "Including only '/' in %s", sz_filelist);
    16711657            open_and_list_dir("/", exclude_paths, fout,
     
    16851671            }
    16861672        }
     1673        mr_free(exclude_paths);
    16871674        paranoid_fclose(fout);
    16881675    }
     
    17021689    paranoid_free(sz_filelist);
    17031690    log_msg(2, "Freeing variables");
    1704     paranoid_free(exclude_paths);
    17051691    paranoid_free(tmp);
    17061692    paranoid_free(g_skeleton_filelist);
Note: See TracChangeset for help on using the changeset viewer.