Ignore:
Timestamp:
Feb 8, 2007, 12:09:34 AM (13 years ago)
Author:
Bruno Cornec
Message:

log_msg => mr_msg for common files

File:
1 edited

Legend:

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

    r1103 r1107  
    165165    int retval = 0;
    166166
    167     log_msg(1, "Sorting file %s", orig_fname);
     167    mr_msg(1, "Sorting file %s", orig_fname);
    168168    malloc_string(tmp_fname);
    169169    malloc_string(command);
     
    179179    retval = system(command);
    180180    if (retval) {
    181         log_msg(2, "Failed to sort %s - oh dear", orig_fname);
     181        mr_msg(2, "Failed to sort %s - oh dear", orig_fname);
    182182    } else {
    183         log_msg(2, "Sorted %s --> %s OK. Copying it back to %s now",
     183        mr_msg(2, "Sorted %s --> %s OK. Copying it back to %s now",
    184184                orig_fname, tmp_fname, orig_fname);
    185185        sprintf(command, "mv -f %s %s", tmp_fname, orig_fname);
    186186        retval += run_program_and_log_output(command, 2);
    187187        if (retval) {
    188             log_msg(2, "Failed to copy %s back to %s - oh dear", tmp_fname,
     188            mr_msg(2, "Failed to copy %s back to %s - oh dear", tmp_fname,
    189189                    orig_fname);
    190190        } else {
    191             log_msg(2, "%s was sorted OK.", orig_fname);
     191            mr_msg(2, "%s was sorted OK.", orig_fname);
    192192        }
    193193    }
    194194    mr_free(tmp_fname);
    195195    mr_free(command);
    196     log_msg(1, "Finished sorting file %s", orig_fname);
     196    mr_msg(1, "Finished sorting file %s", orig_fname);
    197197    return (retval);
    198198}
     
    289289        if (i > MAX_STR_LEN - 1) {
    290290            incoming[MAX_STR_LEN - 30] = '\0';
    291             log_msg(1, "Warning - truncating file %s's name", incoming);
     291            mr_msg(1, "Warning - truncating file %s's name", incoming);
    292292            err++;
    293293        }
     
    350350        sprintf(tmp, "Filelist divided into %ld sets", curr_set_no + 1);
    351351    }
    352     log_msg(1, tmp);
     352    mr_msg(1, tmp);
    353353    close_evalcall_form();
    354354    /* This is to work around an obscure bug in Newt; open a form, close it,
     
    435435    pattr = popen(sys_call, "r");
    436436    if (!pattr) {
    437         log_msg(1, "Failed to open fattr() %s", sys_call);
     437        mr_msg(1, "Failed to open fattr() %s", sys_call);
    438438        return (1);
    439439    }
    440440    if (feof(pattr)) {
    441         log_msg(1, "Failed to call fattr() %s", sys_call);
     441        mr_msg(1, "Failed to call fattr() %s", sys_call);
    442442        paranoid_pclose(pattr);
    443443        return (2);
     
    467467
    468468    if (!(fin = fopen(filelist, "r"))) {
    469         log_msg(1, "Cannot openin filelist %s", filelist);
     469        mr_msg(1, "Cannot openin filelist %s", filelist);
    470470        return (1);
    471471    }
     
    473473    sprintf(pout_command, "gzip -c1 > %s", auxlist_fname);
    474474    if (!(pout = popen(pout_command, "w"))) {
    475         log_msg(1, "Cannot openout auxlist_fname %s", auxlist_fname);
     475        mr_msg(1, "Cannot openout auxlist_fname %s", auxlist_fname);
    476476        fclose(fin);
    477477        mr_free(pout_command);
     
    485485            file_to_analyze[i - 1] = '\0';
    486486        }
    487         log_msg(8, "Analyzing %s", file_to_analyze);
     487        mr_msg(8, "Analyzing %s", file_to_analyze);
    488488        asprintf(&strtmp, syscall_sprintf, mr_stresc(file_to_analyze, "`$\\\"", '\\'));
    489489        asprintf(&sys_call, "%s 2>> /dev/null", strtmp);    // " MONDO_LOGFILE);
     
    552552
    553553    malloc_string(command);
    554     log_msg(1, "set_EXAT_list(%s, %s, %s)", orig_msklist,
     554    mr_msg(1, "set_EXAT_list(%s, %s, %s)", orig_msklist,
    555555            original_exat_fname, executable);
    556556    if (!orig_msklist || !orig_msklist[0]
    557557        || !does_file_exist(orig_msklist)) {
    558         log_msg(1,
     558        mr_msg(1,
    559559                "No masklist provided. I shall therefore set ALL attributes.");
    560560        sprintf(command, "gzip -dc %s | %s --restore - 2>> %s",
    561561                original_exat_fname, executable, MONDO_LOGFILE);
    562         log_msg(1, "command = %s", command);
     562        mr_msg(1, "command = %s", command);
    563563        retval = system(command);
    564564        mr_free(command);
    565         log_msg(1, "Returning w/ retval=%d", retval);
     565        mr_msg(1, "Returning w/ retval=%d", retval);
    566566        return (retval);
    567567    }
    568568    if (length_of_file(original_exat_fname) <= 0) {
    569         log_msg(1,
     569        mr_msg(1,
    570570                "original_exat_fname %s is empty or missing, so no need to set EXAT list",
    571571                original_exat_fname);
     
    589589            MONDO_LOGFILE);
    590590
    591     log_msg(1, "syscall_pin = %s", syscall_pin);
    592     log_msg(1, "syscall_pout = %s", syscall_pout);
     591    mr_msg(1, "syscall_pin = %s", syscall_pin);
     592    mr_msg(1, "syscall_pout = %s", syscall_pout);
    593593    pout = popen(syscall_pout, "w");
    594594    if (!pout) {
     
    638638
    639639        i = strcmp(p, q);
    640         log_msg(my_depth, "'%s' v '%s' --> %d\n", p, q, i);
     640        mr_msg(my_depth, "'%s' v '%s' --> %d\n", p, q, i);
    641641
    642642//      printf("%s v %s --> %d\n", p, q, i);
    643643
    644644        if (i < 0) {            // read another subset file in.
    645             log_msg(my_depth, "Reading next subset line in\n\n");
     645            mr_msg(my_depth, "Reading next subset line in\n\n");
    646646            fgets(current_subset_file, MAX_STR_LEN, faclin);
    647647            continue;
     
    653653        fgets(incoming, MAX_STR_LEN, pin);
    654654        if (!i) {
    655             log_msg(my_depth, "Copying master %s", q);
     655            mr_msg(my_depth, "Copying master %s", q);
    656656        }
    657657//      if (!i) { printf("Match --- %s\n", q); }
     
    696696        return (set_EXAT_list(masklist, fattr_fname, "setfattr"));
    697697    } else {
    698         log_msg(1, "ERROR: set_EXAT_list: setfattr doesn't exist");
     698        mr_msg(1, "ERROR: set_EXAT_list: setfattr doesn't exist");
    699699        return(0);
    700700    }
     
    708708        return (set_EXAT_list(masklist, acl_fname, "setfacl"));
    709709    } else {
    710         log_msg(1, "ERROR: set_EXAT_list: setfacl doesn't exist");
     710        mr_msg(1, "ERROR: set_EXAT_list: setfacl doesn't exist");
    711711        return(0);
    712712    }
     
    786786    char_to_add = string_to_add[0];
    787787    if (node->right != NULL && node->ch < char_to_add) {
    788         log_msg(7, "depth=%d --- going RIGHT ... %c-->%c", depth,
     788        mr_msg(7, "depth=%d --- going RIGHT ... %c-->%c", depth,
    789789                char_to_add, node->ch, (node->right)->ch);
    790790        return (add_string_at_node(node->right, string_to_add));
     
    793793/* walk down tree if appropriate */
    794794    if (node->down != NULL && node->ch == char_to_add) {
    795         log_msg(7, "depth=%d char=%c --- going DOWN", depth, char_to_add);
     795        mr_msg(7, "depth=%d char=%c --- going DOWN", depth, char_to_add);
    796796        depth++;
    797797        res = add_string_at_node(node->down, string_to_add + 1);
     
    801801
    802802    if (char_to_add == '\0' && node->ch == '\0') {
    803         log_msg(6, "%s already in tree", original_string);
     803        mr_msg(6, "%s already in tree", original_string);
    804804        return (1);
    805805    }
     
    809809    if (char_to_add < node->ch) // add to the left of node
    810810    {
    811         log_msg(7, "depth=%d char=%c --- adding (left)", depth,
     811        mr_msg(7, "depth=%d char=%c --- adding (left)", depth,
    812812                char_to_add);
    813813        memcpy((void *) newnode, (void *) node, sizeof(struct s_node));
     
    815815    } else if (char_to_add > node->ch)  // add to the right of node
    816816    {
    817         log_msg(7, "depth=%d char=%c --- adding (right)", depth,
     817        mr_msg(7, "depth=%d char=%c --- adding (right)", depth,
    818818                char_to_add);
    819819        newnode->right = node->right;   // newnode is to the RIGHT of node
     
    826826    node->expanded = node->selected = FALSE;
    827827    if (char_to_add == '\0') {
    828         log_msg(6, "Added %s OK", original_string);
     828        mr_msg(6, "Added %s OK", original_string);
    829829        return (0);
    830830    }
    831831// add the rest
    832     log_msg(6, "Adding remaining chars ('%s')", string_to_add + 1);
     832    mr_msg(6, "Adding remaining chars ('%s')", string_to_add + 1);
    833833    for (i = 1; i < noof_chars; i++) {
    834834        node->down = (struct s_node *) mr_malloc(sizeof(struct s_node));
    835835        node = node->down;
    836836        char_to_add = string_to_add[i];
    837         log_msg(6, "Adding '%c'", char_to_add);
     837        mr_msg(6, "Adding '%c'", char_to_add);
    838838        node->ch = char_to_add;
    839839        node->right = node->down = NULL;
     
    843843        }
    844844    }
    845     log_msg(6, "Finally - added %s OK", original_string);
     845    mr_msg(6, "Finally - added %s OK", original_string);
    846846    return (0);
    847847}
     
    886886    sprintf(command_to_open_fname, "gzip -dc %s", filelist_fname);
    887887    sprintf(tmp, "zcat %s | wc -l", filelist_fname);
    888     log_msg(6, "tmp = %s", tmp);
     888    mr_msg(6, "tmp = %s", tmp);
    889889    lines_in_filelist =
    890890        atol(call_program_and_get_last_line_of_output(tmp));
     
    949949
    950950    if (depth == 0) {
    951         log_msg(0, "----------------show filelist--------------");
     951        mr_msg(0, "----------------show filelist--------------");
    952952    }
    953953    current_string[depth] = node->ch;
    954954
    955     log_msg(3, "depth=%d", depth);
     955    mr_msg(3, "depth=%d", depth);
    956956    if (node->down) {
    957         log_msg(3, "moving down");
     957        mr_msg(3, "moving down");
    958958        depth++;
    959959        show_filelist(node->down);
     
    962962
    963963    if (!node->ch) {
    964         log_msg(0, "%s\n", current_string);
     964        mr_msg(0, "%s\n", current_string);
    965965    }
    966966
    967967    if (node->right) {
    968         log_msg(3, "moving right");
     968        mr_msg(3, "moving right");
    969969        show_filelist(node->right);
    970970    }
    971971    if (depth == 0) {
    972         log_msg(0, "----------------show filelist--------------");
     972        mr_msg(0, "----------------show filelist--------------");
    973973    }
    974974    return;
     
    10311031    for (node = filelist; node != NULL; node = node->right) {
    10321032        str[depth] = node->ch;
    1033         log_msg(5, "depth=%d ch=%c", depth, node->ch);
     1033        mr_msg(5, "depth=%d ch=%c", depth, node->ch);
    10341034        if (!node->ch) {
    10351035//    if (node->selected)
     
    14031403#endif
    14041404        mr_free(find_excludes);
    1405         log_msg(5, "find command = %s", strtmp);
     1405        mr_msg(5, "find command = %s", strtmp);
    14061406        system(strtmp);
    14071407        mr_free(strtmp);
     
    14131413        find_skeleton_marker[0] = '\0';
    14141414        skeleton_lino = 1;
    1415         log_msg(5, "entries = %ld", g_skeleton_entries);
     1415        mr_msg(5, "entries = %ld", g_skeleton_entries);
    14161416        percentage = 0;
    14171417    } else if (depth <= MAX_SKEL_DEPTH) // update evalcall form if appropriate
     
    14201420                "grep -Fv \"%s\" %s > %s.new 2> /dev/null", dir,
    14211421                g_skeleton_filelist, g_skeleton_filelist);
    1422 //    log_msg(0, "fsm = %s", find_skeleton_marker);
     1422//    mr_msg(0, "fsm = %s", find_skeleton_marker);
    14231423        if (!system(find_skeleton_marker)) {
    14241424            percentage = (int) (skeleton_lino * 100 / g_skeleton_entries);
    14251425            skeleton_lino++;
    1426 //        log_msg(5, "Found %s", dir);
    1427 //        log_msg(2, "Incrementing skeleton_lino; now %ld/%ld (%d%%)", skeleton_lino, g_skeleton_entries, percentage);
     1426//        mr_msg(5, "Found %s", dir);
     1427//        mr_msg(2, "Incrementing skeleton_lino; now %ld/%ld (%d%%)", skeleton_lino, g_skeleton_entries, percentage);
    14281428            sprintf(find_skeleton_marker, "mv -f %s.new %s",
    14291429                    g_skeleton_filelist, g_skeleton_filelist);
    1430 //        log_msg(6, "fsm = %s", find_skeleton_marker);
     1430//        mr_msg(6, "fsm = %s", find_skeleton_marker);
    14311431            run_program_and_log_output(find_skeleton_marker, 8);
    14321432            time(&this_time);
     
    14461446    depth++;
    14471447
    1448 //  log_msg(0, "Cataloguing %s", dir);
     1448//  mr_msg(0, "Cataloguing %s", dir);
    14491449    if (sth[0] == ' ') {
    14501450        skip_these = sth;
     
    15131513        mr_free(find_skeleton_marker);
    15141514        unlink(g_skeleton_filelist);
    1515         log_msg(5, "g_skeleton_entries = %ld", g_skeleton_entries);
     1515        mr_msg(5, "g_skeleton_entries = %ld", g_skeleton_entries);
    15161516    }
    15171517    mr_free(tmp);
     
    15841584    malloc_string(g_skeleton_filelist);
    15851585    exclude_paths = mr_malloc(1000);
    1586     log_msg(3, "Trying to write test string to exclude_paths");
     1586    mr_msg(3, "Trying to write test string to exclude_paths");
    15871587    strcpy(exclude_paths, "/blah /froo");
    1588     log_msg(3, "...Success!");
     1588    mr_msg(3, "...Success!");
    15891589    sprintf(sz_datefile, sz_datefile_wildcard, 0);
    15901590    if (!include_paths && !userdef_filelist) {
     
    16131613                                  ("date +%s"));
    16141614    } else if (lstat(sz_datefile, &statbuf)) {
    1615         log_msg(2,
     1615        mr_msg(2,
    16161616                "Warning - unable to find date of previous backup. Full backup instead.");
    16171617        differential = 0;
     
    16191619    } else {
    16201620        time_of_last_full_backup = statbuf.st_mtime;
    1621         log_msg(2, "Differential backup. Yay.");
     1621        mr_msg(2, "Differential backup. Yay.");
    16221622    }
    16231623
    16241624// use user-specified filelist (if specified)
    16251625    if (userdef_filelist) {
    1626         log_msg(1,
     1626        mr_msg(1,
    16271627                "Using the user-specified filelist - %s - instead of calculating one",
    16281628                userdef_filelist);
     
    16321632        }
    16331633    } else {
    1634         log_msg(2, "include_paths = '%s'", include_paths);
    1635         log_msg(1, "Calculating filelist");
     1634        mr_msg(2, "include_paths = '%s'", include_paths);
     1635        mr_msg(1, "Calculating filelist");
    16361636        sprintf(exclude_paths, " %s %s %s %s %s %s . .. \
    16371637" MNT_CDROM " " MNT_FLOPPY " /media \
    16381638/proc /sys /tmp /root/images/mondo /var/cache/mindi ", excp, call_program_and_get_last_line_of_output("locate /win386.swp 2> /dev/null"), call_program_and_get_last_line_of_output("locate /hiberfil.sys 2> /dev/null"), call_program_and_get_last_line_of_output("locate /pagefile.sys 2> /dev/null"), (tmpdir[0] == '/' && tmpdir[1] == '/') ? (tmpdir + 1) : tmpdir, (scratchdir[0] == '/' && scratchdir[1] == '/') ? (scratchdir + 1) : scratchdir);
    16391639
    1640         log_msg(2, "Excluding paths = '%s'", exclude_paths);
    1641         log_msg(2,
     1640        mr_msg(2, "Excluding paths = '%s'", exclude_paths);
     1641        mr_msg(2,
    16421642                "Generating skeleton filelist so that we can track our progress");
    16431643        sprintf(g_skeleton_filelist, "%s/tmpfs/skeleton.txt", tmpdir);
    16441644        make_hole_for_file(g_skeleton_filelist);
    1645         log_msg(4, "g_skeleton_entries = %ld", g_skeleton_entries);
    1646         log_msg(2, "Opening out filelist to %s", sz_filelist);
     1645        mr_msg(4, "g_skeleton_entries = %ld", g_skeleton_entries);
     1646        mr_msg(2, "Opening out filelist to %s", sz_filelist);
    16471647        if (!(fout = fopen(sz_filelist, "w"))) {
    16481648            fatal_error("Cannot openout to sz_filelist");
     
    16501650        i = 0;
    16511651        if (strlen(include_paths) == 0) {
    1652             log_msg(1, "Including only '/' in %s", sz_filelist);
     1652            mr_msg(1, "Including only '/' in %s", sz_filelist);
    16531653            open_and_list_dir("/", exclude_paths, fout,
    16541654                              time_of_last_full_backup);
     
    16571657            while (*p) {
    16581658                q = next_entry(p);
    1659                 log_msg(1, "Including %s in filelist %s", q, sz_filelist);
     1659                mr_msg(1, "Including %s in filelist %s", q, sz_filelist);
    16601660                open_and_list_dir(q, exclude_paths, fout,
    16611661                                  time_of_last_full_backup);
     
    16681668        paranoid_fclose(fout);
    16691669    }
    1670     log_msg(2, "Copying new filelist to scratchdir");
     1670    mr_msg(2, "Copying new filelist to scratchdir");
    16711671    sprintf(command, "mkdir -p %s/archives", scratchdir);
    16721672    paranoid_system(command);
     
    16751675    sprintf(command, "mv -f %s %s", sz_filelist, tmpdir);
    16761676    paranoid_system(command);
    1677     log_msg(2, "Freeing variables");
     1677    mr_msg(2, "Freeing variables");
    16781678    mr_free(sz_filelist);
    16791679    mr_free(command);
     
    16811681    mr_free(tmp);
    16821682    mr_free(g_skeleton_filelist);
    1683     log_msg(2, "Exiting");
     1683    mr_msg(2, "Exiting");
    16841684    return (0);
    16851685}
     
    17201720    noof_chars = strlen(string_to_find) + 1;    /* we include the '\0' */
    17211721
    1722     log_msg(7, "starting --- str=%s", string_to_find);
     1722    mr_msg(7, "starting --- str=%s", string_to_find);
    17231723
    17241724/* walk across tree if necessary */
     
    17261726    char_to_find = string_to_find[0];
    17271727    if (node->right != NULL && node->ch < char_to_find) {
    1728         log_msg(7, "depth=%d --- going RIGHT ... %c-->%c", depth,
     1728        mr_msg(7, "depth=%d --- going RIGHT ... %c-->%c", depth,
    17291729                char_to_find, node->ch, (node->right)->ch);
    17301730        return (find_string_at_node(node->right, string_to_find));
     
    17331733/* walk down tree if appropriate */
    17341734    if (node->down != NULL && node->ch == char_to_find) {
    1735         log_msg(7, "depth=%d char=%c --- going DOWN", depth, char_to_find);
     1735        mr_msg(7, "depth=%d char=%c --- going DOWN", depth, char_to_find);
    17361736        depth++;
    17371737        node = find_string_at_node(node->down, string_to_find + 1);
     
    17411741
    17421742    if (char_to_find == '\0' && node->ch == '\0') {
    1743         log_msg(7, "%s is in tree", original_string);
     1743        mr_msg(7, "%s is in tree", original_string);
    17441744        return (node);
    17451745    } else {
    1746         log_msg(7, "%s is NOT in tree", original_string);
     1746        mr_msg(7, "%s is NOT in tree", original_string);
    17471747        return (NULL);
    17481748    }
     
    17721772    size_t len = 0;             // Scrub's patch doesn't work without that
    17731773
    1774 //  log_msg(1, "use_star = %s", (use_star)?"TRUE":"FALSE");
     1774//  mr_msg(1, "use_star = %s", (use_star)?"TRUE":"FALSE");
    17751775    malloc_string(fname);
    17761776    malloc_string(tmp);
    1777     log_msg(5, "starting");
    1778     log_msg(5, "needles_list_fname = %s", needles_list_fname);
    1779     log_msg(5, "matches_list_fname = %s", matches_list_fname);
     1777    mr_msg(5, "starting");
     1778    mr_msg(5, "needles_list_fname = %s", needles_list_fname);
     1779    mr_msg(5, "matches_list_fname = %s", matches_list_fname);
    17801780    if (!(fin = fopen(needles_list_fname, "r"))) {
    17811781        fatal_error("Cannot openin needles_list_fname");
     
    18081808*/
    18091809
    1810         log_msg(5, "Looking for '%s'", fname);
     1810        mr_msg(5, "Looking for '%s'", fname);
    18111811        found_node = find_string_at_node(filelist, fname);
    18121812        if (found_node) {
     
    18171817                    strcpy(fname, tmp);
    18181818                }
    1819                 log_msg(5, "Found '%s'", fname);
     1819                mr_msg(5, "Found '%s'", fname);
    18201820                turn_wildcard_chars_into_literal_chars(tmp, fname);
    18211821                fprintf(fout, "%s\n", tmp);
     
    18521852
    18531853    malloc_string(tmp);
    1854     log_msg(3, "Adding %s to filelist", list_of_files_fname);
     1854    mr_msg(3, "Adding %s to filelist", list_of_files_fname);
    18551855    if (!(fin = fopen(list_of_files_fname, "r"))) {
    18561856        iamhere(list_of_files_fname);
     
    18661866            tmp[strlen(tmp) - 1] = '\0';
    18671867        }
    1868         log_msg(2, "tmp = '%s'", tmp);
     1868        mr_msg(2, "tmp = '%s'", tmp);
    18691869        if (!tmp[0]) {
    18701870            continue;
    18711871        }
    18721872        if ((nod = find_string_at_node(filelist, tmp))) {
    1873             log_msg(5, "Found '%s' in filelist already. Cool.", tmp);
     1873            mr_msg(5, "Found '%s' in filelist already. Cool.", tmp);
    18741874        } else {
    18751875            add_string_at_node(filelist, tmp);
     
    18791879        if (nod && flag_em) {
    18801880            toggle_path_selection(filelist, tmp, TRUE);
    1881             log_msg(5, "Flagged '%s'", tmp);
     1881            mr_msg(5, "Flagged '%s'", tmp);
    18821882        }
    18831883    }
Note: See TracChangeset for help on using the changeset viewer.