Changeset 900 in MondoRescue for trunk/mondo/src/common/libmondo-filelist.c
- Timestamp:
- Oct 24, 2006, 8:49:18 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/src/common/libmondo-filelist.c
r863 r900 17 17 #include "newt-specific-EXT.h" 18 18 #include "libmondo-tools-EXT.h" 19 #include "mr_string.h" 19 #include "mr_str.h" 20 #include "mr_mem.h" 20 21 21 22 #include <time.h> … … 102 103 { i=0; log_to_screen ("This will take more time. Please be patient."); } 103 104 */ 104 asprintf(&filelist, "%s/archives/filelist.full", bkpinfo->scratchdir);105 mr_asprintf(&filelist, "%s/archives/filelist.full", bkpinfo->scratchdir); 105 106 if (!does_file_exist(filelist)) { 106 107 log_it("filelist %s not found", filelist); … … 111 112 chop_filelist(filelist, bkpinfo->tmpdir, 112 113 bkpinfo->optimal_set_size); 113 paranoid_free(filelist);114 mr_free(filelist); 114 115 115 116 estimate_noof_media_required(bkpinfo, noof_sets); // for cosmetic purposes 116 117 117 asprintf(&tempfile, "%s/biggielist.txt", bkpinfo->tmpdir);118 mr_asprintf(&tempfile, "%s/biggielist.txt", bkpinfo->tmpdir); 118 119 if (!(fout = fopen(tempfile, "a"))) { 119 120 log_OS_error("Cannot append to biggielist"); 120 121 retval++; 121 122 } 122 paranoid_free(tempfile);123 mr_free(tempfile); 123 124 log_it(bkpinfo->image_devs); 124 125 … … 126 127 127 128 while (ptr && *ptr) { 128 asprintf(&dev, ptr);129 mr_asprintf(&dev, ptr); 129 130 log_it("Examining imagedev %s", dev); 130 131 for (i = 0; i < (int) strlen(dev) && dev[i] != ' '; i++); … … 135 136 fprintf(fout, "%s\n", dev); 136 137 log_it("Adding '%s' to biggielist", dev); 137 paranoid_free(dev);138 mr_free(dev); 138 139 139 140 if ((ptr = strchr(ptr, ' '))) { … … 156 157 157 158 log_msg(1, "Sorting file %s", orig_fname); 158 asprintf(&tmp_fname, "/tmp/sort.%d.%d.%d", (int) (random() % 32768),159 mr_asprintf(&tmp_fname, "/tmp/sort.%d.%d.%d", (int) (random() % 32768), 159 160 (int) (random() % 32768), (int) (random() % 32768)); 160 161 … … 163 164 } // no sense in trying to sort an empty file 164 165 165 asprintf(&command, "sort %s > %s 2>> %s", orig_fname, tmp_fname,166 mr_asprintf(&command, "sort %s > %s 2>> %s", orig_fname, tmp_fname, 166 167 MONDO_LOGFILE); 167 168 retval = system(command); 168 paranoid_free(command);169 mr_free(command); 169 170 170 171 if (retval) { … … 173 174 log_msg(2, "Sorted %s --> %s OK. Copying it back to %s now", 174 175 orig_fname, tmp_fname, orig_fname); 175 asprintf(&command, "mv -f %s %s", tmp_fname, orig_fname);176 mr_asprintf(&command, "mv -f %s %s", tmp_fname, orig_fname); 176 177 retval += run_program_and_log_output(command, 2); 177 paranoid_free(command);178 mr_free(command); 178 179 179 180 if (retval) { … … 184 185 } 185 186 } 186 paranoid_free(tmp_fname);187 mr_free(tmp_fname); 187 188 log_msg(1, "Finished sorting file %s", orig_fname); 188 189 return (retval); … … 248 249 curr_set_no = 0; 249 250 curr_set_size = 0; 250 asprintf(&outfname, "%s/filelist.%ld", outdir, curr_set_no);251 asprintf(&biggie_fname, "%s/biggielist.txt", outdir);251 mr_asprintf(&outfname, "%s/filelist.%ld", outdir, curr_set_no); 252 mr_asprintf(&biggie_fname, "%s/biggielist.txt", outdir); 252 253 log_it("outfname=%s; biggie_fname=%s", outfname, biggie_fname); 253 254 if (!(fbig = fopen(biggie_fname, "w"))) { … … 259 260 return (0); 260 261 } 261 (void)getline(&incoming, &n, fin);262 mr_getline(&incoming, &n, fin); 262 263 while (!feof(fin)) { 263 264 lino++; … … 286 287 paranoid_fclose(fout); 287 288 sort_file(outfname); 288 paranoid_free(outfname);289 mr_free(outfname); 289 290 290 291 curr_set_no++; 291 292 curr_set_size = 0; 292 asprintf(&outfname, "%s/filelist.%ld", outdir,293 mr_asprintf(&outfname, "%s/filelist.%ld", outdir, 293 294 curr_set_no); 294 295 if (!(fout = fopen(outfname, "w"))) { … … 299 300 } 300 301 } 301 (void)getline(&incoming, &n, fin);302 mr_getline(&incoming, &n, fin); 302 303 } 303 304 paranoid_fclose(fin); … … 312 313 sort_file(outfname); 313 314 sort_file(biggie_fname); 314 paranoid_free(biggie_fname);315 paranoid_free(outfname);316 317 asprintf(&outfname, "%s/LAST-FILELIST-NUMBER", outdir);318 asprintf(&tmp, "%ld", curr_set_no);315 mr_free(biggie_fname); 316 mr_free(outfname); 317 318 mr_asprintf(&outfname, "%s/LAST-FILELIST-NUMBER", outdir); 319 mr_asprintf(&tmp, "%ld", curr_set_no); 319 320 if (write_one_liner_data_file(outfname, tmp)) { 320 321 log_OS_error … … 322 323 return (0); 323 324 } 324 paranoid_free(outfname);325 paranoid_free(tmp);325 mr_free(outfname); 326 mr_free(tmp); 326 327 327 328 if (curr_set_no == 0) { 328 asprintf(&tmp, "Only one fileset. Fine.");329 mr_asprintf(&tmp, "Only one fileset. Fine."); 329 330 } else { 330 asprintf(&tmp, "Filelist divided into %ld sets", curr_set_no + 1);331 mr_asprintf(&tmp, "Filelist divided into %ld sets", curr_set_no + 1); 331 332 } 332 333 log_msg(1, tmp); 333 paranoid_free(tmp);334 mr_free(tmp); 334 335 close_evalcall_form(); 335 336 /* This is to work around an obscure bug in Newt; open a form, close it, … … 391 392 } 392 393 filelist->ch = '\0'; 393 paranoid_free(filelist);394 mr_free((void *)filelist); 394 395 depth--; 395 396 if (depth == 0) { … … 416 417 return (2); 417 418 } 418 for ( getline(&tmp, &n, pattr); !feof(pattr);getline(&tmp, &n, pattr)) {419 for (mr_getline(&tmp, &n, pattr); !feof(pattr); mr_getline(&tmp, &n, pattr)) { 419 420 fputs(tmp, pout); 420 421 } 421 422 paranoid_pclose(pattr); 422 paranoid_free(tmp);423 mr_free(tmp); 423 424 return (0); 424 425 } … … 432 433 char *pout_command; 433 434 char *syscall; 434 char *tmp;435 435 char *file_to_analyze = NULL; 436 436 int i; … … 441 441 return (1); 442 442 } 443 asprintf(&pout_command, "gzip -c1 > %s", auxlist_fname);443 mr_asprintf(&pout_command, "gzip -c1 > %s", auxlist_fname); 444 444 if (!(pout = popen(pout_command, "w"))) { 445 445 log_msg(1, "Cannot openout auxlist_fname %s", auxlist_fname); 446 446 fclose(fin); 447 paranoid_free(pout_command);447 mr_free(pout_command); 448 448 return (4); 449 449 } 450 paranoid_free(pout_command);451 452 for ( getline(&file_to_analyze, &n, fin); !feof(fin);453 getline(&file_to_analyze, &n, fin)) {450 mr_free(pout_command); 451 452 for (mr_getline(&file_to_analyze, &n, fin); !feof(fin); 453 mr_getline(&file_to_analyze, &n, fin)) { 454 454 i = strlen(file_to_analyze); 455 455 if (i > 0 && file_to_analyze[i - 1] < 32) { … … 458 458 log_msg(8, "Analyzing %s", file_to_analyze); 459 459 /* BERLIOS : to be checked */ 460 asprintf(&syscall, "%s %s 2>> /dev/null", syscall_sprintf,mr_stresc(file_to_analyze, "`$\\\"", '\\'));460 mr_asprintf(&syscall, "%s %s 2>> /dev/null", syscall_sprintf,mr_stresc(file_to_analyze, "`$\\\"", '\\')); 461 461 call_exe_and_pipe_output_to_fd(syscall, pout); 462 paranoid_free(syscall);462 mr_free(syscall); 463 463 } 464 464 paranoid_fclose(fin); 465 465 paranoid_pclose(pout); 466 paranoid_free(file_to_analyze);466 mr_free(file_to_analyze); 467 467 return (0); 468 468 } … … 475 475 int retval = 0; 476 476 477 asprintf(&command, "touch %s", facl_fname);477 mr_asprintf(&command, "touch %s", facl_fname); 478 478 run_program_and_log_output(command, 8); 479 paranoid_free(command);479 mr_free(command); 480 480 481 481 tmp = find_home_of_exe("getfacl"); 482 482 if (tmp) { 483 483 // sort_file(filelist); // FIXME - filelist chopper sorts, so this isn't necessary 484 asprintf(&command,484 mr_asprintf(&command, 485 485 "getfacl --all-effective -P %s 2>> %s | gzip -c1 > %s 2>> %s", 486 486 filelist, MONDO_LOGFILE, facl_fname, MONDO_LOGFILE); 487 487 iamhere(command); 488 488 retval = system(command); 489 paranoid_free(command);490 } 491 paranoid_free(tmp);489 mr_free(command); 490 } 491 mr_free(tmp); 492 492 return (retval); 493 493 } … … 500 500 int retval = 0; 501 501 502 asprintf(&command, "touch %s", fattr_fname);502 mr_asprintf(&command, "touch %s", fattr_fname); 503 503 run_program_and_log_output(command, 8); 504 paranoid_free(command);504 mr_free(command); 505 505 506 506 tmp = find_home_of_exe("getfattr"); … … 511 511 fattr_fname); 512 512 } 513 paranoid_free(tmp);513 mr_free(tmp); 514 514 return (retval); 515 515 } … … 531 531 retval = system(command); 532 532 } 533 paranoid_free(command);533 mr_free(command); 534 534 return(retval); 535 535 } … … 557 557 log_msg(1, 558 558 "No masklist provided. I shall therefore set ALL attributes."); 559 asprintf(&command, "gzip -dc %s | %s --restore - 2>> %s",559 mr_asprintf(&command, "gzip -dc %s | %s --restore - 2>> %s", 560 560 original_exat_fname, executable, MONDO_LOGFILE); 561 561 log_msg(1, "command = %s", command); 562 562 retval = system(command); 563 paranoid_free(command);563 mr_free(command); 564 564 log_msg(1, "Returning w/ retval=%d", retval); 565 565 return (retval); … … 571 571 return (0); 572 572 } 573 asprintf(&masklist, "/tmp/%d.%d.mask", (int) (random() % 32768),573 mr_asprintf(&masklist, "/tmp/%d.%d.mask", (int) (random() % 32768), 574 574 (int) (random() % 32768)); 575 asprintf(&command, "cp -f %s %s", orig_msklist, masklist);575 mr_asprintf(&command, "cp -f %s %s", orig_msklist, masklist); 576 576 run_program_and_log_output(command, 1); 577 paranoid_free(command);577 mr_free(command); 578 578 579 579 sort_file(masklist); 580 asprintf(&syscall_pin, "gzip -dc %s", original_exat_fname);581 asprintf(&syscall_pout, "%s --restore - 2>> %s", executable,580 mr_asprintf(&syscall_pin, "gzip -dc %s", original_exat_fname); 581 mr_asprintf(&syscall_pout, "%s --restore - 2>> %s", executable, 582 582 MONDO_LOGFILE); 583 583 … … 589 589 return (1); 590 590 } 591 paranoid_free(syscall_pout);591 mr_free(syscall_pout); 592 592 593 593 pin = popen(syscall_pin, "r"); … … 597 597 return (1); 598 598 } 599 paranoid_free(syscall_pin);599 mr_free(syscall_pin); 600 600 601 601 faclin = fopen(masklist, "r"); … … 608 608 // printf("Hi there. Starting the loop\n"); 609 609 610 getline(¤t_subset_file, &n, faclin);611 getline(&incoming, &n, pin);610 mr_getline(¤t_subset_file, &n, faclin); 611 mr_getline(&incoming, &n, pin); 612 612 while (!feof(pin) && !feof(faclin)) { 613 613 // printf("incoming = %s", incoming); 614 614 615 asprintf(¤t_master_file, incoming + 8);615 mr_asprintf(¤t_master_file, incoming + 8); 616 616 617 617 p = current_subset_file; … … 641 641 if (i < 0) { // read another subset file in. 642 642 log_msg(my_depth, "Reading next subset line in\n\n"); 643 getline(¤t_subset_file, &n, faclin);643 mr_getline(¤t_subset_file, &n, faclin); 644 644 continue; 645 645 } … … 648 648 fputs(incoming, pout); 649 649 } 650 getline(&incoming, &n, pin);650 mr_getline(&incoming, &n, pin); 651 651 if (!i) { 652 652 log_msg(my_depth, "Copying master %s", q); … … 661 661 fputs(incoming, pout); 662 662 } 663 getline(&incoming, &n, pin);663 mr_getline(&incoming, &n, pin); 664 664 } 665 665 if (!i) { 666 getline(¤t_subset_file, &n, faclin);667 } 668 paranoid_free(current_master_file);669 } 670 paranoid_free(current_subset_file);666 mr_getline(¤t_subset_file, &n, faclin); 667 } 668 mr_free(current_master_file); 669 } 670 mr_free(current_subset_file); 671 671 672 672 while (!feof(pin)) { 673 getline(&incoming, &n, pin);674 } 675 paranoid_free(incoming);673 mr_getline(&incoming, &n, pin); 674 } 675 mr_free(incoming); 676 676 fclose(faclin); 677 677 pclose(pin); … … 681 681 682 682 unlink(masklist); 683 paranoid_free(masklist);683 mr_free(masklist); 684 684 685 685 return (retval); … … 719 719 assert(bkpinfo != NULL); 720 720 721 asprintf(&cfg_fname, "%s/mondo-restore.cfg", bkpinfo->tmpdir);721 mr_asprintf(&cfg_fname, "%s/mondo-restore.cfg", bkpinfo->tmpdir); 722 722 read_cfg_var(cfg_fname, "last-filelist-number", val_sz); 723 723 val_i = atoi(val_sz); 724 paranoid_free(val_sz);724 mr_free(val_sz); 725 725 726 726 if (val_i <= 0) { 727 727 val_i = 500; 728 728 } 729 paranoid_free(cfg_fname);729 mr_free(cfg_fname); 730 730 return (val_i); 731 731 } … … 866 866 } 867 867 log_to_screen(_("Loading filelist")); 868 asprintf(&command_to_open_fname, "gzip -dc %s", filelist_fname);869 asprintf(&tmp, "zcat %s | wc -l", filelist_fname);868 mr_asprintf(&command_to_open_fname, "gzip -dc %s", filelist_fname); 869 mr_asprintf(&tmp, "zcat %s | wc -l", filelist_fname); 870 870 log_msg(6, "tmp = %s", tmp); 871 871 tmp1 = call_program_and_get_last_line_of_output(tmp); 872 paranoid_free(tmp);872 mr_free(tmp); 873 873 874 874 lines_in_filelist = atol(tmp1); 875 paranoid_free(tmp1);875 mr_free(tmp1); 876 876 877 877 if (lines_in_filelist < 3) { … … 893 893 return (NULL); 894 894 } 895 paranoid_free(command_to_open_fname);895 mr_free(command_to_open_fname); 896 896 897 897 open_evalcall_form(_("Loading filelist from disk")); 898 for ( getline(&fname, &n, pin); !feof(pin);getline(&fname, &n, pin)) {898 for (mr_getline(&fname, &n, pin); !feof(pin); mr_getline(&fname, &n, pin)) { 899 899 if ((fname[strlen(fname) - 1] == 13 900 900 || fname[strlen(fname) - 1] == 10) && strlen(fname) > 0) { … … 908 908 continue; 909 909 } 910 asprintf(&tmp, fname);910 mr_asprintf(&tmp, fname); 911 911 tmp[pos_in_fname] = '\0'; 912 912 if (strlen(tmp)) { 913 913 add_string_at_node(filelist, tmp); 914 914 } 915 paranoid_free(tmp);915 mr_free(tmp); 916 916 } 917 917 add_string_at_node(filelist, fname); … … 921 921 } 922 922 } 923 paranoid_free(fname);923 mr_free(fname); 924 924 paranoid_pclose(pin); 925 925 close_evalcall_form(); … … 1352 1352 if (!depth) { 1353 1353 malloc_string(find_skeleton_marker); 1354 asprintf(&find_excludes, " ");1354 mr_asprintf(&find_excludes, " "); 1355 1355 while((token = mr_strtok (sth, delims, &lastpos))) { 1356 asprintf(&strtmp,"%s", find_excludes);1357 paranoid_free(find_excludes);1358 asprintf(&find_excludes,"%s -path %s -prune -o", strtmp, token);1359 paranoid_free(strtmp);1360 paranoid_free(token);1356 mr_asprintf(&strtmp,"%s", find_excludes); 1357 mr_free(find_excludes); 1358 mr_asprintf(&find_excludes,"%s -path %s -prune -o", strtmp, token); 1359 mr_free(strtmp); 1360 mr_free(token); 1361 1361 } 1362 1362 #if linux 1363 1363 // 2.6 has /sys as a proc-type thing -- must be excluded 1364 asprintf(&strtmp,1364 mr_asprintf(&strtmp, 1365 1365 "find %s -maxdepth %d -fstype mvfs -prune -o -path /dev/shm -prune -o %s -type d -print > %s 2> /dev/null", 1366 1366 dir, MAX_SKEL_DEPTH, find_excludes, skeleton_filelist); 1367 1367 #else 1368 1368 // On BSD, for example, /sys is the kernel sources -- don't exclude 1369 asprintf(&strtmp,1369 mr_asprintf(&strtmp, 1370 1370 "find %s -maxdepth %d -fstype mvfs -prune -o -path /proc -prune -o %s -type d -print > %s 2> /dev/null", 1371 1371 dir, MAX_SKEL_DEPTH, find_excludes, skeleton_filelist); 1372 1372 #endif 1373 paranoid_free(find_excludes);1373 mr_free(find_excludes); 1374 1374 log_msg(5, "find command = %s", strtmp); 1375 1375 system(strtmp); 1376 paranoid_free(strtmp);1377 paranoid_free(tmp);1378 1379 asprintf(&tmp, "wc -l %s | awk '{print $1;}'", skeleton_filelist);1376 mr_free(strtmp); 1377 mr_free(tmp); 1378 1379 mr_asprintf(&tmp, "wc -l %s | awk '{print $1;}'", skeleton_filelist); 1380 1380 tmp1 = call_program_and_get_last_line_of_output(tmp); 1381 paranoid_free(tmp);1381 mr_free(tmp); 1382 1382 1383 1383 g_skeleton_entries = 1 + atol(tmp1); 1384 paranoid_free(tmp1);1385 1386 asprintf(&name_of_evalcall_form, "Making catalog of %s", dir);1384 mr_free(tmp1); 1385 1386 mr_asprintf(&name_of_evalcall_form, "Making catalog of %s", dir); 1387 1387 open_evalcall_form(name_of_evalcall_form); 1388 1388 find_skeleton_marker[0] = '\0'; … … 1410 1410 #ifndef _XWIN 1411 1411 if (!g_text_mode) { 1412 asprintf(&tmp, _("Reading %-68s"), dir);1412 mr_asprintf(&tmp, _("Reading %-68s"), dir); 1413 1413 newtDrawRootText(0, g_noof_rows - 3, tmp); 1414 paranoid_free(tmp);1414 mr_free(tmp); 1415 1415 } 1416 1416 #endif … … 1424 1424 // log_msg(0, "Cataloguing %s", dir); 1425 1425 if (sth[0] == ' ') { 1426 asprintf(&skip_these, "%s", sth);1426 mr_asprintf(&skip_these, "%s", sth); 1427 1427 } else { 1428 asprintf(&skip_these, " %s ", sth);1429 } 1430 asprintf(&new_with_spaces, " %s ", dir);1428 mr_asprintf(&skip_these, " %s ", sth); 1429 } 1430 mr_asprintf(&new_with_spaces, " %s ", dir); 1431 1431 if ((dip = opendir(dir)) == NULL) { 1432 1432 log_OS_error("opendir"); … … 1438 1438 i++; 1439 1439 if (strcmp(dir, "/")) { 1440 asprintf(&new, "%s/%s", dir, dit->d_name);1440 mr_asprintf(&new, "%s/%s", dir, dit->d_name); 1441 1441 } else { 1442 asprintf(&new, "%s%s", dir, dit->d_name);1442 mr_asprintf(&new, "%s%s", dir, dit->d_name); 1443 1443 } 1444 paranoid_free(new_with_spaces);1445 asprintf(&new_with_spaces, " %s ", new);1444 mr_free(new_with_spaces); 1445 mr_asprintf(&new_with_spaces, " %s ", new); 1446 1446 /* BERLIOS: Old code 1447 1447 new_with_spaces[0] = ' '; … … 1466 1466 counter = 0; 1467 1467 uberctr++; 1468 asprintf(&tmp, " %c ",1468 mr_asprintf(&tmp, " %c ", 1469 1469 special_dot_char(uberctr)); 1470 1470 #ifndef _XWIN … … 1474 1474 newtRefresh(); 1475 1475 } 1476 paranoid_free(tmp);1476 mr_free(tmp); 1477 1477 #endif 1478 1478 } … … 1481 1481 } 1482 1482 } 1483 paranoid_free(new);1484 } 1485 } 1486 paranoid_free(new_with_spaces);1487 paranoid_free(skip_these);1483 mr_free(new); 1484 } 1485 } 1486 mr_free(new_with_spaces); 1487 mr_free(skip_these); 1488 1488 1489 1489 if (dip) { … … 1495 1495 if (!depth) { 1496 1496 close_evalcall_form(); 1497 paranoid_free(name_of_evalcall_form);1498 paranoid_free(find_skeleton_marker);1497 mr_free(name_of_evalcall_form); 1498 mr_free(find_skeleton_marker); 1499 1499 unlink(skeleton_filelist); 1500 1500 log_msg(5, "g_skeleton_entries = %ld", g_skeleton_entries); … … 1565 1565 1566 1566 // The pathname to the skeleton filelist, used to give better progress reporting for mondo_makefilelist(). 1567 asprintf(&sz_datefile, sz_datefile_wildcard, 0);1567 mr_asprintf(&sz_datefile, sz_datefile_wildcard, 0); 1568 1568 if (!include_paths && !userdef_filelist) { 1569 1569 fatal_error … … 1571 1571 } 1572 1572 // make hole for filelist 1573 asprintf(&command, "mkdir -p %s/archives", scratchdir);1573 mr_asprintf(&command, "mkdir -p %s/archives", scratchdir); 1574 1574 paranoid_system(command); 1575 paranoid_free(command);1576 1577 asprintf(&sz_filelist, "%s/tmpfs/filelist.full", tmpdir);1575 mr_free(command); 1576 1577 mr_asprintf(&sz_filelist, "%s/tmpfs/filelist.full", tmpdir); 1578 1578 make_hole_for_file(sz_filelist); 1579 1579 1580 1580 if (differential == 0) { 1581 1581 // restore last good datefile if it exists 1582 asprintf(&command, "cp -f %s.aborted %s", sz_datefile,1582 mr_asprintf(&command, "cp -f %s.aborted %s", sz_datefile, 1583 1583 sz_datefile); 1584 1584 run_program_and_log_output(command, 3); 1585 paranoid_free(command);1585 mr_free(command); 1586 1586 1587 1587 // backup last known good datefile just in case :) 1588 1588 if (does_file_exist(sz_datefile)) { 1589 asprintf(&command, "mv -f %s %s.aborted", sz_datefile,1589 mr_asprintf(&command, "mv -f %s %s.aborted", sz_datefile, 1590 1590 sz_datefile); 1591 1591 paranoid_system(command); 1592 paranoid_free(command);1592 mr_free(command); 1593 1593 } 1594 1594 make_hole_for_file(sz_datefile); 1595 1595 tmp = call_program_and_get_last_line_of_output("date +%s"); 1596 1596 write_one_liner_data_file(sz_datefile, tmp); 1597 paranoid_free(tmp);1597 mr_free(tmp); 1598 1598 } else if (lstat(sz_datefile, &statbuf)) { 1599 1599 log_msg(2, … … 1605 1605 log_msg(2, "Differential backup. Yay."); 1606 1606 } 1607 paranoid_free(sz_datefile);1607 mr_free(sz_datefile); 1608 1608 1609 1609 // use user-specified filelist (if specified) … … 1612 1612 "Using the user-specified filelist - %s - instead of calculating one", 1613 1613 userdef_filelist); 1614 asprintf(&command, "cp -f %s %s", userdef_filelist, sz_filelist);1614 mr_asprintf(&command, "cp -f %s %s", userdef_filelist, sz_filelist); 1615 1615 if (run_program_and_log_output(command, 3)) { 1616 1616 fatal_error("Failed to copy user-specified filelist"); 1617 1617 } 1618 paranoid_free(command);1618 mr_free(command); 1619 1619 } else { 1620 1620 log_msg(2, "include_paths = '%s'", include_paths); … … 1623 1623 tmp1 = call_program_and_get_last_line_of_output("locate /hiberfil.sys 2> /dev/null"); 1624 1624 tmp2 = call_program_and_get_last_line_of_output("locate /pagefile.sys 2> /dev/null"); 1625 asprintf(&exclude_paths, " %s %s %s %s %s %s . .. \1625 mr_asprintf(&exclude_paths, " %s %s %s %s %s %s . .. \ 1626 1626 " MNT_CDROM " " MNT_FLOPPY " /media/cdrom /media/cdrecorder \ 1627 1627 /proc /sys /tmp /var/cache/mondo /var/cache/mindi", excp, tmp, tmp1, tmp2, (tmpdir[0] == '/' && tmpdir[1] == '/') ? (tmpdir + 1) : tmpdir, (scratchdir[0] == '/' && scratchdir[1] == '/') ? (scratchdir + 1) : scratchdir); 1628 paranoid_free(tmp);1629 paranoid_free(tmp1);1630 paranoid_free(tmp2);1628 mr_free(tmp); 1629 mr_free(tmp1); 1630 mr_free(tmp2); 1631 1631 1632 1632 log_msg(2, "Excluding paths = '%s'", exclude_paths); 1633 1633 log_msg(2, 1634 1634 "Generating skeleton filelist so that we can track our progress"); 1635 asprintf(&skeleton_filelist, "%s/tmpfs/skeleton.txt", tmpdir);1635 mr_asprintf(&skeleton_filelist, "%s/tmpfs/skeleton.txt", tmpdir); 1636 1636 make_hole_for_file(skeleton_filelist); 1637 1637 … … 1661 1661 } 1662 1662 paranoid_fclose(fout); 1663 paranoid_free(skeleton_filelist);1664 paranoid_free(exclude_paths);1663 mr_free(skeleton_filelist); 1664 mr_free(exclude_paths); 1665 1665 } 1666 1666 log_msg(2, "Copying new filelist to scratchdir"); 1667 asprintf(&command, "mkdir -p %s/archives", scratchdir);1667 mr_asprintf(&command, "mkdir -p %s/archives", scratchdir); 1668 1668 paranoid_system(command); 1669 paranoid_free(command);1670 1671 asprintf(&command, "cp -f %s %s/archives/", sz_filelist, scratchdir);1669 mr_free(command); 1670 1671 mr_asprintf(&command, "cp -f %s %s/archives/", sz_filelist, scratchdir); 1672 1672 paranoid_system(command); 1673 paranoid_free(command);1674 1675 asprintf(&command, "mv -f %s %s", sz_filelist, tmpdir);1673 mr_free(command); 1674 1675 mr_asprintf(&command, "mv -f %s %s", sz_filelist, tmpdir); 1676 1676 paranoid_system(command); 1677 paranoid_free(command);1678 paranoid_free(sz_filelist);1677 mr_free(command); 1678 mr_free(sz_filelist); 1679 1679 1680 1680 log_msg(2, "Exiting"); … … 1777 1777 } 1778 1778 while (!feof(fin)) { 1779 getline(&fname, &len, fin);1779 mr_getline(&fname, &len, fin); 1780 1780 if (!use_star) { 1781 1781 if (fname[0] == '/') { 1782 asprintf(&tmp, fname);1782 mr_asprintf(&tmp, fname); 1783 1783 } else { 1784 asprintf(&tmp, "/%s", fname);1784 mr_asprintf(&tmp, "/%s", fname); 1785 1785 } 1786 paranoid_free(fname);1786 mr_free(fname); 1787 1787 fname = tmp; 1788 1788 } … … 1796 1796 if (found_node->selected) { 1797 1797 if (fname[0] == '/') { 1798 asprintf(&tmp, fname + 1);1799 paranoid_free(fname);1798 mr_asprintf(&tmp, fname + 1); 1799 mr_free(fname); 1800 1800 fname = tmp; 1801 1801 } … … 1803 1803 turn_wildcard_chars_into_literal_chars(tmp, fname); 1804 1804 fprintf(fout, "%s\n", tmp); 1805 paranoid_free(tmp);1805 mr_free(tmp); 1806 1806 retval++; 1807 1807 } 1808 1808 } 1809 paranoid_free(fname);1809 mr_free(fname); 1810 1810 } 1811 1811 paranoid_fclose(fout); … … 1836 1836 return (1); 1837 1837 } 1838 for ( getline(&tmp, &n, fin); !feof(fin);getline(&tmp, &n, fin)) {1838 for (mr_getline(&tmp, &n, fin); !feof(fin); mr_getline(&tmp, &n, fin)) { 1839 1839 if (!tmp[0]) { 1840 1840 continue; … … 1861 1861 } 1862 1862 paranoid_fclose(fin); 1863 paranoid_free(tmp);1863 mr_free(tmp); 1864 1864 return (0); 1865 1865 }
Note:
See TracChangeset
for help on using the changeset viewer.