Changeset 1107 in MondoRescue for branches/stable/mondo/src/common/libmondo-filelist.c
- Timestamp:
- Feb 8, 2007, 12:09:34 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/src/common/libmondo-filelist.c
r1103 r1107 165 165 int retval = 0; 166 166 167 log_msg(1, "Sorting file %s", orig_fname);167 mr_msg(1, "Sorting file %s", orig_fname); 168 168 malloc_string(tmp_fname); 169 169 malloc_string(command); … … 179 179 retval = system(command); 180 180 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); 182 182 } 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", 184 184 orig_fname, tmp_fname, orig_fname); 185 185 sprintf(command, "mv -f %s %s", tmp_fname, orig_fname); 186 186 retval += run_program_and_log_output(command, 2); 187 187 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, 189 189 orig_fname); 190 190 } else { 191 log_msg(2, "%s was sorted OK.", orig_fname);191 mr_msg(2, "%s was sorted OK.", orig_fname); 192 192 } 193 193 } 194 194 mr_free(tmp_fname); 195 195 mr_free(command); 196 log_msg(1, "Finished sorting file %s", orig_fname);196 mr_msg(1, "Finished sorting file %s", orig_fname); 197 197 return (retval); 198 198 } … … 289 289 if (i > MAX_STR_LEN - 1) { 290 290 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); 292 292 err++; 293 293 } … … 350 350 sprintf(tmp, "Filelist divided into %ld sets", curr_set_no + 1); 351 351 } 352 log_msg(1, tmp);352 mr_msg(1, tmp); 353 353 close_evalcall_form(); 354 354 /* This is to work around an obscure bug in Newt; open a form, close it, … … 435 435 pattr = popen(sys_call, "r"); 436 436 if (!pattr) { 437 log_msg(1, "Failed to open fattr() %s", sys_call);437 mr_msg(1, "Failed to open fattr() %s", sys_call); 438 438 return (1); 439 439 } 440 440 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); 442 442 paranoid_pclose(pattr); 443 443 return (2); … … 467 467 468 468 if (!(fin = fopen(filelist, "r"))) { 469 log_msg(1, "Cannot openin filelist %s", filelist);469 mr_msg(1, "Cannot openin filelist %s", filelist); 470 470 return (1); 471 471 } … … 473 473 sprintf(pout_command, "gzip -c1 > %s", auxlist_fname); 474 474 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); 476 476 fclose(fin); 477 477 mr_free(pout_command); … … 485 485 file_to_analyze[i - 1] = '\0'; 486 486 } 487 log_msg(8, "Analyzing %s", file_to_analyze);487 mr_msg(8, "Analyzing %s", file_to_analyze); 488 488 asprintf(&strtmp, syscall_sprintf, mr_stresc(file_to_analyze, "`$\\\"", '\\')); 489 489 asprintf(&sys_call, "%s 2>> /dev/null", strtmp); // " MONDO_LOGFILE); … … 552 552 553 553 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, 555 555 original_exat_fname, executable); 556 556 if (!orig_msklist || !orig_msklist[0] 557 557 || !does_file_exist(orig_msklist)) { 558 log_msg(1,558 mr_msg(1, 559 559 "No masklist provided. I shall therefore set ALL attributes."); 560 560 sprintf(command, "gzip -dc %s | %s --restore - 2>> %s", 561 561 original_exat_fname, executable, MONDO_LOGFILE); 562 log_msg(1, "command = %s", command);562 mr_msg(1, "command = %s", command); 563 563 retval = system(command); 564 564 mr_free(command); 565 log_msg(1, "Returning w/ retval=%d", retval);565 mr_msg(1, "Returning w/ retval=%d", retval); 566 566 return (retval); 567 567 } 568 568 if (length_of_file(original_exat_fname) <= 0) { 569 log_msg(1,569 mr_msg(1, 570 570 "original_exat_fname %s is empty or missing, so no need to set EXAT list", 571 571 original_exat_fname); … … 589 589 MONDO_LOGFILE); 590 590 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); 593 593 pout = popen(syscall_pout, "w"); 594 594 if (!pout) { … … 638 638 639 639 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); 641 641 642 642 // printf("%s v %s --> %d\n", p, q, i); 643 643 644 644 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"); 646 646 fgets(current_subset_file, MAX_STR_LEN, faclin); 647 647 continue; … … 653 653 fgets(incoming, MAX_STR_LEN, pin); 654 654 if (!i) { 655 log_msg(my_depth, "Copying master %s", q);655 mr_msg(my_depth, "Copying master %s", q); 656 656 } 657 657 // if (!i) { printf("Match --- %s\n", q); } … … 696 696 return (set_EXAT_list(masklist, fattr_fname, "setfattr")); 697 697 } 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"); 699 699 return(0); 700 700 } … … 708 708 return (set_EXAT_list(masklist, acl_fname, "setfacl")); 709 709 } 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"); 711 711 return(0); 712 712 } … … 786 786 char_to_add = string_to_add[0]; 787 787 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, 789 789 char_to_add, node->ch, (node->right)->ch); 790 790 return (add_string_at_node(node->right, string_to_add)); … … 793 793 /* walk down tree if appropriate */ 794 794 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); 796 796 depth++; 797 797 res = add_string_at_node(node->down, string_to_add + 1); … … 801 801 802 802 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); 804 804 return (1); 805 805 } … … 809 809 if (char_to_add < node->ch) // add to the left of node 810 810 { 811 log_msg(7, "depth=%d char=%c --- adding (left)", depth,811 mr_msg(7, "depth=%d char=%c --- adding (left)", depth, 812 812 char_to_add); 813 813 memcpy((void *) newnode, (void *) node, sizeof(struct s_node)); … … 815 815 } else if (char_to_add > node->ch) // add to the right of node 816 816 { 817 log_msg(7, "depth=%d char=%c --- adding (right)", depth,817 mr_msg(7, "depth=%d char=%c --- adding (right)", depth, 818 818 char_to_add); 819 819 newnode->right = node->right; // newnode is to the RIGHT of node … … 826 826 node->expanded = node->selected = FALSE; 827 827 if (char_to_add == '\0') { 828 log_msg(6, "Added %s OK", original_string);828 mr_msg(6, "Added %s OK", original_string); 829 829 return (0); 830 830 } 831 831 // 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); 833 833 for (i = 1; i < noof_chars; i++) { 834 834 node->down = (struct s_node *) mr_malloc(sizeof(struct s_node)); 835 835 node = node->down; 836 836 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); 838 838 node->ch = char_to_add; 839 839 node->right = node->down = NULL; … … 843 843 } 844 844 } 845 log_msg(6, "Finally - added %s OK", original_string);845 mr_msg(6, "Finally - added %s OK", original_string); 846 846 return (0); 847 847 } … … 886 886 sprintf(command_to_open_fname, "gzip -dc %s", filelist_fname); 887 887 sprintf(tmp, "zcat %s | wc -l", filelist_fname); 888 log_msg(6, "tmp = %s", tmp);888 mr_msg(6, "tmp = %s", tmp); 889 889 lines_in_filelist = 890 890 atol(call_program_and_get_last_line_of_output(tmp)); … … 949 949 950 950 if (depth == 0) { 951 log_msg(0, "----------------show filelist--------------");951 mr_msg(0, "----------------show filelist--------------"); 952 952 } 953 953 current_string[depth] = node->ch; 954 954 955 log_msg(3, "depth=%d", depth);955 mr_msg(3, "depth=%d", depth); 956 956 if (node->down) { 957 log_msg(3, "moving down");957 mr_msg(3, "moving down"); 958 958 depth++; 959 959 show_filelist(node->down); … … 962 962 963 963 if (!node->ch) { 964 log_msg(0, "%s\n", current_string);964 mr_msg(0, "%s\n", current_string); 965 965 } 966 966 967 967 if (node->right) { 968 log_msg(3, "moving right");968 mr_msg(3, "moving right"); 969 969 show_filelist(node->right); 970 970 } 971 971 if (depth == 0) { 972 log_msg(0, "----------------show filelist--------------");972 mr_msg(0, "----------------show filelist--------------"); 973 973 } 974 974 return; … … 1031 1031 for (node = filelist; node != NULL; node = node->right) { 1032 1032 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); 1034 1034 if (!node->ch) { 1035 1035 // if (node->selected) … … 1403 1403 #endif 1404 1404 mr_free(find_excludes); 1405 log_msg(5, "find command = %s", strtmp);1405 mr_msg(5, "find command = %s", strtmp); 1406 1406 system(strtmp); 1407 1407 mr_free(strtmp); … … 1413 1413 find_skeleton_marker[0] = '\0'; 1414 1414 skeleton_lino = 1; 1415 log_msg(5, "entries = %ld", g_skeleton_entries);1415 mr_msg(5, "entries = %ld", g_skeleton_entries); 1416 1416 percentage = 0; 1417 1417 } else if (depth <= MAX_SKEL_DEPTH) // update evalcall form if appropriate … … 1420 1420 "grep -Fv \"%s\" %s > %s.new 2> /dev/null", dir, 1421 1421 g_skeleton_filelist, g_skeleton_filelist); 1422 // log_msg(0, "fsm = %s", find_skeleton_marker);1422 // mr_msg(0, "fsm = %s", find_skeleton_marker); 1423 1423 if (!system(find_skeleton_marker)) { 1424 1424 percentage = (int) (skeleton_lino * 100 / g_skeleton_entries); 1425 1425 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); 1428 1428 sprintf(find_skeleton_marker, "mv -f %s.new %s", 1429 1429 g_skeleton_filelist, g_skeleton_filelist); 1430 // log_msg(6, "fsm = %s", find_skeleton_marker);1430 // mr_msg(6, "fsm = %s", find_skeleton_marker); 1431 1431 run_program_and_log_output(find_skeleton_marker, 8); 1432 1432 time(&this_time); … … 1446 1446 depth++; 1447 1447 1448 // log_msg(0, "Cataloguing %s", dir);1448 // mr_msg(0, "Cataloguing %s", dir); 1449 1449 if (sth[0] == ' ') { 1450 1450 skip_these = sth; … … 1513 1513 mr_free(find_skeleton_marker); 1514 1514 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); 1516 1516 } 1517 1517 mr_free(tmp); … … 1584 1584 malloc_string(g_skeleton_filelist); 1585 1585 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"); 1587 1587 strcpy(exclude_paths, "/blah /froo"); 1588 log_msg(3, "...Success!");1588 mr_msg(3, "...Success!"); 1589 1589 sprintf(sz_datefile, sz_datefile_wildcard, 0); 1590 1590 if (!include_paths && !userdef_filelist) { … … 1613 1613 ("date +%s")); 1614 1614 } else if (lstat(sz_datefile, &statbuf)) { 1615 log_msg(2,1615 mr_msg(2, 1616 1616 "Warning - unable to find date of previous backup. Full backup instead."); 1617 1617 differential = 0; … … 1619 1619 } else { 1620 1620 time_of_last_full_backup = statbuf.st_mtime; 1621 log_msg(2, "Differential backup. Yay.");1621 mr_msg(2, "Differential backup. Yay."); 1622 1622 } 1623 1623 1624 1624 // use user-specified filelist (if specified) 1625 1625 if (userdef_filelist) { 1626 log_msg(1,1626 mr_msg(1, 1627 1627 "Using the user-specified filelist - %s - instead of calculating one", 1628 1628 userdef_filelist); … … 1632 1632 } 1633 1633 } 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"); 1636 1636 sprintf(exclude_paths, " %s %s %s %s %s %s . .. \ 1637 1637 " MNT_CDROM " " MNT_FLOPPY " /media \ 1638 1638 /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); 1639 1639 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, 1642 1642 "Generating skeleton filelist so that we can track our progress"); 1643 1643 sprintf(g_skeleton_filelist, "%s/tmpfs/skeleton.txt", tmpdir); 1644 1644 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); 1647 1647 if (!(fout = fopen(sz_filelist, "w"))) { 1648 1648 fatal_error("Cannot openout to sz_filelist"); … … 1650 1650 i = 0; 1651 1651 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); 1653 1653 open_and_list_dir("/", exclude_paths, fout, 1654 1654 time_of_last_full_backup); … … 1657 1657 while (*p) { 1658 1658 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); 1660 1660 open_and_list_dir(q, exclude_paths, fout, 1661 1661 time_of_last_full_backup); … … 1668 1668 paranoid_fclose(fout); 1669 1669 } 1670 log_msg(2, "Copying new filelist to scratchdir");1670 mr_msg(2, "Copying new filelist to scratchdir"); 1671 1671 sprintf(command, "mkdir -p %s/archives", scratchdir); 1672 1672 paranoid_system(command); … … 1675 1675 sprintf(command, "mv -f %s %s", sz_filelist, tmpdir); 1676 1676 paranoid_system(command); 1677 log_msg(2, "Freeing variables");1677 mr_msg(2, "Freeing variables"); 1678 1678 mr_free(sz_filelist); 1679 1679 mr_free(command); … … 1681 1681 mr_free(tmp); 1682 1682 mr_free(g_skeleton_filelist); 1683 log_msg(2, "Exiting");1683 mr_msg(2, "Exiting"); 1684 1684 return (0); 1685 1685 } … … 1720 1720 noof_chars = strlen(string_to_find) + 1; /* we include the '\0' */ 1721 1721 1722 log_msg(7, "starting --- str=%s", string_to_find);1722 mr_msg(7, "starting --- str=%s", string_to_find); 1723 1723 1724 1724 /* walk across tree if necessary */ … … 1726 1726 char_to_find = string_to_find[0]; 1727 1727 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, 1729 1729 char_to_find, node->ch, (node->right)->ch); 1730 1730 return (find_string_at_node(node->right, string_to_find)); … … 1733 1733 /* walk down tree if appropriate */ 1734 1734 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); 1736 1736 depth++; 1737 1737 node = find_string_at_node(node->down, string_to_find + 1); … … 1741 1741 1742 1742 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); 1744 1744 return (node); 1745 1745 } else { 1746 log_msg(7, "%s is NOT in tree", original_string);1746 mr_msg(7, "%s is NOT in tree", original_string); 1747 1747 return (NULL); 1748 1748 } … … 1772 1772 size_t len = 0; // Scrub's patch doesn't work without that 1773 1773 1774 // log_msg(1, "use_star = %s", (use_star)?"TRUE":"FALSE");1774 // mr_msg(1, "use_star = %s", (use_star)?"TRUE":"FALSE"); 1775 1775 malloc_string(fname); 1776 1776 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); 1780 1780 if (!(fin = fopen(needles_list_fname, "r"))) { 1781 1781 fatal_error("Cannot openin needles_list_fname"); … … 1808 1808 */ 1809 1809 1810 log_msg(5, "Looking for '%s'", fname);1810 mr_msg(5, "Looking for '%s'", fname); 1811 1811 found_node = find_string_at_node(filelist, fname); 1812 1812 if (found_node) { … … 1817 1817 strcpy(fname, tmp); 1818 1818 } 1819 log_msg(5, "Found '%s'", fname);1819 mr_msg(5, "Found '%s'", fname); 1820 1820 turn_wildcard_chars_into_literal_chars(tmp, fname); 1821 1821 fprintf(fout, "%s\n", tmp); … … 1852 1852 1853 1853 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); 1855 1855 if (!(fin = fopen(list_of_files_fname, "r"))) { 1856 1856 iamhere(list_of_files_fname); … … 1866 1866 tmp[strlen(tmp) - 1] = '\0'; 1867 1867 } 1868 log_msg(2, "tmp = '%s'", tmp);1868 mr_msg(2, "tmp = '%s'", tmp); 1869 1869 if (!tmp[0]) { 1870 1870 continue; 1871 1871 } 1872 1872 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); 1874 1874 } else { 1875 1875 add_string_at_node(filelist, tmp); … … 1879 1879 if (nod && flag_em) { 1880 1880 toggle_path_selection(filelist, tmp, TRUE); 1881 log_msg(5, "Flagged '%s'", tmp);1881 mr_msg(5, "Flagged '%s'", tmp); 1882 1882 } 1883 1883 }
Note:
See TracChangeset
for help on using the changeset viewer.