Changeset 2323 in MondoRescue for branches/2.2.10/mondo/src/common/libmondo-filelist.c
- Timestamp:
- Aug 18, 2009, 3:05:43 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-filelist.c
r2321 r2323 97 97 log_to_screen("Dividing filelist into sets. Please wait."); 98 98 i = 0; 99 mr_asprintf( &filelist, "%s/archives/filelist.full", bkpinfo->scratchdir);99 mr_asprintf(filelist, "%s/archives/filelist.full", bkpinfo->scratchdir); 100 100 if (!does_file_exist(filelist)) { 101 101 log_it("filelist %s not found", filelist); … … 108 108 estimate_noof_media_required(noof_sets); // for cosmetic purposes 109 109 110 mr_asprintf( &tempfile, "%s/biggielist.txt", bkpinfo->tmpdir);110 mr_asprintf(tempfile, "%s/biggielist.txt", bkpinfo->tmpdir); 111 111 if (!(fout = fopen(tempfile, "a"))) { 112 112 log_OS_error("Cannot append to biggielist"); … … 158 158 } // no sense in trying to sort an empty file 159 159 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); 163 163 retval = system(command); 164 164 mr_free(command); … … 168 168 } else { 169 169 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); 171 171 retval += run_program_and_log_output(command, 5); 172 172 mr_free(command); … … 240 240 curr_set_no = 0; 241 241 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); 244 244 log_it("outfname=%s; biggie_fname=%s", outfname, biggie_fname); 245 245 if (!(fbig = fopen(biggie_fname, "w"))) { … … 293 293 curr_set_size = 0; 294 294 295 mr_asprintf( &outfname, "%s/filelist.%ld", bkpinfo->tmpdir, curr_set_no);295 mr_asprintf(outfname, "%s/filelist.%ld", bkpinfo->tmpdir, curr_set_no); 296 296 if (!(fout = fopen(outfname, "w"))) { 297 297 log_OS_error("Unable to openout outfname"); … … 323 323 mr_free(biggie_fname); 324 324 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); 327 327 if (write_one_liner_data_file(outfname, tmp)) { 328 328 log_OS_error … … 334 334 335 335 if (curr_set_no == 0) { 336 mr_asprintf( &tmp, "Only one fileset. Fine.");336 mr_asprintf(tmp, "Only one fileset. Fine."); 337 337 } 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); 339 339 } 340 340 log_msg(1, tmp); … … 453 453 return (1); 454 454 } 455 mr_asprintf( &pout_command, "gzip -c1 > %s", auxlist_fname);455 mr_asprintf(pout_command, "gzip -c1 > %s", auxlist_fname); 456 456 if (!(pout = popen(pout_command, "w"))) { 457 457 log_msg(1, "Cannot openout auxlist_fname %s", auxlist_fname); … … 471 471 log_msg(8, "Analyzing %s", file_to_analyze); 472 472 tmp = mr_stresc(file_to_analyze, "`$\\\"(){}[]'*?&|!#~", '\\'); 473 mr_asprintf( &strtmp, syscall_sprintf, tmp);473 mr_asprintf(strtmp, syscall_sprintf, tmp); 474 474 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); 476 476 paranoid_free(strtmp); 477 477 call_exe_and_pipe_output_to_fd(syscall, pout); … … 491 491 492 492 if (g_getfacl != NULL) { 493 mr_asprintf( &command, "touch %s", facl_fname);493 mr_asprintf(command, "touch %s", facl_fname); 494 494 run_program_and_log_output(command, 8); 495 495 mr_free(command); 496 496 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); 498 498 log_it("%s",command); 499 499 retval = system(command); … … 510 510 511 511 if (g_getfattr != NULL) { 512 mr_asprintf( &command, "touch %s", fattr_fname);512 mr_asprintf(command, "touch %s", fattr_fname); 513 513 run_program_and_log_output(command, 8); 514 514 mr_free(command); … … 540 540 || !does_file_exist(orig_msklist)) { 541 541 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); 543 543 log_msg(1, "command = %s", command); 544 544 retval = system(command); … … 554 554 malloc_string(current_subset_file); 555 555 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); 558 558 run_program_and_log_output(command, 1); 559 559 mr_free(command); … … 562 562 current_subset_file[0] = current_master_file[0] = '\0'; 563 563 564 mr_asprintf( &syscall_pout, "%s --restore - 2>> %s", executable, MONDO_LOGFILE);564 mr_asprintf(syscall_pout, "%s --restore - 2>> %s", executable, MONDO_LOGFILE); 565 565 log_msg(1, "syscall_pout = %s", syscall_pout); 566 566 pout = popen(syscall_pout, "w"); … … 573 573 } 574 574 575 mr_asprintf( &syscall_pin, "gzip -dc %s", original_exat_fname);575 mr_asprintf(syscall_pin, "gzip -dc %s", original_exat_fname); 576 576 log_msg(1, "syscall_pin = %s", syscall_pin); 577 577 pin = popen(syscall_pin, "r"); … … 714 714 715 715 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); 717 717 read_cfg_var(cfg_fname, "last-filelist-number", val_sz); 718 718 mr_free(cfg_fname); … … 876 876 } 877 877 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); 879 879 log_msg(6, "tmp1 = %s", tmp1); 880 880 lines_in_filelist = atol(call_program_and_get_last_line_of_output(tmp1)); … … 896 896 (filelist->down)->expanded = (filelist->down)->selected = FALSE; 897 897 898 mr_asprintf( &command_to_open_fname, "gzip -dc %s", filelist_fname);898 mr_asprintf(command_to_open_fname, "gzip -dc %s", filelist_fname); 899 899 if (!(pin = popen(command_to_open_fname, "r"))) { 900 900 log_OS_error("Unable to openin filelist_fname"); … … 1368 1368 malloc_string(name_of_evalcall_form); 1369 1369 malloc_string(find_skeleton_marker); 1370 mr_asprintf( &find_excludes, " ");1370 mr_asprintf(find_excludes, " "); 1371 1371 if (sth != NULL) { 1372 1372 while((token = mr_strtok(sth, delims, &lastpos))) { … … 1377 1377 #if linux 1378 1378 // 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); 1380 1380 #else 1381 1381 // 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); 1383 1383 #endif 1384 1384 mr_free(find_excludes); … … 1388 1388 mr_free(strtmp); 1389 1389 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); 1391 1391 g_skeleton_entries = 1 + atol(call_program_and_get_last_line_of_output(tmp)); 1392 1392 mr_free(tmp); … … 1414 1414 #ifndef _XWIN 1415 1415 if (!g_text_mode) { 1416 mr_asprintf( &tmp, "Reading %-68s", dir);1416 mr_asprintf(tmp, "Reading %-68s", dir); 1417 1417 newtDrawRootText(0, g_noof_rows - 3, tmp); 1418 1418 paranoid_free(tmp); … … 1428 1428 // log_msg(0, "Cataloguing %s", dir); 1429 1429 if (sth[0] == ' ') { 1430 mr_asprintf( &skip_these, "%s", sth);1430 mr_asprintf(skip_these, "%s", sth); 1431 1431 } 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); 1435 1435 if ((dip = opendir(dir)) == NULL) { 1436 mr_asprintf( &tmp,"opendir %s", dir);1436 mr_asprintf(tmp,"opendir %s", dir); 1437 1437 log_OS_error(tmp); 1438 1438 paranoid_free(tmp); … … 1444 1444 i++; 1445 1445 if (strcmp(dir, "/")) { 1446 mr_asprintf( &new,"%s/%s",dir,dit->d_name);1446 mr_asprintf(new,"%s/%s",dir,dit->d_name); 1447 1447 } else { 1448 mr_asprintf( &new,"%s%s",dir,dit->d_name);1448 mr_asprintf(new,"%s%s",dir,dit->d_name); 1449 1449 } 1450 1450 paranoid_free(new_with_spaces); 1451 mr_asprintf( &new_with_spaces, " %s ", new);1451 mr_asprintf(new_with_spaces, " %s ", new); 1452 1452 if (strstr(skip_these, new_with_spaces)) { 1453 1453 fprintf(fout, "%s\n", new); … … 1468 1468 counter = 0; 1469 1469 uberctr++; 1470 mr_asprintf( &tmp, " %c ", special_dot_char(uberctr));1470 mr_asprintf(tmp, " %c ", special_dot_char(uberctr)); 1471 1471 #ifndef _XWIN 1472 1472 if (!g_text_mode) { … … 1521 1521 bool in_quotes = FALSE; 1522 1522 1523 mr_asprintf( &sz_res, "%s", incoming);1523 mr_asprintf(sz_res, "%s", incoming); 1524 1524 p = sz_res; 1525 1525 while ((*p != ' ' || in_quotes) && *p != '\0') { … … 1563 1563 malloc_string(tmp); 1564 1564 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); 1566 1566 if (!include_paths && !userdef_filelist) { 1567 1567 fatal_error … … 1569 1569 } 1570 1570 // make hole for filelist 1571 mr_asprintf( &command, "mkdir -p %s/archives", bkpinfo->scratchdir);1571 mr_asprintf(command, "mkdir -p %s/archives", bkpinfo->scratchdir); 1572 1572 paranoid_system(command); 1573 1573 mr_free(command); 1574 1574 1575 mr_asprintf( &sz_filelist, "%s/tmpfs/filelist.full", bkpinfo->tmpdir);1575 mr_asprintf(sz_filelist, "%s/tmpfs/filelist.full", bkpinfo->tmpdir); 1576 1576 make_hole_for_file(sz_filelist); 1577 1577 1578 1578 if (differential == 0) { 1579 1579 // 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); 1581 1581 run_program_and_log_output(command, 3); 1582 1582 mr_free(command); … … 1584 1584 // backup last known good datefile just in case :) 1585 1585 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, 1587 1587 sz_datefile); 1588 1588 paranoid_system(command); … … 1609 1609 "Using the user-specified filelist - %s - instead of calculating one", 1610 1610 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); 1612 1612 if (run_program_and_log_output(command, 3)) { 1613 1613 mr_free(command); … … 1620 1620 } 1621 1621 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}'")); 1623 1623 if (strlen(tmp2) < 1) { 1624 mr_asprintf( &tmp1," ");1624 mr_asprintf(tmp1," "); 1625 1625 } else { 1626 1626 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); 1628 1628 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)); 1630 1630 log_msg(2, "Found windows files: %s",tmp2); 1631 1631 } 1632 1632 mr_free(tmp1); 1633 1633 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); 1635 1635 mr_free(tmp2); 1636 1636 … … 1667 1667 } 1668 1668 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); 1670 1670 paranoid_system(command); 1671 1671 mr_free(command); 1672 1672 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); 1674 1674 paranoid_system(command); 1675 1675 mr_free(command); 1676 1676 1677 mr_asprintf( &command, "mv -f %s %s", sz_filelist, bkpinfo->tmpdir);1677 mr_asprintf(command, "mv -f %s %s", sz_filelist, bkpinfo->tmpdir); 1678 1678 paranoid_system(command); 1679 1679 mr_free(command);
Note:
See TracChangeset
for help on using the changeset viewer.