Ignore:
Timestamp:
Aug 18, 2009, 3:05:43 PM (15 years ago)
Author:
Bruno Cornec
Message:

r3334@localhost: bruno | 2009-08-08 12:17:37 +0200

  • Change mr_asprintf interface to pass only the char * (makes bkpinfo usage more easy)
File:
1 edited

Legend:

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

    r2321 r2323  
    9797    log_to_screen("Dividing filelist into sets. Please wait.");
    9898    i = 0;
    99     mr_asprintf(&filelist, "%s/archives/filelist.full", bkpinfo->scratchdir);
     99    mr_asprintf(filelist, "%s/archives/filelist.full", bkpinfo->scratchdir);
    100100    if (!does_file_exist(filelist)) {
    101101        log_it("filelist %s not found", filelist);
     
    108108    estimate_noof_media_required(noof_sets);    // for cosmetic purposes
    109109
    110     mr_asprintf(&tempfile, "%s/biggielist.txt", bkpinfo->tmpdir);
     110    mr_asprintf(tempfile, "%s/biggielist.txt", bkpinfo->tmpdir);
    111111    if (!(fout = fopen(tempfile, "a"))) {
    112112        log_OS_error("Cannot append to biggielist");
     
    158158    }                           // no sense in trying to sort an empty file
    159159
    160     mr_asprintf(&tmp_fname, "%s/sortfile", bkpinfo->tmpdir);
    161 
    162     mr_asprintf(&command, "sort %s > %s 2>> %s", orig_fname, tmp_fname, MONDO_LOGFILE);
     160    mr_asprintf(tmp_fname, "%s/sortfile", bkpinfo->tmpdir);
     161
     162    mr_asprintf(command, "sort %s > %s 2>> %s", orig_fname, tmp_fname, MONDO_LOGFILE);
    163163    retval = system(command);
    164164    mr_free(command);
     
    168168    } else {
    169169        log_msg(5, "Sorted %s --> %s OK. Copying it back to %s now", orig_fname, tmp_fname, orig_fname);
    170         mr_asprintf(&command, "mv -f %s %s", tmp_fname, orig_fname);
     170        mr_asprintf(command, "mv -f %s %s", tmp_fname, orig_fname);
    171171        retval += run_program_and_log_output(command, 5);
    172172        mr_free(command);
     
    240240    curr_set_no = 0;
    241241    curr_set_size = 0;
    242     mr_asprintf(&outfname, "%s/filelist.%ld", bkpinfo->tmpdir, curr_set_no);
    243     mr_asprintf(&biggie_fname, "%s/biggielist.txt", bkpinfo->tmpdir);
     242    mr_asprintf(outfname, "%s/filelist.%ld", bkpinfo->tmpdir, curr_set_no);
     243    mr_asprintf(biggie_fname, "%s/biggielist.txt", bkpinfo->tmpdir);
    244244    log_it("outfname=%s; biggie_fname=%s", outfname, biggie_fname);
    245245    if (!(fbig = fopen(biggie_fname, "w"))) {
     
    293293                curr_set_size = 0;
    294294
    295                 mr_asprintf(&outfname, "%s/filelist.%ld", bkpinfo->tmpdir, curr_set_no);
     295                mr_asprintf(outfname, "%s/filelist.%ld", bkpinfo->tmpdir, curr_set_no);
    296296                if (!(fout = fopen(outfname, "w"))) {
    297297                    log_OS_error("Unable to openout outfname");
     
    323323    mr_free(biggie_fname);
    324324
    325     mr_asprintf(&outfname, "%s/LAST-FILELIST-NUMBER", bkpinfo->tmpdir);
    326     mr_asprintf(&tmp, "%ld", curr_set_no);
     325    mr_asprintf(outfname, "%s/LAST-FILELIST-NUMBER", bkpinfo->tmpdir);
     326    mr_asprintf(tmp, "%ld", curr_set_no);
    327327    if (write_one_liner_data_file(outfname, tmp)) {
    328328        log_OS_error
     
    334334
    335335    if (curr_set_no == 0) {
    336         mr_asprintf(&tmp, "Only one fileset. Fine.");
     336        mr_asprintf(tmp, "Only one fileset. Fine.");
    337337    } else {
    338         mr_asprintf(&tmp, "Filelist divided into %ld sets", curr_set_no + 1);
     338        mr_asprintf(tmp, "Filelist divided into %ld sets", curr_set_no + 1);
    339339    }
    340340    log_msg(1, tmp);
     
    453453        return (1);
    454454    }
    455     mr_asprintf(&pout_command, "gzip -c1 > %s", auxlist_fname);
     455    mr_asprintf(pout_command, "gzip -c1 > %s", auxlist_fname);
    456456    if (!(pout = popen(pout_command, "w"))) {
    457457        log_msg(1, "Cannot openout auxlist_fname %s", auxlist_fname);
     
    471471        log_msg(8, "Analyzing %s", file_to_analyze);
    472472        tmp = mr_stresc(file_to_analyze, "`$\\\"(){}[]'*?&|!#~", '\\');
    473         mr_asprintf(&strtmp, syscall_sprintf, tmp);
     473        mr_asprintf(strtmp, syscall_sprintf, tmp);
    474474        paranoid_free(tmp);
    475         mr_asprintf(&syscall, "%s 2>> /dev/null", strtmp);  // " MONDO_LOGFILE);
     475        mr_asprintf(syscall, "%s 2>> /dev/null", strtmp);   // " MONDO_LOGFILE);
    476476        paranoid_free(strtmp);
    477477        call_exe_and_pipe_output_to_fd(syscall, pout);
     
    491491
    492492    if (g_getfacl != NULL) {
    493         mr_asprintf(&command, "touch %s", facl_fname);
     493        mr_asprintf(command, "touch %s", facl_fname);
    494494        run_program_and_log_output(command, 8);
    495495        mr_free(command);
    496496
    497         mr_asprintf(&command, "getfacl --all-effective -P %s 2>> %s | gzip -c1 > %s 2>> %s", filelist, MONDO_LOGFILE, facl_fname, MONDO_LOGFILE);
     497        mr_asprintf(command, "getfacl --all-effective -P %s 2>> %s | gzip -c1 > %s 2>> %s", filelist, MONDO_LOGFILE, facl_fname, MONDO_LOGFILE);
    498498        log_it("%s",command);
    499499        retval = system(command);
     
    510510
    511511    if (g_getfattr != NULL) {
    512         mr_asprintf(&command, "touch %s", fattr_fname);
     512        mr_asprintf(command, "touch %s", fattr_fname);
    513513        run_program_and_log_output(command, 8);
    514514        mr_free(command);
     
    540540        || !does_file_exist(orig_msklist)) {
    541541        log_msg(1, "No masklist provided. I shall therefore set ALL attributes.");
    542         mr_asprintf(&command, "gzip -dc %s | %s --restore - 2>> %s", original_exat_fname, executable, MONDO_LOGFILE);
     542        mr_asprintf(command, "gzip -dc %s | %s --restore - 2>> %s", original_exat_fname, executable, MONDO_LOGFILE);
    543543        log_msg(1, "command = %s", command);
    544544        retval = system(command);
     
    554554    malloc_string(current_subset_file);
    555555    malloc_string(current_master_file);
    556     mr_asprintf(&masklist, "%s/masklist", bkpinfo->tmpdir);
    557     mr_asprintf(&command, "cp -f %s %s", orig_msklist, masklist);
     556    mr_asprintf(masklist, "%s/masklist", bkpinfo->tmpdir);
     557    mr_asprintf(command, "cp -f %s %s", orig_msklist, masklist);
    558558    run_program_and_log_output(command, 1);
    559559    mr_free(command);
     
    562562    current_subset_file[0] = current_master_file[0] = '\0';
    563563
    564     mr_asprintf(&syscall_pout, "%s --restore - 2>> %s", executable, MONDO_LOGFILE);
     564    mr_asprintf(syscall_pout, "%s --restore - 2>> %s", executable, MONDO_LOGFILE);
    565565    log_msg(1, "syscall_pout = %s", syscall_pout);
    566566    pout = popen(syscall_pout, "w");
     
    573573    }
    574574
    575     mr_asprintf(&syscall_pin, "gzip -dc %s", original_exat_fname);
     575    mr_asprintf(syscall_pin, "gzip -dc %s", original_exat_fname);
    576576    log_msg(1, "syscall_pin = %s", syscall_pin);
    577577    pin = popen(syscall_pin, "r");
     
    714714
    715715    strcpy(val_sz,"");
    716     mr_asprintf(&cfg_fname, "%s/mondo-restore.cfg", bkpinfo->tmpdir);
     716    mr_asprintf(cfg_fname, "%s/mondo-restore.cfg", bkpinfo->tmpdir);
    717717    read_cfg_var(cfg_fname, "last-filelist-number", val_sz);
    718718    mr_free(cfg_fname);
     
    876876    }
    877877    log_to_screen("Loading filelist");
    878     mr_asprintf(&tmp1, "zcat %s | wc -l", filelist_fname);
     878    mr_asprintf(tmp1, "zcat %s | wc -l", filelist_fname);
    879879    log_msg(6, "tmp1 = %s", tmp1);
    880880    lines_in_filelist = atol(call_program_and_get_last_line_of_output(tmp1));
     
    896896    (filelist->down)->expanded = (filelist->down)->selected = FALSE;
    897897
    898     mr_asprintf(&command_to_open_fname, "gzip -dc %s", filelist_fname);
     898    mr_asprintf(command_to_open_fname, "gzip -dc %s", filelist_fname);
    899899    if (!(pin = popen(command_to_open_fname, "r"))) {
    900900        log_OS_error("Unable to openin filelist_fname");
     
    13681368        malloc_string(name_of_evalcall_form);
    13691369        malloc_string(find_skeleton_marker);
    1370         mr_asprintf(&find_excludes, " ");
     1370        mr_asprintf(find_excludes, " ");
    13711371        if (sth != NULL) {
    13721372            while((token = mr_strtok(sth, delims, &lastpos))) {
     
    13771377#if linux
    13781378        // 2.6 has /sys as a proc-type thing -- must be excluded
    1379         mr_asprintf(&strtmp, "find '%s' -fstype mvfs -prune -o -fstype devpts -prune -o -fstype tmpfs -prune -o -fstype proc -prune -o -fstype sysfs -prune -o %s -type d -print > %s 2> /dev/null", dir, find_excludes, g_skeleton_filelist);
     1379        mr_asprintf(strtmp, "find '%s' -fstype mvfs -prune -o -fstype devpts -prune -o -fstype tmpfs -prune -o -fstype proc -prune -o -fstype sysfs -prune -o %s -type d -print > %s 2> /dev/null", dir, find_excludes, g_skeleton_filelist);
    13801380#else
    13811381        // On BSD, for example, /sys is the kernel sources -- don't exclude
    1382         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);
     1382        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);
    13831383#endif
    13841384        mr_free(find_excludes);
     
    13881388        mr_free(strtmp);
    13891389
    1390         mr_asprintf(&tmp, "wc -l %s | awk '{print $1;}'", g_skeleton_filelist);
     1390        mr_asprintf(tmp, "wc -l %s | awk '{print $1;}'", g_skeleton_filelist);
    13911391        g_skeleton_entries = 1 + atol(call_program_and_get_last_line_of_output(tmp));
    13921392        mr_free(tmp);
     
    14141414#ifndef _XWIN
    14151415                if (!g_text_mode) {
    1416                     mr_asprintf(&tmp, "Reading %-68s", dir);
     1416                    mr_asprintf(tmp, "Reading %-68s", dir);
    14171417                    newtDrawRootText(0, g_noof_rows - 3, tmp);
    14181418                    paranoid_free(tmp);
     
    14281428//  log_msg(0, "Cataloguing %s", dir);
    14291429    if (sth[0] == ' ') {
    1430         mr_asprintf(&skip_these, "%s", sth);
     1430        mr_asprintf(skip_these, "%s", sth);
    14311431    } else {
    1432         mr_asprintf(&skip_these, " %s ", sth);
    1433     }
    1434     mr_asprintf(&new_with_spaces, " %s ", dir);
     1432        mr_asprintf(skip_these, " %s ", sth);
     1433    }
     1434    mr_asprintf(new_with_spaces, " %s ", dir);
    14351435    if ((dip = opendir(dir)) == NULL) {
    1436         mr_asprintf(&tmp,"opendir %s", dir);
     1436        mr_asprintf(tmp,"opendir %s", dir);
    14371437        log_OS_error(tmp);
    14381438        paranoid_free(tmp);
     
    14441444            i++;
    14451445            if (strcmp(dir, "/")) {
    1446                 mr_asprintf(&new,"%s/%s",dir,dit->d_name);
     1446                mr_asprintf(new,"%s/%s",dir,dit->d_name);
    14471447            } else {
    1448                 mr_asprintf(&new,"%s%s",dir,dit->d_name);
     1448                mr_asprintf(new,"%s%s",dir,dit->d_name);
    14491449            }
    14501450            paranoid_free(new_with_spaces);
    1451             mr_asprintf(&new_with_spaces, " %s ", new);
     1451            mr_asprintf(new_with_spaces, " %s ", new);
    14521452            if (strstr(skip_these, new_with_spaces)) {
    14531453                fprintf(fout, "%s\n", new);
     
    14681468                                counter = 0;
    14691469                                uberctr++;
    1470                                 mr_asprintf(&tmp, " %c ", special_dot_char(uberctr));
     1470                                mr_asprintf(tmp, " %c ", special_dot_char(uberctr));
    14711471#ifndef _XWIN
    14721472                                if (!g_text_mode) {
     
    15211521    bool in_quotes = FALSE;
    15221522
    1523     mr_asprintf(&sz_res, "%s", incoming);
     1523    mr_asprintf(sz_res, "%s", incoming);
    15241524    p = sz_res;
    15251525    while ((*p != ' ' || in_quotes) && *p != '\0') {
     
    15631563    malloc_string(tmp);
    15641564    malloc_string(g_skeleton_filelist);
    1565     mr_asprintf(&sz_datefile,MONDO_CACHE"/difflevel.%d" , 0);
     1565    mr_asprintf(sz_datefile,MONDO_CACHE"/difflevel.%d" , 0);
    15661566    if (!include_paths && !userdef_filelist) {
    15671567        fatal_error
     
    15691569    }
    15701570    // make hole for filelist
    1571     mr_asprintf(&command, "mkdir -p %s/archives", bkpinfo->scratchdir);
     1571    mr_asprintf(command, "mkdir -p %s/archives", bkpinfo->scratchdir);
    15721572    paranoid_system(command);
    15731573    mr_free(command);
    15741574
    1575     mr_asprintf(&sz_filelist, "%s/tmpfs/filelist.full", bkpinfo->tmpdir);
     1575    mr_asprintf(sz_filelist, "%s/tmpfs/filelist.full", bkpinfo->tmpdir);
    15761576    make_hole_for_file(sz_filelist);
    15771577
    15781578    if (differential == 0) {
    15791579        // restore last good datefile if it exists
    1580         mr_asprintf(&command, "cp -f %s.aborted %s", sz_datefile, sz_datefile);
     1580        mr_asprintf(command, "cp -f %s.aborted %s", sz_datefile, sz_datefile);
    15811581        run_program_and_log_output(command, 3);
    15821582        mr_free(command);
     
    15841584        // backup last known good datefile just in case :)
    15851585        if (does_file_exist(sz_datefile)) {
    1586             mr_asprintf(&command, "mv -f %s %s.aborted", sz_datefile,
     1586            mr_asprintf(command, "mv -f %s %s.aborted", sz_datefile,
    15871587                    sz_datefile);
    15881588            paranoid_system(command);
     
    16091609                "Using the user-specified filelist - %s - instead of calculating one",
    16101610                userdef_filelist);
    1611         mr_asprintf(&command, "cp -f %s %s", userdef_filelist, sz_filelist);
     1611        mr_asprintf(command, "cp -f %s %s", userdef_filelist, sz_filelist);
    16121612        if (run_program_and_log_output(command, 3)) {
    16131613            mr_free(command);
     
    16201620        }
    16211621        log_msg(1, "Calculating filelist");
    1622         mr_asprintf(&tmp2, "%s", call_program_and_get_last_line_of_output("mount | grep -Ew 'ntfs|ntfs-3g|fat|vfat|dos' | awk '{print $3}'"));
     1622        mr_asprintf(tmp2, "%s", call_program_and_get_last_line_of_output("mount | grep -Ew 'ntfs|ntfs-3g|fat|vfat|dos' | awk '{print $3}'"));
    16231623        if (strlen(tmp2) < 1) {
    1624             mr_asprintf(&tmp1," ");
     1624            mr_asprintf(tmp1," ");
    16251625        } else {
    16261626            log_msg(2, "Found windows FS: %s",tmp2);
    1627             mr_asprintf(&tmp1, "find %s -name '/win386.swp' -o -name '/hiberfil.sys' -o -name '/pagefile.sys' 2> /dev/null\n",tmp2);
     1627            mr_asprintf(tmp1, "find %s -name '/win386.swp' -o -name '/hiberfil.sys' -o -name '/pagefile.sys' 2> /dev/null\n",tmp2);
    16281628            paranoid_free(tmp2);
    1629             mr_asprintf(&tmp2, "%s", call_program_and_get_last_line_of_output(tmp1));
     1629            mr_asprintf(tmp2, "%s", call_program_and_get_last_line_of_output(tmp1));
    16301630            log_msg(2, "Found windows files: %s",tmp2);
    16311631        }
    16321632        mr_free(tmp1);
    16331633
    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);
     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);
    16351635        mr_free(tmp2);
    16361636
     
    16671667    }
    16681668    log_msg(2, "Copying new filelist to scratchdir");
    1669     mr_asprintf(&command, "mkdir -p %s/archives", bkpinfo->scratchdir);
     1669    mr_asprintf(command, "mkdir -p %s/archives", bkpinfo->scratchdir);
    16701670    paranoid_system(command);
    16711671    mr_free(command);
    16721672
    1673     mr_asprintf(&command, "cp -f %s %s/archives/", sz_filelist, bkpinfo->scratchdir);
     1673    mr_asprintf(command, "cp -f %s %s/archives/", sz_filelist, bkpinfo->scratchdir);
    16741674    paranoid_system(command);
    16751675    mr_free(command);
    16761676
    1677     mr_asprintf(&command, "mv -f %s %s", sz_filelist, bkpinfo->tmpdir);
     1677    mr_asprintf(command, "mv -f %s %s", sz_filelist, bkpinfo->tmpdir);
    16781678    paranoid_system(command);
    16791679    mr_free(command);
Note: See TracChangeset for help on using the changeset viewer.